:root {
  --primary-950: #050c18;
  --primary-900: #0a192f;
  --primary-800: #0f2444;
  --primary-700: #173763;
  --primary-600: #1f4a84;
  
  --gold-500: #d4af37;
  --gold-400: #f59e0b;
  --gold-300: #fbbf24;
  --gold-100: #fef3c7;
  --gold-50: #fffbeb;

  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  --emerald-500: #10b981;
  --emerald-100: #d1fae5;
  --emerald-800: #065f46;

  --blue-500: #3b82f6;
  --blue-100: #dbeafe;
  --blue-800: #1e40af;

  --rose-500: #f43f5e;
  --rose-100: #ffe4e6;
  --rose-800: #9f1239;

  --radius-xl: 16px;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 6px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 24px -4px rgba(15, 23, 42, 0.1), 0 4px 8px -2px rgba(15, 23, 42, 0.04);
  --shadow-glow: 0 0 20px rgba(212, 175, 55, 0.25);

  --font-family: 'Cairo', system-ui, -apple-system, sans-serif;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: #f3f6fa;
  color: var(--slate-800);
  direction: rtl;
  text-align: right;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════ NAVBAR ══════════════════════ */
.navbar {
  background: linear-gradient(135deg, var(--primary-950) 0%, var(--primary-900) 60%, var(--primary-800) 100%);
  color: #fff;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 20px rgba(5, 12, 24, 0.15);
  position: sticky;
  top: 0;
  z-index: 99;
  border-bottom: 1px solid rgba(212, 175, 55, 0.25);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  height: 48px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(212, 175, 55, 0.3);
}

.brand-title {
  font-size: 19px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  background: rgba(212, 175, 55, 0.15);
  color: var(--gold-300);
  border: 1px solid rgba(212, 175, 55, 0.4);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
}

.brand-subtitle {
  font-size: 11.5px;
  color: var(--slate-400);
  font-weight: 500;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 700;
}
.live-dot {
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ══════════════════════ BUTTONS ══════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-lg);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: var(--transition);
  white-space: nowrap;
}
.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-400) 0%, var(--gold-500) 100%);
  color: var(--primary-950);
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--gold-300) 0%, var(--gold-400) 100%);
  transform: translateY(-2px);
}

.btn-merchant-link {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn-merchant-link:hover {
  transform: translateY(-2px);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.4);
}

.btn-secondary {
  background-color: #fff;
  color: var(--slate-700);
  border: 1px solid var(--slate-200);
}
.btn-secondary:hover {
  background-color: var(--slate-50);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-md);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--rose-500);
  border: none;
  padding: 6px;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.btn-danger-ghost:hover {
  background: var(--rose-100);
}

/* ══════════════════════ CONTAINER ══════════════════════ */
.container {
  max-width: 1440px;
  margin: 20px auto;
  padding: 0 20px;
}

/* ══════════════════════ TABS BAR ══════════════════════ */
.tabs-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.tabs-nav {
  display: flex;
  background: #fff;
  padding: 5px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  gap: 4px;
}

.tab-btn {
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--slate-600);
  background: transparent;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  font-family: inherit;
}
.tab-btn:hover {
  color: var(--primary-900);
  background: var(--slate-50);
}
.tab-btn.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary-900) 0%, var(--primary-800) 100%);
  box-shadow: 0 3px 10px rgba(10, 25, 47, 0.25);
}

/* ══════════════════════ KPI CARDS ══════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 16px 18px;
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: var(--transition);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

.stat-icon.blue { background: #eff6ff; color: #2563eb; }
.stat-icon.green { background: #ecfdf5; color: #059669; }
.stat-icon.amber { background: #fffbeb; color: #d97706; }
.stat-icon.rose { background: #fff1f2; color: #e11d48; }
.stat-icon.gold { background: #fefce8; color: #ca8a04; }
.stat-icon.purple { background: #faf5ff; color: #7c3aed; }

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-500);
}

.stat-val {
  font-size: 22px;
  font-weight: 900;
  color: var(--slate-900);
  margin-top: 2px;
}

.stat-trend {
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 2px;
}

/* ══════════════════════ CARDS ══════════════════════ */
.card {
  background: #fff;
  border-radius: var(--radius-xl);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--slate-100);
}

.card-title {
  font-size: 16.5px;
  font-weight: 800;
  color: var(--primary-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ══════════════════════ STATUS PILLS ══════════════════════ */
.status-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.status-pill {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--slate-200);
  background: #fff;
  color: var(--slate-600);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  font-family: inherit;
}
.status-pill:hover {
  border-color: var(--primary-600);
  color: var(--primary-900);
}
.status-pill.active {
  background: var(--primary-900);
  color: #fff;
  border-color: var(--primary-900);
}
.pill-count {
  background: rgba(0,0,0,0.06);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10.5px;
}
.status-pill.active .pill-count {
  background: rgba(255,255,255,0.2);
}

/* ══════════════════════ CONTROLS BAR ══════════════════════ */
.controls-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-wrapper {
  flex: 1;
  min-width: 240px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 10px 14px;
  padding-right: 40px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--slate-200);
  background: #fff;
  font-family: inherit;
  font-size: 13px;
}
.search-input:focus {
  outline: none;
  border-color: var(--primary-700);
}
.search-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--slate-400);
}

.filter-select {
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--slate-200);
  background: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-700);
}

/* ══════════════════════ DATA TABLE ══════════════════════ */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th {
  background: var(--slate-50);
  color: var(--slate-600);
  font-weight: 700;
  text-align: right;
  padding: 11px 14px;
  border-bottom: 1.5px solid var(--slate-200);
  white-space: nowrap;
  font-size: 12px;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--slate-100);
  vertical-align: middle;
  background: #fff;
}

tr:hover td {
  background: #f8fafc;
}

/* ══════════════════════ BADGES ══════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-new { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-transit { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.badge-delivered { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.badge-returned { background: #fff1f2; color: #be123c; border: 1px solid #fecdd3; }

/* ══════════════════════ MODALS ══════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 12, 24, 0.65);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay.active {
  display: flex;
}
.modal-content {
  background: #fff;
  border-radius: 18px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px -15px rgba(5, 12, 24, 0.35);
}
.modal-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--primary-950) 0%, var(--primary-900) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 18px 18px 0 0;
}
.modal-title {
  font-size: 16px;
  font-weight: 800;
}
.modal-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  font-size: 18px;
  border-radius: var(--radius-md);
  padding: 4px 8px;
  cursor: pointer;
}
.modal-body {
  padding: 20px;
}

/* ══════════════════════ FORMS ══════════════════════ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-group.full {
  grid-column: span 2;
}
.form-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--slate-700);
}
.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--slate-200);
  font-family: inherit;
  font-size: 13.5px;
}

/* ══════════════════════ TOAST NOTIFICATIONS ══════════════════════ */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  min-width: 260px;
}
.toast-success { background: #064e3b; color: #a7f3d0; border: 1px solid #059669; }
.toast-error { background: #881337; color: #fecdd3; border: 1px solid #e11d48; }
.toast-info { background: #0f2444; color: #bae6fd; border: 1px solid #0284c7; }

/* ══════════════════════ WAYBILL PRINT STYLES ══════════════════════ */
#waybillPrintArea { display: none; }
@media print {
  body * { visibility: hidden !important; }
  #waybillPrintArea, #waybillPrintArea * { visibility: visible !important; }
  #waybillPrintArea {
    display: block !important;
    position: absolute;
    left: 0; top: 0; width: 100%;
    margin: 0; padding: 8mm; background: #fff;
  }
  .no-print { display: none !important; }
}

/* ══════════════════════ MOBILE RESPONSIVE TWEAKS ══════════════════════ */
@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 14px;
    gap: 12px;
  }
  .brand {
    justify-content: space-between;
    width: 100%;
  }
  .brand-logo {
    height: 40px;
  }
  .brand-title {
    font-size: 17px;
  }
  .nav-actions {
    display: flex;
    width: 100%;
    gap: 6px;
    justify-content: stretch;
  }
  .nav-actions .btn {
    flex: 1 1 auto;
    padding: 8px 10px;
    font-size: 12px;
    justify-content: center;
  }
  .live-indicator {
    display: none; /* Hide on small mobile to save space */
  }
  .container {
    padding: 0 12px;
    margin: 14px auto;
  }
  .tabs-wrapper {
    flex-direction: column;
    gap: 10px;
  }
  .tabs-nav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    padding: 3px;
  }
  .tab-btn {
    padding: 8px 4px;
    font-size: 11.5px;
    justify-content: center;
    text-align: center;
    border-radius: var(--radius-md);
  }
  .tab-btn span {
    display: none; /* Hide emoji on mobile to prevent wrapping */
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .stat-card {
    padding: 12px;
    gap: 10px;
  }
  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
    border-radius: 10px;
  }
  .stat-val {
    font-size: 18px;
  }
  .stat-trend {
    display: none;
  }
  .status-pills {
    gap: 6px;
  }
  .status-pill {
    padding: 5px 10px;
    font-size: 11px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-group.full {
    grid-column: span 1;
  }
  .card {
    padding: 14px;
  }
}
