/* =========================================================
   SAFEDRIVE AI - DRIVER DROWSINESS DETECTION HUD
   Design System & Styling
   ========================================================= */

:root {
  /* Color Palette */
  --bg-main: #060913;
  --bg-surface: rgba(13, 20, 38, 0.75);
  --bg-surface-elevated: rgba(20, 31, 58, 0.85);
  --bg-card-subtle: rgba(255, 255, 255, 0.03);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(0, 242, 254, 0.4);
  --border-danger: rgba(255, 0, 85, 0.6);

  --accent-cyan: #00f2fe;
  --accent-cyan-glow: rgba(0, 242, 254, 0.35);
  --accent-blue: #3b82f6;
  --accent-safe: #10b981;
  --accent-safe-glow: rgba(16, 185, 129, 0.35);
  --accent-warn: #f59e0b;
  --accent-danger: #ff0055;
  --accent-danger-bright: #ff3366;
  --accent-danger-glow: rgba(255, 0, 85, 0.5);

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-hud: 'Orbitron', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-hud: 0 12px 40px -10px rgba(0, 0, 0, 0.6);
  --shadow-neon: 0 0 25px var(--accent-cyan-glow);
  --shadow-danger: 0 0 35px var(--accent-danger-glow);
}

/* Light Theme Variables */
body.theme-light {
  --bg-main: #e2e8f0;
  --bg-surface: rgba(255, 255, 255, 0.85);
  --bg-surface-elevated: rgba(248, 250, 252, 0.95);
  --bg-card-subtle: rgba(0, 0, 0, 0.03);
  --border-subtle: rgba(0, 0, 0, 0.1);
  --border-active: rgba(0, 150, 255, 0.4);
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
}

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

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(0, 242, 254, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(255, 0, 85, 0.05) 0%, transparent 40%);
  background-attachment: fixed;
}

/* Typography Utilities */
.mono-font {
  font-family: var(--font-mono);
}

.text-safe { color: var(--accent-safe) !important; }
.text-danger { color: var(--accent-danger-bright) !important; }
.text-cyan { color: var(--accent-cyan) !important; }
.text-warn { color: var(--accent-warn) !important; }

/* Danger Screen Strobe Flash */
.danger-strobe {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0;
  background: radial-gradient(circle, rgba(255, 0, 85, 0.35) 0%, rgba(255, 0, 85, 0.7) 100%);
  box-shadow: inset 0 0 100px rgba(255, 0, 85, 0.9);
  transition: opacity 0.15s ease-in-out;
}

.danger-strobe.active {
  animation: strobePulse 0.4s infinite alternate;
}

@keyframes strobePulse {
  0% { opacity: 0.3; }
  100% { opacity: 0.85; }
}

/* =========================================================
   TOP NAVIGATION / HUD BAR
   ========================================================= */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(6, 9, 19, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 1.5rem;
}

.nav-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-icon-pulse {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.2), rgba(0, 102, 255, 0.3));
  border: 1px solid var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
  font-size: 1.25rem;
  box-shadow: 0 0 15px var(--accent-cyan-glow);
}

.pulse-ring {
  position: absolute;
  inset: -4px;
  border-radius: calc(var(--radius-md) + 4px);
  border: 1px solid var(--accent-cyan);
  animation: ringPulse 2.5s infinite;
  opacity: 0;
}

@keyframes ringPulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  100% { transform: scale(1.3); opacity: 0; }
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-hud);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-badge {
  font-size: 0.65rem;
  background: var(--accent-cyan);
  color: #050914;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 800;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* Nav Telemetry Pills */
.nav-telemetry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.telemetry-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-warn);
  box-shadow: 0 0 8px var(--accent-warn);
  transition: all 0.3s ease;
}

.status-indicator.ready {
  background-color: var(--accent-safe);
  box-shadow: 0 0 10px var(--accent-safe);
}

.status-indicator.active {
  background-color: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan);
  animation: blinkFast 1s infinite;
}

.status-indicator.danger {
  background-color: var(--accent-danger);
  box-shadow: 0 0 12px var(--accent-danger);
  animation: blinkFast 0.3s infinite;
}

@keyframes blinkFast {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.pill-label {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.7rem;
}

.pill-value {
  font-weight: 700;
  color: var(--text-main);
}

.pill-icon {
  color: var(--accent-cyan);
}

.pill-icon-warn {
  color: var(--accent-danger);
}

.alert-pill {
  border-color: rgba(255, 0, 85, 0.3);
}

/* Nav Action Buttons & Language Selector */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lang-selector-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.lang-icon {
  position: absolute;
  left: 10px;
  color: var(--accent-cyan);
  font-size: 0.85rem;
  pointer-events: none;
}

.lang-select {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.45rem 0.85rem 0.45rem 2rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-main);
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-select:hover, .lang-select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan-glow);
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--bg-surface-elevated);
  color: var(--accent-cyan);
  border-color: var(--border-active);
  transform: translateY(-1px);
}

.btn-icon.active {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px var(--accent-cyan-glow);
}

/* =========================================================
   MAIN LAYOUT & GRID SYSTEM
   ========================================================= */
.main-layout {
  max-width: 1440px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.grid-container {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* Cards & Glassmorphism */
.hud-card {
  background: var(--bg-surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hud);
  overflow: hidden;
  transition: border-color 0.3s ease;
}

.hud-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  letter-spacing: 0.5px;
}

.card-title i {
  color: var(--accent-cyan);
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Live Badge */
.hud-live-tag {
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(0, 242, 254, 0.12);
  border: 1px solid rgba(0, 242, 254, 0.3);
  color: var(--accent-cyan);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.5px;
}

.blink-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
  animation: blinkFast 1s infinite;
}

.hud-resolution, .hud-stat {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.hud-stat strong {
  color: var(--accent-cyan);
}

/* =========================================================
   VISION WEBCAM VIEWPORT & HUD EFFECTS
   ========================================================= */
.webcam-viewport {
  position: relative;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #04060c;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8);
}

.webcam-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.webcam-container canvas, 
.webcam-container video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  display: block;
}

/* Mirror Mode */
.webcam-container.mirrored canvas,
.webcam-container.mirrored video {
  transform: scaleX(-1);
}

/* HUD Overlay Scanner Brackets */
.hud-scanner-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.hud-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 2px solid var(--accent-cyan);
  opacity: 0.7;
}

.top-left { top: 12px; left: 12px; border-right: 0; border-bottom: 0; }
.top-right { top: 12px; right: 12px; border-left: 0; border-bottom: 0; }
.bottom-left { bottom: 12px; left: 12px; border-right: 0; border-top: 0; }
.bottom-right { bottom: 12px; right: 12px; border-left: 0; border-top: 0; }

.scanner-laser {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--accent-cyan) 50%, transparent 100%);
  box-shadow: 0 0 12px var(--accent-cyan);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.scanner-laser.active {
  opacity: 0.8;
  animation: scanLaser 3s infinite linear;
}

@keyframes scanLaser {
  0% { top: 0%; }
  50% { top: 100%; }
  100% { top: 0%; }
}

.hud-center-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 1px dashed rgba(0, 242, 254, 0.25);
  opacity: 0.5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reticle-circle {
  width: 70px;
  height: 70px;
  border: 1px solid rgba(0, 242, 254, 0.4);
  border-radius: 50%;
}

.reticle-line {
  position: absolute;
  background: rgba(0, 242, 254, 0.3);
}

.h-line { width: 100%; height: 1px; }
.v-line { height: 100%; width: 1px; }

/* Drowsy Danger Alert Banner */
.drowsy-banner {
  position: absolute;
  inset: 0;
  background: rgba(255, 0, 85, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.drowsy-banner.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
  animation: alertBorderShake 0.4s infinite;
}

@keyframes alertBorderShake {
  0%, 100% { transform: scale(1) translate(0, 0); }
  25% { transform: scale(1) translate(-2px, 2px); }
  75% { transform: scale(1) translate(2px, -2px); }
}

.drowsy-banner-content {
  text-align: center;
  padding: 1.5rem;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.alert-big-icon {
  font-size: 3.5rem;
  color: #fff;
  animation: pulseIcon 0.8s infinite alternate;
  filter: drop-shadow(0 0 15px #fff);
}

@keyframes pulseIcon {
  0% { transform: scale(0.9); }
  100% { transform: scale(1.15); }
}

.alert-title {
  font-family: var(--font-hud);
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.alert-desc {
  font-size: 0.95rem;
  font-weight: 500;
  opacity: 0.95;
}

/* Standby Overlay */
.standby-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 13, 27, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
  transition: opacity 0.3s ease;
}

.standby-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.standby-content {
  text-align: center;
  max-width: 360px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.standby-icon-box {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0, 242, 254, 0.08);
  border: 1px solid rgba(0, 242, 254, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: var(--accent-cyan);
  margin-bottom: 0.5rem;
}

.standby-content h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.standby-content p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Bottom Vision Status Strip */
.vision-status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg-surface-elevated);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

.status-badge.status-normal {
  color: var(--accent-safe);
}

.status-badge.status-drowsy {
  color: var(--accent-danger-bright);
}

.status-badge.status-standby {
  color: var(--text-muted);
}

.vigilance-meter {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.meter-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.meter-track {
  width: 120px;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-danger) 0%, var(--accent-warn) 40%, var(--accent-safe) 100%);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.meter-value {
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 42px;
}

/* Camera Action Controls Bar */
.hud-controls-bar {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.01);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.camera-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.select-icon {
  position: absolute;
  left: 10px;
  color: var(--text-dim);
  font-size: 0.8rem;
  pointer-events: none;
}

.hud-select {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.5rem 1rem 0.5rem 2rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: var(--font-main);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.hud-select:focus {
  border-color: var(--accent-cyan);
}

.hud-select-full {
  width: 100%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: var(--font-main);
  outline: none;
}

.hud-select-full:focus {
  border-color: var(--accent-cyan);
}

/* =========================================================
   BUTTONS & FORM CONTROLS
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-main);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #00f2fe 0%, #0077ff 100%);
  color: #050914;
  box-shadow: 0 4px 15px rgba(0, 242, 254, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 242, 254, 0.4);
}

.btn-glow {
  animation: buttonGlow 2s infinite alternate;
}

@keyframes buttonGlow {
  0% { box-shadow: 0 0 10px rgba(0, 242, 254, 0.3); }
  100% { box-shadow: 0 0 25px rgba(0, 242, 254, 0.6); }
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-active);
  color: var(--accent-cyan);
}

.btn-warning-glow {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #050914;
  font-weight: 700;
}

.btn-warning-glow:hover {
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
}

.btn-danger-sm {
  background: rgba(255, 0, 85, 0.15);
  border: 1px solid rgba(255, 0, 85, 0.3);
  color: var(--accent-danger-bright);
}

.btn-danger-sm:hover {
  background: rgba(255, 0, 85, 0.3);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.78rem;
}

.btn-full {
  width: 100%;
}

.btn-icon-small {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-icon-small:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* =========================================================
   SIDEBAR TABS & REAL-TIME TELEMETRY
   ========================================================= */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.01);
}

.tab-btn {
  flex: 1;
  padding: 0.85rem 0.5rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.04);
}

.tab-pane {
  display: none;
  padding: 1.25rem;
}

.tab-pane.active {
  display: block;
}

.section-title {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.section-title i {
  color: var(--accent-cyan);
}

.section-subtitle {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 1.25rem;
}

.section-subtitle code {
  color: var(--accent-cyan);
  background: rgba(0, 242, 254, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

/* Class Probability Cards */
.class-prob-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 0.85rem;
  transition: all 0.2s ease;
}

.prob-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.prob-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.prob-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.prob-indicator-dot.safe { background: var(--accent-safe); box-shadow: 0 0 8px var(--accent-safe); }
.prob-indicator-dot.danger { background: var(--accent-danger); box-shadow: 0 0 8px var(--accent-danger); }

.prob-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.prob-percent {
  font-size: 1rem;
  font-weight: 700;
}

.prob-bar-track {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.prob-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.15s ease-out;
}

.safe-bar {
  background: linear-gradient(90deg, #059669 0%, #10b981 100%);
  box-shadow: 0 0 10px var(--accent-safe-glow);
}

.danger-bar {
  background: linear-gradient(90deg, #e11d48 0%, #ff0055 100%);
  box-shadow: 0 0 12px var(--accent-danger-glow);
}

/* Continuous Drowsy Progress Tracker */
.stat-box-drowsy-counter {
  background: rgba(255, 0, 85, 0.06);
  border: 1px dashed rgba(255, 0, 85, 0.3);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin: 1.25rem 0;
}

.drowsy-timer-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.timer-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.timer-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-danger-bright);
}

.timer-progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.timer-progress-fill {
  height: 100%;
  background: var(--accent-danger);
  box-shadow: 0 0 8px var(--accent-danger);
  transition: width 0.1s linear;
}

.timer-hint {
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* Summary Metrics Grid */
.summary-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.metric-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
}

.m-title {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.m-val {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 2px 0;
}

.m-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* Driver Rest Fatigue Card */
.fatigue-rest-box {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(0, 242, 254, 0.05) 100%);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.fatigue-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.2);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.fatigue-details {
  flex: 1;
}

.fatigue-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--accent-cyan);
}

.fatigue-timer {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.fatigue-desc {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* =========================================================
   FORM ELEMENTS & SETTINGS TABS
   ========================================================= */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
}

.field-desc {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.switch-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Toggle Switch Custom */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: 0.25s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.25s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-cyan);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Range Sliders */
.range-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.range-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.hud-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
  margin: 0.4rem 0;
}

.hud-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-cyan-glow);
  transition: transform 0.1s;
}

.hud-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Model URL Readonly Box */
.model-url-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hud-input {
  flex: 1;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  outline: none;
}

/* =========================================================
   INCIDENT HISTORY LOG & SNAPSHOT GALLERY
   ========================================================= */
.incident-history-card {
  margin-top: 0.5rem;
}

.badge-count {
  font-size: 0.75rem;
  background: rgba(255, 0, 85, 0.12);
  color: var(--accent-danger-bright);
  border: 1px solid rgba(255, 0, 85, 0.3);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.incident-log-content {
  padding: 1.25rem;
  min-height: 180px;
}

.incident-empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.incident-empty-state.hidden {
  display: none;
}

.empty-icon {
  font-size: 2.5rem;
  color: var(--accent-safe);
  margin-bottom: 0.25rem;
  opacity: 0.7;
}

.incident-empty-state h4 {
  color: var(--text-main);
  font-size: 1.05rem;
}

.incident-empty-state p {
  font-size: 0.85rem;
}

/* Incident Cards Grid */
.incident-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.incident-item {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--accent-danger);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  gap: 0.85rem;
  align-items: center;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.incident-item:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 0, 85, 0.4);
}

.incident-thumb {
  width: 70px;
  height: 52px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: #000;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  transition: transform 0.2s ease;
}

.incident-thumb:hover {
  transform: scale(1.05);
}

.incident-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.incident-time {
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
}

.incident-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.incident-conf {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-danger-bright);
}

/* =========================================================
   SAFETY GUIDE & FATIGUE TIPS SECTION
   ========================================================= */
.safety-guide-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.guide-header {
  text-align: left;
}

.guide-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.guide-title i {
  color: var(--accent-danger-bright);
}

.guide-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.guide-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.guide-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: transform 0.2s ease;
}

.guide-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.15);
}

.guide-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.icon-danger { background: rgba(255, 0, 85, 0.15); color: var(--accent-danger-bright); }
.icon-warning { background: rgba(245, 158, 11, 0.15); color: var(--accent-warn); }
.icon-success { background: rgba(16, 185, 129, 0.15); color: var(--accent-safe); }
.icon-cyan { background: rgba(0, 242, 254, 0.15); color: var(--accent-cyan); }

.guide-card h4 {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.guide-card p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.guide-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.guide-list li {
  font-size: 0.8rem;
  color: var(--text-muted);
  position: relative;
  padding-left: 1.15rem;
  line-height: 1.4;
}

.guide-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--accent-cyan);
  font-size: 1.1rem;
  line-height: 1;
}

.emergency-contacts {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.contact-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface-elevated);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

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

.contact-num {
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

/* =========================================================
   IMAGE ZOOM MODAL
   ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-title i {
  color: var(--accent-cyan);
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.btn-close-modal:hover {
  color: #fff;
}

.modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.modal-body img {
  width: 100%;
  max-height: 380px;
  object-fit: contain;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.modal-caption {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

/* =========================================================
   FOOTER
   ========================================================= */
.app-footer {
  border-top: 1px solid var(--border-subtle);
  background: rgba(6, 9, 19, 0.8);
  padding: 1.5rem;
  text-align: center;
  margin-top: 2rem;
}

.footer-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.footer-brand {
  font-size: 0.85rem;
  color: var(--text-main);
}

.footer-note {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* =========================================================
   RESPONSIVE DESIGN
   ========================================================= */
@media (max-width: 1024px) {
  .grid-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .nav-container {
    flex-wrap: wrap;
  }
  .nav-telemetry {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }
  .hud-controls-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .controls-left, .controls-right {
    width: 100%;
    justify-content: space-between;
  }
  .btn {
    flex: 1;
  }
}
