/* ════════════════════════════════════════════════════════════════════
   PeakPulse — Horizon Design System
   A premium, motion-rich design language for modern fleet operations.
   ══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── Design Tokens ────────────────────────────────────────────────── */
:root {
  /* Brand palette — comma-separated so rgba(var(--coral), 0.5) expands to valid rgba(255, 107, 74, 0.5).
     Space-separated channels would produce `rgba(255 107 74, 0.5)` which is invalid CSS and causes
     any declaration containing it to be silently dropped (including multi-layer backgrounds). */
  --coral:  255, 107, 74;
  --indigo: 99, 102, 241;
  --mint:   16, 217, 196;
  --violet: 167, 139, 250;

  /* Neutrals — light mode */
  --gray-50:  #fafbfc;
  --gray-100: #f4f5f8;
  --gray-200: #e5e7ed;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #0f172a;

  /* Surfaces */
  --bg-page:      #f7f8fb;
  --bg-surface:   #ffffff;
  --bg-elevated:  #ffffff;
  --bg-sunken:    #f1f3f7;
  --bg-hover:     #f0f2f7;
  --bg-card:      #ffffff;
  --bg-input:     #ffffff;
  --bg-secondary: #ffffff;
  --bg-primary:   #f7f8fb;

  /* Borders */
  --border:        #e7eaf0;
  --border-strong: #d1d5db;
  --border-focus:  rgb(var(--coral));

  /* Text */
  --text-primary:   #0f172a;
  --text-secondary: #4b5563;
  --text-tertiary:  #6b7280;
  --text-muted:     #94a3b8;
  --text-on-accent: #ffffff;

  /* Semantic */
  --accent:        rgb(var(--coral));
  --accent-hover:  rgb(232 89 59);
  --accent-soft:   rgba(var(--coral), 0.08);
  --accent-dim:    rgba(var(--coral), 0.12);
  --accent-border: rgba(var(--coral), 0.22);
  --accent-glow:   rgba(var(--coral), 0.35);

  --success:       rgb(var(--mint));
  --success-dim:   rgba(var(--mint), 0.12);
  --green:         rgb(16 185 129);
  --green-dim:     rgba(16, 185, 129, 0.12);
  --amber:         #f59e0b;
  --amber-dim:     rgba(245, 158, 11, 0.14);
  --red:           #ef4444;
  --danger:        #ef4444;
  --red-dim:       rgba(239, 68, 68, 0.12);
  --purple:        rgb(var(--violet));
  --purple-dim:    rgba(var(--violet), 0.14);

  /* Gradients */
  --gradient-brand:       linear-gradient(135deg, rgb(var(--coral)) 0%, rgb(var(--indigo)) 100%);
  --gradient-brand-soft:  linear-gradient(135deg, rgba(var(--coral), 0.12) 0%, rgba(var(--indigo), 0.12) 100%);
  --gradient-aurora:      linear-gradient(135deg, rgb(var(--coral)) 0%, rgb(var(--violet)) 50%, rgb(var(--indigo)) 100%);
  --gradient-sheen:       linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0) 100%);

  /* Radii */
  --radius-xs:   4px;
  --radius-sm:   8px;
  --radius:      12px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   20px;
  --radius-2xl:  28px;
  --radius-full: 9999px;

  /* Elevation — layered, honest shadows */
  --shadow-xs:     0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm:     0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow:        0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-md:     0 8px 24px rgba(15, 23, 42, 0.08), 0 3px 8px rgba(15, 23, 42, 0.04);
  --shadow-lg:     0 16px 40px rgba(15, 23, 42, 0.10), 0 6px 16px rgba(15, 23, 42, 0.06);
  --shadow-xl:     0 32px 64px rgba(15, 23, 42, 0.14);
  --shadow-glow:   0 0 32px rgba(var(--coral), 0.25);

  /* Motion */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast:    120ms;
  --dur-base:    200ms;
  --dur-slow:    360ms;

  /* Layout */
  --sidebar-width: 260px;
  --topbar-height: 64px;
}

/* ── Dark mode — first-class premium experience ──────────────────── */
html.dark {
  --bg-page:      #080b12;
  --bg-surface:   #0d111a;
  --bg-elevated:  #131825;
  --bg-sunken:    #05070c;
  --bg-hover:     #19202e;
  --bg-card:      #131825;
  --bg-input:     #0f131d;
  --bg-secondary: #0d111a;
  --bg-primary:   #080b12;

  --border:        #1e2535;
  --border-strong: #2a3348;
  --border-focus:  rgb(var(--coral));

  --text-primary:   #e6e9f1;
  --text-secondary: #9aa4ba;
  --text-tertiary:  #6b7489;
  --text-muted:     #4d5568;

  --accent-soft:   rgba(var(--coral), 0.10);
  --accent-dim:    rgba(var(--coral), 0.16);
  --accent-border: rgba(var(--coral), 0.28);
  --accent-glow:   rgba(var(--coral), 0.45);

  --success:       rgb(var(--mint));
  --success-dim:   rgba(var(--mint), 0.16);
  --green:         rgb(52 211 153);
  --green-dim:     rgba(52, 211, 153, 0.16);
  --amber:         #fbbf24;
  --amber-dim:     rgba(251, 191, 36, 0.16);
  --red:           #f87171;
  --danger:        #f87171;
  --red-dim:       rgba(248, 113, 113, 0.14);
  --purple:        rgb(var(--violet));
  --purple-dim:    rgba(var(--violet), 0.18);

  --gradient-sheen: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0) 100%);

  --shadow-xs:   0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm:   0 2px 6px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow:      0 6px 20px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-md:   0 12px 32px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg:   0 24px 48px rgba(0, 0, 0, 0.6);
  --shadow-xl:   0 48px 96px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 48px rgba(var(--coral), 0.35);
}

/* ── Reset + base ─────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
*::selection { background: rgba(var(--coral), 0.28); color: var(--text-primary); }

html { color-scheme: light dark; }
html.dark { color-scheme: dark; }

body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Space Grotesk', 'DM Sans', system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h1 { font-size: 28px; letter-spacing: -0.03em; }
h2 { font-size: 22px; }
h3 { font-size: 16px; }

a { color: var(--accent); text-decoration: none; transition: color var(--dur-fast) var(--ease-out); }
a:hover { color: var(--accent-hover); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; border: 2px solid var(--bg-page); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ── Keyframes ────────────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
@keyframes pulseRing {
  0%   { transform: scale(1);   opacity: 0.9; }
  80%  { transform: scale(2.4); opacity: 0; }
  100% { transform: scale(2.4); opacity: 0; }
}
@keyframes meshDrift {
  0%   { transform: translate(0, 0) scale(1); }
  33%  { transform: translate(2%, -1%) scale(1.02); }
  66%  { transform: translate(-1%, 2%) scale(0.98); }
  100% { transform: translate(0, 0) scale(1); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.animate-in { animation: fadeInUp var(--dur-slow) var(--ease-out) both; }
.stagger-1 { animation-delay: 40ms; }
.stagger-2 { animation-delay: 80ms; }
.stagger-3 { animation-delay: 120ms; }
.stagger-4 { animation-delay: 160ms; }
.stagger-5 { animation-delay: 200ms; }
.stagger-6 { animation-delay: 240ms; }

/* ══════════════════════════════════════════════════════════════════
   Auth pages — login, register, forgot
   ══════════════════════════════════════════════════════════════════ */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background: var(--bg-page);
}

/* Animated mesh gradient background */
.auth-container::before {
  content: '';
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(ellipse 50% 40% at 15% 25%, rgba(var(--coral), 0.22) 0%, transparent 60%),
    radial-gradient(ellipse 55% 45% at 85% 75%, rgba(var(--indigo), 0.22) 0%, transparent 60%),
    radial-gradient(ellipse 45% 35% at 65% 15%, rgba(var(--violet), 0.18) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 25% 85%, rgba(var(--mint), 0.15) 0%, transparent 60%);
  filter: blur(40px);
  animation: meshDrift 24s ease-in-out infinite;
  z-index: 0;
}
html.dark .auth-container::before {
  background:
    radial-gradient(ellipse 55% 45% at 15% 25%, rgba(var(--coral), 0.28) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 85% 75%, rgba(var(--indigo), 0.30) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 65% 15%, rgba(var(--violet), 0.22) 0%, transparent 60%),
    radial-gradient(ellipse 45% 35% at 25% 85%, rgba(var(--mint), 0.18) 0%, transparent 60%);
  opacity: 0.6;
}

.auth-card {
  position: relative;
  z-index: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 44px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(24px);
  animation: fadeInUp var(--dur-slow) var(--ease-out) both;
}

html.dark .auth-card {
  background: rgba(19, 24, 37, 0.85);
  border-color: rgba(255, 255, 255, 0.06);
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 32px;
}
.auth-logo img,
.auth-logo .icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  background: var(--gradient-brand);
  box-shadow: 0 8px 24px rgba(var(--coral), 0.35);
  display: flex; align-items: center; justify-content: center;
}
.auth-logo .icon svg { width: 26px; height: 26px; color: white; }
.auth-logo h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.auth-logo h1 span {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-title {
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}
.auth-subtitle {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

/* ══════════════════════════════════════════════════════════════════
   Forms
   ══════════════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: -0.005em;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.form-input:hover { border-color: var(--border-strong); }
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  background: var(--bg-surface);
}
.form-input::placeholder { color: var(--text-muted); }

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239ca3af' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

textarea.form-input { resize: vertical; min-height: 72px; }

/* ══════════════════════════════════════════════════════════════════
   Buttons — premium tactile feel with gradient + glow
   ══════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: -0.005em;
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) var(--ease-out);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--gradient-brand);
  background-size: 200% 200%;
  background-position: 0% 50%;
  color: #fff;
  box-shadow: 0 6px 18px rgba(var(--coral), 0.28), inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn-primary:hover {
  background-position: 100% 50%;
  box-shadow: 0 10px 28px rgba(var(--coral), 0.42), inset 0 1px 0 rgba(255,255,255,0.22);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-primary.btn-block,
.auth-card .btn-primary { width: 100%; padding: 12px 20px; }

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.24);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.18); transform: translateY(-1px); }

.btn-sm { padding: 7px 12px; font-size: 12.5px; gap: 6px; }
.btn-lg { padding: 13px 24px; font-size: 15px; }

.btn-icon {
  padding: 7px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }

/* OAuth / divider */
.oauth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 24px 0 18px;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}
.oauth-divider::before,
.oauth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.oauth-buttons { display: flex; flex-direction: column; gap: 10px; }

.btn-oauth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  text-decoration: none;
  width: 100%;
}
.btn-oauth:hover { background: var(--bg-hover); border-color: var(--border-strong); transform: translateY(-1px); }
.btn-oauth svg { width: 20px; height: 20px; }

/* ══════════════════════════════════════════════════════════════════
   Alerts
   ══════════════════════════════════════════════════════════════════ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.5;
  animation: fadeInUp var(--dur-base) var(--ease-out);
}
.alert-error   { background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(239, 68, 68, 0.25); }
.alert-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(16, 185, 129, 0.25); }
.alert-warning { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(245, 158, 11, 0.25); }
.alert-info    { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent-border); }

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 13.5px;
  color: var(--text-secondary);
}
.auth-footer a { font-weight: 600; }

/* ══════════════════════════════════════════════════════════════════
   Admin Layout
   ══════════════════════════════════════════════════════════════════ */
.admin-layout { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
html.dark .admin-sidebar {
  background: rgba(13, 17, 26, 0.85);
  border-right-color: rgba(255, 255, 255, 0.05);
}

.admin-sidebar .logo {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 22px 18px;
  border-bottom: 1px solid var(--border);
}
.admin-sidebar .logo img,
.admin-sidebar .logo .icon {
  width: 36px; height: 36px;
  background: var(--gradient-brand);
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(var(--coral), 0.35);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.admin-sidebar .logo .icon svg { width: 18px; height: 18px; color: white; }
.admin-sidebar .logo h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.admin-sidebar .logo h2 span {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.admin-sidebar .role-badge {
  margin: 14px 22px 6px;
  padding: 4px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-full);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
  align-self: flex-start;
  display: inline-block;
  width: fit-content;
}

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

.nav-section {
  padding: 14px 22px 6px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 22px;
  margin: 1px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  text-decoration: none;
  position: relative;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--accent-border);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--gradient-brand);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 12px var(--accent-glow);
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-item.active svg { opacity: 1; }

.admin-sidebar .user-info {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: var(--gradient-brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(var(--coral), 0.28);
}

.user-meta { flex: 1; min-width: 0; }
.user-meta .name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); }
.user-meta .email { font-size: 11.5px; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-logout {
  padding: 7px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--dur-fast) var(--ease-out);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-logout:hover { background: var(--red-dim); color: var(--red); border-color: rgba(239, 68, 68, 0.3); }

/* ── Main content ─────────────────────────────────────────────────── */
.admin-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 28px 36px 48px;
  overflow-y: auto;
  min-width: 0;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(180deg, var(--text-primary) 0%, var(--text-secondary) 150%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.page-header h2 { font-size: 20px; font-weight: 600; }

.page-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: -18px;
  margin-bottom: 24px;
}

/* ══════════════════════════════════════════════════════════════════
   Stat cards — premium with icon + trend
   ══════════════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  overflow: hidden;
  transition: all var(--dur-base) var(--ease-out);
  animation: fadeInUp var(--dur-slow) var(--ease-out) both;
}
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-sheen);
  pointer-events: none;
  opacity: 0.5;
}
.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.stat-card .label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  font-weight: 600;
}
.stat-card .value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.stat-card .sub {
  font-size: 12.5px;
  color: var(--text-tertiary);
  margin-top: 6px;
}

.stat-card.accent .value {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat-card.green  .value { color: var(--green); }
.stat-card.amber  .value { color: var(--amber); }
.stat-card.purple .value { color: var(--purple); }
.stat-card.red    .value { color: var(--red); }

/* Stat card with leading icon treatment */
.stat-card.has-icon {
  display: flex; align-items: center; gap: 14px;
  text-decoration: none; color: inherit;
  cursor: pointer;
}
.stat-card.has-icon .icon-wrap {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}
.stat-card.has-icon .icon-wrap svg { width: 22px; height: 22px; }
.stat-card.has-icon.green  .icon-wrap { background: var(--green-dim);  color: var(--green); }
.stat-card.has-icon.amber  .icon-wrap { background: var(--amber-dim);  color: var(--amber); }
.stat-card.has-icon.purple .icon-wrap { background: var(--purple-dim); color: var(--purple); }
.stat-card.has-icon.red    .icon-wrap { background: var(--red-dim);    color: var(--red); }

.stat-card.has-icon .info { flex: 1; min-width: 0; }
.stat-card.has-icon .info .label { margin-bottom: 2px; }
.stat-card.has-icon .info .value { font-size: 22px; }

/* Optional trend pill */
.trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
}
.trend.up   { background: var(--green-dim); color: var(--green); }
.trend.down { background: var(--red-dim);   color: var(--red); }
.trend.flat { background: var(--bg-hover);  color: var(--text-secondary); }

/* ══════════════════════════════════════════════════════════════════
   Panels
   ══════════════════════════════════════════════════════════════════ */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  animation: fadeInUp var(--dur-slow) var(--ease-out) both;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.panel:hover { border-color: var(--border-strong); }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
}
.panel-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.panel-header a {
  font-size: 12.5px;
  color: var(--text-tertiary);
  font-weight: 500;
  transition: color var(--dur-fast) var(--ease-out);
}
.panel-header a:hover { color: var(--accent); }

.panel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  transition: background var(--dur-fast) var(--ease-out);
}
.panel-row:hover { background: var(--bg-hover); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: var(--radius-sm); }
.panel-row:last-child { border-bottom: none; }
.panel-row:last-child:hover { border-bottom-color: transparent; }
.panel-empty {
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 16px 0;
  text-align: center;
}

/* ══════════════════════════════════════════════════════════════════
   Data tables
   ══════════════════════════════════════════════════════════════════ */
.table-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: fadeInUp var(--dur-slow) var(--ease-out) both;
}

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

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 11px 22px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
  white-space: nowrap;
}
td {
  padding: 14px 22px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
tr:last-child td { border-bottom: none; }
tbody tr {
  transition: background var(--dur-fast) var(--ease-out);
}
tbody tr:hover td { background: var(--bg-hover); }

/* ══════════════════════════════════════════════════════════════════
   Badges
   ══════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.4;
}
.badge-green,   .badge-success   { background: var(--green-dim);   color: var(--green); }
.badge-red,     .badge-danger    { background: var(--red-dim);     color: var(--red); }
.badge-amber,   .badge-warning   { background: var(--amber-dim);   color: var(--amber); }
.badge-accent,  .badge-primary   { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-border); }
.badge-secondary { background: var(--bg-hover); color: var(--text-secondary); }

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; }

.actions { display: flex; gap: 6px; }

/* ══════════════════════════════════════════════════════════════════
   Modals
   ══════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 18, 0.55);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn var(--dur-base) var(--ease-out);
}
.modal-overlay[style*="flex"],
.modal-overlay.visible { display: flex !important; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-xl);
  animation: fadeInUp var(--dur-base) var(--ease-out);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
html.dark .modal { background: rgba(19, 24, 37, 0.96); backdrop-filter: blur(24px); }

.modal h3 { font-size: 18px; margin-bottom: 18px; letter-spacing: -0.02em; }
.modal .form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* ══════════════════════════════════════════════════════════════════
   Skeleton loaders
   ══════════════════════════════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-hover) 25%,
    var(--bg-sunken) 50%,
    var(--bg-hover) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--radius-sm);
  display: inline-block;
}
.skeleton-line { height: 14px; width: 100%; margin-bottom: 8px; }
.skeleton-line:last-child { width: 70%; margin-bottom: 0; }

/* ══════════════════════════════════════════════════════════════════
   Toast notifications
   ══════════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  animation: fadeInUp var(--dur-base) var(--ease-out);
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast-success { border-color: rgba(16, 185, 129, 0.3); }
.toast-success::before { content: '✓'; color: var(--green); font-weight: 700; font-size: 16px; }
.toast-error { border-color: rgba(239, 68, 68, 0.3); }
.toast-error::before { content: '!'; color: var(--red); font-weight: 700; }

/* ══════════════════════════════════════════════════════════════════
   Utility helpers
   ══════════════════════════════════════════════════════════════════ */
.glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.6);
}
html.dark .glass {
  background: rgba(19, 24, 37, 0.6);
  border-color: rgba(255, 255, 255, 0.06);
}

.divider { height: 1px; background: var(--border); margin: 16px 0; }

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ══════════════════════════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .admin-sidebar {
    width: 68px;
    min-width: 68px;
  }
  .admin-sidebar .logo h2,
  .admin-sidebar .role-badge,
  .nav-section,
  .nav-item span,
  .user-meta { display: none; }
  .nav-item {
    justify-content: center;
    padding: 12px;
    margin: 2px 8px;
  }
  .nav-item.active::before { display: none; }
  .admin-sidebar .user-info { justify-content: center; padding: 14px 10px; }
  .btn-logout { display: none; }
  .admin-main {
    margin-left: 68px;
    padding: 20px 20px 40px;
  }
  .page-header h1 { font-size: 24px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 32px 24px; }
}

/* ══════════════════════════════════════════════════════════════════
   Mobile-first overrides ( < 768px — phones in portrait )
   ══════════════════════════════════════════════════════════════════
   Goal: drivers in the field can do walkaround / POD / view current job
   without pinch-zoom. Bottom-tab nav (instead of side nav), touch targets
   ≥ 44px (Apple HIG), tables collapse to cards, modals full-screen.

   Rules of thumb:
   - .mobile-only / .desktop-only utility classes for content swaps
   - .table-mobile-cards on a <table> turns its rows into stacked cards
   - .btn-mobile-primary makes a button big enough for a thumb in a glove
   - .body-has-bottom-nav adds bottom padding so the last row clears the nav
   ══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Hide the desktop side nav — we render a bottom-nav via JS instead. */
  .admin-sidebar { display: none !important; }
  .admin-main { margin-left: 0 !important; padding: 16px 14px 96px !important; }

  /* Page header collapses to a tighter row */
  .page-header { flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
  .page-header h1 { font-size: 22px !important; line-height: 1.2; }
  .page-header > div { width: 100%; display: flex; gap: 8px; }
  .page-header .btn { flex: 1 1 0; }

  /* Touch targets — Apple's minimum is 44px tappable */
  .btn { min-height: 44px; padding: 12px 16px; }
  .btn-sm { min-height: 38px; padding: 9px 12px; font-size: 13px; }
  .btn-icon { min-width: 44px; min-height: 44px; padding: 10px; }
  input, select, textarea { min-height: 44px; font-size: 16px !important; /* 16px stops iOS auto-zooming on focus */ }
  input[type="checkbox"], input[type="radio"] { min-height: auto; min-width: 22px; min-height: 22px; }

  /* Modals — make full-screen on phones so the keyboard doesn't push content offscreen */
  .modal-overlay.visible { align-items: flex-end; padding: 0; }
  .modal {
    width: 100% !important; max-width: 100% !important;
    max-height: 92vh; min-height: 50vh;
    border-radius: 18px 18px 0 0 !important;
    padding: 18px 18px 24px !important;
    overflow-y: auto;
  }
  .form-row { grid-template-columns: 1fr !important; }

  /* Tables that drop the .table-mobile-cards class become a stacked card list. */
  table.table-mobile-cards { border: 0; }
  table.table-mobile-cards thead { display: none; }
  table.table-mobile-cards, table.table-mobile-cards tbody,
  table.table-mobile-cards tr, table.table-mobile-cards td { display: block; width: 100%; }
  table.table-mobile-cards tr {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 12px; margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
  }
  table.table-mobile-cards td {
    border: 0 !important; padding: 4px 0 !important; text-align: left !important;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
  }
  table.table-mobile-cards td::before {
    content: attr(data-label); font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-tertiary); font-weight: 600;
    flex-shrink: 0;
  }
  table.table-mobile-cards td:not([data-label])::before { content: ''; }

  /* Generic table fallback: horizontal scroll if developer hasn't opted in */
  .table-container:not(.cards-on-mobile) { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Forms breathe on small screens */
  .form-group label { font-size: 13px; }
  .form-group { margin-bottom: 14px; }
  .form-actions { flex-direction: column-reverse; gap: 8px; }
  .form-actions .btn { width: 100%; }

  /* Hide things the desktop UI shows that are noise on a phone */
  .desktop-only { display: none !important; }
  .mobile-only  { display: block !important; }

  /* Stats / dashboard tiles */
  .stats-grid { gap: 10px; }

  /* Charts — keep them tappable but not taking the whole screen */
  canvas { max-height: 240px !important; }
}

/* ── Bottom-tab nav (rendered by auth.js renderBottomNav) ───────────
   The tracker page uses `body { display: flex; overflow: hidden }` to lay
   out the map full-screen. A flex child with `position: fixed` SHOULD be
   pulled out of flow but some browser/page combos collapse it to 0 height,
   so the nav disappears. The !important + explicit width + max-z-index
   below makes the nav unconditionally visible regardless of parent layout. */
.mobile-bottom-nav {
  display: none;
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  z-index: 99999 !important;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.05);
}
.mobile-bottom-nav .nav-row { display: flex; justify-content: space-around; max-width: 600px; margin: 0 auto; }
.mobile-bottom-nav a {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; min-height: 56px;
  color: var(--text-tertiary); text-decoration: none;
  font-size: 11px; font-weight: 500; text-align: center;
  border-radius: var(--radius-sm);
}
.mobile-bottom-nav a.active { color: var(--accent); }
.mobile-bottom-nav a svg { width: 22px; height: 22px; flex-shrink: 0; }
.mobile-bottom-nav a span { line-height: 1; }
@media (max-width: 768px) { .mobile-bottom-nav { display: block !important; } }

/* Hide elements only shown on phones */
.mobile-only { display: none; }

/* ══════════════════════════════════════════════════════════════════
   Leaflet dark mode polish
   ══════════════════════════════════════════════════════════════════ */
html.dark .leaflet-popup-content-wrapper,
html.dark .leaflet-popup-tip,
html.dark .leaflet-tooltip {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
html.dark .leaflet-control-zoom a {
  background: var(--bg-elevated) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}
html.dark .leaflet-control-zoom a:hover {
  background: var(--bg-hover) !important;
}
html.dark .leaflet-container { background: #05070c; }

/* Floating map panels (tracker) */
.map-panel {
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 500;
}
html.dark .map-panel {
  background: rgba(13, 17, 26, 0.78);
  border-color: rgba(255, 255, 255, 0.06);
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
