/* ==========================================================================
   SAFEDRIVE AI - DRIVER DROWSINESS DETECTION SYSTEM
   Futuristic HUD & Driver Cockpit Design System
   ========================================================================== */

:root {
    /* Color Palette */
    --bg-base: #060911;
    --bg-card: rgba(13, 20, 36, 0.78);
    --bg-card-hover: rgba(19, 29, 52, 0.88);
    --bg-surface: #0b1120;
    --bg-elevated: #111a2e;
    
    /* Neon Accents */
    --cyan: #06b6d4;
    --cyan-glow: rgba(6, 182, 212, 0.35);
    --emerald: #10b981;
    --emerald-glow: rgba(16, 185, 129, 0.35);
    --amber: #f59e0b;
    --amber-glow: rgba(245, 158, 11, 0.4);
    --crimson: #ef4444;
    --crimson-glow: rgba(239, 68, 68, 0.45);
    --violet: #8b5cf6;

    /* Text Colors */
    --text-main: #f8fafc;
    --text-sub: #94a3b8;
    --text-muted: #64748b;
    
    /* Borders & Glows */
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-accent: rgba(6, 182, 212, 0.25);
    --border-emerald: rgba(16, 185, 129, 0.3);
    --border-crimson: rgba(239, 68, 68, 0.4);

    /* Fonts */
    --font-ui: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Transitions & Shadows */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.6), 0 0 1px 1px var(--border-glass);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
}

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

html, body {
    width: 100%;
    min-height: 100vh;
    font-family: var(--font-ui);
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Futuristic Cyber Grid Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(6, 182, 212, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(6, 182, 212, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

/* Background Radial Glow */
body::after {
    content: '';
    position: fixed;
    top: -20%;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 600px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.08) 0%, rgba(139, 92, 246, 0.03) 50%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* Red Alarm Strobe Overlay */
.alarm-strobe-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    box-shadow: inset 0 0 100px 30px rgba(239, 68, 68, 0.8);
    pointer-events: none;
    z-index: 999;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.alarm-strobe-overlay.active {
    animation: strobeFlash 0.6s infinite alternate;
}

@keyframes strobeFlash {
    0% { opacity: 0.15; box-shadow: inset 0 0 60px 10px rgba(239, 68, 68, 0.4); }
    100% { opacity: 0.9; box-shadow: inset 0 0 140px 50px rgba(239, 68, 68, 0.9); }
}

/* App Wrapper */
.app-wrapper {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 1.25rem 2rem;
    max-width: 1680px;
    margin: 0 auto;
    gap: 1.5rem;
}

/* ==========================================================================
   HEADER HUD
   ========================================================================== */
.hud-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}

.hud-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-radar {
    position: relative;
    width: 44px;
    height: 44px;
    background: rgba(6, 182, 212, 0.12);
    border: 1px solid var(--cyan);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px var(--cyan-glow);
}

.brand-icon {
    font-size: 1.25rem;
    color: var(--cyan);
}

.radar-ping {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    border: 1px solid var(--cyan);
    animation: radarPing 2.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes radarPing {
    75%, 100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

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

.brand-title {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-accent {
    color: var(--cyan);
    text-shadow: 0 0 12px var(--cyan-glow);
}

.brand-badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    background: rgba(6, 182, 212, 0.15);
    border: 1px solid var(--cyan);
    border-radius: var(--radius-full);
    color: var(--cyan);
    font-family: var(--font-mono);
    font-weight: 700;
}

.brand-subtitle {
    font-size: 0.72rem;
    color: var(--text-sub);
    letter-spacing: 1.5px;
    font-family: var(--font-mono);
}

/* Header Center */
.hud-header-center {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.system-status-pill {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 1rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--border-emerald);
    border-radius: var(--radius-full);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--emerald);
    transition: var(--transition-normal);
}

.system-status-pill.warning {
    background: rgba(245, 158, 11, 0.12);
    border-color: var(--amber);
    color: var(--amber);
}

.system-status-pill.danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--crimson);
    color: var(--crimson);
    box-shadow: 0 0 15px var(--crimson-glow);
    animation: pulseBorder 1s infinite alternate;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor;
    box-shadow: 0 0 8px currentColor;
}

.live-clock-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-full);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-sub);
}

/* Header Actions */
.hud-header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* Button Styles */
.btn-hud-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    font-size: 1rem;
}

.btn-hud-icon:hover {
    background: var(--bg-elevated);
    border-color: var(--cyan);
    color: var(--cyan);
    box-shadow: 0 0 12px var(--cyan-glow);
    transform: translateY(-1px);
}

.btn-hud-icon.active {
    background: rgba(6, 182, 212, 0.15);
    border-color: var(--cyan);
    color: var(--cyan);
}

.btn-hud-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.4rem;
    background: linear-gradient(135deg, #0284c7, #06b6d4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: 0 4px 15px var(--cyan-glow);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.btn-hud-primary:hover {
    background: linear-gradient(135deg, #0369a1, #0891b2);
    box-shadow: 0 6px 22px rgba(6, 182, 212, 0.6);
    transform: translateY(-2px);
}

.btn-hud-primary.btn-stop {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    box-shadow: 0 4px 15px var(--crimson-glow);
}

.btn-hud-primary.btn-stop:hover {
    background: linear-gradient(135deg, #b91c1c, #dc2626);
    box-shadow: 0 6px 22px rgba(239, 68, 68, 0.7);
}

.btn-hud-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-hud-secondary:hover:not(:disabled) {
    background: var(--bg-elevated);
    border-color: var(--cyan);
    color: var(--cyan);
}

.btn-hud-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-hud-small {
    padding: 0.35rem 0.7rem;
    font-size: 0.75rem;
    border-radius: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    color: var(--text-sub);
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-hud-small:hover {
    background: var(--bg-elevated);
    color: var(--text-main);
    border-color: var(--cyan);
}

.btn-hud-small.btn-danger:hover {
    border-color: var(--crimson);
    color: var(--crimson);
}

/* ==========================================================================
   MAIN DASHBOARD GRID LAYOUT
   ========================================================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* HUD Cards */
.hud-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    transition: var(--transition-fast);
}

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.75px;
    font-family: var(--font-mono);
}

.hud-tag {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 2px 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 4px;
    color: var(--text-sub);
}

.tag-model {
    background: rgba(139, 92, 246, 0.12);
    border-color: var(--violet);
    color: #c4b5fd;
}

.hud-badge {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 2px 8px;
    background: rgba(6, 182, 212, 0.12);
    border: 1px solid var(--cyan);
    border-radius: 4px;
    color: var(--cyan);
}

.pulse-dot {
    position: relative;
}

/* Left Column Grouping */
.hud-camera-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ==========================================================================
   WEBCAM VIEWPORT & HUD ELEMENTS
   ========================================================================== */
.webcam-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    min-height: 380px;
    background: #030712;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid rgba(6, 182, 212, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

#webcamVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transform: scaleX(-1); /* Default mirrored */
}

#webcamVideo.unmirrored {
    transform: scaleX(1);
}

#hudCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* Standby Overlay */
.standby-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.9) 0%, rgba(3, 7, 18, 0.98) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    gap: 1rem;
    z-index: 20;
    transition: var(--transition-normal);
}

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

.standby-graphic {
    position: relative;
    width: 80px;
    height: 80px;
    background: var(--bg-surface);
    border: 2px dashed rgba(6, 182, 212, 0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.standby-icon {
    font-size: 2rem;
    color: var(--text-sub);
}

.standby-scanner-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--cyan), transparent);
    box-shadow: 0 0 10px var(--cyan);
    animation: scannerSweep 2s linear infinite;
}

@keyframes scannerSweep {
    0% { top: 0; }
    100% { top: 100%; }
}

.standby-overlay h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-main);
}

.standby-overlay p {
    font-size: 0.88rem;
    color: var(--text-sub);
    max-width: 440px;
}

/* Model Loading Overlay */
.model-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(3, 7, 18, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    z-index: 25;
    padding: 2rem;
    text-align: center;
}

.model-loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(6, 182, 212, 0.15);
    border-top-color: var(--cyan);
    border-right-color: var(--violet);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-bar-track {
    width: 240px;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: 0.75rem;
}

.loading-bar-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--cyan), var(--violet));
    animation: loadingFill 1.5s ease-in-out infinite;
}

@keyframes loadingFill {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* HUD Corner Brackets */
.hud-bracket {
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: var(--cyan);
    border-style: solid;
    pointer-events: none;
    z-index: 12;
    filter: drop-shadow(0 0 5px var(--cyan-glow));
}

.hud-bracket.top-left {
    top: 12px;
    left: 12px;
    border-width: 2px 0 0 2px;
}

.hud-bracket.top-right {
    top: 12px;
    right: 12px;
    border-width: 2px 2px 0 0;
}

.hud-bracket.bottom-left {
    bottom: 12px;
    left: 12px;
    border-width: 0 0 2px 2px;
}

.hud-bracket.bottom-right {
    bottom: 12px;
    right: 12px;
    border-width: 0 2px 2px 0;
}

/* HUD Scan Beam */
.hud-scan-beam {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, transparent, rgba(6, 182, 212, 0.8), transparent);
    box-shadow: 0 0 15px var(--cyan);
    z-index: 11;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.webcam-viewport.active .hud-scan-beam {
    opacity: 0.7;
    animation: beamSweep 3s cubic-bezier(0.4, 0, 0.6, 1) infinite alternate;
}

@keyframes beamSweep {
    0% { top: 5%; }
    100% { top: 95%; }
}

/* Target Reticle */
.hud-target-reticle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 220px;
    height: 220px;
    border: 1px dashed rgba(6, 182, 212, 0.4);
    border-radius: 12px;
    pointer-events: none;
    z-index: 12;
    display: none;
}

.webcam-viewport.active .hud-target-reticle {
    display: block;
}

.reticle-box {
    position: relative;
    width: 100%;
    height: 100%;
}

.reticle-label {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(11, 17, 32, 0.85);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-family: var(--font-mono);
    color: var(--cyan);
    border: 1px solid rgba(6, 182, 212, 0.3);
    white-space: nowrap;
}

/* Live Status Banner Overlay */
.hud-status-banner {
    position: absolute;
    bottom: 14px;
    left: 14px;
    right: 14px;
    padding: 0.75rem 1.25rem;
    border-radius: 10px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 15;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border: 1px solid transparent;
    transition: var(--transition-normal);
}

.status-banner-content {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.status-banner-icon {
    font-size: 1.5rem;
}

.status-main-text {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    font-family: var(--font-mono);
}

.status-sub-text {
    font-size: 0.75rem;
    color: var(--text-sub);
}

/* Banner States */
.hud-status-banner.status-normal {
    background: rgba(11, 17, 32, 0.85);
    border-color: var(--border-glass);
    color: var(--text-sub);
}

.hud-status-banner.status-awake {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--emerald);
    color: var(--emerald);
    box-shadow: 0 0 20px var(--emerald-glow);
}

.hud-status-banner.status-warning {
    background: rgba(245, 158, 11, 0.25);
    border-color: var(--amber);
    color: var(--amber);
    box-shadow: 0 0 25px var(--amber-glow);
}

.hud-status-banner.status-danger {
    background: rgba(239, 68, 68, 0.35);
    border-color: var(--crimson);
    color: #ffffff;
    box-shadow: 0 0 35px var(--crimson-glow);
    animation: dangerPulse 0.5s infinite alternate;
}

@keyframes dangerPulse {
    0% { transform: scale(1); filter: brightness(1); }
    100% { transform: scale(1.015); filter: brightness(1.3); }
}

/* Drowsy Countdown Progress */
.drowsy-countdown-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    overflow: hidden;
    display: none;
}

.drowsy-countdown-bar {
    width: 0%;
    height: 100%;
    background: var(--amber);
    transition: width 0.1s linear;
}

.hud-status-banner.status-warning .drowsy-countdown-track,
.hud-status-banner.status-danger .drowsy-countdown-track {
    display: block;
}

.hud-status-banner.status-danger .drowsy-countdown-bar {
    background: var(--crimson);
}

/* Camera Controls Toolbar */
.camera-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

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

.device-select-group {
    position: relative;
    display: flex;
    align-items: center;
}

.select-icon {
    position: absolute;
    left: 12px;
    font-size: 0.85rem;
    color: var(--text-sub);
    pointer-events: none;
}

.hud-select {
    appearance: none;
    -webkit-appearance: none;
    padding: 0.55rem 2.2rem 0.55rem 2.2rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-main);
    font-family: var(--font-ui);
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    transition: var(--transition-fast);
}

.hud-select:hover, .hud-select:focus {
    border-color: var(--cyan);
    background: var(--bg-elevated);
}

/* Safety & Fatigue Prevention Guide */
.guide-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.guide-item {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.85rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.guide-item:hover {
    border-color: rgba(255, 255, 255, 0.15);
    background: var(--bg-elevated);
}

.guide-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.bg-cyan { background: rgba(6, 182, 212, 0.15); color: var(--cyan); }
.bg-emerald { background: rgba(16, 185, 129, 0.15); color: var(--emerald); }
.bg-amber { background: rgba(245, 158, 11, 0.15); color: var(--amber); }
.bg-crimson { background: rgba(239, 68, 68, 0.15); color: var(--crimson); }

.guide-body h5 {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 2px;
}

.guide-body p {
    font-size: 0.75rem;
    color: var(--text-sub);
    line-height: 1.35;
}

/* ==========================================================================
   RIGHT COLUMN: TELEMETRY & ANALYTICS
   ========================================================================== */
.hud-telemetry-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Probability Bars */
.telemetry-bars-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.prob-row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.prob-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    font-weight: 600;
}

.prob-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
}

.prob-value {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.95rem;
}

.prob-track {
    width: 100%;
    height: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-full);
    overflow: hidden;
    padding: 2px;
}

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

.fill-emerald {
    background: linear-gradient(90deg, #059669, #10b981);
    box-shadow: 0 0 10px var(--emerald-glow);
}

.fill-crimson {
    background: linear-gradient(90deg, #dc2626, #ef4444);
    box-shadow: 0 0 12px var(--crimson-glow);
}

/* Fatigue Risk Gauge & Stat Cards */
.risk-gauge-container {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.gauge-box {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.circular-progress {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: conic-gradient(var(--emerald) 0deg, var(--amber) 180deg, var(--crimson) 360deg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    transition: all 0.3s;
}

.gauge-inner {
    width: 100%;
    height: 100%;
    background: var(--bg-surface);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-glass);
}

.gauge-val {
    font-size: 1.4rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--text-main);
}

.gauge-sub {
    font-size: 0.65rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--emerald);
    letter-spacing: 1px;
}

.stat-mini-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    flex-grow: 1;
}

.stat-mini-box {
    padding: 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.stat-mini-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
}

.stat-mini-value {
    font-size: 1.15rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--text-main);
}

/* Alarm & Sound Configuration */
.alarm-controls-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.control-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--text-sub);
    font-weight: 500;
}

.slider-val {
    font-family: var(--font-mono);
    color: var(--cyan);
    font-weight: 700;
}

/* Custom Slider */
.hud-slider {
    width: 100%;
    height: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-full);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.hud-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--cyan);
    border: 2px solid #ffffff;
    box-shadow: 0 0 10px var(--cyan);
    cursor: pointer;
    transition: transform 0.1s;
}

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

/* Custom Toggle Switch */
.control-toggles {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-top: 0.25rem;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.85rem;
    color: var(--text-sub);
}

.toggle-container input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 38px;
    height: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-full);
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition-fast);
}

.toggle-container input:checked + .toggle-slider {
    background: rgba(6, 182, 212, 0.25);
    border-color: var(--cyan);
}

.toggle-container input:checked + .toggle-slider::before {
    transform: translateX(17px);
    background: var(--cyan);
    box-shadow: 0 0 8px var(--cyan);
}

/* Incident Log Card */
.incident-card {
    flex-grow: 1;
}

.log-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.incident-log-container {
    max-height: 240px;
    min-height: 140px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-right: 4px;
}

/* Custom Scrollbar */
.incident-log-container::-webkit-scrollbar {
    width: 5px;
}

.incident-log-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.empty-log-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem 1rem;
    gap: 0.75rem;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 2rem;
    color: var(--emerald);
    opacity: 0.6;
}

.empty-log-state p {
    font-size: 0.8rem;
    max-width: 280px;
}

.incident-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    background: var(--bg-surface);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    font-size: 0.8rem;
    transition: var(--transition-fast);
    animation: fadeIn 0.3s ease-out;
}

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

.incident-item:hover {
    background: var(--bg-elevated);
    border-color: var(--crimson);
}

.incident-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.incident-thumb {
    width: 38px;
    height: 28px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid var(--border-glass);
}

.incident-meta {
    display: flex;
    flex-direction: column;
}

.incident-time {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-main);
}

.incident-duration {
    font-size: 0.7rem;
    color: var(--crimson);
    font-family: var(--font-mono);
}

.incident-conf {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--crimson);
    background: rgba(239, 68, 68, 0.12);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.hud-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.5rem;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    font-size: 0.78rem;
    color: var(--text-sub);
}

.footer-model-id code {
    font-family: var(--font-mono);
    color: var(--cyan);
    background: rgba(6, 182, 212, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.safe-badge {
    color: var(--emerald);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

/* ==========================================================================
   SETTINGS MODAL DRAWER
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(3, 7, 18, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.settings-drawer {
    width: 100%;
    max-width: 460px;
    height: 100%;
    background: #0b1220;
    border-left: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.7);
}

.modal-backdrop.open .settings-drawer {
    transform: translateX(0);
}

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

.drawer-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.btn-close-drawer {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    color: var(--text-sub);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-close-drawer:hover {
    color: var(--text-main);
    border-color: var(--cyan);
}

.drawer-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.setting-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.setting-badge {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--cyan);
    background: rgba(6, 182, 212, 0.12);
    padding: 2px 8px;
    border-radius: 4px;
}

.setting-desc {
    font-size: 0.75rem;
    color: var(--text-sub);
    line-height: 1.4;
}

.model-info-box {
    padding: 0.85rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.78rem;
}

.info-line {
    display: flex;
    justify-content: space-between;
    color: var(--text-sub);
}

.info-line strong {
    color: var(--text-main);
}

.info-line a {
    color: var(--cyan);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}

.drawer-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-glass);
}

/* ==========================================================================
   TOAST NOTIFICATION
   ========================================================================== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 0.85rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    animation: toastSlideIn 0.3s ease-out;
    pointer-events: auto;
}

.toast.success { border-color: var(--emerald); }
.toast.danger { border-color: var(--crimson); }
.toast.info { border-color: var(--cyan); }

@keyframes toastSlideIn {
    from { transform: translateX(50px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   UTILITY COLORS & RESPONSIVE
   ========================================================================== */
.text-cyan { color: var(--cyan); }
.text-emerald { color: var(--emerald); }
.text-amber { color: var(--amber); }
.text-crimson { color: var(--crimson); }
.text-muted { color: var(--text-muted); }

.glow-pulse {
    animation: glowPulse 2s infinite alternate;
}

@keyframes glowPulse {
    0% { box-shadow: 0 0 10px rgba(6, 182, 212, 0.3); }
    100% { box-shadow: 0 0 25px rgba(6, 182, 212, 0.8); }
}

@keyframes pulseBorder {
    0% { border-color: var(--crimson); }
    100% { border-color: transparent; }
}

/* Responsive Breakpoints */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-wrapper {
        padding: 0.75rem;
        gap: 1rem;
    }
    
    .hud-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .hud-header-center, .hud-header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .guide-grid {
        grid-template-columns: 1fr;
    }

    .risk-gauge-container {
        flex-direction: column;
    }

    .stat-mini-grid {
        width: 100%;
    }

    .hud-footer {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}
