/* ===== CSS VARIABLES ===== */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #8b5cf6;
  --pink: #ec4899;
  --cyan: #06b6d4;
  --orange: #f97316;

  --bg-base: #0f172a;
  --bg-surface: #1e293b;
  --bg-card: #1e293b;
  --bg-card2: #273449;
  --bg-hover: #334155;
  --border: #334155;
  --border-light: #475569;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --sidebar-w: 260px;
  --topbar-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.5);
  --font: 'Cairo', 'Tajawal', sans-serif;
  --transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ===== LOGIN PAGE ===== */
.login-page {
  position: fixed; inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  background: var(--bg-base);
}
.login-page.active { display: flex; }

.login-bg {
  position: absolute; inset: 0;
  overflow: hidden;
}

.login-glow {
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(99,102,241,0.15) 0%, transparent 70%);
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  animation: glowPulse 4s ease-in-out infinite;
}

@keyframes glowPulse {
  0%,100% { transform: translate(-50%,-50%) scale(1); opacity: 0.5; }
  50% { transform: translate(-50%,-50%) scale(1.2); opacity: 1; }
}

.login-particles {
  position: absolute; inset: 0;
}

.particle {
  position: absolute;
  width: 3px; height: 3px;
  background: var(--primary-light);
  border-radius: 50%;
  animation: float linear infinite;
  opacity: 0.4;
}

@keyframes float {
  0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
  10% { opacity: 0.4; }
  90% { opacity: 0.4; }
  100% { transform: translateY(-100px) rotate(720deg); opacity: 0; }
}

.login-container {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  align-items: center; gap: 28px;
  width: 100%; max-width: 420px;
  padding: 24px;
  animation: slideUp 0.6s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-logo {
  text-align: center;
}

.logo-icon {
  width: 80px; height: 80px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; color: white;
  margin: 0 auto 16px;
  box-shadow: 0 0 40px rgba(99,102,241,0.4);
  animation: logoBounce 2s ease-in-out infinite;
}

@keyframes logoBounce {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.login-logo h1 {
  font-size: 26px; font-weight: 800;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}

.login-logo p {
  color: var(--text-secondary); font-size: 13px;
}

.login-form-card {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.login-form-card h2 {
  font-size: 18px; font-weight: 700;
  margin-bottom: 24px;
  color: var(--text-primary);
  display: flex; align-items: center; gap: 10px;
}

.form-group {
  margin-bottom: 18px;
  position: relative;
}

.form-group label {
  display: block;
  color: var(--text-secondary);
  font-size: 13px; font-weight: 600;
  margin-bottom: 8px;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  background: var(--bg-card2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  padding: 11px 16px;
  transition: var(--transition);
  outline: none;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.form-group select option { background: var(--bg-surface); }

.form-group textarea { resize: vertical; min-height: 80px; }

.eye-toggle {
  position: absolute;
  left: 12px; top: 40px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}
.eye-toggle:hover { color: var(--primary); }

.remember-row { display: flex; align-items: center; }

.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; color: var(--text-secondary); font-size: 13px;
}
.checkbox-label input { width: auto; margin: 0; }

.btn-login {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; border: none;
  border-radius: var(--radius-sm);
  padding: 13px;
  font-family: var(--font);
  font-size: 16px; font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99,102,241,0.4);
}

.login-error {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  color: #f87171;
  font-size: 13px;
  display: none;
}

.login-footer {
  color: var(--text-muted); font-size: 12px;
}

/* ===== MAIN APP ===== */
.main-app {
  display: flex; min-height: 100vh;
  display: none;
}
.main-app.active { display: flex; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; right: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: var(--transition);
  overflow-y: auto;
}

.sidebar.collapsed { width: 72px; }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .user-details,
.sidebar.collapsed .badge { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 14px; }
.sidebar.collapsed .sidebar-bottom span { display: none; }

.sidebar-logo {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}

.logo-icon-sm {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: white;
  flex-shrink: 0;
}

.logo-text {
  font-size: 18px; font-weight: 800;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  flex: 1;
}

.sidebar-toggle {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 6px; border-radius: 6px;
  font-size: 16px;
  transition: var(--transition);
}
.sidebar-toggle:hover { color: var(--primary); background: rgba(99,102,241,0.1); }

.user-info {
  display: flex; align-items: center; gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.user-avatar {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: white; flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 700; display: block; }
.user-role { font-size: 11px; color: var(--text-muted); }

.sidebar-nav {
  flex: 1; padding: 12px 10px;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 10px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 14px 8px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px; font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(99,102,241,0.15);
  color: var(--primary-light);
  border-right: 3px solid var(--primary);
}

.nav-item i { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.badge {
  margin-right: auto;
  background: var(--primary);
  color: white; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px;
}

.badge-green { background: var(--success); }
.badge-red { background: var(--danger); }
.badge-yellow { background: var(--warning); }

.sidebar-bottom {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.btn-logout {
  width: 100%;
  background: rgba(239,68,68,0.1);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-family: var(--font);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn-logout:hover { background: rgba(239,68,68,0.2); }

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  margin-right: var(--sidebar-w);
  display: flex; flex-direction: column;
  min-height: 100vh;
  transition: var(--transition);
}

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  gap: 16px;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.mobile-menu-btn {
  display: none;
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 20px; cursor: pointer;
}

.page-title {
  font-size: 18px; font-weight: 700;
  color: var(--text-primary);
}

.topbar-right {
  display: flex; align-items: center; gap: 16px;
}

.topbar-time {
  font-size: 13px; color: var(--text-muted);
  font-weight: 500;
}

.sheet-status, .api-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted);
  padding: 6px 12px;
  background: var(--bg-card2);
  border-radius: 20px;
  border: 1px solid var(--border);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: pulse 2s infinite;
}

.status-dot.connected { background: var(--success); }
.status-dot.error { background: var(--danger); }

@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.notifications { position: relative; }

.notif-btn {
  position: relative;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 16px;
  transition: var(--transition);
}
.notif-btn:hover { color: var(--primary); border-color: var(--primary); }

.notif-badge {
  position: absolute;
  top: -4px; left: -4px;
  background: var(--danger);
  color: white; font-size: 10px; font-weight: 700;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px); left: 0;
  width: 320px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 200;
}

.notif-dropdown.open { display: block; animation: dropDown 0.2s ease; }

@keyframes dropDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.notif-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 14px;
}

.notif-list { max-height: 300px; overflow-y: auto; }

.notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.notif-item:last-child { border: none; }
.notif-item .notif-icon { font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.notif-item .notif-text { color: var(--text-primary); }
.notif-item .notif-time { color: var(--text-muted); font-size: 11px; }

.topbar-user {
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
  padding: 6px 12px;
  background: var(--bg-card2);
  border-radius: 20px;
}

/* ===== PAGES ===== */
.page { display: none; padding: 24px; flex: 1; }
.page.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}

.page-header h2 {
  font-size: 22px; font-weight: 800;
  display: flex; align-items: center; gap: 10px;
}

.page-header h2 i { color: var(--primary); }

.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== KPI CARDS ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-grid.mini { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  position: relative; overflow: hidden;
  transition: var(--transition);
}

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--border-light);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 4px; height: 100%;
}

.kpi-total::before { background: var(--primary); }
.kpi-confirmed::before { background: var(--success); }
.kpi-cancelled::before { background: var(--danger); }
.kpi-pending::before { background: var(--warning); }
.kpi-delivery::before { background: var(--secondary); }
.kpi-coverage::before { background: var(--purple); }
.kpi-wrong::before { background: var(--pink); }
.kpi-revenue::before { background: var(--cyan); }

.kpi-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.kpi-total .kpi-icon { background: rgba(99,102,241,0.15); color: var(--primary); }
.kpi-confirmed .kpi-icon { background: rgba(16,185,129,0.15); color: var(--success); }
.kpi-cancelled .kpi-icon { background: rgba(239,68,68,0.15); color: var(--danger); }
.kpi-pending .kpi-icon { background: rgba(245,158,11,0.15); color: var(--warning); }
.kpi-delivery .kpi-icon { background: rgba(14,165,233,0.15); color: var(--secondary); }
.kpi-coverage .kpi-icon { background: rgba(139,92,246,0.15); color: var(--purple); }
.kpi-wrong .kpi-icon { background: rgba(236,72,153,0.15); color: var(--pink); }
.kpi-revenue .kpi-icon { background: rgba(6,182,212,0.15); color: var(--cyan); }

.kpi-info { flex: 1; }
.kpi-value {
  font-size: 28px; font-weight: 800;
  display: block; line-height: 1;
}
.kpi-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; display: block; }

.kpi-percent {
  position: absolute;
  bottom: 10px; left: 12px;
  font-size: 11px; font-weight: 700;
  color: var(--success);
  background: rgba(16,185,129,0.1);
  padding: 2px 8px; border-radius: 10px;
}

/* ===== CHARTS ===== */
.charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.chart-card.wide { grid-column: 1 / -1; }

.chart-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.chart-header h3 { font-size: 15px; font-weight: 700; }

/* ===== TABLE CARD ===== */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
}

.table-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.table-header h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--bg-card2);
  padding: 12px 14px;
  text-align: right;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(51,65,85,0.5);
  color: var(--text-primary);
  vertical-align: middle;
  white-space: nowrap;
}

.data-table tr:hover td { background: var(--bg-hover); }

.empty-row {
  text-align: center;
  color: var(--text-muted);
  padding: 40px !important;
  font-size: 16px;
}
.empty-row i { display: block; font-size: 36px; margin-bottom: 10px; opacity: 0.4; }

/* ===== STATUS BADGES ===== */
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700;
  white-space: nowrap;
}

.status-confirmed { background: rgba(16,185,129,0.15); color: #34d399; border: 1px solid rgba(16,185,129,0.3); }
.status-cancelled { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.status-no_answer_1, .status-no_answer_2, .status-no_answer_3 { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.status-no_answer_4, .status-no_answer_5, .status-no_answer_6 { background: rgba(249,115,22,0.15); color: #fb923c; border: 1px solid rgba(249,115,22,0.3); }
.status-no_answer_7, .status-no_answer_8 { background: rgba(239,68,68,0.1); color: #fca5a5; border: 1px solid rgba(239,68,68,0.2); }
.status-no_answer_final { background: rgba(239,68,68,0.2); color: #ef4444; border: 1px solid rgba(239,68,68,0.4); }
.status-out_of_range { background: rgba(139,92,246,0.15); color: #a78bfa; border: 1px solid rgba(139,92,246,0.3); }
.status-wrong_number { background: rgba(236,72,153,0.15); color: #f472b6; border: 1px solid rgba(236,72,153,0.3); }
.status-postponed { background: rgba(6,182,212,0.15); color: #22d3ee; border: 1px solid rgba(6,182,212,0.3); }
.status-in_delivery { background: rgba(14,165,233,0.15); color: #38bdf8; border: 1px solid rgba(14,165,233,0.3); }
.status-pending { background: rgba(100,116,139,0.15); color: #94a3b8; border: 1px solid rgba(100,116,139,0.3); }
.status-unreachable { background: rgba(100,116,139,0.15); color: #64748b; border: 1px solid rgba(100,116,139,0.3); }

/* ===== FILTERS ===== */
.filters-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  flex: 1; min-width: 200px;
}

.search-box i { color: var(--text-muted); }

.search-box input {
  background: none; border: none; outline: none;
  color: var(--text-primary); font-family: var(--font); font-size: 13px;
  flex: 1;
}

.filter-select {
  background: var(--bg-card2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font); font-size: 13px;
  padding: 9px 14px;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}
.filter-select:focus { border-color: var(--primary); }

.results-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}

.results-bar span { color: var(--text-muted); font-size: 13px; }

.view-toggle { display: flex; gap: 4px; }

.view-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}
.view-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== ORDERS CARDS ===== */
.orders-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.order-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.order-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.order-card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 12px;
}

.order-card-code { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.order-card-name { font-size: 16px; font-weight: 700; margin: 4px 0; }
.order-card-phone { font-size: 13px; color: var(--primary-light); }

.order-card-body { margin: 12px 0; }
.order-info-row { display: flex; justify-content: space-between; margin: 6px 0; font-size: 12px; }
.order-info-row span:first-child { color: var(--text-muted); }
.order-info-row span:last-child { font-weight: 600; }

.order-card-footer {
  display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap;
}

.order-card-actions {
  display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap;
}

/* ===== ACTION BUTTONS ===== */
.btn-primary, .btn-success, .btn-warning, .btn-danger, .btn-outline, .btn-link, .btn-info, .btn-sm {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(99,102,241,0.3); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(16,185,129,0.3); }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #d97706; transform: translateY(-1px); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(239,68,68,0.3); }

.btn-info { background: var(--secondary); color: white; }
.btn-info:hover { background: #0284c7; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border-light);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-link { background: none; color: var(--primary); padding: 0; }
.btn-link:hover { color: var(--primary-light); }

.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-lg { padding: 13px 24px; font-size: 15px; }

.btn-icon {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  cursor: pointer; border: none;
  transition: var(--transition); font-size: 14px;
}

.btn-icon-primary { background: rgba(99,102,241,0.1); color: var(--primary); }
.btn-icon-primary:hover { background: var(--primary); color: white; }

.btn-icon-success { background: rgba(16,185,129,0.1); color: var(--success); }
.btn-icon-success:hover { background: var(--success); color: white; }

.btn-icon-danger { background: rgba(239,68,68,0.1); color: var(--danger); }
.btn-icon-danger:hover { background: var(--danger); color: white; }

.btn-icon-warning { background: rgba(245,158,11,0.1); color: var(--warning); }
.btn-icon-warning:hover { background: var(--warning); color: white; }

.btn-icon-info { background: rgba(14,165,233,0.1); color: var(--secondary); }
.btn-icon-info:hover { background: var(--secondary); color: white; }

.btn-icon-purple { background: rgba(139,92,246,0.1); color: var(--purple); }
.btn-icon-purple:hover { background: var(--purple); color: white; }

/* ===== FORM LAYOUTS ===== */
.form-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; margin-bottom: 24px; }
.big-form { max-width: 100%; }

.form-section-title {
  font-size: 15px; font-weight: 700;
  color: var(--primary-light);
  margin: 24px 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.form-section-title:first-child { margin-top: 0; }

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.form-group.full-width { grid-column: 1 / -1; }

.form-actions {
  display: flex; gap: 12px; margin-top: 28px; flex-wrap: wrap;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.req { color: var(--danger); }

/* ===== PAGINATION ===== */
.pagination {
  display: flex; align-items: center; gap: 6px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.page-btn {
  min-width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer; font-size: 13px; font-weight: 600;
  transition: var(--transition);
  font-family: var(--font);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== STATS PAGE ===== */
.stats-big-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.stat-hero-card h3 {
  font-size: 14px; color: var(--text-muted); margin-bottom: 16px;
}

.donut-wrap {
  position: relative; display: inline-block; margin: 0 auto;
}

.donut-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 20px; font-weight: 800;
  color: var(--success);
}

.geo-stats { padding: 12px; }

.geo-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.geo-item:last-child { border: none; }
.geo-zone { font-weight: 600; flex: 1; }
.geo-count { font-size: 18px; font-weight: 800; }
.geo-bar-wrap { flex: 2; }
.geo-bar { height: 8px; background: var(--bg-card2); border-radius: 4px; overflow: hidden; }
.geo-bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--primary), var(--secondary)); }

/* ===== AGENTS PAGE ===== */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  transition: var(--transition);
}
.agent-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.agent-avatar {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: white;
  margin: 0 auto 14px;
}

.agent-name { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.agent-role { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }

.agent-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-bottom: 14px;
}

.agent-stat { text-align: center; }
.agent-stat-val { font-size: 20px; font-weight: 800; display: block; }
.agent-stat-lbl { font-size: 10px; color: var(--text-muted); }

.agent-rate {
  font-size: 13px; font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(16,185,129,0.1);
  color: var(--success);
}

/* ===== SETTINGS PAGE ===== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 20px;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.settings-card.full-width { grid-column: 1 / -1; }

.settings-card-header {
  font-size: 16px; font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  color: var(--primary-light);
}

.settings-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.test-result {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: none;
}

.test-result.success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); color: #34d399; display: block; }
.test-result.error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #f87171; display: block; }

.info-box {
  display: flex; gap: 12px;
  background: rgba(99,102,241,0.08);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 20px;
  font-size: 12px; color: var(--text-secondary);
  line-height: 1.7;
}
.info-box i { color: var(--primary); font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.info-box ol { padding-right: 16px; }

.code-block {
  background: #0a0f1a;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: #7dd3fc;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 8px;
  direction: ltr;
  text-align: left;
}

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text-secondary);
}
.toggle-row:last-of-type { border: none; }

.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--bg-hover);
  border-radius: 24px; cursor: pointer;
  transition: var(--transition);
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 18px; height: 18px;
  right: 3px; top: 3px;
  background: white; border-radius: 50%;
  transition: var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(-20px); }

.zones-list {
  max-height: 200px; overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.zone-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.zone-item:last-child { border: none; }
.zone-id { color: var(--text-muted); font-size: 11px; }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: none; align-items: center; justify-content: center;
  z-index: 500;
  backdrop-filter: blur(4px);
  padding: 20px;
}
.modal-overlay.open { display: flex; animation: fadeIn 0.2s ease; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
  width: 100%;
  animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.large-modal { max-width: 900px; }
.medium-modal { max-width: 520px; }
.small-modal { max-width: 400px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; }

.modal-close {
  background: none; border: none;
  color: var(--text-muted); font-size: 18px;
  cursor: pointer; padding: 6px;
  border-radius: 6px;
  transition: var(--transition);
}
.modal-close:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

.modal-body { padding: 24px; }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.confirm-header {
  justify-content: center; padding: 28px;
  background: var(--bg-card2);
}
.confirm-icon {
  width: 72px; height: 72px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
}

.confirm-icon.confirm-success { background: rgba(16,185,129,0.15); color: var(--success); }
.confirm-icon.confirm-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.confirm-icon.confirm-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.confirm-icon.confirm-info { background: rgba(14,165,233,0.15); color: var(--secondary); }

.modal-body h3 { text-align: center; font-size: 18px; margin-bottom: 8px; }
.modal-body > p { text-align: center; color: var(--text-secondary); font-size: 14px; margin-bottom: 16px; }

.btn-confirm { background: var(--primary); color: white; border: none; }

/* ORDER DETAIL LAYOUT */
.order-detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}

.order-detail-section {
  background: var(--bg-card2);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.order-detail-section h4 {
  font-size: 13px; color: var(--primary-light);
  margin-bottom: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
}

.detail-row {
  display: flex; justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid rgba(51,65,85,0.5);
  font-size: 13px;
}
.detail-row:last-child { border: none; }
.detail-label { color: var(--text-muted); }
.detail-value { font-weight: 600; text-align: left; }

.status-change-area {
  background: var(--bg-card2);
  border-radius: var(--radius-sm);
  padding: 20px;
  grid-column: 1 / -1;
}

.status-change-area h4 {
  font-size: 14px; font-weight: 700; margin-bottom: 14px;
  color: var(--warning);
}

.status-buttons-grid {
  display: flex; flex-wrap: wrap; gap: 10px;
}

.status-btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: 2px solid transparent;
  cursor: pointer;
  font-family: var(--font); font-size: 13px; font-weight: 600;
  transition: var(--transition);
  display: flex; align-items: center; gap: 8px;
}

.status-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.status-btn.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.attempt-history {
  background: var(--bg-card2);
  border-radius: var(--radius-sm);
  padding: 16px;
  grid-column: 1 / -1;
}

.attempt-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(51,65,85,0.5);
  font-size: 13px;
}
.attempt-item:last-child { border: none; }
.attempt-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-hover);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.attempt-info { flex: 1; }
.attempt-time { color: var(--text-muted); font-size: 11px; }
.attempt-agent { color: var(--primary-light); font-size: 11px; }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px; left: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 360px;
}

.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: toastIn 0.3s ease;
  cursor: pointer;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.out { animation: toastOut 0.3s ease forwards; }

@keyframes toastOut {
  to { opacity: 0; transform: translateX(-20px); }
}

.toast-icon { font-size: 20px; flex-shrink: 0; }
.toast-msg { flex: 1; }
.toast-title { font-weight: 700; margin-bottom: 2px; }
.toast-body { color: var(--text-muted); font-size: 12px; }

.toast.success { border-color: rgba(16,185,129,0.4); }
.toast.success .toast-icon { color: var(--success); }
.toast.error { border-color: rgba(239,68,68,0.4); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning { border-color: rgba(245,158,11,0.4); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info { border-color: rgba(99,102,241,0.4); }
.toast.info .toast-icon { color: var(--primary); }

/* ===== LOADING ===== */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center;
  z-index: 9000;
  backdrop-filter: blur(3px);
}
.loading-overlay.active { display: flex; }

.loading-spinner { text-align: center; color: var(--text-primary); }

.spinner {
  width: 52px; height: 52px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
  grid-column: 1 / -1;
}
.empty-state i { font-size: 52px; opacity: 0.3; margin-bottom: 16px; display: block; }
.empty-state p { font-size: 15px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(100%); }
  .sidebar.mobile-open { transform: translateX(0); width: 260px; }
  .main-content { margin-right: 0; }
  .mobile-menu-btn { display: flex; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .order-detail-grid { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr; }
  .stats-big-grid { grid-template-columns: repeat(2, 1fr); }
  .page { padding: 16px; }
  .topbar-time, .api-status { display: none; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .stats-big-grid { grid-template-columns: 1fr; }
  .orders-cards { grid-template-columns: 1fr; }
}
/* ===== APP.JS ADDITIONS ===== */
.action-btns { display: flex; gap: 6px; align-items: center; }
.order-code { font-family: monospace; font-size: 12px; color: var(--primary-light); font-weight: 700; }
.phone-link { color: var(--primary-light); text-decoration: none; }
.phone-link:hover { color: var(--secondary); text-decoration: underline; }
.attempt-badge { font-size: 12px; font-weight: 700; }
.attempt-badge.zero { color: var(--text-muted); }
.selected-row td { background: rgba(99,102,241,0.08) !important; }
.selected-card { border-color: var(--primary) !important; box-shadow: 0 0 0 2px rgba(99,102,241,0.3); }
.name-cell { font-weight: 600; }
.address-cell { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.price-cell { color: var(--cyan); font-weight: 700; }
.notes-cell { color: var(--text-muted); font-size: 12px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.notif-item.unread { background: rgba(99,102,241,0.06); }

/* ===== PHONE & WHATSAPP BUTTONS ===== */
.phone-action-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.phone-num {
  font-size: 12px;
  color: var(--primary-light);
  font-family: monospace;
  letter-spacing: 0.5px;
  direction: ltr;
  display: block;
}

.phone-btns {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* زر الاتصال - أخضر داكن */
.btn-phone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  text-decoration: none;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.btn-phone:hover {
  background: #10b981;
  color: white;
  transform: scale(1.1);
  box-shadow: 0 0 8px rgba(16,185,129,0.4);
}

/* زر WhatsApp - أخضر واتساب */
.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(37, 211, 102, 0.15);
  color: #25D366;
  border: 1px solid rgba(37, 211, 102, 0.3);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  padding: 0;
}
.btn-whatsapp:hover {
  background: #25D366;
  color: white;
  transform: scale(1.1);
  box-shadow: 0 0 8px rgba(37,209,102,0.45);
}

/* النسخة الكبيرة لنافذة التفاصيل */
.btn-phone-lg {
  width: auto;
  height: 34px;
  border-radius: 8px;
  padding: 0 12px;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Cairo', sans-serif;
}

.btn-whatsapp-lg {
  width: auto;
  height: 34px;
  border-radius: 8px;
  padding: 0 12px;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Cairo', sans-serif;
}

.btn-whatsapp-lg i,
.btn-phone-lg i {
  margin-left: 4px;
}
