/* ============================================
   VALFRI ADMIN — Modern Dashboard
   ============================================ */

:root {
  --bg: #0A0E1A;
  --bg-2: #111827;
  --bg-3: #1F2937;
  --card: #131825;
  --card-hi: #1A2030;
  --border: rgba(255, 255, 255, 0.06);
  --border-hi: rgba(255, 255, 255, 0.12);
  --text: #F9FAFB;
  --text-2: #D1D5DB;
  --text-3: #9CA3AF;
  --text-4: #6B7280;
  --primary: #A855F7;
  --primary-hi: #C084FC;
  --accent: #00C896;
  --blue: #3B82F6;
  --pink: #EC4899;
  --orange: #F59E0B;
  --red: #EF4444;
  --grad: linear-gradient(135deg, #A855F7 0%, #3B82F6 100%);
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg: #F9FAFB;
  --bg-2: #FFFFFF;
  --bg-3: #F3F4F6;
  --card: #FFFFFF;
  --card-hi: #F9FAFB;
  --border: rgba(0, 0, 0, 0.06);
  --border-hi: rgba(0, 0, 0, 0.12);
  --text: #111827;
  --text-2: #374151;
  --text-3: #6B7280;
  --text-4: #9CA3AF;
}

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

body.admin-body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  min-height: 100vh;
  /* overflow-x: hidden removed — breaks position:sticky on iOS Safari */
}

.muted { color: var(--text-3); }

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0;
  z-index: 50;
  transition: transform 0.3s;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  width: 36px; height: 36px;
  background: var(--grad);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 18px; color: white;
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}
.brand-text { font-size: 18px; font-weight: 800; }
.brand-text span { color: var(--text-3); font-weight: 500; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 2px;
  position: relative;
}
.nav-item:hover { background: var(--card-hi); color: var(--text); }
.nav-item.active { background: var(--grad); color: white; box-shadow: 0 4px 16px rgba(168, 85, 247, 0.25); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item span:first-of-type { flex: 1; }
.nav-badge {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}
.nav-item:not(.active) .nav-badge { background: var(--card-hi); color: var(--text-3); }
.nav-badge.green { background: rgba(0, 200, 150, 0.15); color: var(--accent); }
.nav-badge.red { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.nav-badge.soon { background: rgba(168, 85, 247, 0.15); color: #A855F7; font-size: 10px; }

/* ============== NAV SECTIONS (Accordion) ============== */
.nav-section { margin-bottom: 2px; }

.nav-section-header {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 11px 12px;
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  transition: all 0.15s;
  margin-bottom: 2px;
  font-family: inherit;
}
.nav-section-header:hover { background: var(--card-hi); }
.nav-section-header[aria-expanded="true"] { background: var(--card-hi); }

.nav-section-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.nav-section-icon svg { width: 16px; height: 16px; stroke-width: 2.5; }

.nav-section-title { flex: 1; font-size: 13px; letter-spacing: 0.2px; }

.nav-section-badge {
  background: var(--card);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}

.nav-section-chevron {
  width: 16px; height: 16px;
  color: var(--text-3);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}
.nav-section-header[aria-expanded="true"] .nav-section-chevron { transform: rotate(180deg); }

.nav-section-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding-left: 0;
}
.nav-section-items.open { max-height: 500px; }

.nav-subitem {
  padding: 8px 12px 8px 42px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  margin: 1px 0;
  position: relative;
  display: flex; align-items: center; gap: 10px;
  border-radius: 8px;
}
.nav-subitem .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-4);
  flex-shrink: 0;
  transition: all 0.15s;
}
.nav-subitem:hover { background: var(--card-hi); color: var(--text); }
.nav-subitem:hover .dot { background: var(--primary-hi); transform: scale(1.4); }
.nav-subitem.active {
  background: rgba(168, 85, 247, 0.10);
  color: var(--text);
  font-weight: 600;
}
.nav-subitem.active .dot {
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2);
  width: 7px; height: 7px;
}
.nav-subitem.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 8px;
  position: relative;
}
.nav-divider::before {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 4px; height: 4px;
  background: var(--border-hi);
  border-radius: 50%;
}

.nav-item-standalone { margin-top: 4px; }
.nav-item-standalone svg { stroke-width: 2; }

/* ============== TOAST NOTIFICATIONS ============== */
.valfri-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border: 1px solid var(--border-hi);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  z-index: 9999;
  max-width: 360px;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.valfri-toast.show { transform: translateY(0); opacity: 1; }
.valfri-toast-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.valfri-toast-text { flex: 1; }
@media (max-width: 640px) {
  .valfri-toast {
    left: 16px; right: 16px; bottom: 16px;
    max-width: none;
  }
}

.sidebar-bottom { padding: 12px; border-top: 1px solid var(--border); }
.admin-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.admin-avatar {
  width: 36px; height: 36px;
  background: var(--grad);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: white;
  flex-shrink: 0;
}
.admin-info { flex: 1; min-width: 0; }
.admin-name { font-weight: 700; font-size: 13px; }
.admin-role { font-size: 11px; color: var(--text-3); }
.admin-logout {
  background: none; border: none; color: var(--text-3);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.admin-logout:hover { background: var(--card-hi); color: var(--red); }
.admin-logout svg { width: 16px; height: 16px; }

/* ============ MAIN ============ */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex; flex-direction: column;
}

/* ============ TOPBAR ============ */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex !important; align-items: center; gap: 16px;
  padding: 0 24px;
  position: relative;
  z-index: 40;
  flex-shrink: 0;
}
.icon-btn {
  width: 38px; height: 38px;
  display: inline-flex !important; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  padding: 0;
}
.icon-btn svg { width: 18px; height: 18px; display: block; }
.icon-btn:hover { background: var(--card-hi); color: var(--text); }
.notif-pulse {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px;
  background: var(--red);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--bg-2);
}
.notif-pulse::after {
  content: '';
  position: absolute; inset: -2px;
  border-radius: 50%;
  background: var(--red);
  opacity: 0.3;
  animation: pulse 1.5s infinite;
}
@keyframes pulse { 0% { transform: scale(1); opacity: 0.3; } 100% { transform: scale(2.5); opacity: 0; } }

.search-bar {
  flex: 1; max-width: 480px;
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  color: var(--text-3);
  transition: all 0.15s;
}
.search-bar:focus-within { border-color: var(--primary); background: var(--card-hi); }
.search-bar svg { width: 16px; height: 16px; }
.search-bar input {
  background: none; border: none; color: var(--text);
  flex: 1; font-size: 14px; font-family: inherit;
}
.search-bar input::placeholder { color: var(--text-3); }
.search-bar input:focus { outline: none; }
.search-bar kbd {
  font-size: 11px;
  padding: 2px 6px;
  background: var(--card-hi);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-3);
  font-family: inherit;
}

.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar-avatar {
  width: 36px; height: 36px;
  background: var(--grad);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: white;
  cursor: pointer;
}

/* ============ PAGE CONTENT ============ */
.page-content { flex: 1; padding: 24px; }
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.page-head p { margin-top: 4px; }
.page-actions { display: flex; gap: 8px; }

.btn-primary, .btn-secondary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}
.btn-primary { background: var(--grad); color: white; box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(168, 85, 247, 0.4); }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--card-hi); border-color: var(--border-hi); }
.btn-primary svg, .btn-secondary svg { width: 16px; height: 16px; }

/* ============ KPI CARDS ============ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  transition: all 0.2s;
}
.kpi-card:hover { transform: translateY(-2px); border-color: var(--border-hi); box-shadow: var(--shadow-lg); }
.kpi-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.kpi-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.kpi-trend {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}
.kpi-trend.up { background: rgba(0, 200, 150, 0.15); color: var(--accent); }
.kpi-trend.down { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.kpi-value { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.kpi-label { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.kpi-spark { height: 30px; margin-top: 12px; }
.kpi-spark svg { width: 100%; height: 100%; }

/* ============ CARDS ============ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}
.card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 16px;
  gap: 12px;
}
.card-head h3 { font-size: 16px; font-weight: 700; }
.card-head p { font-size: 13px; margin-top: 2px; }
.card-link { color: var(--primary-hi); font-size: 13px; font-weight: 600; text-decoration: none; }
.card-link:hover { text-decoration: underline; }

.dash-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* ============ CHART ============ */
.chart-area {
  display: flex;
  gap: 12px;
  height: 220px;
  margin-bottom: 12px;
}
.y-axis {
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: 11px;
  color: var(--text-3);
  padding-bottom: 4px;
}
.chart-bars {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  position: relative;
}
.chart-bars::before {
  content: '';
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--border) 1px, transparent 1px);
  background-size: 100% 20%;
  opacity: 0.5;
  pointer-events: none;
}
.bar {
  flex: 1;
  height: var(--h);
  background: var(--grad);
  border-radius: 6px 6px 0 0;
  position: relative;
  min-height: 4px;
  transition: opacity 0.2s;
  cursor: pointer;
}
.bar:hover { opacity: 0.85; }
.bar-val {
  position: absolute;
  top: -20px; left: 50%; transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-3);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
}
.bar:hover .bar-val { opacity: 1; }
.chart-legend {
  display: flex; gap: 20px;
  font-size: 12px;
  color: var(--text-3);
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.chart-legend i {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

.seg-control {
  display: flex;
  background: var(--card-hi);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.seg {
  padding: 5px 12px;
  border: none;
  background: none;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.seg.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

/* ============ LIVE MAP ============ */
.live-map {
  height: 220px;
  background: var(--bg);
  border-radius: var(--r);
  position: relative;
  overflow: hidden;
}
.map-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(168, 85, 247, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(168, 85, 247, 0.08) 1px, transparent 1px);
  background-size: 25px 25px;
}
.map-driver {
  position: absolute;
  width: 28px; height: 28px;
  background: var(--grad);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.5);
  animation: driverPulse 2s infinite;
}
.map-driver::after {
  content: '🚗';
  transform: rotate(45deg);
}
@keyframes driverPulse {
  0%, 100% { box-shadow: 0 0 16px rgba(168, 85, 247, 0.5); }
  50% { box-shadow: 0 0 24px rgba(168, 85, 247, 0.8); }
}
.d1 { top: 20%; left: 30%; }
.d2 { top: 50%; left: 60%; animation-delay: 0.3s; }
.d3 { top: 70%; left: 20%; animation-delay: 0.6s; }
.d4 { top: 30%; left: 75%; animation-delay: 0.9s; }
.d5 { top: 60%; left: 40%; animation-delay: 1.2s; }
.d6 { top: 15%; left: 50%; animation-delay: 1.5s; }

.live-dot {
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  margin-right: 4px;
  animation: blink 1.5s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ============ LIVE ORDERS ============ */
.live-orders { display: flex; flex-direction: column; gap: 8px; }
.live-order {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--card-hi);
  border-radius: 10px;
  border: 1px solid var(--border);
  transition: all 0.15s;
  cursor: pointer;
}
.live-order:hover { border-color: var(--border-hi); transform: translateX(2px); }
.lo-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.lo-icon.taxi { background: rgba(59, 130, 246, 0.15); }
.lo-icon.food { background: rgba(245, 158, 11, 0.15); }
.lo-icon.moving { background: rgba(16, 185, 129, 0.15); }
.lo-icon.beauty { background: rgba(236, 72, 153, 0.15); }
.lo-icon.cleaning { background: rgba(6, 182, 212, 0.15); }
.lo-icon.shopping { background: rgba(168, 85, 247, 0.15); }
.lo-body { flex: 1; min-width: 0; }
.lo-title { font-weight: 600; font-size: 13px; }
.lo-meta { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.lo-status {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}
.lo-status.pending { background: rgba(245, 158, 11, 0.15); color: var(--orange); }
.lo-status.progress { background: rgba(59, 130, 246, 0.15); color: var(--blue); }
.lo-status.done { background: rgba(0, 200, 150, 0.15); color: var(--accent); }
.lo-status.upcoming { background: rgba(168, 85, 247, 0.15); color: var(--primary-hi); }
.lo-price { font-weight: 800; font-size: 14px; min-width: 60px; text-align: right; }

/* ============ DONUT ============ */
.donut-wrap {
  display: flex; align-items: center; gap: 20px;
  flex-direction: column;
}
.donut { width: 160px; height: 160px; position: relative; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle { transition: stroke-dasharray 0.5s; }
.donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.donut-num { font-size: 28px; font-weight: 800; }
.donut-label { font-size: 11px; color: var(--text-3); }
.donut-legend { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.dl-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  color: var(--text-2);
  padding: 4px 0;
}
.dl-item strong { margin-left: auto; color: var(--text); }
.dl-dot { width: 10px; height: 10px; border-radius: 3px; }

/* ============ TABS ============ */
.tabs {
  display: flex; gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  font-family: inherit;
  display: flex; align-items: center; gap: 6px;
}
.tab span { color: var(--text-4); font-size: 12px; }
.tab.active { color: var(--text); }
.tab.active::after {
  content: '';
  position: absolute; bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
}

/* ============ DATA TABLE ============ */
.data-table { overflow-x: auto; }
.dt-head, .dt-row {
  display: grid;
  grid-template-columns: 110px 100px 1fr 1fr 130px 100px 90px 40px;
  gap: 12px;
  padding: 12px 12px;
  align-items: center;
  font-size: 13px;
  min-width: 900px;
}
.dt-head {
  background: var(--card-hi);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.dt-row {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.dt-row:hover { background: var(--card-hi); }
.dt-id { font-family: 'SF Mono', Monaco, monospace; color: var(--text-3); font-size: 12px; }
.dt-price { font-weight: 700; text-align: right; }
.dt-actions button {
  background: none; border: none;
  color: var(--text-3);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.dt-actions button:hover { background: var(--card-hi); color: var(--text); }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.badge.green { background: rgba(0, 200, 150, 0.15); color: var(--accent); }
.badge.blue { background: rgba(59, 130, 246, 0.15); color: var(--blue); }
.badge.yellow { background: rgba(245, 158, 11, 0.15); color: var(--orange); }
.badge.red { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.badge.purple { background: rgba(168, 85, 247, 0.15); color: var(--primary-hi); }

/* ============ USER CARDS ============ */
.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.user-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  transition: all 0.2s;
}
.user-card:hover { transform: translateY(-2px); border-color: var(--border-hi); }
.uc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.uc-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: white;
  flex-shrink: 0;
}
.uc-info { flex: 1; min-width: 0; }
.uc-name { font-weight: 700; }
.uc-email { font-size: 12px; color: var(--text-3); }
.uc-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.uc-stats > div { text-align: center; }
.uc-stats strong { display: block; font-size: 16px; }
.uc-stats span { font-size: 11px; color: var(--text-3); }
.uc-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px;
}

/* ============ PLACEHOLDER ============ */
.placeholder {
  background: var(--card);
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: 80px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 18px;
}

/* ============ SEGMENTED CONTROL ============ */
.seg-control {
  display: inline-flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  gap: 2px;
  margin-bottom: 16px;
}
.seg {
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.seg:hover { color: var(--text-1); }
.seg.active {
  background: var(--primary);
  color: white;
}

/* ============ PAGE HEADER ============ */
.page-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 20px;
}
.page-header h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.page-header p { color: var(--text-3); font-size: 14px; }

/* ============ SECTORS MODULE ============ */
.sectors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.sector-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.sector-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: var(--sector-color);
}
.sector-card:hover {
  transform: translateY(-3px);
  border-color: var(--sector-color);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.sector-card-icon { font-size: 36px; margin-bottom: 12px; }
.sector-card-name { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.sector-card-meta { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.meta-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); }
.meta-row b { color: var(--text-1); }
.sector-card-cta { color: var(--sector-color); font-weight: 700; font-size: 13px; }

.sector-header {
  display: flex; align-items: center; gap: 20px;
  padding: 24px; border-radius: var(--r-lg); margin-bottom: 24px;
}
.sector-icon {
  width: 64px; height: 64px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; flex-shrink: 0;
}
.sector-info { flex: 1; }
.sector-info h2 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.sector-info p { color: var(--text-3); font-size: 13px; }
.sector-actions { display: flex; gap: 8px; }

.service-list { display: flex; flex-direction: column; gap: 8px; }
.service-item {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.service-num {
  width: 28px; height: 28px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
}
.service-name { font-weight: 600; font-size: 14px; }
.service-stats { display: flex; gap: 12px; align-items: center; font-size: 12px; }
.service-actions { display: flex; gap: 4px; }

.sector-config-list { display: flex; flex-direction: column; }
.config-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 0; border-bottom: 1px solid var(--border);
}
.config-row:last-child { border-bottom: none; }
.config-row > div:first-child b { display: block; margin-bottom: 2px; }
.config-row > div:first-child .muted { font-size: 12px; }
.config-row > div:last-child { text-align: right; font-size: 14px; }

/* ============ DRIVERS MODULE ============ */
.driver-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.driver-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  transition: all 0.15s;
}
.driver-card:hover { border-color: var(--primary); }
.driver-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.driver-avatar { font-size: 32px; }
.driver-status-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  padding: 3px 8px; border-radius: 6px;
}
.driver-status-badge.status-available { background: rgba(16,185,129,0.15); color: #10B981; }
.driver-status-badge.status-on_trip { background: rgba(59,130,246,0.15); color: #3B82F6; }
.driver-status-badge.status-off_duty { background: rgba(156,163,175,0.15); color: #9CA3AF; }
.driver-status-badge.status-on_break { background: rgba(245,158,11,0.15); color: #F59E0B; }
.driver-name { font-size: 15px; font-weight: 700; }
.driver-sector { font-size: 12px; color: var(--text-3); margin-bottom: 10px; }
.driver-stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.driver-stat { text-align: center; padding: 6px; background: rgba(255,255,255,0.03); border-radius: 8px; }
.ds-num { font-size: 14px; font-weight: 700; }
.ds-label { font-size: 10px; color: var(--text-3); }
.driver-schedule { padding: 8px 0; font-size: 12px; border-top: 1px solid var(--border); margin-bottom: 10px; }
.driver-actions { display: flex; gap: 6px; }
.driver-actions button { flex: 1; }

/* Schedule grid */
.schedule-grid {
  display: grid;
  grid-template-columns: 100px repeat(7, 1fr);
  gap: 4px;
  font-size: 12px;
}
.schedule-corner {
  background: var(--card);
  padding: 8px;
  font-weight: 700;
  border-radius: 6px;
  display: flex; align-items: center;
}
.schedule-day-head {
  background: var(--card);
  padding: 8px;
  text-align: center;
  font-weight: 700;
  border-radius: 6px;
}
.schedule-driver-cell {
  background: var(--card);
  padding: 8px;
  font-weight: 600;
  border-radius: 6px;
  display: flex; align-items: center;
}
.schedule-cell {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  min-height: 50px;
  display: flex; flex-direction: column; justify-content: center;
}
.schedule-cell.empty { color: var(--text-3); text-align: center; }
.schedule-cell.filled { padding: 6px 8px; }
.shift-time { font-size: 11px; font-weight: 700; }
.shift-sector { font-size: 10px; opacity: 0.7; }

.week-label { padding: 0 12px; font-weight: 600; font-size: 13px; }

/* Time-off cards */
.timeoff-list { display: flex; flex-direction: column; gap: 10px; }
.timeoff-card {
  display: grid;
  grid-template-columns: 50px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  border-left-width: 4px;
}
.timeoff-card.status-pending { border-left-color: #F59E0B; }
.timeoff-card.status-approved { border-left-color: #10B981; }
.timeoff-card.status-rejected { border-left-color: #EF4444; }
.timeoff-icon { font-size: 30px; text-align: center; }
.timeoff-driver { font-weight: 700; font-size: 14px; }
.timeoff-type { font-size: 12px; color: var(--text-3); }
.timeoff-dates { font-size: 12px; margin-top: 2px; }
.timeoff-reason { font-size: 11px; font-style: italic; margin-top: 4px; }
.timeoff-status { text-align: right; }
.timeoff-actions { display: flex; gap: 6px; margin-top: 8px; }

/* Leaderboard */
.leaderboard { display: flex; flex-direction: column; gap: 8px; }
.leaderboard-item {
  display: grid;
  grid-template-columns: 36px 40px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.lb-rank {
  width: 28px; height: 28px;
  background: var(--bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px;
}
.lb-rank.rank-1 { background: linear-gradient(135deg, #FFD700, #FFA500); color: #000; }
.lb-rank.rank-2 { background: linear-gradient(135deg, #C0C0C0, #808080); color: #000; }
.lb-rank.rank-3 { background: linear-gradient(135deg, #CD7F32, #8B4513); color: #fff; }
.lb-avatar { font-size: 28px; text-align: center; }
.lb-name { font-weight: 700; font-size: 13px; }
.lb-stats { font-size: 11px; color: var(--text-3); }
.lb-earnings { font-weight: 800; color: #10B981; font-size: 14px; }

.perf-stats { display: flex; flex-direction: column; }
.perf-row {
  display: flex; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.perf-row:last-child { border-bottom: none; }

/* ============ FLEET MODULE ============ */
.search-input {
  padding: 8px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-1);
  font-size: 13px;
  font-family: inherit;
  min-width: 200px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 12px;
  font-weight: 700;
  color: var(--text-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

.maintenance-list { display: flex; flex-direction: column; gap: 8px; }
.maint-item {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  border-left: 3px solid var(--border);
}
.maint-item.urgent { border-left-color: #EF4444; }
.maint-icon { font-size: 22px; text-align: center; }
.maint-info b { display: block; font-size: 13px; }
.maint-info .muted { font-size: 11px; }
.maint-cost { font-weight: 700; font-size: 13px; color: #F59E0B; }

.cost-chart {
  display: flex; align-items: flex-end; gap: 12px;
  height: 200px; padding: 16px 0;
}
.cost-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.cost-bar {
  width: 100%; background: linear-gradient(180deg, #3B82F6, #1E40AF);
  border-radius: 6px 6px 0 0;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 6px; min-height: 20px;
}
.cost-label { font-size: 10px; font-weight: 700; color: white; }
.cost-plate { font-size: 11px; color: var(--text-3); font-weight: 600; }

/* ============ LOYALTY MODULE ============ */
.tiers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.tier-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  border-top: 4px solid var(--tier-color);
}
.tier-icon { font-size: 42px; text-align: center; margin-bottom: 8px; }
.tier-name { font-size: 18px; font-weight: 800; text-align: center; margin-bottom: 4px; }
.tier-min { text-align: center; color: var(--text-3); font-size: 12px; margin-bottom: 12px; }
.tier-discount {
  text-align: center; font-size: 28px; font-weight: 900;
  color: var(--tier-color); margin-bottom: 12px;
}
.tier-perks { list-style: none; padding: 0; margin: 12px 0; }
.tier-perks li {
  font-size: 12px; padding: 4px 0; color: var(--text-2);
  padding-left: 18px; position: relative;
}
.tier-perks li::before {
  content: '✓'; position: absolute; left: 0;
  color: var(--tier-color); font-weight: 800;
}
.tier-count { text-align: center; font-size: 11px; color: var(--text-3); padding-top: 8px; border-top: 1px solid var(--border); }

.reward-list { display: flex; flex-direction: column; gap: 8px; }
.reward-item {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.reward-icon { font-size: 24px; text-align: center; }
.reward-name { font-weight: 700; font-size: 13px; }
.reward-cost { font-size: 11px; color: var(--text-3); }
.reward-redeemed { font-size: 11px; font-weight: 700; color: #10B981; }

.activity-chart { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding: 16px 0; }
.day-column { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; }
.bar { width: 16px; border-radius: 4px 4px 0 0; position: relative; min-height: 10px; display: flex; align-items: flex-start; justify-content: center; padding-top: 4px; }
.bar.earned { background: linear-gradient(180deg, #A855F7, #7E22CE); }
.bar.redeemed { background: linear-gradient(180deg, #10B981, #047857); }
.bar-value { font-size: 9px; color: white; font-weight: 800; white-space: nowrap; }
.day-label { font-size: 11px; color: var(--text-3); font-weight: 600; }
.chart-legend { display: flex; gap: 20px; justify-content: center; font-size: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.dot.earned { background: #A855F7; }
.dot.redeemed { background: #10B981; }

/* ============ STAFF MODULE ============ */
.filter-select, .filter-date {
  padding: 8px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-1);
  font-size: 13px;
  font-family: inherit;
}

.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.role-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  border-top: 4px solid var(--role-color);
}
.role-icon { font-size: 32px; text-align: center; margin-bottom: 8px; }
.role-name { font-size: 15px; font-weight: 800; text-align: center; }
.role-desc { font-size: 12px; color: var(--text-3); text-align: center; margin: 8px 0; }
.role-count { text-align: center; font-size: 11px; color: var(--text-2); padding: 8px 0; border-top: 1px solid var(--border); }
.role-actions { display: flex; justify-content: center; margin-top: 10px; }

.permission-matrix-wrap { overflow-x: auto; }
.permission-matrix { width: 100%; border-collapse: collapse; font-size: 12px; }
.permission-matrix th, .permission-matrix td {
  padding: 8px; border: 1px solid var(--border);
  text-align: center;
}
.permission-matrix th.rotate { height: 120px; vertical-align: bottom; }
.permission-matrix th.rotate > span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; padding: 8px 0; }
.permission-matrix td.perm-yes { background: rgba(16,185,129,0.15); color: #10B981; font-weight: 800; }
.permission-matrix td.perm-no { color: var(--text-3); }
.permission-matrix code { background: var(--bg-2); padding: 2px 6px; border-radius: 4px; font-size: 11px; color: var(--primary-hi); }

.audit-list { display: flex; flex-direction: column; gap: 4px; max-height: 600px; overflow-y: auto; }
.audit-item {
  display: grid;
  grid-template-columns: 70px 24px 140px 80px 1fr 2fr;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-2);
  border-radius: 6px;
  font-size: 12px;
  border-left: 3px solid var(--border);
}
.audit-item.audit-login { border-left-color: #10B981; }
.audit-item.audit-create { border-left-color: #3B82F6; }
.audit-item.audit-update { border-left-color: #F59E0B; }
.audit-item.audit-delete { border-left-color: #EF4444; }
.audit-item.audit-export { border-left-color: #A855F7; }
.audit-item.audit-system { border-left-color: #9CA3AF; }
.audit-time { font-family: monospace; color: var(--text-3); }
.audit-icon { text-align: center; }
.audit-actor b { font-weight: 700; }
.audit-action { color: var(--primary-hi); font-weight: 600; }
.audit-resource code { background: var(--bg); padding: 2px 5px; border-radius: 3px; font-size: 11px; }

/* ============ TOGGLE SWITCH ============ */
.toggle {
  width: 40px; height: 22px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: var(--text-3);
  border-radius: 50%;
  transition: all 0.2s;
}
.toggle.on { background: #10B981; border-color: #10B981; }
.toggle.on::after { left: 20px; background: white; }

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-lg);
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  animation: slideUp 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal h3 { margin-bottom: 16px; font-size: 18px; }
.config-form { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.form-group input, .form-group select, .form-group textarea {
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-1);
  font-size: 13px;
  font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary);
}
.form-group small { font-size: 11px; color: var(--text-3); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.perm-checkboxes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.checkbox-row { display: flex; align-items: center; gap: 6px; font-size: 12px; }

/* ============ TOAST ============ */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--card);
  border: 1px solid var(--border-hi);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 2000;
  animation: slideInRight 0.3s;
}
.toast.success { border-left-color: #10B981; }
.toast.error { border-left-color: #EF4444; }
.toast.info { border-left-color: #3B82F6; }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============ DETAIL COMPONENTS ============ */
.driver-detail, .vehicle-detail { display: flex; flex-direction: column; gap: 16px; }
.dd-header, .vd-header { display: flex; align-items: center; gap: 16px; }
.dd-avatar, .vd-icon { font-size: 48px; }
.dd-stats, .vd-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 12px; padding: 16px; background: var(--bg-2); border-radius: 10px;
}
.dd-stats > div, .vd-stats > div { text-align: center; }
.dd-stats b, .vd-stats b { display: block; font-size: 18px; color: var(--primary-hi); }
.dd-stats span, .vd-stats span { font-size: 11px; color: var(--text-3); }
.dd-chart-mini { display: flex; align-items: flex-end; gap: 2px; height: 60px; padding: 8px 0; }
.mini-bar { flex: 1; background: linear-gradient(180deg, #A855F7, #7E22CE); border-radius: 2px 2px 0 0; min-height: 4px; }
.service-history { list-style: none; padding: 0; }
.service-history li { padding: 6px 0; font-size: 12px; color: var(--text-2); border-bottom: 1px solid var(--border); }

/* ============ RESPONSIVE ============ */
.icon-btn { display: inline-flex; }
#menuBtn { 
  position: relative; 
  transition: background 0.2s, transform 0.2s; 
  z-index: 200;
  display: flex !important; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; /* iOS tap target */
}
#menuBtn:hover { transform: scale(1.05); }
#menuBtn:active { transform: scale(0.95); }
#menuBtn.active { background: var(--primary); color: white; }
#menuBtn.active svg { stroke: white; }
#menuBtn svg { transition: transform 0.3s; width: 22px; height: 22px; }
#menuBtn.active svg { transform: rotate(90deg); }
.topbar { z-index: 200 !important; }

@media (min-width: 1025px) {
  #menuBtn { display: none !important; }
  .sidebar-overlay { display: none !important; }
  .topbar { z-index: 40 !important; }
}
@media (max-width: 1024px) {
  body.admin-body { display: block !important; }
  .sidebar { 
    transform: translateX(-105%); 
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    box-shadow: 4px 0 24px rgba(0,0,0,0.5); 
    z-index: 150; 
    visibility: hidden;
  }
  .sidebar.open { transform: translateX(0); visibility: visible; }
  .main { margin-left: 0 !important; width: 100% !important; max-width: 100vw !important; }
  .dash-row { grid-template-columns: 1fr !important; }
  .kpi-grid { grid-template-columns: 1fr 1fr !important; }
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 140;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  .sidebar-overlay.show { display: block; }
  .page-head { flex-direction: column; align-items: flex-start !important; gap: 12px; }
  .page-head .page-actions { width: 100%; flex-wrap: wrap; }
  .page { padding: 12px !important; }
  .topbar { padding: 0 12px !important; gap: 8px !important; }
  .topbar .search-bar { display: none !important; }
  /* Accordion optimizations for mobile */
  .nav-section-header { padding: 12px 10px; }
  .nav-section-icon { width: 32px; height: 32px; }
  .nav-subitem { padding: 9px 10px 9px 36px; }
  .nav-section-items.open { max-height: 600px; }
}
@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: 1fr !important; }
  .topbar { padding: 0 12px !important; height: 56px !important; }
  #menuBtn { min-width: 40px; min-height: 40px; }
  #menuBtn svg { width: 20px; height: 20px; }
  .topbar-avatar { width: 32px; height: 32px; font-size: 12px; }
  .data-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .contact-layout { grid-template-columns: 1fr !important; }
  .contact-layout .card:first-child { max-height: 280px; overflow-y: auto; }
  .user-grid { grid-template-columns: 1fr !important; }
  .modal { max-width: 95vw !important; max-height: 90vh; margin: 16px !important; }
  .form-group input, .form-group select, .form-group textarea { font-size: 16px; }
  .btn-primary, .btn-secondary { padding: 10px 14px; font-size: 14px; }
  .page-head h1 { font-size: 18px !important; }
  table { font-size: 12px; }
}
@media (max-width: 640px) {
  .page-content { padding: 12px !important; }
  .page-head h1 { font-size: 20px !important; }
  .topbar-right .theme-toggle { display: none; }
  .chart-bars { height: 120px; }
  .seg-control { flex-wrap: wrap; }
  .seg { padding: 6px 10px; font-size: 12px; }
  .kpi-mini .kpi-val { font-size: 20px !important; }
}
@media (max-width: 380px) {
  .topbar { padding: 0 8px !important; }
  .topbar-avatar { display: none; }
  .notif-btn { display: none; }
}

/* ===== Subitem Icons (Lucide) ===== */
.nav-subitem {
  padding-left: 14px !important;
  gap: 10px !important;
}
.nav-subitem .nav-subicon {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #94a3b8);
  flex-shrink: 0;
  transition: color 0.15s;
  line-height: 0;
}
.nav-subitem .nav-subicon svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  display: block;
}
.nav-subitem > span:not(.nav-subicon):not(.nav-badge) { flex: 1; }
.nav-subitem.active .nav-subicon,
.nav-subitem:hover .nav-subicon { color: var(--primary, #6366f1); }
.nav-subitem .dot { display: none !important; }

/* ===== Inline Content Additions (Aug 6 2026) ===== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.kpi-label { font-size: 12px; color: var(--text-muted, #64748b); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--text, #0f172a); margin-top: 4px; }
.kpi-delta { font-size: 12px; margin-top: 4px; font-weight: 600; }
.kpi-delta.up { color: #10b981; }
.kpi-delta.down { color: #10b981; }
.kpi-delta.warn { color: #f59e0b; }

.page-actions { display: flex; gap: 10px; }
.btn-primary, .btn-secondary {
  padding: 8px 16px; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; border: none; transition: all 0.15s;
}
.btn-primary { background: var(--primary, #6366f1); color: white; }
.btn-primary:hover { background: #4f46e5; transform: translateY(-1px); }
.btn-secondary { background: var(--surface, #fff); color: var(--text, #0f172a); border: 1px solid var(--border, #e5e7eb); }
.btn-secondary:hover { background: #f8fafc; }

.data-table { background: var(--surface, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 12px; overflow: hidden; }
.dt-head, .dt-row { display: grid; grid-template-columns: 2fr 1.2fr 1fr 0.8fr 0.8fr 1fr 0.5fr; gap: 12px; padding: 12px 16px; align-items: center; }
.dt-head { background: #f8fafc; font-size: 11px; text-transform: uppercase; color: var(--text-muted, #64748b); font-weight: 700; letter-spacing: 0.5px; }
.dt-body .dt-row { border-top: 1px solid var(--border, #e5e7eb); transition: background 0.1s; }
.dt-body .dt-row:hover { background: #f8fafc; }
.dt-price { font-weight: 700; color: var(--text, #0f172a); }
.dt-actions button { background: none; border: none; cursor: pointer; padding: 4px 8px; border-radius: 6px; color: var(--text-muted); }
.dt-actions button:hover { background: #f1f5f9; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge.green { background: #dcfce7; color: #166534; }
.badge.yellow { background: #fef3c7; color: #92400e; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.blue { background: #dbeafe; color: #1e40af; }
.badge.purple { background: #f3e8ff; color: #6b21a8; }
.badge.orange { background: #ffedd5; color: #9a3412; }
.badge.gray { background: #f1f5f9; color: #475569; }

.uc-avatar { border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; flex-shrink: 0; }

.sector-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.sector-card { padding: 24px; border-radius: 16px; color: white; box-shadow: 0 4px 12px rgba(0,0,0,0.08); transition: transform 0.2s; cursor: pointer; }
.sector-card:hover { transform: translateY(-3px); }
.sc-icon { font-size: 36px; margin-bottom: 12px; }
.sc-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.sc-stats { font-size: 12px; opacity: 0.9; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.settings-card { background: var(--surface, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 12px; padding: 20px; }
.settings-card h3 { font-size: 15px; margin-bottom: 14px; }
.setting-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid var(--border, #e5e7eb); font-size: 13px; }
.setting-row:first-of-type { border-top: none; }
.toggle { width: 36px; height: 20px; background: #cbd5e1; border-radius: 999px; position: relative; cursor: pointer; transition: background 0.2s; }
.toggle.on { background: #10b981; }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: white; border-radius: 50%; transition: left 0.2s; }
.toggle.on::after { left: 18px; }

.chart-card { background: var(--surface, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.bar-chart { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: flex; align-items: center; gap: 12px; }
.bar-label { width: 110px; font-size: 13px; font-weight: 600; }
.bar-track { flex: 1; height: 28px; background: #f1f5f9; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; display: flex; align-items: center; justify-content: flex-end; padding-right: 10px; color: white; font-size: 12px; font-weight: 700; border-radius: 6px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.muted { color: var(--text-muted, #64748b); margin-top: 4px; }


/* ============================================
   SB- SHORTHAND ALIASES (dashboard pages)
   ============================================ */
.sb-brand { display: flex; align-items: center; gap: 12px; padding: 20px 16px; border-bottom: 1px solid var(--border); }
.sb-logo { width: 40px; height: 40px; border-radius: 10px; background: var(--grad); display: flex; align-items: center; justify-content: center; font-weight: 800; color: white; font-size: 20px; }
.sb-name { font-weight: 800; font-size: 16px; color: var(--text); }
.sb-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.sb-nav { flex: 1; padding: 12px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.sb-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--text-2); text-decoration: none; font-size: 13px; font-weight: 500; transition: all 0.15s; white-space: nowrap; }
.sb-nav a:hover { background: var(--card-hi); color: var(--text); }
.sb-nav a.active { background: var(--grad); color: white; font-weight: 700; }
.sb-foot { padding: 12px; border-top: 1px solid var(--border); }
.sb-foot a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--text-3); text-decoration: none; font-size: 12px; }
.sb-foot a:hover { background: var(--card-hi); color: var(--text); }


/* ============================================
   SIDEBAR GROUPS (collapsible categories)
   ============================================ */
.sb-group { margin-bottom: 4px; }
.sb-group-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--text-3); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  cursor: pointer; user-select: none; transition: all 0.15s;
}
.sb-group-head:hover { background: var(--card-hi); color: var(--text); }
.sb-group-head .ic { font-size: 16px; }
.sb-group-head .chev { margin-left: auto; font-size: 10px; transition: transform 0.2s; }
.sb-group.collapsed .chev { transform: rotate(-90deg); }
.sb-group.collapsed .sb-group-items { display: none; }
.sb-group-items { display: flex; flex-direction: column; gap: 1px; padding-left: 8px; margin-top: 2px; }
.sb-group-items a {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px 7px 24px; border-radius: 6px;
  color: var(--text-2); text-decoration: none;
  font-size: 12.5px; font-weight: 500;
  transition: all 0.15s; position: relative;
}
.sb-group-items a::before {
  content: ''; position: absolute; left: 12px; top: 50%;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--text-4); transform: translateY(-50%);
}
.sb-group-items a:hover { background: var(--card-hi); color: var(--text); }
.sb-group-items a:hover::before { background: var(--primary); }
.sb-group-items a.active {
  background: var(--grad); color: white; font-weight: 700;
}
.sb-group-items a.active::before { background: white; }


/* ============================================
   DESIGN SYSTEM FIX — Consistent across all pages
   Applied 2026-08-06 after visual audit
   ============================================ */

/* --- 1. Body / root color consistency --- */
html, body.admin-body, .main, .content {
  background: var(--bg, #0a0e1a) !important;
  color: var(--text, #e5e7eb) !important;
}
.admin-body {
  min-height: 100vh;
  background: var(--bg) !important;
}

/* --- 2. Content area padding — consistent --- */
.content {
  padding: 28px 32px !important;
  max-width: 100%;
  box-sizing: border-box;
}

/* --- 3. Card padding — consistent --- */
.card {
  background: var(--card) !important;
  border: 1px solid var(--border) !important;
  border-radius: 14px !important;
  padding: 0 !important;  /* internal sections handle padding */
  margin-bottom: 20px;
  overflow: hidden;
  box-sizing: border-box;
}
.card-head {
  padding: 18px 24px !important;
  border-bottom: 1px solid var(--border);
}
.card-body, .card > .table-wrap, .card > table {
  padding: 4px 0;
}

/* --- 4. Page header — global style --- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}
.page-title {
  font-size: 28px !important;
  font-weight: 800 !important;
  margin: 0 !important;
  color: var(--text) !important;
}
.page-subtitle {
  color: var(--text-muted) !important;
  font-size: 14px !important;
  margin-top: 4px;
}

/* --- 5. Tables — wrap, no horizontal overflow --- */
.card { overflow-x: auto; }
table {
  width: 100% !important;
  max-width: 100% !important;
  table-layout: auto;
  border-collapse: collapse;
}
table th, table td {
  padding: 12px 16px !important;
  font-size: 13px !important;
  white-space: nowrap;  /* keep cells tidy */
}
.card > table { display: block; overflow-x: auto; }

/* --- 6. Buttons — global consistency --- */
.btn {
  padding: 8px 16px !important;
  border-radius: 8px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  cursor: pointer;
  border: 0;
  transition: all 0.15s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--primary) !important; color: white !important; }
.btn-secondary { background: var(--card-hi) !important; color: var(--text) !important; border: 1px solid var(--border) !important; }
.btn-success { background: #10b981 !important; color: white !important; }
.btn-warn { background: #f59e0b !important; color: white !important; }
.btn-danger { background: #ef4444 !important; color: white !important; }
.btn-sm { padding: 5px 10px !important; font-size: 11px !important; }
.btn:hover { transform: translateY(-1px); filter: brightness(1.1); }

/* --- 7. Inputs / selects / textareas --- */
input[type="text"], input[type="email"], input[type="number"],
input[type="search"], input[type="password"], input[type="tel"],
select, textarea {
  background: var(--card-hi) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  padding: 9px 12px !important;
  border-radius: 8px !important;
  font-size: 13px !important;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary) !important;
}

/* --- 8. Form labels --- */
label, .form-label {
  font-size: 12px !important;
  font-weight: 600 !important;
  color: var(--text-muted) !important;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 6px;
}

/* --- 9. Status pills — global --- */
.status {
  display: inline-block;
  padding: 4px 10px !important;
  border-radius: 6px !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.status.active, .status.done, .status.ready, .status.completed {
  background: rgba(16,185,129,0.15) !important;
  color: #10b981 !important;
}
.status.pending, .status.waiting {
  background: rgba(59,130,246,0.15) !important;
  color: #60a5fa !important;
}
.status.processing, .status.washing, .status.in_progress {
  background: rgba(6,182,212,0.15) !important;
  color: #22D3EE !important;
}
.status.drying, .status.warning {
  background: rgba(245,158,11,0.15) !important;
  color: #f59e0b !important;
}
.status.cancelled, .status.inactive, .status.failed, .status.rejected {
  background: rgba(239,68,68,0.15) !important;
  color: #ef4444 !important;
}

/* --- 10. Topbar — fix for all pages --- */
.topbar {
  padding: 14px 28px !important;
  background: var(--card) !important;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.tb-title {
  font-size: 18px !important;
  font-weight: 700 !important;
  color: var(--text) !important;
  flex: 1;
}
.tb-actions { display: flex; gap: 8px; align-items: center; }

/* --- 11. Stat/KPI cards --- */
.kpi-card {
  background: var(--card) !important;
  border: 1px solid var(--border) !important;
  border-radius: 14px !important;
  padding: 20px !important;
  position: relative;
  overflow: hidden;
}
.kpi-value { font-size: 28px !important; font-weight: 800 !important; color: var(--text) !important; }
.kpi-label { font-size: 12px !important; text-transform: uppercase; color: var(--text-muted) !important; font-weight: 600 !important; }
.kpi-sub { font-size: 12px !important; color: var(--text-muted) !important; margin-top: 4px; }

/* --- 12. Sidebar visual fix — kill the color band --- */
.sidebar {
  background: var(--card) !important;
  border-right: 1px solid var(--border);
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 260px;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.2s;
}
.sb-brand {
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sb-nav { flex: 1; padding: 12px; overflow-y: auto; }
.sb-foot { padding: 12px 18px; border-top: 1px solid var(--border); font-size: 12px; }
.sb-foot a { color: var(--text-muted); text-decoration: none; }

/* --- 13. Main area offset for sidebar --- */
.main {
  margin-left: 260px;
  min-height: 100vh;
  background: var(--bg);
}
@media (max-width: 900px) {
  .main { margin-left: 0; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 20px 16px !important; }
}

/* --- 14. Sidebar items --- */
.sb-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}
.sb-group-head:hover { background: var(--card-hi); color: var(--text); }
.sb-group.collapsed .chev { transform: rotate(-90deg); }
.sb-group.collapsed .sb-group-items { display: none; }
.sb-group-items { padding-left: 8px; margin-top: 2px; display: flex; flex-direction: column; gap: 1px; }
.sb-group-items a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 24px;
  border-radius: 6px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  position: relative;
  transition: all 0.15s;
}
.sb-group-items a::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-4);
  transform: translateY(-50%);
}
.sb-group-items a:hover { background: var(--card-hi); color: var(--text); }
.sb-group-items a:hover::before { background: var(--primary); }
.sb-group-items a.active {
  background: var(--grad);
  color: white;
  font-weight: 700;
}
.sb-group-items a.active::before { background: white; }
.chev { margin-left: auto; font-size: 10px; transition: transform 0.2s; }

/* --- 15. Tables — striped + hover --- */
table tbody tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
table tbody tr:hover td { background: var(--card-hi) !important; }
table th {
  background: var(--card-hi) !important;
  font-weight: 700 !important;
  color: var(--text-muted) !important;
  text-transform: uppercase;
  font-size: 11px !important;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

/* --- 16. Grids — responsive --- */
.kpi-row, .grid, .row {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}
.kpi-row { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* --- 17. Tabs --- */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--card-hi);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 20px;
  overflow-x: auto;
  flex-wrap: wrap;
}
.tab {
  padding: 9px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all 0.15s;
  background: transparent;
  border: 0;
  font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* --- 18. Light theme overrides --- */
[data-theme="light"] body.admin-body,
[data-theme="light"] .main,
[data-theme="light"] .content {
  background: #f9fafb !important;
  color: #111827 !important;
}
[data-theme="light"] .card,
[data-theme="light"] .sidebar,
[data-theme="light"] .topbar {
  background: #ffffff !important;
  border-color: #e5e7eb !important;
}
[data-theme="light"] .kpi-value,
[data-theme="light"] .page-title,
[data-theme="light"] .tb-title { color: #111827 !important; }
[data-theme="light"] .kpi-label,
[data-theme="light"] .page-subtitle,
[data-theme="light"] .card-sub { color: #6b7280 !important; }
[data-theme="light"] .btn-secondary {
  background: #f3f4f6 !important;
  color: #111827 !important;
}
[data-theme="light"] .kpi-card,
[data-theme="light"] .card { box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
[data-theme="light"] table th { background: #f3f4f6 !important; color: #6b7280 !important; }
[data-theme="light"] table tbody tr:hover td { background: #f9fafb !important; }
[data-theme="light"] .sb-group-head { color: #6b7280; }
[data-theme="light"] .sb-group-items a { color: #4b5563; }
[data-theme="light"] .sb-group-items a.active { color: white; }

/* --- 19. Header cleanup — kill purple/white headers --- */
.page-header h1, .page-header h2 {
  color: var(--text) !important;
  background: none !important;
  -webkit-background-clip: initial !important;
  background-clip: initial !important;
  -webkit-text-fill-color: var(--text) !important;
}

/* --- 20. Mobile menu button --- */
.menu-btn {
  background: var(--card-hi);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  display: none;
  align-items: center;
  justify-content: center;
}
@media (max-width: 900px) {
  .menu-btn { display: flex; }
}


/* --- Table overflow protection --- */
.cohort-table, .pricing-table, .drivers-table, .orders-table,
table.large-table, .table-wrap {
  display: block;
  overflow-x: auto;
  max-width: 100%;
  white-space: nowrap;
}
.cohort-table thead, .cohort-table tbody,
.pricing-table thead, .pricing-table tbody {
  display: table;
  width: 100%;
}
.table-wrap { padding: 4px 8px; }


/* --- Filter bar constraints --- */
.filters-bar {
  flex-wrap: wrap !important;
  max-width: 100%;
  overflow: hidden;
}
.filters-bar .filter-input,
.filters-bar input[type="search"],
.filters-bar input[type="text"] {
  flex: 1 1 220px;
  min-width: 0;
  max-width: 100%;
}
.filters-bar select,
.filters-bar .filter-select {
  flex: 0 1 180px;
  min-width: 0;
  max-width: 100%;
}
.filters-bar button {
  flex: 0 0 auto;
}

/* --- Orders grid responsive --- */
.orders-grid {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 360px !important;
  gap: 20px;
}
@media (max-width: 1300px) {
  .orders-grid { grid-template-columns: 1fr !important; }
}

/* --- Tab panel + card overflow --- */
.tab-panel.active { overflow: hidden; }
.card { 
  overflow: hidden !important;
  max-width: 100%;
}
.card > .table-wrap {
  overflow-x: auto;
  max-width: 100%;
  padding: 0;
}


/* --- AGGRESSIVE table containment --- */
table {
  display: table !important;
  width: 100% !important;
  max-width: 100% !important;
  table-layout: auto;
}
.card > table, .table-wrap > table {
  display: table;
  width: 100% !important;
  table-layout: auto;
}
table thead { display: table-header-group; }
table tbody { display: table-row-group; }
table tr { display: table-row; }
table th, table td { display: table-cell; }

/* Hide content overflow on tab panels and cards */
.tab-panel, .content, .main {
  max-width: 100%;
}


/* --- Table wrap scrollable container --- */
.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.table-wrap > table {
  min-width: 600px;
}



/* --- Document-level horizontal overflow guard --- */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* --- Sidebar/main responsive --- */
.main {
  margin-left: 260px;
  min-height: 100vh;
  max-width: calc(100vw - 260px);
}
@media (max-width: 900px) {
  .main { margin-left: 0; max-width: 100vw; }
}

/* --- Orders grid: stack at narrow widths --- */
.orders-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
}
@media (max-width: 1300px) {
  .orders-grid { grid-template-columns: 1fr; }
}
.orders-card { min-width: 0; max-width: 100%; }


/* === ROW ACTIONS - SVG ICONS === */
.row-actions {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
}
.ra-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
}
.ra-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  display: block;
}
.ra-btn:hover {
  background: var(--card-hi);
  border-color: var(--primary);
  color: var(--primary);
}
.ra-btn:active {
  transform: scale(0.95);
}
/* Legacy dt-actions support */
.dt-actions {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
}
.dt-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-3);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  transition: all 0.15s;
}
.dt-actions button:hover {
  background: var(--card-hi);
  border-color: var(--primary);
  color: var(--primary);
}

/* === IMPROVED CARD CONTRAST === */
.card {
  background: var(--card) !important;
  border: 1px solid var(--border-hi) !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2) !important;
}

/* Sidebar gets a slightly different bg for contrast */
.sidebar {
  background: var(--bg-2) !important;
  border-right: 1px solid var(--border-hi) !important;
}

/* === FIX PAGE 2 - MEDDELANDE PLURAL === */
/* Done in JS files */



/* ============================================= */
/* === RESPONSIVE TABLE OVERFLOW HANDLING === */
/* ============================================= */
@media (max-width: 1200px) {
  /* Make all card content scrollable horizontally if needed */
  .card-body, .card > .table-wrap, .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Ensure tables have min-width to prevent squishing */
  .table-wrap > table,
  table {
    min-width: 900px;
  }
  
  /* Status pills should be allowed to wrap or scroll */
  .status, .status-pill, .pill {
    white-space: nowrap;
  }
}

/* === STATUS PILL FIX - allow wider content === */
.status {
  display: inline-block !important;
  padding: 4px 12px !important;
  border-radius: 6px !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.3px;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === TABLE LAYOUT - PREVENT TRUNCATION === */
table {
  table-layout: auto !important;
  width: 100% !important;
}
table td {
  vertical-align: middle !important;
  padding: 12px 14px !important;
}
table th {
  white-space: nowrap;
  padding: 12px 14px !important;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* === KILL EMPTY SIDEBAR GROUPS === */
.sidebar .group-items {
  padding-left: 12px;
}
.sidebar .group-items a {
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
}
.sidebar .group-items a:hover {
  background: var(--card-hi);
  color: var(--text);
}
.sidebar .group-items a.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

/* === CARDS - CLEAR VISUAL HIERARCHY === */
.card {
  background: var(--card) !important;
  border: 1px solid rgba(255,255,255,0.06) !important;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3) !important;
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-weight: 600;
  color: var(--text);
}
.card-body {
  padding: 20px;
}
.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.card-sub {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 4px;
}

/* === LIGHT THEME OVERRIDES === */
body.light-theme .card {
  background: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
}
body.light-theme .card-header {
  border-bottom: 1px solid #e5e7eb;
}
body.light-theme .sidebar {
  background: #f9fafb !important;
  border-right: 1px solid #e5e7eb !important;
}
body.light-theme .sidebar .group-items a {
  color: #4b5563;
}
body.light-theme .sidebar .group-items a:hover {
  background: #f3f4f6;
  color: #111827;
}
body.light-theme .sidebar .group-items a.active {
  background: #6366f1;
  color: white;
}

/* Direct table inside card-body should be scrollable */
.card table, .card-body > table {
  display: block;
  width: 100%;
  overflow-x: auto;
  max-width: 100%;
  white-space: nowrap;
}
.card table thead, 
.card table tbody,
.card-body > table thead,
.card-body > table tbody {
  display: table;
  width: 100%;
}
