:root {
  --bg-body: #0f111a;
  --bg-sidebar: #131624;
  --bg-card: #181c2c;
  --bg-card-hover: #1e2336;
  --bg-input: #111420;
  --border-color: #252a3f;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #f97316;
  --accent-hover: #ea580c;
  --accent-soft: rgba(249, 115, 22, 0.14);
  --indigo: #818cf8;
  --green: #34d399;
  --red: #fb7185;
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.25);
}

html.light {
  --bg-body: #f1f5f9;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f8fafc;
  --border-color: #dbe3ee;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --accent: #ea580c;
  --accent-hover: #c2410c;
  --accent-soft: #fff7ed;
  --indigo: #4f46e5;
  --green: #059669;
  --red: #e11d48;
  --shadow-card: 0 2px 10px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 999px;
}

.card-surface {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
}

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  transition: width 0.2s ease;
}

.sidebar.collapsed {
  width: 72px !important;
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .section-label,
.sidebar.collapsed .brand-text,
.sidebar.collapsed .user-meta,
.sidebar.collapsed .cta-text {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  width: 100%;
  text-align: left;
  background: transparent;
}

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

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(249, 115, 22, 0.25);
}

.kpi-card {
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 18px 20px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
}

.kpi-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.kpi-indigo::before { background: linear-gradient(180deg, #818cf8, #6366f1); }
.kpi-orange::before { background: linear-gradient(180deg, #fb923c, #f97316); }
.kpi-green::before  { background: linear-gradient(180deg, #34d399, #10b981); }
.kpi-red::before    { background: linear-gradient(180deg, #fb7185, #f43f5e); }

.input-field {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease;
}

.input-field:focus {
  border-color: var(--accent);
}

.btn-primary {
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-secondary {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-secondary:hover {
  border-color: var(--accent);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

table.orders-table {
  table-layout: fixed;
  width: 100%;
  min-width: 980px;
}

table.orders-table th,
table.orders-table td {
  padding: 11px 10px;
  overflow-wrap: anywhere;
}

.badge-completed { background: rgba(52, 211, 153, 0.15); color: #34d399; }
.badge-processing { background: rgba(249, 115, 22, 0.16); color: #fb923c; }
.badge-pending { background: rgba(129, 140, 248, 0.16); color: #818cf8; }
.badge-cancelled, .badge-refunded { background: rgba(251, 113, 133, 0.16); color: #fb7185; }

.pill-tab {
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  border: 1px solid transparent;
  background: transparent;
}

.pill-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(249, 115, 22, 0.35);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
}

table.data-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-color);
}

table.data-table td {
  padding: 12px 14px;
  font-size: 13.5px;
  border-bottom: 1px solid rgba(37, 42, 63, 0.45);
  vertical-align: middle;
}

html.light table.data-table td {
  border-bottom: 1px solid #f1f5f9;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  font-size: 13.5px;
  font-weight: 500;
}

.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #2b324a;
  cursor: pointer;
  transition: background 0.18s ease;
  border: 1px solid var(--border-color);
  padding: 2px;
}

.toggle-switch.on {
  background: #f97316;
  border-color: #f97316;
}

.toggle-switch .toggle-knob {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #ffffff;
  transition: transform 0.18s ease;
}

.toggle-switch.on .toggle-knob {
  transform: translateX(18px);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-chip:hover {
  border-color: #34d399;
  color: var(--text-primary);
}

.filter-chip.active {
  background: #10b981;
  border-color: #10b981;
  color: #ffffff;
}

.filter-chip .chip-count {
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 10.5px;
  background: rgba(255, 255, 255, 0.12);
}

/* ==================== LIGHT MODE HIGH-CONTRAST POLISH ==================== */
html.light .nav-item.active {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fdba74;
  font-weight: 600;
}

html.light .input-field {
  background: #ffffff;
  border-color: #cbd5e1;
}

html.light .input-field:focus {
  border-color: #ea580c;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.12);
}

html.light .btn-secondary {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #1e293b;
}

html.light .btn-secondary:hover {
  background: #f8fafc;
  border-color: #ea580c;
  color: #c2410c;
}

html.light .badge-completed {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

html.light .badge-processing {
  background: #ffedd5;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

html.light .badge-pending {
  background: #e0e7ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
}

html.light .badge-cancelled,
html.light .badge-refunded {
  background: #ffe4e6;
  color: #be123c;
  border: 1px solid #fecdd3;
}

html.light table.data-table thead th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
}

html.light table.data-table td {
  border-bottom: 1px solid #e2e8f0;
}

html.light table.data-table tbody tr:hover {
  background: #f8fafc;
}

html.light .toggle-switch {
  background: #cbd5e1;
  border-color: #94a3b8;
}

html.light .filter-chip {
  background: #ffffff;
  color: #334155;
  border-color: #cbd5e1;
}

html.light .filter-chip:hover {
  border-color: #059669;
  color: #047857;
}

html.light .filter-chip .chip-count {
  background: #e2e8f0;
  color: #334155;
}

html.light .filter-chip.active .chip-count {
  background: rgba(255, 255, 255, 0.24);
  color: #ffffff;
}

html.light .modal-backdrop {
  background: rgba(15, 23, 42, 0.45);
}

html.light .toast {
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
}

/* Upgrade dark-mode pastel Tailwind utility colors for crisp Light Mode readability */
html.light .text-amber-300,
html.light .text-amber-400,
html.light .text-yellow-300,
html.light .text-yellow-400 {
  color: #b45309 !important;
}

html.light .text-orange-300,
html.light .text-orange-400 {
  color: #c2410c !important;
}

html.light .text-emerald-300,
html.light .text-emerald-400,
html.light .text-green-400 {
  color: #047857 !important;
}

html.light .text-rose-300,
html.light .text-rose-400,
html.light .text-red-400 {
  color: #be123c !important;
}

html.light .text-sky-300,
html.light .text-sky-400,
html.light .text-cyan-400 {
  color: #0369a1 !important;
}

html.light .text-indigo-300,
html.light .text-indigo-400 {
  color: #4338ca !important;
}

html.light .text-purple-300,
html.light .text-purple-400 {
  color: #7e22ce !important;
}

/* ==================== MOBILE RESPONSIVE (< 1024px) ==================== */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 40;
}

.sidebar-backdrop.open {
  display: block;
}

.overflow-x-auto {
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 1023px) {
  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100dvh !important;
    width: 272px !important;
    max-width: 84vw;
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.28);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar.collapsed {
    width: 272px !important;
  }

  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .section-label,
  .sidebar.collapsed .brand-text,
  .sidebar.collapsed .user-meta,
  .sidebar.collapsed .cta-text {
    display: initial;
  }

  .nav-item {
    min-height: 42px;
    font-size: 14px;
  }
}

@media (max-width: 639px) {
  .kpi-card {
    padding: 14px 14px;
    border-radius: 12px;
  }

  .card-surface {
    border-radius: 12px;
  }

  table.data-table th {
    padding: 9px 10px;
    font-size: 10.5px;
    white-space: nowrap;
  }

  table.data-table td {
    padding: 10px 10px;
    font-size: 12.5px;
  }

  .input-field {
    font-size: 16px; /* Prevents iOS Safari auto-zoom on input focus */
    padding: 9px 11px;
  }

  .btn-primary,
  .btn-secondary {
    min-height: 36px;
    padding: 7px 12px;
    font-size: 12.5px;
  }

  .modal-backdrop {
    padding: 10px;
    align-items: flex-end;
  }

  .modal-backdrop > .card-surface {
    max-height: 90dvh;
    overflow-y: auto;
    border-radius: 16px 16px 12px 12px;
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: 14px;
    text-align: center;
  }
}
