/* ============================================================
   EMOTIV FMS — Design System v3: Crisp Light / Modern SaaS
   Inspired by: Linear, Vercel, Arc — high-signal, low-noise
   Fonts: DM Sans (UI) + DM Mono (telemetry/data)
   Logo: Emerald green #1DB954 — used as brand signature accent
   Secondary: Indigo #6366F1 — data states & supporting actions
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@300;400;500&display=swap');

/* ── 1. Design Tokens ─────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-app: #F2F4F7;
  --bg-surface: #FFFFFF;
  --bg-elevated: #F7F8FA;
  --bg-subtle: #EEF0F4;
  --bg-overlay: rgba(0, 0, 0, 0.04);

  /* Borders */
  --border-light: rgba(0, 0, 0, 0.06);
  --border-medium: rgba(0, 0, 0, 0.10);
  --border-strong: rgba(0, 0, 0, 0.16);
  --border-brand: rgba(29, 185, 84, 0.35);
  --border-indigo: rgba(99, 102, 241, 0.3);

  /* Brand Accent — Emotiv Emerald */
  --brand: #1DB954;
  --brand-dark: #16A34A;
  --brand-light: #F0FDF4;
  --brand-dim: rgba(29, 185, 84, 0.10);
  --brand-glow: 0 0 0 3px rgba(29, 185, 84, 0.15);

  /* Secondary — Indigo (data, states) */
  --indigo: #6366F1;
  --indigo-dark: #4F46E5;
  --indigo-light: #EEF2FF;
  --indigo-dim: rgba(99, 102, 241, 0.10);

  /* Semantic */
  --danger: #E5473D;
  --danger-light: #FEF2F2;
  --danger-dim: rgba(229, 71, 61, 0.10);
  --danger-glow: 0 0 0 3px rgba(229, 71, 61, 0.15);

  --warning: #D97706;
  --warning-light: #FFFBEB;
  --warning-dim: rgba(217, 119, 6, 0.10);

  --success: var(--brand);
  --success-light: var(--brand-light);
  --success-dim: var(--brand-dim);

  /* Text */
  --text-primary: #0F1117;
  --text-secondary: #4B5563;
  --text-tertiary: #9CA3AF;
  --text-disabled: #D1D5DB;
  --text-on-brand: #FFFFFF;
  --text-on-indigo: #FFFFFF;

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --detail-w: 360px;

  /* Radius */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 9999px;

  /* Elevation (shadows) */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.10), 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-modal: 0 32px 80px rgba(0, 0, 0, 0.14), 0 4px 16px rgba(0, 0, 0, 0.08);

  /* Transitions */
  --t-fast: 100ms ease;
  --t-base: 200ms ease;
  --t-spring: 460ms cubic-bezier(0.16, 1, 0.3, 1);
  --t-slow: 600ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Z-index */
  --z-sidebar: 100;
  --z-topbar: 200;
  --z-panel: 300;
  --z-modal: 400;
  --z-toast: 500;
}

/* ── 2. Reset & Base ──────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-optical-sizing: auto;
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

input,
select,
textarea {
  font-family: inherit;
}

ul,
ol {
  list-style: none;
}

img {
  max-width: 100%;
  display: block;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--r-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* ── 3. Typography ────────────────────────────────────────── */
.font-mono {
  font-family: 'DM Mono', 'Fira Code', monospace;
}

.text-xs {
  font-size: 11px;
}

.text-sm {
  font-size: 12px;
}

.text-base {
  font-size: 14px;
}

.text-lg {
  font-size: 16px;
}

.text-xl {
  font-size: 18px;
}

.text-2xl {
  font-size: 22px;
}

.text-3xl {
  font-size: 28px;
}

.font-medium {
  font-weight: 500;
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

.text-muted {
  color: var(--text-secondary);
}

.text-dim {
  color: var(--text-tertiary);
}

.text-brand {
  color: var(--brand);
}

.text-indigo {
  color: var(--indigo);
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 4. App Shell ─────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: var(--z-sidebar);
  overflow: hidden;
  transition: transform var(--t-spring);
  box-shadow: var(--shadow-sm);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.sidebar-logo img {
  height: 24px;
  width: auto;
  object-fit: contain;
}

.sidebar-logo-divider {
  width: 1px;
  height: 16px;
  background: var(--border-medium);
}

.sidebar-logo-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 12px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--r-md);
  transition: background var(--t-fast), color var(--t-fast);
  user-select: none;
  position: relative;
  margin-bottom: 1px;
}

.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 600;
}

.nav-item.active .nav-icon {
  filter: none;
}

.nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: var(--r-full);
  min-width: 18px;
  text-align: center;
}

.nav-badge.warning {
  background: var(--warning);
  color: #fff;
}

.sidebar-footer {
  border-top: 1px solid var(--border-light);
  padding: 10px 8px;
  flex-shrink: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  padding: 7px 8px;
  border-radius: var(--r-md);
  transition: background var(--t-fast);
}

.user-chip:hover {
  background: var(--bg-elevated);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--brand), var(--indigo));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-role {
  font-size: 11px;
  color: var(--brand);
  font-weight: 500;
  margin-top: 0px;
}

/* ── Topbar ───────────────────────────────────────────────── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

#topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: var(--z-topbar);
}

.topbar-hamburger {
  display: none;
  background: none;
  color: var(--text-tertiary);
  font-size: 18px;
  padding: 5px;
  border-radius: var(--r-sm);
  transition: color var(--t-fast);
}

.topbar-hamburger:hover {
  color: var(--text-primary);
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--r-full);
  padding: 7px 14px;
  transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-base);
  max-width: 260px;
  width: 100%;
}

.search-bar:focus-within {
  background: var(--bg-surface);
  border-color: var(--brand);
  box-shadow: var(--brand-glow);
}

.search-bar span {
  color: var(--text-tertiary);
  font-size: 13px;
}

.search-bar input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 13px;
  width: 100%;
}

.search-bar input::placeholder {
  color: var(--text-tertiary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 15px;
  transition: all var(--t-fast);
  position: relative;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.icon-btn .notif-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
  animation: dot-pulse 2s infinite;
}

@keyframes dot-pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.3);
    opacity: 0.7;
  }
}

/* Page container */
#page {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

/* ── 5. Page Animations ───────────────────────────────────── */
.page-content {
  padding: 24px;
  animation: pageIn 0.35s var(--t-spring) backwards;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Staggered children */
.stagger-child>* {
  animation: staggerReveal 0.5s var(--t-spring) backwards;
}

.stagger-child>*:nth-child(1) {
  animation-delay: 0.04s;
}

.stagger-child>*:nth-child(2) {
  animation-delay: 0.08s;
}

.stagger-child>*:nth-child(3) {
  animation-delay: 0.12s;
}

.stagger-child>*:nth-child(4) {
  animation-delay: 0.16s;
}

@keyframes staggerReveal {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Shimmer (loading feel for numbers) */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

/* ── 6. Cards ─────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* ── 7. Stat Cards ────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-base), transform var(--t-base), border-color var(--t-base);
  cursor: default;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--border-medium);
}

/* Colored top strip via pseudo */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.stat-card.accent-orange::before {
  background: var(--brand);
}

.stat-card.accent-teal::before {
  background: var(--indigo);
}

.stat-card.accent-amber::before {
  background: var(--warning);
}

.stat-card.accent-red::before {
  background: var(--danger);
}

.stat-card-icon {
  font-size: 22px;
}

.stat-card-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-card-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
  font-feature-settings: "tnum";
}

.stat-card-sub {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ── 8. Badges & Status ───────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  font-family: 'DM Mono', monospace;
}

.badge-green {
  background: var(--brand-dim);
  color: var(--brand-dark);
  border: 1px solid rgba(29, 185, 84, 0.2);
}

.badge-teal {
  background: var(--brand-dim);
  color: var(--brand-dark);
  border: 1px solid rgba(29, 185, 84, 0.2);
}

.badge-blue {
  background: var(--indigo-dim);
  color: var(--indigo-dark);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.badge-red {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(229, 71, 61, 0.2);
}

.badge-amber {
  background: var(--warning-dim);
  color: var(--warning);
  border: 1px solid rgba(217, 119, 6, 0.2);
}

.badge-purple {
  background: rgba(139, 92, 246, 0.1);
  color: #7C3AED;
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.badge-gray {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

.badge-orange {
  background: var(--brand-dim);
  color: var(--brand-dark);
  border: 1px solid rgba(29, 185, 84, 0.2);
}

.badge-pulse {
  animation: badgePulse 2s infinite;
}

@keyframes badgePulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(229, 71, 61, 0.3);
  }

  50% {
    box-shadow: 0 0 0 5px rgba(229, 71, 61, 0);
  }
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-green {
  background: var(--brand);
}

.dot-amber {
  background: var(--warning);
}

.dot-red {
  background: var(--danger);
  animation: dot-pulse 1.8s infinite;
}

.dot-gray {
  background: var(--border-strong);
}

.dot-purple {
  background: var(--indigo);
}

/* ── 9. Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--t-fast);
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

/* Subtle ripple on click */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.2);
  opacity: 0;
  transition: opacity var(--t-fast);
  border-radius: inherit;
}

.btn:active::after {
  opacity: 1;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand-dark);
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-dark);
  box-shadow: var(--brand-glow);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: var(--danger-glow);
}

.btn-success {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand-dark);
}

.btn-success:hover:not(:disabled) {
  background: var(--brand-dark);
  box-shadow: var(--brand-glow);
}

.btn-purple {
  background: var(--indigo);
  color: #fff;
  border-color: var(--indigo-dark);
}

.btn-purple:hover:not(:disabled) {
  background: var(--indigo-dark);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 14px;
  min-height: 48px;
}

.btn-block {
  width: 100%;
}

/* ── 10. Forms ────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-md);
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  width: 100%;
}

.form-input:focus {
  border-color: var(--brand);
  box-shadow: var(--brand-glow);
}

.form-input::placeholder {
  color: var(--text-tertiary);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%239CA3AF' d='M5 7L0 2h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
  background-color: var(--bg-surface);
}

/* Toggle */
.toggle {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-medium);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background var(--t-base);
  border: 1px solid var(--border-medium);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--t-base);
  box-shadow: var(--shadow-xs);
}

.toggle input:checked+.toggle-slider {
  background: var(--brand);
  border-color: var(--brand);
}

.toggle input:checked+.toggle-slider::before {
  transform: translate(16px, -50%);
}

/* ── 11. Table ────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--bg-elevated);
}

th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-light);
}

td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

tbody tr {
  transition: background var(--t-fast);
  cursor: pointer;
}

tbody tr:hover {
  background: var(--bg-elevated);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ── 12. Section Header ───────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ── 13. Alert Items ──────────────────────────────────────── */
.alert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-left: 3px solid;
  border-radius: var(--r-md);
  margin-bottom: 7px;
  transition: background var(--t-fast), box-shadow var(--t-fast);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
}

.alert-item:hover {
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

.alert-item.critical {
  border-left-color: var(--danger);
}

.alert-item.warning {
  border-left-color: var(--warning);
}

.alert-item.info {
  border-left-color: var(--brand);
}

.alert-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-size: 13px;
  font-weight: 600;
}

.alert-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.alert-time {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* ── 14. Detail Panel ─────────────────────────────────────── */
#detail-panel {
  width: var(--detail-w);
  height: auto;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform var(--t-spring);
  z-index: 1000;
  position: fixed;
  right: 0;
  top: var(--topbar-h);
  bottom: 0;
  box-shadow: var(--shadow-lg);
}

#detail-panel.open {
  transform: translateX(0);
}

.detail-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: flex-start;
  gap: 11px;
  background: var(--bg-elevated);
}

.detail-close-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  color: var(--text-tertiary);
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
  transition: all var(--t-fast);
}

.detail-close-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.detail-vehicle-emoji {
  font-size: 26px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border-radius: var(--r-md);
  border: 1px solid var(--border-medium);
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.detail-vehicle-info {
  flex: 1;
  overflow: hidden;
}

.detail-vehicle-plate {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.detail-vehicle-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.detail-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.detail-tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--t-fast), border-color var(--t-fast);
}

.detail-tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.detail-tab:hover:not(.active) {
  color: var(--text-secondary);
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 8px;
}

/* Telemetry */
.telemetry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.telem-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  padding: 10px 12px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.telem-card:hover {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-dim);
}

.telem-label {
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.telem-value {
  font-family: 'DM Mono', monospace;
  font-size: 22px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.25;
  margin-top: 3px;
}

.telem-unit {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
}

/* SOC bar */
.soc-bar-wrap {
  margin-top: 5px;
}

.soc-bar-track {
  background: var(--border-light);
  border-radius: var(--r-full);
  height: 4px;
  overflow: hidden;
}

.soc-bar-fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width 0.6s var(--t-spring);
}

.soc-high {
  background: var(--brand);
}

.soc-mid {
  background: var(--warning);
}

.soc-low {
  background: var(--danger);
}

/* Compliance */
.compliance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.compliance-row:last-child {
  border-bottom: none;
}

.compliance-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.compliance-date {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 500;
}

.enforce-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── 15. Tabs ─────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  padding: 3px;
  border: 1px solid var(--border-light);
  margin-bottom: 16px;
}

.tab-btn {
  flex: 1;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 600;
  background: none;
  color: var(--text-tertiary);
  transition: all var(--t-fast);
  border: 1px solid transparent;
}

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
  border-color: var(--border-light);
}

.tab-btn:hover:not(.active) {
  color: var(--text-secondary);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: pageIn 0.2s ease;
}

/* ── 16. Modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 23, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
  padding: 16px;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-xl);
  padding: 24px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-modal);
  transform: scale(0.95) translateY(10px);
  transition: transform var(--t-spring);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
}

/* ── 17. Toasts ───────────────────────────────────────────── */
#toast-area {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 270px;
  max-width: 340px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.4s var(--t-spring), toastOut 0.3s ease 2.7s forwards;
  pointer-events: all;
}

.toast.success {
  border-left: 3px solid var(--brand);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

.toast.warning {
  border-left: 3px solid var(--warning);
}

.toast.info {
  border-left: 3px solid var(--indigo);
}

.toast-icon {
  font-size: 15px;
  flex-shrink: 0;
}

.toast-msg {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(24px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
    transform: translateX(24px);
  }
}

/* ── 18. Leaflet / Map ────────────────────────────────────── */
#map-container {
  width: 100%;
  height: 100%;
}

.leaflet-container {
  background: var(--bg-app) !important;
}

.leaflet-control-attribution {
  display: none !important;
}

.leaflet-control-zoom a {
  background: var(--bg-surface) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-light) !important;
  box-shadow: var(--shadow-sm) !important;
  font-weight: 600 !important;
}

.leaflet-control-zoom a:hover {
  color: var(--brand) !important;
}

.emoji-marker {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  transition: transform 0.2s var(--t-spring), box-shadow 0.2s ease;
  box-shadow: var(--shadow-md);
  cursor: pointer;
}

.emoji-marker:hover {
  transform: scale(1.18);
  box-shadow: var(--shadow-lg);
}

.emoji-marker.status-available {
  background: var(--brand-light);
  border-color: var(--brand);
}

.emoji-marker.status-on_rental {
  background: var(--indigo-light);
  border-color: var(--indigo);
}

.emoji-marker.status-restricted {
  background: var(--warning-light);
  border-color: var(--warning);
}

.emoji-marker.status-killed {
  background: var(--danger-light);
  border-color: var(--danger);
}

.emoji-marker.status-maintenance {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

/* Map controls */
.map-controls {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: all;
}

.map-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-full);
  padding: 8px 16px;
  box-shadow: var(--shadow-md);
  width: 270px;
  transition: border-color var(--t-base), box-shadow var(--t-base);
}

.map-search:focus-within {
  border-color: var(--brand);
  box-shadow: var(--brand-glow), var(--shadow-md);
}

.map-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 13px;
  width: 100%;
}

.map-search input::placeholder {
  color: var(--text-tertiary);
}

.map-filter-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: var(--r-md);
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: var(--shadow-sm);
  transition: all var(--t-fast);
  cursor: pointer;
}

.map-filter-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* Filter Drawer */
.filter-drawer {
  position: absolute;
  left: -300px;
  top: 0;
  bottom: 0;
  width: 270px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  z-index: 999;
  transition: left var(--t-spring);
  padding: 76px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.filter-drawer.open {
  left: 0;
}

.filter-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  display: block;
  margin-bottom: 7px;
}

.filter-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.filter-chip {
  padding: 4px 10px;
  border-radius: var(--r-full);
  border: 1px solid var(--border-medium);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
}

.filter-chip.active {
  background: var(--brand-light);
  border-color: var(--brand);
  color: var(--brand-dark);
  font-weight: 600;
}

.filter-chip:hover:not(.active) {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* ── 19. Replay Controls ──────────────────────────────────── */
.replay-controls {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.replay-playback {
  display: flex;
  align-items: center;
  gap: 9px;
}

.replay-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--r-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: all var(--t-fast);
}

.replay-btn:hover,
.replay-btn.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  box-shadow: var(--brand-glow);
}

.replay-scrub {
  flex: 1;
  accent-color: var(--brand);
  cursor: pointer;
}

.replay-timestamp {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--indigo);
  white-space: nowrap;
  min-width: 44px;
  text-align: center;
}

.replay-speed-btns {
  display: flex;
  gap: 4px;
}

.speed-btn {
  padding: 3px 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-medium);
  background: var(--bg-surface);
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
}

.speed-btn.active {
  background: var(--brand-light);
  border-color: var(--brand);
  color: var(--brand-dark);
}

.audit-icon {
  font-size: 16px;
  cursor: pointer;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));
}

/* ── 20. Login Screen ─────────────────────────────────────── */
#login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #F0FDF8 0%, #F2F4F7 50%, #EEF2FF 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#login-screen.hidden {
  display: none;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-xl);
  padding: 36px;
  box-shadow: var(--shadow-xl);
  animation: loginReveal 0.5s var(--t-spring);
}

@keyframes loginReveal {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(18px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.login-logo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 28px;
}

.login-logo {
  height: 30px;
  object-fit: contain;
}

.login-logo-sep {
  width: 1px;
  height: 22px;
  background: var(--border-light);
}

.login-title {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 26px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.login-footer {
  margin-top: 26px;
  text-align: center;
  font-size: 11px;
  color: var(--text-tertiary);
}

.login-footer img {
  height: 14px;
  opacity: 0.5;
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
}

/* ── 21. Notifications ────────────────────────────────────── */
.notif-dropdown {
  position: fixed;
  top: calc(var(--topbar-h) + 6px);
  right: 14px;
  width: 310px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-modal);
  overflow: hidden;
  display: none;
}

.notif-dropdown.open {
  display: block;
  animation: pageIn 0.2s ease;
}

.notif-header {
  padding: 12px 15px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-elevated);
}

.notif-list {
  max-height: 300px;
  overflow-y: auto;
}

.notif-item {
  padding: 11px 15px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--t-fast);
}

.notif-item:hover {
  background: var(--bg-elevated);
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item-title {
  font-size: 12px;
  font-weight: 600;
}

.notif-item-body {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.notif-item-time {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 3px;
}

.notif-item.unread {
  background: var(--brand-light);
}

.notif-item.unread:hover {
  background: rgba(29, 185, 84, 0.08);
}

/* ── 22. Analytics ────────────────────────────────────────── */
.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.chart-label {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bar-name {
  font-size: 12px;
  color: var(--text-secondary);
  width: 110px;
  flex-shrink: 0;
}

.bar-track {
  flex: 1;
  background: var(--bg-elevated);
  border-radius: var(--r-full);
  height: 6px;
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.bar-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand), var(--indigo));
  transition: width 0.9s var(--t-spring);
}

.bar-pct {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  width: 34px;
  text-align: right;
}

.donut-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── 23. Mobile ───────────────────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 23, 0.35);
  z-index: calc(var(--z-sidebar) - 1);
  backdrop-filter: blur(2px);
}

#sidebar-overlay.open {
  display: block;
}

@media (max-width: 1024px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  :root {
    --detail-w: 320px;
  }
}

@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #sidebar-overlay.open {
    display: block;
  }

  .topbar-hamburger {
    display: flex;
  }

  .search-bar {
    display: none;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .stat-card-value {
    font-size: 26px;
  }

  .page-content {
    padding: 12px;
  }

  #detail-panel {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    height: 75vh;
    border-left: none;
    border-top: 1px solid var(--border-light);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    transform: translateY(100%);
    z-index: 1000;
  }

  #detail-panel.open {
    transform: translateY(0);
  }

  .btn-lg,
  .enforce-row .btn {
    min-height: 48px;
    font-size: 14px;
  }

  #toast-area {
    left: 12px;
    right: 12px;
  }

  .toast {
    min-width: unset;
    max-width: 100%;
  }

  .filter-drawer {
    width: 100%;
    left: -100%;
  }
}

/* ── 24. Utilities ────────────────────────────────────────── */
.flex {
  display: flex;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.gap-4 {
  gap: 16px;
}

.w-full {
  width: 100%;
}

.mt-2 {
  margin-top: 8px;
}

.mt-4 {
  margin-top: 16px;
}

.mt-6 {
  margin-top: 24px;
}

.mb-2 {
  margin-bottom: 8px;
}

.mb-4 {
  margin-bottom: 16px;
}

.hidden {
  display: none !important;
}

.grid {
  display: grid;
}

.grid-2 {
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}