/* =============================================================
   DOUROUB FLEET V4.0 — MIDNIGHT OPERATIONS CENTER
   Premium Dark Theme — Unified Design System
   ============================================================= */

/* ─── 1. GOOGLE FONTS ─── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ─── 2. DESIGN TOKENS ─── */
:root {
  /* Background layers */
  --bg-deep:        #060910;
  --bg-base:        #0a0e17;
  --bg-surface:     #111827;
  --bg-elevated:    #1a2332;
  --bg-hover:       #243044;
  --bg-active:      #2d3c52;
  --bg-glass:       rgba(17, 24, 39, 0.75);
  --bg-glass-heavy: rgba(17, 24, 39, 0.92);

  /* Primary palette — Cyan/Sky */
  --primary:        #38bdf8;
  --primary-hover:  #0ea5e9;
  --primary-dark:   #0284c7;
  --primary-light:  #7dd3fc;
  --primary-glow:   rgba(56, 189, 248, 0.15);
  --primary-glow-s: rgba(56, 189, 248, 0.25);
  --primary-subtle: rgba(56, 189, 248, 0.08);

  /* Accent — Emerald */
  --success:        #10b981;
  --success-hover:  #059669;
  --success-light:  #34d399;
  --success-glow:   rgba(16, 185, 129, 0.15);
  --success-subtle: rgba(16, 185, 129, 0.08);

  /* Warning — Amber */
  --warning:        #f59e0b;
  --warning-hover:  #d97706;
  --warning-light:  #fbbf24;
  --warning-glow:   rgba(245, 158, 11, 0.15);
  --warning-subtle: rgba(245, 158, 11, 0.08);

  /* Danger — Red */
  --danger:         #ef4444;
  --danger-hover:   #dc2626;
  --danger-light:   #f87171;
  --danger-glow:    rgba(239, 68, 68, 0.15);
  --danger-subtle:  rgba(239, 68, 68, 0.08);

  /* Info — Violet */
  --info:           #8b5cf6;
  --info-hover:     #7c3aed;
  --info-glow:      rgba(139, 92, 246, 0.15);

  /* Maintenance — Orange */
  --maintenance:    #f97316;
  --maintenance-glow: rgba(249, 115, 22, 0.15);

  /* Text */
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-dim:       #475569;
  --text-inverse:   #0f172a;

  /* Borders */
  --border:         rgba(255, 255, 255, 0.15);
  --border-light:   rgba(255, 255, 255, 0.2);
  --border-strong:  rgba(255, 255, 255, 0.3);
  --border-primary: rgba(56, 189, 248, 0.4);
  --border-glow:    rgba(56, 189, 248, 0.5);

  /* Typography */
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;

  --text-xs:    0.6875rem;  /* 11px */
  --text-sm:    0.8125rem;  /* 13px */
  --text-base:  0.875rem;   /* 14px */
  --text-md:    0.9375rem;  /* 15px */
  --text-lg:    1.0625rem;  /* 17px */
  --text-xl:    1.25rem;    /* 20px */
  --text-2xl:   1.5rem;     /* 24px */
  --text-3xl:   1.875rem;   /* 30px */
  --text-4xl:   2.25rem;    /* 36px */

  --weight-light:    300;
  --weight-normal:   400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;
  --weight-black:    900;

  /* Spacing */
  --sp-0: 0;
  --sp-1: 0.25rem;   /* 4px */
  --sp-2: 0.5rem;    /* 8px */
  --sp-3: 0.75rem;   /* 12px */
  --sp-4: 1rem;      /* 16px */
  --sp-5: 1.25rem;   /* 20px */
  --sp-6: 1.5rem;    /* 24px */
  --sp-8: 2rem;      /* 32px */
  --sp-10: 2.5rem;   /* 40px */
  --sp-12: 3rem;     /* 48px */
  --sp-16: 4rem;     /* 64px */

  /* Radius */
  --radius-xs:   4px;
  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-2xl:  20px;
  --radius-3xl:  24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs:    0 1px 2px rgba(0,0,0,0.3);
  --shadow-sm:    0 2px 4px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.4), 0 2px 4px rgba(0,0,0,0.2);
  --shadow-lg:    0 8px 24px rgba(0,0,0,0.5), 0 4px 8px rgba(0,0,0,0.3);
  --shadow-xl:    0 16px 48px rgba(0,0,0,0.6), 0 8px 16px rgba(0,0,0,0.4);
  --shadow-glow:  0 0 20px var(--primary-glow), 0 0 40px rgba(56,189,248,0.05);
  --shadow-glow-s: 0 0 12px var(--primary-glow);
  --shadow-success-glow: 0 0 16px var(--success-glow);
  --shadow-danger-glow:  0 0 16px var(--danger-glow);
  --shadow-warning-glow: 0 0 16px var(--warning-glow);

  /* Transitions */
  --ease:       cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out:   cubic-bezier(0.33, 1, 0.68, 1);
  --ease-in:    cubic-bezier(0.32, 0, 0.67, 0);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast:   150ms;
  --dur-normal: 250ms;
  --dur-slow:   400ms;
  --dur-slower: 600ms;
  --transition: all var(--dur-normal) var(--ease);

  /* Z-index layers */
  --z-base:     1;
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-overlay:  500;
  --z-modal:    1000;
  --z-toast:    2000;
  --z-tooltip:  3000;
  --z-max:      9999;

  /* Component tokens */
  --header-height: 64px;
  --nav-height: 52px;
  --sidebar-width: 280px;
}

/* ─── LIGHT THEME OVERRIDE ─── */
:root[data-theme="light"] {
  --bg-deep:        #f8fafc;
  --bg-base:        #ffffff;
  --bg-surface:     #f1f5f9;
  --bg-elevated:    #e2e8f0;
  --bg-hover:       #cbd5e1;
  --bg-active:      #94a3b8;
  --bg-glass:       rgba(255, 255, 255, 0.85);
  --bg-glass-heavy: rgba(255, 255, 255, 0.95);

  --text-primary:   #0f172a;
  --text-secondary: #334155;
  --text-muted:     #64748b;
  --text-dim:       #94a3b8;
  --text-inverse:   #ffffff;

  --border:         rgba(0, 0, 0, 0.15);
  --border-light:   rgba(0, 0, 0, 0.2);
  --border-strong:  rgba(0, 0, 0, 0.3);
  --border-primary: rgba(2, 132, 199, 0.4);
  --border-glow:    rgba(2, 132, 199, 0.5);

  --shadow-xs:    0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:    0 2px 4px rgba(0,0,0,0.06);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:    0 8px 24px rgba(0,0,0,0.1);
  --shadow-xl:    0 16px 48px rgba(0,0,0,0.12);
  --shadow-glow:  0 0 20px rgba(56,189,248,0.08);
  --shadow-glow-s: 0 0 12px rgba(56,189,248,0.06);
}

/* ─── LIGHT THEME COMPONENT FIXES ─── */
:root[data-theme="light"] .main-header { background: rgba(255,255,255,0.95); border-bottom-color: rgba(15,23,42,0.1); }
:root[data-theme="light"] .tabs { background: #f1f5f9; border-bottom-color: rgba(15,23,42,0.1); }
:root[data-theme="light"] .nav-group { background: #e2e8f0; border-color: rgba(15,23,42,0.08); }
:root[data-theme="light"] .tab-button { color: #334155; }
:root[data-theme="light"] .tab-button.active { color: #0284c7; background: rgba(56,189,248,0.12); }
:root[data-theme="light"] .truck-card,
:root[data-theme="light"] .stat-card,
:root[data-theme="light"] .card,
:root[data-theme="light"] .controls-section { background: #ffffff; border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
:root[data-theme="light"] select option { background: #ffffff; color: #0f172a; }
:root[data-theme="light"] .maint-card { background: #ffffff !important; color: #0f172a !important; }
:root[data-theme="light"] .mapboxgl-popup-content { background: #ffffff !important; color: #0f172a !important; }
:root[data-theme="light"] .notification-panel { background: #ffffff; border-color: rgba(15,23,42,0.12); }

/* ─── DARK THEME: Fix hardcoded inline dark-on-dark text ─── */
[style*="background:white"], [style*="background: white"] { background: var(--bg-surface) !important; color: var(--text-primary) !important; }
[style*="background:#fdf4ff"], [style*="background:#f5f0ff"], [style*="background:#f3e8ff"],
[style*="background:#fff1f2"], [style*="background:#f0fdf4"], [style*="background:#f8fafc"] { background: var(--bg-elevated) !important; }
[style*="color:#0f172a"], [style*="color: #0f172a"] { color: var(--text-primary) !important; }
[style*="color:#333"], [style*="color:#1e293b"], [style*="color:#555"] { color: var(--text-secondary) !important; }

/* Undo dark fixes in light mode */
:root[data-theme="light"] [style*="background:white"], :root[data-theme="light"] [style*="background: white"] { background: white !important; color: #0f172a !important; }
:root[data-theme="light"] [style*="background:#fdf4ff"], :root[data-theme="light"] [style*="background:#f5f0ff"],
:root[data-theme="light"] [style*="background:#f3e8ff"], :root[data-theme="light"] [style*="background:#fff1f2"],
:root[data-theme="light"] [style*="background:#f0fdf4"], :root[data-theme="light"] [style*="background:#f8fafc"] { background: inherit !important; }
:root[data-theme="light"] [style*="color:#0f172a"], :root[data-theme="light"] [style*="color:#333"],
:root[data-theme="light"] [style*="color:#1e293b"], :root[data-theme="light"] [style*="color:#555"] { color: inherit !important; }

/* ─── Theme Toggle Button ─── */
.theme-toggle-btn { position: relative; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text-secondary); font-size: 1.15rem; cursor: pointer; transition: all 0.3s var(--ease); }
.theme-toggle-btn:hover { background: var(--bg-hover); color: #f59e0b; border-color: rgba(245,158,11,0.3); box-shadow: 0 0 12px rgba(245,158,11,0.15); }
.theme-toggle-btn .theme-icon { transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1); }
.theme-toggle-btn:hover .theme-icon { transform: rotate(30deg); }

/* ─── 3. RESET & BASE ─── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-base);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-light); }

img, video { max-width: 100%; height: auto; display: block; }

/* ─── 4. CUSTOM SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--text-dim);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
* { scrollbar-width: thin; scrollbar-color: var(--text-dim) transparent; }

/* ─── 5. SELECTION ─── */
::selection {
  background: var(--primary);
  color: var(--text-inverse);
}

/* ─── 6. LOGIN OVERLAY ─── */
#loginOverlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-max);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(56,189,248,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 30% 70%, rgba(139,92,246,0.04) 0%, transparent 60%);
}

.login-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-2xl);
  padding: var(--sp-10);
  width: 420px;
  max-width: 92vw;
  box-shadow: var(--shadow-xl), var(--shadow-glow);
  text-align: center;
  animation: loginAppear 0.6s var(--ease) both;
}

.login-box h2 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  background: linear-gradient(135deg, var(--primary), var(--info));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--sp-2);
}

.login-box p {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--sp-6);
}

.login-box input[type="password"] {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--text-md);
  letter-spacing: 3px;
  text-align: center;
  outline: none;
  transition: var(--transition);
}

.login-box input[type="password"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow), var(--shadow-glow-s);
}

.login-box input[type="password"]::placeholder {
  letter-spacing: 0;
  color: var(--text-dim);
}

.login-box .error-msg {
  color: var(--danger);
  font-size: var(--text-sm);
  margin-top: var(--sp-3);
  animation: shake 0.4s var(--ease);
}

/* ─── 7. MAIN HEADER ─── */
.main-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--sp-6);
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--border), var(--shadow-sm);
}

.logo-box {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.logo-box .logo-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-lg);
  font-size: 1.2rem;
  box-shadow: var(--shadow-glow-s);
}

.logo-box .brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.logo-box .brand-name {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.logo-box .brand-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--weight-medium);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  background: linear-gradient(135deg, var(--primary-glow), var(--info-glow));
  color: var(--primary-light);
  border: 1px solid var(--border-primary);
}

.header-clock,
#clockDisplay {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  padding: var(--sp-1) var(--sp-3);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

/* Notification Bell */
.notif-bell-btn {
  position: relative;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  font-size: 1.15rem;
  cursor: pointer;
  transition: var(--transition);
}

.notif-bell-btn:hover {
  background: var(--bg-hover);
  color: var(--primary);
  border-color: var(--border-primary);
  box-shadow: var(--shadow-glow-s);
}

.notif-bell-btn .notif-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: var(--weight-bold);
  border-radius: var(--radius-full);
  box-shadow: 0 0 8px var(--danger-glow);
  animation: notifPulse 2s ease-in-out infinite;
}

/* Live Fleet Pulse */
#liveFleetPulse,
.fleet-pulse {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success), 0 0 16px var(--success-glow);
  animation: livePulse 2s ease-in-out infinite;
}

/* ─── 8. NAVIGATION TABS ─── */
.tabs {
  display: flex;
  align-items: center;
  gap: 0;
  padding: var(--sp-2) 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-strong);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.tabs::-webkit-scrollbar { height: 0; }

/* Fixed home button */
.btn-home-fixed {
  flex-shrink: 0;
  position: sticky;
  left: 0;
  z-index: 10;
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-surface)) !important;
  margin: 0 4px 0 var(--sp-3);
  width: 44px;
  height: 44px;
  border-radius: 14px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  border: 1px solid var(--border-strong) !important;
  box-shadow: var(--shadow-md);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--text-primary) !important;
}

.btn-home-fixed:hover {
  background: linear-gradient(135deg, var(--primary-subtle), var(--bg-surface)) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
  box-shadow: 0 4px 15px rgba(56,189,248,0.25);
  transform: translateY(-2px);
}

.btn-home-fixed.active {
  background: linear-gradient(135deg, var(--primary), #0284c7) !important;
  border-color: transparent !important;
  color: white !important;
  box-shadow: 0 6px 20px rgba(56,189,248,0.35);
}

/* Scrollable tabs area */
.tabs-scroll-area {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  padding: 0 var(--sp-2);
  scroll-behavior: smooth;
}

.tabs-scroll-area::-webkit-scrollbar { height: 0; }

/* Scroll hover zones */
.tab-scroll-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  font-size: 10px;
  color: var(--text-muted);
}

.tab-scroll-zone.tab-scroll-left {
  left: 48px;
  background: linear-gradient(to right, var(--bg-surface) 60%, transparent);
}

.tab-scroll-zone.tab-scroll-right {
  right: 0;
  background: linear-gradient(to left, var(--bg-surface) 60%, transparent);
}

.tabs:hover .tab-scroll-zone {
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
}

.nav-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  position: relative;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab-btn.active {
  color: var(--primary);
  background: var(--primary-subtle);
  box-shadow: inset 0 0 0 1px var(--border-primary);
}

.tab-btn .tab-icon {
  font-size: 1rem;
  line-height: 1;
}

.tab-btn .tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--primary-glow);
  color: var(--primary);
  font-size: 10px;
  font-weight: var(--weight-bold);
}

/* Sub-tabs inside sections */
.sub-tabs {
  display: flex;
  gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  margin-bottom: var(--sp-4);
}

.sub-tab-btn {
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: var(--transition);
}

.sub-tab-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.sub-tab-btn.active {
  color: var(--primary);
  background: var(--primary-subtle);
  border-color: var(--border-primary);
}

/* ─── 9. TAB CONTENT ─── */
.tab-content {
  display: none;
  animation: fadeSlideIn 0.35s var(--ease) both;
  padding: var(--sp-6);
}

.tab-content.active {
  display: block;
}

/* Section boxes */
.section-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp-6);
  margin-bottom: var(--sp-6);
  position: relative;
  overflow: hidden;
}

.section-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--info), var(--primary));
  opacity: 0;
  transition: opacity var(--dur-normal) var(--ease);
}

.section-box:hover::before {
  opacity: 1;
}

.section-box.bordered-primary { border-left: 3px solid var(--primary); }
.section-box.bordered-success { border-left: 3px solid var(--success); }
.section-box.bordered-warning { border-left: 3px solid var(--warning); }
.section-box.bordered-danger  { border-left: 3px solid var(--danger); }
.section-box.bordered-info    { border-left: 3px solid var(--info); }
.section-box.bordered-orange  { border-left: 3px solid var(--maintenance); }

.section-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.section-title .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg);
  background: var(--primary-subtle);
  color: var(--primary);
  font-size: 1.1rem;
}

.section-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--sp-4);
}

.tip-box {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--primary-subtle);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  color: var(--primary-light);
  font-size: var(--text-sm);
  margin-bottom: var(--sp-4);
}

.tip-box .tip-icon {
  flex-shrink: 0;
  font-size: 1rem;
}

/* ─── 10. BUTTONS ─── */
button, .btn {
  font-family: var(--font-sans);
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1.4;
  transition: var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-fast);
}

.btn:hover::after { opacity: 1; }

.btn:active {
  transform: scale(0.97);
}

/* Primary */
.btn-primary,
.btn--primary {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: var(--text-inverse);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm), 0 0 12px var(--primary-glow);
}

.btn-primary:hover,
.btn--primary:hover {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  box-shadow: var(--shadow-md), var(--shadow-glow);
  transform: translateY(-1px);
}

/* Success */
.btn-success,
.btn--success {
  background: linear-gradient(135deg, var(--success-hover), var(--success));
  color: var(--text-inverse);
  border-color: var(--success);
  box-shadow: var(--shadow-sm), 0 0 12px var(--success-glow);
}

.btn-success:hover,
.btn--success:hover {
  background: linear-gradient(135deg, var(--success), var(--success-light));
  box-shadow: var(--shadow-md), var(--shadow-success-glow);
  transform: translateY(-1px);
}

/* Warning */
.btn-warning,
.btn--warning {
  background: linear-gradient(135deg, var(--warning-hover), var(--warning));
  color: var(--text-inverse);
  border-color: var(--warning);
  box-shadow: var(--shadow-sm);
}

.btn-warning:hover,
.btn--warning:hover {
  background: linear-gradient(135deg, var(--warning), var(--warning-light));
  box-shadow: var(--shadow-md), var(--shadow-warning-glow);
  transform: translateY(-1px);
}

/* Danger */
.btn-danger,
.btn--danger {
  background: linear-gradient(135deg, var(--danger-hover), var(--danger));
  color: #fff;
  border-color: var(--danger);
  box-shadow: var(--shadow-sm);
}

.btn-danger:hover,
.btn--danger:hover {
  background: linear-gradient(135deg, var(--danger), var(--danger-light));
  box-shadow: var(--shadow-md), var(--shadow-danger-glow);
  transform: translateY(-1px);
}

/* Ghost / Outline */
.btn-ghost,
.btn--outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.btn-ghost:hover,
.btn--outline:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--primary);
}

/* Secondary */
.btn-secondary,
.btn--secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-secondary:hover,
.btn--secondary:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* Sizes */
.btn-xs { padding: 2px 8px; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-sm, .btn--sm { padding: 4px 12px; font-size: var(--text-xs); }
.btn-lg, .btn--lg { padding: var(--sp-3) var(--sp-6); font-size: var(--text-md); }
.btn-full, .btn--full-width { width: 100%; }

/* Icon button */
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 1rem;
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--primary);
  border-color: var(--border-primary);
}

/* ─── 11. CARDS ─── */

/* Generic card */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: var(--sp-5);
  transition: var(--transition);
  position: relative;
}

.card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Premium Card Aesthetics */
.card-premium {
  background: linear-gradient(145deg, var(--bg-surface), var(--bg-elevated));
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: var(--sp-5);
  box-shadow: 0 4px 20px rgba(0,0,0,0.05), inset 0 1px 0 rgba(255,255,255,0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.card-premium:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 12px 30px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.1);
  border-color: var(--primary-glow);
}

.card-glass {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

:root[data-theme="light"] .card-glass {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255,255,255,0.8);
  box-shadow: 0 8px 32px rgba(0,0,0,0.05);
}

.card-gradient {
  background: linear-gradient(135deg, var(--bg-surface), var(--primary-subtle));
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  color: var(--text-primary);
}

/* Truck card */
.truck-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: var(--sp-4);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.truck-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  border-radius: var(--radius-full);
  transition: var(--transition);
}

.truck-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.truck-card.status-moving::before { background: var(--success); box-shadow: 0 0 8px var(--success-glow); }
.truck-card.status-stopped::before { background: var(--text-muted); }
.truck-card.status-gps-cut::before { background: var(--danger); box-shadow: 0 0 8px var(--danger-glow); }

.truck-card .truck-name {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--sp-1);
}

.truck-card .truck-location {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.truck-card .truck-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.truck-card .truck-meta-item {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

/* Stat card */
.stat-card {
  background: var(--bg-surface);
  padding: 20px 16px;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 0 0 1px var(--border-strong);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  padding: 2px;
  background: linear-gradient(135deg, transparent 40%, var(--border-glow));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s;
}

.stat-card::after {
  content: '▸ Filtrer';
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 800;
  color: var(--text-dim);
  opacity: 0;
  transform: translateX(-4px);
  transition: all 0.3s;
}

.stat-card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 12px 28px rgba(0,0,0,0.12), 0 0 0 1px var(--border-primary);
  border-color: var(--border-primary);
}

.stat-card:hover::before { opacity: 1; }
.stat-card:hover::after { opacity: 1; transform: translateX(0); }

.stat-card:active {
  transform: translateY(-1px) scale(0.98);
  transition-duration: 0.1s;
}

.stat-card.active-filter {
  background: var(--primary-subtle);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15), 0 4px 12px rgba(0,0,0,0.1);
}

.stat-card.active-filter::after {
  content: '✓ Actif';
  color: var(--primary);
  opacity: 1;
  transform: translateX(0);
}

.stat-card .stat-icon {
  font-size: 1.6rem;
  margin-bottom: 8px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--bg-elevated);
  transition: all 0.3s;
}

.stat-card:hover .stat-icon {
  transform: scale(1.1);
  background: var(--primary-subtle);
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 900;
  line-height: 1.1;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.stat-card .stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: 0.8px;
}

.stat-card .stat-trend {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  display: flex;
  align-items: center;
  gap: 2px;
}

.stat-card .stat-trend.up   { color: var(--success); }
.stat-card .stat-trend.down { color: var(--danger); }

/* KPI card */
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp-5);
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
}

.kpi-card:hover {
  border-color: var(--border-primary);
  box-shadow: var(--shadow-md), var(--shadow-glow-s);
  transform: translateY(-2px);
}

.kpi-card .kpi-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-black);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.kpi-card .kpi-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: var(--sp-1);
}

/* Alert card */
.alert-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  transition: var(--transition);
}

.alert-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.alert-card.severity-critical {
  border-left-color: var(--danger);
  background: linear-gradient(135deg, var(--danger-subtle), var(--bg-surface));
}

.alert-card.severity-warning {
  border-left-color: var(--warning);
  background: linear-gradient(135deg, var(--warning-subtle), var(--bg-surface));
}

.alert-card.severity-info {
  border-left-color: var(--info);
  background: linear-gradient(135deg, var(--info-glow), var(--bg-surface));
}

/* Refuel card */
.refuel-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  border-left: 3px solid var(--primary);
  transition: var(--transition);
}

.refuel-card:hover {
  box-shadow: var(--shadow-md);
  border-left-color: var(--primary-light);
}

/* Maintenance card */
.maintenance-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  border-left: 3px solid var(--maintenance);
  transition: var(--transition);
}

.maintenance-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* ─── 12. FUEL GAUGE ─── */
.fuel-gauge-container {
  margin: var(--sp-3) 0;
}

.fuel-bar-wrapper {
  width: 100%;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.fuel-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 1s var(--ease), background 0.5s;
  position: relative;
}

.fuel-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.2), transparent);
  border-radius: var(--radius-full) var(--radius-full) 0 0;
}

.fuel-bar.fuel-good    { background: linear-gradient(90deg, var(--success-hover), var(--success)); box-shadow: 0 0 8px var(--success-glow); }
.fuel-bar.fuel-medium  { background: linear-gradient(90deg, var(--warning-hover), var(--warning)); box-shadow: 0 0 8px var(--warning-glow); }
.fuel-bar.fuel-low     { background: linear-gradient(90deg, var(--danger-hover), var(--danger)); box-shadow: 0 0 8px var(--danger-glow); animation: fuelPulse 2s ease-in-out infinite; }

.fuel-text {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: var(--sp-1);
}

/* Circular fuel gauge */
.fuel-ring {
  position: relative;
  width: 60px;
  height: 60px;
}

.fuel-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.fuel-ring .ring-bg {
  fill: none;
  stroke: var(--bg-elevated);
  stroke-width: 5;
}

.fuel-ring .ring-fill {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s var(--ease), stroke 0.5s;
}

.fuel-ring .ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}

/* ─── 13. FORMS & INPUTS ─── */
.form-group {
  margin-bottom: var(--sp-4);
}

.form-label, label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--sp-1);
}

.form-control,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="email"],
input[type="search"],
input[type="url"],
textarea,
select {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  outline: none;
  transition: var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.form-control:hover,
input:hover,
textarea:hover,
select:hover {
  border-color: var(--border-strong);
}

.form-control:focus,
input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-surface);
}

.form-control::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-dim);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8.5L1 3.5h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

select option {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.form-text {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

.form-inline {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
}

.toggle-switch input {
  width: 0;
  height: 0;
  opacity: 0;
  position: absolute;
}

.toggle-track {
  width: 44px;
  height: 24px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  transition: var(--transition);
  position: relative;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: var(--transition);
}

.toggle-switch input:checked + .toggle-track {
  background: var(--primary);
  border-color: var(--primary);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(20px);
  background: #fff;
}

.toggle-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ─── 14. BADGES & STATUS ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1.4;
  white-space: nowrap;
}

.badge.success, .badge.online, .badge-success  { background: var(--success-subtle); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.badge.error, .badge.danger, .badge-danger     { background: var(--danger-subtle);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.2); }
.badge.warning, .badge-warning                 { background: var(--warning-subtle); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }
.badge.info, .badge-info                       { background: var(--info-glow);      color: var(--info);    border: 1px solid rgba(139,92,246,0.2); }
.badge.primary, .badge-primary                 { background: var(--primary-subtle); color: var(--primary); border: 1px solid var(--border-primary); }
.badge.offline                                 { background: var(--bg-hover);       color: var(--text-muted); border: 1px solid var(--border); }
.badge.maintenance                             { background: var(--maintenance-glow); color: var(--maintenance); border: 1px solid rgba(249,115,22,0.2); }

/* Status dots */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.moving  { background: var(--success); box-shadow: 0 0 6px var(--success); animation: livePulse 2s ease-in-out infinite; }
.status-dot.stopped { background: var(--text-muted); }
.status-dot.gps-cut { background: var(--danger); box-shadow: 0 0 6px var(--danger); animation: dangerPulse 1.5s ease-in-out infinite; }

/* ─── 15. DATA TABLES ─── */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
}

.data-table thead th {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  font-weight: var(--weight-semibold);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 2;
}

.data-table thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
.data-table thead th:last-child  { border-radius: 0 var(--radius-lg) 0 0; }

.data-table tbody td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  transition: background var(--dur-fast);
}

.data-table tbody tr:hover td {
  background: var(--bg-hover);
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table .sortable { cursor: pointer; user-select: none; }
.data-table .sortable:hover { color: var(--primary); }

/* Table wrapper for scroll */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
}

/* ─── 16. MODALS ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: overlayIn 0.25s var(--ease);
}

.modal-overlay.show,
.modal-overlay[style*="flex"] {
  display: flex;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-2xl);
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl), var(--shadow-glow);
  animation: modalIn 0.35s var(--ease) both;
  overflow: hidden;
}

.modal.modal-lg { max-width: 900px; }
.modal.modal-xl { max-width: 1100px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.modal-header h3,
.modal-header .modal-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--danger-subtle);
  color: var(--danger);
}

.modal-body {
  padding: var(--sp-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

/* ─── 17. TOASTS ─── */
#toastContainer,
.toast-container {
  position: fixed;
  top: var(--sp-6);
  right: var(--sp-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-width: 420px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: toastSlideIn 0.4s var(--ease-bounce) both;
  pointer-events: auto;
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
}

.toast.success::before { background: var(--success); }
.toast.error::before   { background: var(--danger); }
.toast.warning::before { background: var(--warning); }
.toast.info::before    { background: var(--primary); }

.toast .toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon   { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon    { color: var(--primary); }

.toast .toast-message {
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.4;
}

.toast.dismissing {
  animation: toastSlideOut 0.3s var(--ease-in) both;
}

/* ─── 18. MAP SECTION ─── */
.map-wrapper,
#map-wrapper {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-deep);
}

#map-container {
  width: 100%;
  height: 75vh;
  min-height: 500px;
}

/* Map overlay controls */
.map-controls-overlay {
  position: absolute;
  top: var(--sp-4);
  left: var(--sp-4);
  right: var(--sp-4);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  z-index: 10;
  pointer-events: none;
}

.map-controls-overlay > * {
  pointer-events: auto;
}

.map-control-panel {
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--sp-2) var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  box-shadow: var(--shadow-md);
}

.map-control-panel select,
.map-control-panel input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-1) var(--sp-2);
  color: var(--text-primary);
  font-size: var(--text-xs);
  min-width: 0;
}

.map-style-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: var(--transition);
}

.map-style-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.map-style-btn.active {
  background: var(--primary-subtle);
  color: var(--primary);
  border-color: var(--border-primary);
}

/* Filter pills */
.filter-pill {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.filter-pill:hover { background: var(--bg-hover); color: var(--text-primary); }
.filter-pill.active { background: var(--primary-subtle); color: var(--primary); border-color: var(--border-primary); }
.filter-pill.active-green { background: var(--success-subtle); color: var(--success); border-color: rgba(16,185,129,0.3); }
.filter-pill.active-red { background: var(--danger-subtle); color: var(--danger); border-color: rgba(239,68,68,0.3); }

.filter-pill .pill-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--bg-hover);
  font-size: 10px;
  margin-left: 4px;
}

/* Map extras bar */
/* Map extras bar */
.map-extras-bar {
  position: absolute;
  top: 80px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 0 !important;
  transform: none !important;
  left: auto !important;
  bottom: auto !important;
}

.map-extras-bar button {
  width: 40px; height: 40px; border-radius: 50% !important;
  background: white !important; border: none !important;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2) !important;
  color: #555 !important; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.map-extras-bar button:hover { transform: scale(1.1); color: #0084a7 !important; }

/* Route info panel */
.route-info-panel {
  position: absolute;
  bottom: var(--sp-16);
  left: var(--sp-4);
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--shadow-lg);
  z-index: 10;
  display: none;
}

.route-info-panel.visible { display: block; animation: fadeSlideIn 0.3s var(--ease); }

/* History controls */
.history-controls {
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  box-shadow: var(--shadow-lg);
  z-index: 10;
  min-width: 280px;
}

/* History player bar */
.history-player-bar {
  position: absolute;
  bottom: var(--sp-4);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  padding: var(--sp-2) var(--sp-5);
  box-shadow: var(--shadow-xl);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 500px;
}

.player-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: var(--text-inverse);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: 0 0 12px var(--primary-glow);
}

.player-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.08);
  box-shadow: var(--shadow-glow);
}

.player-progress {
  flex: 1;
  height: 4px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  position: relative;
  cursor: pointer;
}

.player-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: var(--radius-full);
  transition: width 0.1s linear;
  box-shadow: 0 0 6px var(--primary-glow);
}

.player-speed {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--primary);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  font-family: var(--font-mono);
  cursor: pointer;
  transition: var(--transition);
}

.player-speed:hover {
  border-color: var(--primary);
}

/* Timeline strip */
.timeline-strip {
  position: absolute;
  bottom: 60px;
  left: var(--sp-6);
  right: var(--sp-6);
  height: 24px;
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  z-index: 10;
  overflow: hidden;
  cursor: pointer;
}

.timeline-strip .segment {
  position: absolute;
  top: 0;
  height: 100%;
  transition: opacity 0.2s;
}

.timeline-strip .segment:hover { opacity: 0.8; }
.timeline-strip .segment.driving    { background: var(--success); }
.timeline-strip .segment.stopped    { background: var(--text-dim); }
.timeline-strip .segment.refueling  { background: var(--primary); }
.timeline-strip .segment.gps-cut    { background: var(--danger); }
.timeline-strip .segment.maintenance { background: var(--maintenance); }

/* Map markers */
.mapboxgl-marker {
  transition: transform 0.3s var(--ease);
}

/* --- MARKERS --- */
.truck-marker {
    width: 40px; height: 40px; cursor: pointer; z-index: 10;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.truck-marker:hover { transform: scale(1.2) translateY(-5px); z-index: 100; }

.marker-icon {
    width: 32px; height: 32px; border-radius: 50%;
    background: white; border: 2px solid #555;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    font-size: 14px; color: #333;
}
.marker-icon.moving { border-color: #2e7d32; color: #2e7d32; background: white; }
.marker-icon.stopped { border-color: #d32f2f; color: #d32f2f; background: white; }
.marker-icon.gps-cut { border-color: #333; color: #333; background: #ddd; }
.marker-icon.selected {
    background: #0084a7; color: white; border-color: white;
    box-shadow: 0 0 0 4px rgba(0, 132, 167, 0.4);
    transform: scale(1.1);
}

/* Map popup */
.mapboxgl-popup-content {
    padding: 0 !important;
    border-radius: 8px !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2) !important;
    min-width: 220px;
    font-family: 'Segoe UI', sans-serif;
    overflow: hidden;
    background: white !important;
    color: #333 !important;
}

.mapboxgl-popup-close-button {
    color: white !important;
    font-size: 16px !important;
    padding: 2px 6px !important;
    outline: none;
}
.mapboxgl-popup-close-button:hover {
    background: rgba(0,0,0,0.2) !important;
}

/* ─── 19. DASHBOARD LAYOUT ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.trucks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--sp-4);
}

.alerts-strip {
  display: flex;
  gap: var(--sp-3);
  overflow-x: auto;
  padding-bottom: var(--sp-2);
  margin-bottom: var(--sp-4);
}

/* Live controls bar */
.live-controls-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--sp-4);
}

.live-controls-bar label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 0;
  white-space: nowrap;
}

.live-controls-bar input[type="number"] {
  width: 70px;
  padding: var(--sp-1) var(--sp-2);
  font-size: var(--text-xs);
}

/* ─── 20. KANBAN BOARD (Maintenance) ─── */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
  min-height: 400px;
}

.kanban-column {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border);
}

.kanban-column-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.kanban-column-title .col-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.kanban-column-title .col-dot.planned    { background: var(--primary); }
.kanban-column-title .col-dot.in-workshop { background: var(--warning); }
.kanban-column-title .col-dot.confirm    { background: var(--maintenance); }
.kanban-column-title .col-dot.done       { background: var(--success); }

.kanban-column-count {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-hover);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--weight-semibold);
}

.kanban-cards {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  overflow-y: auto;
}

.kanban-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-3);
  cursor: pointer;
  transition: var(--transition);
}

.kanban-card:hover {
  border-color: var(--border-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.kanban-card .kc-truck {
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  color: var(--text-primary);
  margin-bottom: var(--sp-1);
}

.kanban-card .kc-type {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}

.kanban-card .kc-meta {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--text-dim);
}

/* ─── 21. NOTIFICATION CENTER ─── */
.notif-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: calc(var(--z-modal) + 1);
  transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease);
  display: flex;
  flex-direction: column;
}

.notif-panel.open {
  transform: translateX(0);
}

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.notif-panel-header h3 {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.notif-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-2);
}

.notif-item {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.notif-item:hover {
  background: var(--bg-hover);
}

.notif-item.unread {
  background: var(--primary-subtle);
  border-color: var(--border-primary);
}

.notif-item .notif-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  font-size: 1rem;
  flex-shrink: 0;
}

.notif-item .notif-icon.fuel     { background: var(--primary-subtle); color: var(--primary); }
.notif-item .notif-icon.maint    { background: var(--maintenance-glow); color: var(--maintenance); }
.notif-item .notif-icon.alert    { background: var(--danger-subtle); color: var(--danger); }
.notif-item .notif-icon.gps      { background: var(--info-glow); color: var(--info); }
.notif-item .notif-icon.speed    { background: var(--warning-subtle); color: var(--warning); }

.notif-item .notif-content { flex: 1; min-width: 0; }

.notif-item .notif-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  line-height: 1.3;
}

.notif-item .notif-body {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.3;
}

.notif-item .notif-time {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
}

.notif-panel-footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
  text-align: center;
}

/* ─── 22. COMMAND PALETTE ─── */
.command-palette-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal) + 5);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}

.command-palette-overlay.open {
  display: flex;
  animation: overlayIn 0.2s var(--ease);
}

.command-palette {
  width: 560px;
  max-width: 90vw;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl), var(--shadow-glow);
  overflow: hidden;
  animation: modalIn 0.25s var(--ease);
}

.command-palette-input {
  width: 100%;
  padding: var(--sp-4) var(--sp-5);
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  outline: none;
}

.command-palette-input::placeholder {
  color: var(--text-dim);
}

.command-palette-results {
  max-height: 360px;
  overflow-y: auto;
  padding: var(--sp-2);
}

.command-result-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--dur-fast);
}

.command-result-item:hover,
.command-result-item.selected {
  background: var(--bg-hover);
}

.command-result-item .cr-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.command-result-item .cr-label {
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.command-result-item .cr-hint {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* ─── 23. PREDICTION CARDS ─── */
.prediction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-4);
}

.prediction-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp-5);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.prediction-card:hover {
  border-color: var(--border-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.prediction-card .pred-urgency {
  position: absolute;
  top: 0;
  right: 0;
  padding: 4px 14px 4px 18px;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  border-radius: 0 var(--radius-xl) 0 var(--radius-lg);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.prediction-card .pred-urgency.ok        { background: var(--success-subtle); color: var(--success); }
.prediction-card .pred-urgency.approach   { background: var(--warning-subtle); color: var(--warning); }
.prediction-card .pred-urgency.soon       { background: rgba(249,115,22,0.12); color: var(--maintenance); }
.prediction-card .pred-urgency.overdue    { background: var(--danger-subtle); color: var(--danger); }

.prediction-card .pred-truck {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--sp-1);
}

.prediction-card .pred-type {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
}

.prediction-card .pred-progress-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--sp-2);
}

.prediction-card .pred-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 1s var(--ease);
}

.prediction-card .pred-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

/* ─── 24. CONFIDENCE RING (Gasoil) ─── */
.confidence-ring {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.confidence-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.confidence-ring .c-bg {
  fill: none;
  stroke: var(--bg-elevated);
  stroke-width: 4;
}

.confidence-ring .c-fill {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s var(--ease);
}

.confidence-ring .c-fill.high   { stroke: var(--success); }
.confidence-ring .c-fill.medium { stroke: var(--warning); }
.confidence-ring .c-fill.low    { stroke: var(--danger); }

.confidence-ring .c-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: var(--weight-bold);
}

/* ─── 25. CHARTS ─── */
.chart-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
}

.chart-container .chart-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--sp-4);
}

.chart-container canvas {
  max-height: 350px;
}

/* ─── 26. ACCORDION (Settings) ─── */
.accordion-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--sp-2);
  overflow: hidden;
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.accordion-header:hover {
  background: var(--bg-hover);
}

.accordion-header h4 {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.accordion-header .arrow {
  color: var(--text-muted);
  transition: transform var(--dur-normal) var(--ease);
}

.accordion-item.open .accordion-header .arrow {
  transform: rotate(180deg);
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--dur-slow) var(--ease);
}

.accordion-item.open .accordion-body {
  max-height: 2000px;
}

.accordion-body-inner {
  padding: 0 var(--sp-5) var(--sp-5);
}

/* ─── 27. DRIVER LEADERBOARD ─── */
.leaderboard {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: var(--transition);
}

.leaderboard-item:hover {
  border-color: var(--border-primary);
  background: var(--bg-hover);
}

.leaderboard-item .rank {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: var(--text-sm);
  font-weight: var(--weight-black);
  flex-shrink: 0;
}

.leaderboard-item:nth-child(1) .rank { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: var(--text-inverse); }
.leaderboard-item:nth-child(2) .rank { background: linear-gradient(135deg, #cbd5e1, #94a3b8); color: var(--text-inverse); }
.leaderboard-item:nth-child(3) .rank { background: linear-gradient(135deg, #d97706, #92400e); color: #fff; }

.leaderboard-item .driver-name {
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  font-size: var(--text-sm);
}

.leaderboard-item .driver-score {
  margin-left: auto;
  font-size: var(--text-lg);
  font-weight: var(--weight-black);
}

.leaderboard-item .driver-score.excellent { color: var(--success); }
.leaderboard-item .driver-score.good      { color: var(--primary); }
.leaderboard-item .driver-score.average   { color: var(--warning); }
.leaderboard-item .driver-score.poor      { color: var(--danger); }

/* ─── 28. FLEET HEALTH SCORE ─── */
.health-score-ring {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto var(--sp-4);
}

.health-score-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.health-score-ring .ring-bg {
  fill: none;
  stroke: var(--bg-elevated);
  stroke-width: 10;
}

.health-score-ring .ring-fill {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.5s var(--ease);
}

.health-score-ring .score-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.health-score-ring .score-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-black);
  line-height: 1;
}

.health-score-ring .score-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ─── 29. GLOBAL SEARCH ─── */
.global-search-overlay {
  position: fixed;
  top: var(--header-height);
  right: var(--sp-4);
  z-index: var(--z-dropdown);
}

.global-search-box {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: var(--sp-1) var(--sp-3);
  transition: var(--transition);
}

.global-search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-surface);
}

.global-search-box input {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--text-sm);
  outline: none;
  width: 200px;
}

.global-search-box .search-icon {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ─── 30. NOTIFICATION PREFERENCES ─── */
.notif-prefs {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.notif-pref-category {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.notif-pref-category-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-hover);
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.notif-pref-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
}

.notif-pref-item .pref-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ─── 31. VERIFICATION BADGES ─── */
.verify-actions {
  display: flex;
  gap: var(--sp-1);
}

.verify-btn {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: transparent;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: var(--transition);
}

.verify-btn.verify {
  color: var(--success);
  border-color: rgba(16,185,129,0.3);
}

.verify-btn.verify:hover {
  background: var(--success-subtle);
}

.verify-btn.reject {
  color: var(--danger);
  border-color: rgba(239,68,68,0.3);
}

.verify-btn.reject:hover {
  background: var(--danger-subtle);
}

.verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: var(--weight-bold);
}

.verified-badge.verified { background: var(--success-subtle); color: var(--success); }
.verified-badge.rejected { background: var(--danger-subtle); color: var(--danger); }
.verified-badge.pending  { background: var(--bg-hover); color: var(--text-muted); }

/* ─── 32. EMPTY STATES ─── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-12) var(--sp-6);
  text-align: center;
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: var(--sp-4);
  opacity: 0.3;
}

.empty-state .empty-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
}

.empty-state .empty-text {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 400px;
}

/* ─── 33. LOADING STATES ─── */
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-glass);
  backdrop-filter: blur(4px);
  border-radius: inherit;
  z-index: 5;
}

/* ─── 34. ANIMATIONS ─── */
@keyframes loginAppear {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulseBlueRed {
  0% { color: var(--primary); transform: scale(1); }
  50% { color: var(--danger); transform: scale(1.15); text-shadow: 0 0 10px rgba(239, 68, 68, 0.6); }
  100% { color: var(--primary); transform: scale(1); }
}

/* AI Predictive Analytics Cards */
.ai-category {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.02);
}

.ai-category .cat-header {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.5px;
}

.ai-category .cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.ai-insight-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--bg-elevated);
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.ai-insight-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.05);
}

.ai-insight-card .icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.ai-insight-card .title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.ai-insight-card .value {
  font-size: 1.4rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.ai-insight-card .desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ─── Speeding animation: hard-blink red with growing glow ─── */
@keyframes speedingPulse {
  0%   { box-shadow: 0 0 6px rgba(239, 68, 68, 0.6), inset 0 0 6px rgba(239, 68, 68, 0.15); border-color: var(--danger); }
  40%  { box-shadow: 0 0 22px rgba(239, 68, 68, 0.9), inset 0 0 12px rgba(239, 68, 68, 0.25); border-color: rgba(239, 68, 68, 0.5); }
  100% { box-shadow: 0 0 6px rgba(239, 68, 68, 0.6), inset 0 0 6px rgba(239, 68, 68, 0.15); border-color: var(--danger); }
}

/* ─── Moving card: subtle green breathing glow ─── */
@keyframes movingCardGlow {
  0%   { box-shadow: 0 4px 20px rgba(0,0,0,0.05), 0 0 0 1px rgba(16,185,129,0.15); }
  50%  { box-shadow: 0 4px 20px rgba(0,0,0,0.08), 0 0 12px rgba(16,185,129,0.30); }
  100% { box-shadow: 0 4px 20px rgba(0,0,0,0.05), 0 0 0 1px rgba(16,185,129,0.15); }
}

/* ─── Speed badge blink when over limit ─── */
@keyframes speedBadgeBlink {
  0%, 100% { background: rgba(239, 68, 68, 0.9); color: #fff; transform: scale(1); }
  50%       { background: rgba(239, 68, 68, 0.3); color: #ef4444; transform: scale(1.08); }
}

@keyframes borderPulseRed {
  0% { border-color: var(--danger); box-shadow: 0 0 5px rgba(239, 68, 68, 0.4); }
  50% { border-color: rgba(239, 68, 68, 0.2); box-shadow: 0 0 15px rgba(239, 68, 68, 0.1); }
  100% { border-color: var(--danger); box-shadow: 0 0 5px rgba(239, 68, 68, 0.4); }
}

.card-premium.speeding {
  animation: speedingPulse 0.9s ease-in-out infinite;
  border: 2px solid var(--danger) !important;
  border-left: 4px solid var(--danger) !important;
  background: linear-gradient(145deg, rgba(239,68,68,0.08), var(--bg-elevated)) !important;
}

.card-premium.moving:not(.speeding):not(.critical-alert) {
  animation: movingCardGlow 3s ease-in-out infinite;
  border-left: 4px solid var(--success) !important;
}

.card-premium.speeding .speed-badge,
span.speed-badge-over {
  animation: speedBadgeBlink 0.7s ease-in-out infinite !important;
  border-radius: var(--radius-full) !important;
  padding: 4px 10px !important;
  font-weight: 900 !important;
}

.card-premium.critical-alert {
  animation: borderPulseRed 1.5s infinite;
  border: 1px solid var(--danger);
  border-left: 4px solid var(--danger) !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(-12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(100%) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(100%) scale(0.95); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%  { transform: translateX(-6px); }
  75%  { transform: translateX(6px); }
}

@keyframes livePulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px var(--success); }
  50%      { opacity: 0.6; box-shadow: 0 0 12px var(--success), 0 0 24px var(--success-glow); }
}

@keyframes dangerPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

@keyframes notifPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}

@keyframes markerPulse {
  0%, 100% { box-shadow: 0 0 4px var(--success-glow); }
  50%      { box-shadow: 0 0 16px var(--success-glow), 0 0 32px rgba(16,185,129,0.1); }
}

@keyframes fuelPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 8px var(--primary-glow); }
  50%      { box-shadow: 0 0 20px var(--primary-glow-s), 0 0 40px var(--primary-glow); }
}

@keyframes borderGlow {
  0%, 100% { border-color: var(--border-primary); }
  50%      { border-color: var(--border-glow); }
}

/* ─── 35. UTILITIES ─── */
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.flex-wrap   { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1  { gap: var(--sp-1); }
.gap-2  { gap: var(--sp-2); }
.gap-3  { gap: var(--sp-3); }
.gap-4  { gap: var(--sp-4); }
.gap-6  { gap: var(--sp-6); }

.grid        { display: grid; }
.grid-2      { grid-template-columns: 1fr 1fr; }
.grid-3      { grid-template-columns: repeat(3, 1fr); }
.grid-4      { grid-template-columns: repeat(4, 1fr); }
.grid-auto   { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-xs     { font-size: var(--text-xs); }
.text-sm     { font-size: var(--text-sm); }
.text-md     { font-size: var(--text-md); }
.text-lg     { font-size: var(--text-lg); }
.text-xl     { font-size: var(--text-xl); }
.text-2xl    { font-size: var(--text-2xl); }
.text-3xl    { font-size: var(--text-3xl); }

.font-medium   { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold     { font-weight: var(--weight-bold); }
.font-black    { font-weight: var(--weight-black); }
.font-mono     { font-family: var(--font-mono); }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-success   { color: var(--success); }
.text-warning   { color: var(--warning); }
.text-danger    { color: var(--danger); }
.text-info      { color: var(--info); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.ml-auto { margin-left: auto; }

.p-2 { padding: var(--sp-2); }
.p-3 { padding: var(--sp-3); }
.p-4 { padding: var(--sp-4); }
.p-6 { padding: var(--sp-6); }

.w-full  { width: 100%; }
.h-full  { height: 100%; }
.min-h-0 { min-height: 0; }

.rounded-md  { border-radius: var(--radius-md); }
.rounded-lg  { border-radius: var(--radius-lg); }
.rounded-xl  { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only  { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.hidden   { display: none !important; }
.visible  { display: block; }
.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.pointer   { cursor: pointer; }
.no-select { user-select: none; }

.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
}

.gradient-text {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.glow-border {
  border: 1px solid var(--border-primary);
  box-shadow: var(--shadow-glow-s);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: var(--sp-4) 0;
}

/* ─── 36. RESPONSIVE ─── */
@media (max-width: 1024px) {
  .kanban-board { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root {
    --header-height: 56px;
  }

  .main-header {
    padding: 0 var(--sp-3);
  }

  .logo-box .brand-text { display: none; }

  .tabs {
    padding: var(--sp-2) var(--sp-3);
    gap: var(--sp-1);
  }

  .tab-btn {
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--text-xs);
  }

  .tab-btn .tab-label { display: none; }

  .tab-content {
    padding: var(--sp-3);
  }

  .section-box {
    padding: var(--sp-4);
    border-radius: var(--radius-lg);
  }

  .stats-grid,
  .trucks-grid,
  .prediction-grid {
    grid-template-columns: 1fr;
  }

  .kanban-board {
    grid-template-columns: 1fr;
  }

  .modal {
    max-width: 95vw;
    max-height: 90vh;
    border-radius: var(--radius-xl);
  }

  .modal-body { padding: var(--sp-4); }

  .notif-panel {
    width: 100vw;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .history-player-bar {
    min-width: auto;
    width: calc(100% - var(--sp-8));
    border-radius: var(--radius-lg);
  }

  #map-container {
    height: 60vh;
    min-height: 350px;
  }

  .global-search-box input { width: 140px; }

  .command-palette { width: 95vw; }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .tabs {
    padding: var(--sp-1) var(--sp-2);
  }

  .tab-btn {
    padding: var(--sp-1) var(--sp-2);
  }

  .nav-group {
    border-radius: var(--radius-md);
  }

  .header-badge,
  #clockDisplay {
    display: none;
  }
}

/* ─── 37. PRINT ─── */
@media print {
  body {
    background: #fff;
    color: #000;
  }

  .main-header,
  .tabs,
  .live-controls-bar,
  .toast-container,
  #toastContainer,
  .notif-panel,
  .command-palette-overlay,
  .modal-overlay,
  .map-controls-overlay,
  .map-extras-bar,
  .history-player-bar,
  .timeline-strip,
  .btn,
  .global-search-overlay {
    display: none !important;
  }

  .tab-content {
    display: block !important;
    padding: 0;
  }

  .section-box {
    break-inside: avoid;
    border: 1px solid #ddd;
    box-shadow: none;
    background: #fff;
  }

  .truck-card,
  .stat-card,
  .card {
    break-inside: avoid;
    border: 1px solid #ddd;
    box-shadow: none;
    background: #fff;
    color: #000;
  }

  .data-table {
    font-size: 11px;
  }

  .data-table thead th {
    background: #f5f5f5;
    color: #333;
    border-bottom: 2px solid #333;
  }

  .data-table tbody td {
    border-bottom: 1px solid #ddd;
    color: #000;
  }
}

/* ─── GLOBAL DARK MODE INLINE COLOR OVERRIDES ─── */
/* Catch any leftover JS-generated inline colors that break dark mode */
:root:not([data-theme="light"]) [style*="color: #333"],
:root:not([data-theme="light"]) [style*="color:#333"],
:root:not([data-theme="light"]) [style*="color: #555"],
:root:not([data-theme="light"]) [style*="color:#555"],
:root:not([data-theme="light"]) [style*="color: #666"],
:root:not([data-theme="light"]) [style*="color:#666"],
:root:not([data-theme="light"]) [style*="color: #444"],
:root:not([data-theme="light"]) [style*="color:#444"],
:root:not([data-theme="light"]) [style*="color: #0f172a"],
:root:not([data-theme="light"]) [style*="color:#0f172a"],
:root:not([data-theme="light"]) [style*="color: #1e293b"],
:root:not([data-theme="light"]) [style*="color:#1e293b"] {
  color: var(--text-primary) !important;
}

:root:not([data-theme="light"]) [style*="color: #888"],
:root:not([data-theme="light"]) [style*="color:#888"],
:root:not([data-theme="light"]) [style*="color: #999"],
:root:not([data-theme="light"]) [style*="color:#999"] {
  color: var(--text-muted) !important;
}

:root:not([data-theme="light"]) [style*="background: white"],
:root:not([data-theme="light"]) [style*="background:white"],
:root:not([data-theme="light"]) [style*="background: #fff"],
:root:not([data-theme="light"]) [style*="background:#fff"],
:root:not([data-theme="light"]) [style*="background-color: white"],
:root:not([data-theme="light"]) [style*="background-color:white"],
:root:not([data-theme="light"]) [style*="background-color: #fff"],
:root:not([data-theme="light"]) [style*="background-color:#fff"] {
  background: var(--bg-surface) !important;
  color: var(--text-primary) !important;
}


/* --- NEW FEATURES APPENDED --- */

/* --- Wizard Steps --- */
.maint-wizard { display: flex; flex-direction: column; gap: 0; }
.maint-wizard-nav { display: flex; gap: 0; margin-bottom: 20px; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); }
.maint-wizard-nav button {
  flex: 1; padding: 12px 8px; border: none; background: var(--bg-elevated); color: var(--text-muted);
  font-size: 11px; font-weight: 700; cursor: pointer; transition: all 0.3s ease;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  text-transform: uppercase; letter-spacing: 0.5px; position: relative;
}
.maint-wizard-nav button.active {
  background: linear-gradient(135deg, var(--warning), #e67e22); color: #fff;
  box-shadow: 0 4px 15px rgba(245,158,11,0.3);
}
.maint-wizard-nav button.completed {
  background: var(--success); color: #fff;
}
.maint-wizard-nav button .step-num {
  width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800;
}
.maint-wizard-nav button.active .step-num { background: rgba(255,255,255,0.35); }
.maint-wizard-step { display: none; animation: fadeSlideIn 0.3s ease; }
.maint-wizard-step.active { display: block; }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- Parts Picker --- */
.parts-picker { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.parts-picker-header {
  display: grid; grid-template-columns: 40px 1fr 80px 100px 100px 50px;
  background: var(--bg-elevated); padding: 10px 12px; font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 2px solid var(--border);
  gap: 8px; align-items: center;
}
.parts-picker-body { max-height: 280px; overflow-y: auto; }
.part-row {
  display: grid; grid-template-columns: 40px 1fr 80px 100px 100px 50px;
  padding: 10px 12px; border-bottom: 1px solid var(--border-light); align-items: center; gap: 8px;
  transition: all 0.2s ease; font-size: 12px;
}
.part-row:hover { background: var(--bg-surface); }
.part-row.checked { background: rgba(245, 158, 11, 0.06); border-left: 3px solid var(--warning); }
.part-row.unchecked { opacity: 0.45; }
.part-row input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--warning); cursor: pointer; border-radius: 4px;
}
.part-row input[type="number"], .part-row input[type="text"] {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border-light); border-radius: var(--radius-md);
  background: var(--bg-base); color: var(--text-primary); font-size: 12px; font-weight: 600;
  text-align: center; transition: border-color 0.2s;
}
.part-row input:focus { border-color: var(--warning); outline: none; box-shadow: 0 0 0 2px rgba(245,158,11,0.15); }
.part-row .part-name { font-weight: 700; color: var(--text-primary); }
.part-row .part-cat { font-size: 9px; color: var(--text-muted); text-transform: uppercase; margin-top: 2px; }
.part-row .btn-remove {
  width: 28px; height: 28px; border: none; background: var(--danger-subtle); color: var(--danger);
  border-radius: var(--radius-md); cursor: pointer; font-size: 11px; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.part-row .btn-remove:hover { background: var(--danger); color: #fff; }

/* --- Parts Total Bar --- */
.parts-total-bar {
  display: flex; justify-content: space-between; align-items: center; padding: 14px 16px;
  background: linear-gradient(135deg, rgba(245,158,11,0.08), rgba(234,88,12,0.05));
  border-top: 2px solid var(--warning); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.parts-total-bar .total-label { font-size: 12px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.parts-total-bar .total-value {
  font-size: 20px; font-weight: 900; color: var(--warning);
  background: linear-gradient(135deg, #f59e0b, #ea580c); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.parts-total-bar .total-items { font-size: 10px; color: var(--text-muted); }

/* --- Add Part Button --- */
.btn-add-part {
  width: 100%; padding: 10px; border: 2px dashed var(--border); background: transparent;
  color: var(--text-muted); border-radius: var(--radius-md); cursor: pointer; font-size: 12px;
  font-weight: 600; transition: all 0.2s; margin-top: 8px; display: flex; align-items: center;
  justify-content: center; gap: 6px;
}
.btn-add-part:hover { border-color: var(--warning); color: var(--warning); background: rgba(245,158,11,0.04); }

/* --- Summary Card (Step 3) --- */
.maint-summary-card {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; position: relative; overflow: hidden;
}
.maint-summary-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--warning), #ea580c, var(--danger));
}
.maint-summary-row {
  display: flex; justify-content: space-between; padding: 8px 0;
  border-bottom: 1px solid var(--border-light); font-size: 13px;
}
.maint-summary-row:last-child { border-bottom: none; }
.maint-summary-row .label { color: var(--text-muted); font-weight: 600; }
.maint-summary-row .value { color: var(--text-primary); font-weight: 700; }
.maint-summary-total {
  display: flex; justify-content: space-between; padding: 14px 0; margin-top: 8px;
  border-top: 2px solid var(--warning); font-size: 16px; font-weight: 900;
}
.maint-summary-total .value { color: var(--warning); }

/* --- Reference Badges on Truck Cards --- */
.ref-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.ref-badge {
  display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px;
  border-radius: var(--radius-full); font-size: 9px; font-weight: 700;
  letter-spacing: 0.3px; white-space: nowrap; transition: all 0.2s;
}
.ref-badge.ref-ok { background: rgba(16,185,129,0.12); color: #059669; border: 1px solid rgba(16,185,129,0.2); }
.ref-badge.ref-warn { background: rgba(245,158,11,0.12); color: #d97706; border: 1px solid rgba(245,158,11,0.25); animation: refPulseWarn 2s ease-in-out infinite; }
.ref-badge.ref-danger { background: rgba(239,68,68,0.12); color: #dc2626; border: 1px solid rgba(239,68,68,0.25); animation: refPulseDanger 1.5s ease-in-out infinite; }
.ref-badge.ref-expired { background: rgba(30,30,30,0.15); color: #991b1b; border: 1px solid rgba(239,68,68,0.4); text-decoration: line-through; }
.ref-badge .ref-icon { font-size: 8px; }
.ref-badge-more {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: var(--radius-full); font-size: 9px; font-weight: 700;
  background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.2s;
}
.ref-badge-more:hover { background: var(--primary-subtle); color: var(--primary); }
@keyframes refPulseWarn { 0%,100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); } 50% { box-shadow: 0 0 8px 2px rgba(245,158,11,0.2); } }
@keyframes refPulseDanger { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); } 50% { box-shadow: 0 0 10px 3px rgba(239,68,68,0.25); } }

/* --- Vehicle Reference Modal --- */
.ref-modal-overlay {
  position: fixed; inset: 0; z-index: 10000; display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(10px);
}
.ref-modal-overlay.show { display: flex; }
.ref-modal {
  background: var(--bg-surface); border: 1px solid var(--border-light); border-radius: 20px;
  width: 92%; max-width: 700px; max-height: 85vh; overflow-y: auto; padding: 28px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.4); animation: fadeSlideIn 0.3s ease;
}
.ref-list-item {
  display: flex; justify-content: space-between; align-items: center; padding: 12px 14px;
  background: var(--bg-elevated); border-radius: var(--radius-md); margin-bottom: 8px;
  border: 1px solid var(--border-light); transition: all 0.2s;
}
.ref-list-item:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.ref-list-item .ref-info { flex: 1; }
.ref-list-item .ref-name { font-weight: 800; font-size: 13px; color: var(--text-primary); }
.ref-list-item .ref-details { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.ref-list-item .ref-countdown {
  padding: 4px 12px; border-radius: var(--radius-full); font-size: 11px; font-weight: 800;
  min-width: 80px; text-align: center;
}
.ref-countdown.ok { background: rgba(16,185,129,0.12); color: #059669; }
.ref-countdown.warn { background: rgba(245,158,11,0.12); color: #d97706; }
.ref-countdown.danger { background: rgba(239,68,68,0.12); color: #dc2626; }
.ref-countdown.expired { background: rgba(239,68,68,0.2); color: #991b1b; font-weight: 900; }
.ref-list-item .ref-actions { display: flex; gap: 6px; margin-left: 10px; }
.ref-list-item .ref-actions button {
  width: 30px; height: 30px; border: 1px solid var(--border); background: var(--bg-base);
  border-radius: var(--radius-md); cursor: pointer; font-size: 11px; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.ref-list-item .ref-actions button:hover { border-color: var(--primary); color: var(--primary); }
.ref-list-item .ref-actions button.btn-del:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-subtle); }

/* --- Stat card for documents --- */
.stat-card-docs {
  position: relative; overflow: hidden;
}
.stat-card-docs::after {
  content: ''; position: absolute; top: -50%; right: -30%; width: 80px; height: 80px;
  background: rgba(255,255,255,0.08); border-radius: 50%; pointer-events: none;
}

/* =========================================================================
   OVERSPEED BLINK ANIMATION
========================================================================= */
@keyframes blinkRed {
  0% { opacity: 1; box-shadow: 0 0 12px var(--danger); }
  50% { opacity: 0.5; box-shadow: 0 0 2px var(--danger); }
  100% { opacity: 1; box-shadow: 0 0 12px var(--danger); }
}

.overspeed-blink {
  animation: blinkRed 1s infinite alternate ease-in-out !important;
}
.schemeBtns{display:flex;gap:4px;margin-bottom:6px}
.schemeBtns button{flex:1;padding:4px 0;border:1px solid #bbb;background:#fff;color:#444;font-size:10px;font-weight:700;border-radius:2px;cursor:pointer}
.schemeBtns button.active{background:#e6f7fa;border-color:#0d7f91;color:#0d7f91}
.scheme{display:none}
.scheme.active{display:block}
.tire{cursor:pointer}
.mark{display:none}
.mark.on{display:block}
.tireBox{padding:8px}

/* ─── Speeding animation: hard-blink red with growing glow ─── */
@keyframes speedingPulse {
  0%   { box-shadow: 0 0 6px rgba(239, 68, 68, 0.6), inset 0 0 6px rgba(239, 68, 68, 0.15); border-color: var(--danger); }
  40%  { box-shadow: 0 0 22px rgba(239, 68, 68, 0.9), inset 0 0 12px rgba(239, 68, 68, 0.25); border-color: rgba(239, 68, 68, 0.5); }
  100% { box-shadow: 0 0 6px rgba(239, 68, 68, 0.6), inset 0 0 6px rgba(239, 68, 68, 0.15); border-color: var(--danger); }
}

/* ─── Moving card: subtle green breathing glow ─── */
@keyframes movingCardGlow {
  0%   { box-shadow: 0 4px 20px rgba(0,0,0,0.05), 0 0 0 1px rgba(16,185,129,0.15); }
  50%  { box-shadow: 0 4px 20px rgba(0,0,0,0.08), 0 0 12px rgba(16,185,129,0.30); }
  100% { box-shadow: 0 4px 20px rgba(0,0,0,0.05), 0 0 0 1px rgba(16,185,129,0.15); }
}

/* ─── Speed badge blink when over limit ─── */
@keyframes speedBadgeBlink {
  0%, 100% { background: rgba(239, 68, 68, 0.9); color: #fff; transform: scale(1); }
  50%       { background: rgba(239, 68, 68, 0.3); color: #ef4444; transform: scale(1.08); }
}

@keyframes borderPulseRed {
  0% { border-color: var(--danger); box-shadow: 0 0 5px rgba(239, 68, 68, 0.4); }
  50% { border-color: rgba(239, 68, 68, 0.2); box-shadow: 0 0 15px rgba(239, 68, 68, 0.1); }
  100% { border-color: var(--danger); box-shadow: 0 0 5px rgba(239, 68, 68, 0.4); }
}

.truck-card.speeding {
  animation: speedingPulse 0.9s ease-in-out infinite;
  border: 2px solid var(--danger) !important;
  border-left: 4px solid var(--danger) !important;
  background: linear-gradient(145deg, rgba(239,68,68,0.08), var(--bg-elevated)) !important;
}

.truck-card.moving:not(.speeding):not(.critical-alert) {
  animation: movingCardGlow 3s ease-in-out infinite;
  border-left: 4px solid var(--success) !important;
}

.truck-card.speeding .speed-badge,
span.speed-badge-over {
  animation: speedBadgeBlink 0.7s ease-in-out infinite !important;
  border-radius: var(--radius-full) !important;
  padding: 4px 10px !important;
  font-weight: 900 !important;
}

.truck-card.critical-alert {
  animation: borderPulseRed 1.5s infinite;
  border: 1px solid var(--danger);
  border-left: 4px solid var(--danger) !important;
}

/* Document Expiration Blink */
@keyframes docExpiringBlink {
  0%   { border-color: var(--warning); box-shadow: 0 0 5px rgba(245,158,11,0.4); }
  50%  { border-color: rgba(245,158,11,0.2); box-shadow: 0 0 15px rgba(245,158,11,0.2); }
  100% { border-color: var(--warning); box-shadow: 0 0 5px rgba(245,158,11,0.4); }
}

.truck-card.doc-expiring {
  animation: docExpiringBlink 1.5s infinite;
  border-left: 4px solid var(--warning) !important;
}



/* Fuel Alert Blinking Animations */
@keyframes critical-fuel-pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
@keyframes low-fuel-pulse {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  50% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}
.critical-fuel-blink {
  animation: critical-fuel-pulse 1.5s infinite;
  border: 2px solid var(--danger) !important;
}
.low-fuel-blink {
  animation: low-fuel-pulse 2s infinite;
  border: 1px solid var(--warning) !important;
}
/* Color variable fallbacks for ui.js hardcoded vars */
:root {
  --red: var(--danger);
  --orange: var(--warning);
  --green: var(--success);
}
