/* ============================================================
   GeniTracker — Feuille de style principale
   GeniSolution DIGITAL Sarl
   ============================================================ */

/* ── Variables CSS (Light theme) ─────────────────────────── */
:root {
  --bg:          #f8f9fc;
  --bg-card:     #ffffff;
  --bg-input:    #f1f3f9;
  --bg-hover:    #f4f5f9;
  --border:      #e5e7f0;
  --border-light:#edf0f7;
  --text:        #0f1117;
  --text-muted:  #6b7280;
  --text-light:  #9ca3af;
  --accent:      #4f46e5;
  --accent-soft: rgba(79,70,229,0.1);
  --accent-dark: #3730a3;
  --green:       #16a34a;
  --green-soft:  rgba(22,163,74,0.1);
  --blue:        #2563eb;
  --blue-soft:   rgba(37,99,235,0.1);
  --orange:      #ea580c;
  --orange-soft: rgba(234,88,12,0.1);
  --red:         #dc2626;
  --red-soft:    rgba(220,38,38,0.1);
  --yellow:      #d97706;
  --yellow-soft: rgba(217,119,6,0.1);
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:      0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:   0 20px 40px rgba(0,0,0,0.1);
  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   16px;
  --sidebar-w:   260px;
  --topbar-h:    64px;
  --font:        'Plus Jakarta Sans', system-ui, sans-serif;
  --mono:        'JetBrains Mono', 'Courier New', monospace;
  --transition:  0.2s cubic-bezier(0.4,0,0.2,1);
}

/* Dark theme */
[data-theme="dark"] {
  --bg:          #0d0f14;
  --bg-card:     #161a24;
  --bg-input:    #1e2435;
  --bg-hover:    #1a1f2e;
  --border:      #252d42;
  --border-light:#1e2435;
  --text:        #f0f2f8;
  --text-muted:  #8892a4;
  --text-light:  #5a6480;
  --accent:      #6366f1;
  --accent-soft: rgba(99,102,241,0.15);
  --green-soft:  rgba(22,163,74,0.15);
  --blue-soft:   rgba(37,99,235,0.15);
  --orange-soft: rgba(234,88,12,0.15);
  --red-soft:    rgba(220,38,38,0.15);
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.3);
  --shadow:      0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:   0 20px 40px rgba(0,0,0,0.5);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }

/* ── Layout App ───────────────────────────────────────────── */
.app-body {
  display: block;
  min-height: 100vh;
  background: var(--bg);
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition), width var(--transition);
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logo-icon { display: flex; align-items: center; }

.sidebar-toggle { display: none; flex-direction: column; gap: 4px; padding: 6px; }
.sidebar-toggle span { width: 20px; height: 2px; background: var(--text-muted); border-radius: 2px; transition: var(--transition); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.nav-section { margin-bottom: 4px; }

.nav-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-light);
  padding: 12px 8px 4px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
  position: relative;
}

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

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active .nav-icon { stroke: var(--accent); }

.nav-icon {
  width: 18px; height: 18px;
  stroke: currentColor;
  flex-shrink: 0;
  transition: var(--transition);
}

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

.nav-badge.live { background: var(--green); }

.sidebar-footer {
  border-top: 1px solid var(--border-light);
  padding: 12px;
  flex-shrink: 0;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.user-avatar {
  width: 34px; height: 34px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

.logout-btn {
  color: var(--text-muted);
  padding: 6px;
  border-radius: 6px;
  display: flex;
  transition: var(--transition);
}

.logout-btn:hover { color: var(--red); background: var(--red-soft); text-decoration: none; }

/* ── Main Wrapper ─────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: calc(100% - var(--sidebar-w));
  transition: margin var(--transition), width var(--transition);
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 50;
  backdrop-filter: blur(12px);
}

.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.page-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.menu-btn {
  display: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: var(--transition);
}
.menu-btn:hover { background: var(--bg-hover); color: var(--text); }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  width: 240px;
  transition: var(--transition);
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-box svg { color: var(--text-light); flex-shrink: 0; }

.search-box input {
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--text);
  outline: none;
  width: 100%;
}

.search-box input::placeholder { color: var(--text-light); }

.icon-btn {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: var(--transition);
  position: relative;
}

.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

/* Sun/moon icons toggle */
[data-theme="light"] .moon-icon { display: none; }
[data-theme="dark"]  .sun-icon  { display: none; }

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 28px 28px 40px;
  width: 100%;
  box-sizing: border-box;
}

/* ── Flash Messages ───────────────────────────────────────── */
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  margin: 0 28px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideDown 0.3s ease;
}

.flash-success {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(22,163,74,0.2);
}

.flash-error {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(220,38,38,0.2);
}

.flash-content { display: flex; align-items: center; gap: 8px; }
.flash-close { color: currentColor; opacity: 0.6; font-size: 1.2rem; padding: 0 4px; }
.flash-close:hover { opacity: 1; }

@keyframes slideDown {
  from { transform: translateY(-10px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

/* ── Stat Cards ───────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  overflow: hidden;
  position: relative;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card.accent::before { background: var(--accent); }
.stat-card.green::before  { background: var(--green); }
.stat-card.blue::before   { background: var(--blue); }
.stat-card.orange::before { background: var(--orange); }

.stat-body {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-top: 4px;
}

.stat-sub {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 2px;
}

.stat-icon {
  width: 44px; height: 44px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 22px; height: 22px; stroke: var(--text-muted); }

.stat-card.accent .stat-icon { background: var(--accent-soft); }
.stat-card.accent .stat-icon svg { stroke: var(--accent); }
.stat-card.green  .stat-icon { background: var(--green-soft); }
.stat-card.green  .stat-icon svg { stroke: var(--green); }
.stat-card.blue   .stat-icon { background: var(--blue-soft); }
.stat-card.blue   .stat-icon svg { stroke: var(--blue); }
.stat-card.orange .stat-icon { background: var(--orange-soft); }
.stat-card.orange .stat-icon svg { stroke: var(--orange); }

.stat-chart-bar {
  margin-top: 14px;
  height: 4px;
  background: var(--bg-hover);
  border-radius: 2px;
  overflow: hidden;
}

.stat-chart-bar div {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 1s ease;
}

/* ── Dashboard layout ─────────────────────────────────────── */
.dashboard-grid { display: flex; flex-direction: column; gap: 20px; }

.dashboard-main {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}

.right-column { display: flex; flex-direction: column; gap: 16px; }

.dashboard-map-container {
  height: 360px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-input);
}

.map-legend {
  display: flex;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  margin-top: 12px;
}

.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.green  { background: #22c55e; }
.dot.red    { background: #ef4444; }
.dot.blue   { background: #3b82f6; }

/* Alerts list */
.alerts-list { display: flex; flex-direction: column; gap: 2px; }

.alert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.alert-item:hover { background: var(--bg-hover); }

.alert-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.alert-overspeed .alert-dot   { background: var(--orange); }
.alert-offline .alert-dot     { background: var(--red); }
.alert-geofence .alert-dot    { background: var(--blue); }
.alert-subscription_expired .alert-dot { background: var(--yellow); }

.alert-content { display: flex; flex-direction: column; gap: 1px; }
.alert-title { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.alert-meta  { font-size: 0.76rem; color: var(--text-muted); }

.empty-state-sm {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px;
  color: var(--text-light);
  font-size: 0.85rem;
}

/* Expiry list */
.expiry-list { display: flex; flex-direction: column; gap: 8px; }
.expiry-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}
.expiry-item:last-child { border-bottom: none; }
.expiry-plate { font-family: var(--mono); font-size: 0.85rem; font-weight: 600; flex: 1; }
.expiry-date  { font-size: 0.8rem; color: var(--orange); font-weight: 500; }

/* Chart */
.chart-card { overflow: hidden; }
.chart-wrapper { position: relative; height: 200px; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(79,70,229,0.3); text-decoration: none; color: white; }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--accent); text-decoration: none; }

.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(220,38,38,0.2);
}
.btn-danger:hover { background: var(--red); color: white; text-decoration: none; }

.btn-success {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(22,163,74,0.2);
}
.btn-success:hover { background: var(--green); color: white; text-decoration: none; }

.btn-warning {
  background: var(--yellow-soft);
  color: var(--yellow);
  border-color: rgba(217,119,6,0.2);
}
.btn-warning:hover { background: var(--yellow); color: white; text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
  padding: 6px 10px;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }

.btn-sm  { padding: 6px 12px; font-size: 0.8rem; }
.btn-xs  { padding: 3px 8px; font-size: 0.73rem; }
.btn-full { width: 100%; justify-content: center; }

.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ── Tables ───────────────────────────────────────────────── */
.table-card { overflow: hidden; }

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.table-filters { display: flex; gap: 8px; flex-wrap: wrap; }

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead tr {
  background: var(--bg-input);
  border-bottom: 1px solid var(--border);
}

th {
  padding: 11px 14px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover { background: var(--bg-hover); }

.table-actions { display: flex; gap: 4px; }

/* Immatriculation badge */
.plate-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--bg-input);
  color: var(--text);
  padding: 3px 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  letter-spacing: 0.04em;
}

/* ── Badges / Status ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }

.badge-active   { background: var(--green-soft);  color: var(--green);  }
.badge-active::before   { background: var(--green); }
.badge-inactive { background: var(--red-soft);    color: var(--red);    }
.badge-inactive::before { background: var(--red); }
.badge-expired  { background: var(--orange-soft); color: var(--orange); }
.badge-expired::before  { background: var(--orange); }
.badge-pending  { background: var(--yellow-soft); color: var(--yellow); }
.badge-pending::before  { background: var(--yellow); }
.badge-admin    { background: var(--accent-soft); color: var(--accent); }
.badge-client   { background: var(--blue-soft);   color: var(--blue);   }

/* ── Forms ────────────────────────────────────────────────── */
.form-page { max-width: 760px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.full   { grid-template-columns: 1fr; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.span-2 { grid-column: 1 / -1; }

label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.label-link {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  transition: all var(--transition);
  appearance: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-input::placeholder { color: var(--text-light); }

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

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 12px;
  color: var(--text-light);
  pointer-events: none;
}

.input-wrapper .form-input { padding-left: 40px; }

.input-eye {
  position: absolute;
  right: 10px;
  color: var(--text-light);
  padding: 4px;
  border-radius: 4px;
}

.input-eye:hover { color: var(--text); }

.form-hint { font-size: 0.78rem; color: var(--text-light); }
.form-error { font-size: 0.78rem; color: var(--red); }

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
  margin-top: 8px;
}

/* ── Auth Pages ───────────────────────────────────────────── */
.auth-body {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.auth-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.auth-brand {
  flex: 1;
  background: linear-gradient(135deg, #312e81 0%, #4f46e5 50%, #6366f1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 48px;
  position: relative;
  overflow: hidden;
}

.auth-brand::before {
  content: '';
  position: absolute;
  top: -100px; right: -100px;
  width: 400px; height: 400px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}

.auth-brand::after {
  content: '';
  position: absolute;
  bottom: -80px; left: -80px;
  width: 300px; height: 300px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
}

.auth-brand-content {
  position: relative;
  z-index: 1;
  max-width: 420px;
  color: white;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 40px;
  letter-spacing: -0.03em;
}

.auth-brand h2 {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
  letter-spacing: -0.03em;
}

.auth-brand p {
  font-size: 1rem;
  opacity: 0.8;
  margin-bottom: 40px;
  line-height: 1.6;
}

.brand-features { display: flex; flex-direction: column; gap: 20px; margin-bottom: 48px; }

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

.bf-icon {
  font-size: 1.5rem;
  width: 48px; height: 48px;
  background: rgba(255,255,255,0.15);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-feature strong { display: block; font-size: 0.9rem; font-weight: 700; margin-bottom: 2px; }
.brand-feature span   { font-size: 0.82rem; opacity: 0.75; }

.brand-footer {
  display: flex;
  gap: 16px;
  font-size: 0.78rem;
  opacity: 0.6;
}

.brand-footer a { color: white; }

/* Auth form panel */
.auth-form-panel {
  width: 480px;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 48px;
}

.auth-form-container { width: 100%; max-width: 380px; }

.auth-form-header { margin-bottom: 32px; }
.auth-form-header h1 { font-size: 1.7rem; font-weight: 800; color: var(--text); margin-bottom: 6px; letter-spacing: -0.03em; }
.auth-form-header p  { font-size: 0.9rem; color: var(--text-muted); }

.auth-alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 20px;
}

.auth-alert-error   { background: var(--red-soft);   color: var(--red);   border: 1px solid rgba(220,38,38,0.2); }
.auth-alert-success { background: var(--green-soft); color: var(--green); border: 1px solid rgba(22,163,74,0.2); }

.auth-form { display: flex; flex-direction: column; gap: 18px; margin-bottom: 24px; }

.auth-form .form-group label { font-size: 0.85rem; }

.auth-footer-text {
  font-size: 0.8rem;
  color: var(--text-light);
  text-align: center;
}

/* ── Live Tracking Page ───────────────────────────────────── */
.tracking-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  height: calc(100vh - var(--topbar-h) - 80px);
  min-height: 600px;
}

.vehicles-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.panel-search {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
}

.panel-search .search-box { width: 100%; }

.vehicle-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.vehicle-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  border: 1.5px solid transparent;
}

.vehicle-list-item:hover { background: var(--bg-hover); }
.vehicle-list-item.selected { background: var(--accent-soft); border-color: var(--accent); }

.vehicle-type-icon {
  width: 40px; height: 40px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.vehicle-list-info { flex: 1; min-width: 0; }
.vli-plate { font-family: var(--mono); font-size: 0.85rem; font-weight: 700; }
.vli-meta  { font-size: 0.75rem; color: var(--text-muted); }

.vehicle-status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}

.vehicle-status-dot.online  { background: #22c55e; }
.vehicle-status-dot.offline { background: #9ca3af; }
.vehicle-status-dot.moving  { background: #3b82f6; }

.vehicle-status-dot.moving::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: rgba(59,130,246,0.3);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.5); opacity: 0; }
}

/* Map container */
.map-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}

#tracking-map, #history-map {
  width: 100%;
  height: 100%;
  min-height: 500px;
}

.map-overlay {
  position: absolute;
  top: 12px; right: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.map-overlay-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.map-overlay-btn:hover { background: var(--bg-hover); }

/* Info popup */
.vehicle-info-popup {
  position: absolute;
  bottom: 16px; left: 50%; 
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  width: 320px;
  box-shadow: var(--shadow-lg);
  z-index: 10;
  display: none;
  animation: popupIn 0.2s ease;
}

@keyframes popupIn {
  from { transform: translateX(-50%) translateY(10px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.popup-plate { font-family: var(--mono); font-size: 1rem; font-weight: 800; }
.popup-close { color: var(--text-light); font-size: 1.2rem; }

.popup-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.popup-stat { text-align: center; }
.popup-stat-val  { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.popup-stat-label { font-size: 0.72rem; color: var(--text-muted); }

.popup-address { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 12px; }

.popup-actions { display: flex; gap: 8px; }

/* ── App Footer ───────────────────────────────────────────── */
.app-footer {
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-light);
  border-top: 1px solid var(--border-light);
  margin-top: auto;
}

.app-footer a { color: var(--text-muted); }
.app-footer a:hover { color: var(--accent); }
.version { font-family: var(--mono); font-size: 0.72rem; }

/* ── Sidebar overlay (mobile) ─────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ── Empty states ─────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  gap: 12px;
  color: var(--text-light);
}

.empty-state svg { width: 48px; height: 48px; opacity: 0.3; }
.empty-state h3  { font-size: 1rem; font-weight: 700; color: var(--text-muted); margin: 0; }
.empty-state p   { font-size: 0.875rem; max-width: 300px; line-height: 1.5; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  margin-top: 4px;
}

.page-btn {
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: var(--transition);
  cursor: pointer;
}

.page-btn:hover   { background: var(--bg-hover); color: var(--text); }
.page-btn.current { background: var(--accent); color: white; }

/* ── Spinner ──────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Map popup ────────────────────────────────────────────── */
.map-popup {
  font-family: var(--font);
  font-size: 13px;
  padding: 4px;
  min-width: 140px;
}

.map-popup strong { display: block; font-size: 15px; margin-bottom: 4px; }

/* ── Sidebar collapsed ────────────────────────────────────── */
.sidebar.collapsed { width: 68px; }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .user-card { justify-content: center; }
.sidebar.collapsed + .main-wrapper {
  margin-left: 68px;
  width: calc(100% - 68px);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1100px) {
  .dashboard-main { grid-template-columns: 1fr; }
  .right-column { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .tracking-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .vehicles-panel { max-height: 220px; }
  .vehicle-list { display: flex; overflow-x: auto; padding: 8px; gap: 8px; }
  .vehicle-list-item { min-width: 180px; flex-direction: column; text-align: center; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }

  .sidebar-toggle { display: flex; }
  .menu-btn { display: flex; }

  .main-wrapper { margin-left: 0; width: 100%; }

  .topbar { padding: 0 16px; }
  .main-content { padding: 16px 16px 40px; }

  .search-box { display: none; }

  .stats-row { grid-template-columns: 1fr 1fr; }

  .form-grid,
  .form-grid.cols-3 { grid-template-columns: 1fr; }
  .form-group.span-2 { grid-column: auto; }

  .auth-container { flex-direction: column; }
  .auth-brand { display: none; }
  .auth-form-panel { width: 100%; padding: 40px 24px; }

  .right-column { grid-template-columns: 1fr; }

  .table-toolbar { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.6rem; }
}
