/* ================================================
   RutaSegura — Design System
   Mobile-first, dark theme, glassmorphism
   ================================================ */

/* --- CSS Variables --- */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-glass: rgba(30, 41, 59, 0.85);
    --bg-sheet: #0f172a;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(148, 163, 184, 0.15);
    --border-light: rgba(148, 163, 184, 0.08);
    --safe: #22c55e;
    --safe-bg: rgba(34, 197, 94, 0.12);
    --caution: #f59e0b;
    --caution-bg: rgba(245, 158, 11, 0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --primary: #3b82f6;
    --primary-bg: rgba(59, 130, 246, 0.12);
    --accent: #8b5cf6;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.25);
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%; width: 100%;
    overflow: hidden;
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

/* --- Screens --- */
.screen {
    position: fixed; inset: 0;
    display: none;
    flex-direction: column;
}
.screen.active { display: flex; }

/* --- Map Containers --- */
#map-container, #analysis-map-container {
    width: 100%; height: 100%;
    z-index: 1;
}

/* --- Map Overlays --- */
.map-overlay {
    position: absolute;
    z-index: 1000;
    pointer-events: auto;
}

/* Top Brand Bar */
.top-bar {
    top: 0; left: 0; right: 0;
    padding: 12px 16px 20px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.95) 0%, rgba(15, 23, 42, 0.7) 60%, rgba(15, 23, 42, 0) 100%);
    display: flex; align-items: center; justify-content: space-between;
    pointer-events: none;
}
.brand {
    display: flex; align-items: center; gap: 8px;
    pointer-events: auto; flex-wrap: wrap;
}
.brand-icon { font-size: 24px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }
.brand-name {
    font-size: 20px; font-weight: 900; letter-spacing: -0.3px;
    color: #fff;
    text-shadow: 0 0 12px rgba(59, 130, 246, 0.6), 0 2px 4px rgba(0, 0, 0, 0.5);
}
.brand-sub {
    font-size: 10px; font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    width: 100%; padding-left: 36px;
    margin-top: -4px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.doc-link {
    pointer-events: auto;
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 14px;
    text-decoration: none;
    transition: var(--transition);
}
.doc-link:hover { background: var(--primary); color: #fff; }
.panel-doc-link {
    display: block; text-align: center;
    margin-top: 10px; padding: 6px 0;
    font-size: 11px; font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
}
.panel-doc-link i { margin-right: 4px; }
.panel-doc-link:hover { color: var(--primary); }

/* --- Search Panel --- */
.search-panel {
    top: 68px; left: 12px; right: 12px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}
.search-panel.collapsed {
    padding: 0;
}
.search-panel.collapsed .search-panel-body {
    max-height: 0;
    opacity: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
}
.search-panel-body {
    max-height: 600px;
    opacity: 1;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease;
}

/* Collapse toggle button */
.btn-collapse-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 6px 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: color 0.2s ease;
    gap: 6px;
}
.btn-collapse-panel:hover { color: var(--text-primary); }
.btn-collapse-panel i {
    transition: transform 0.3s ease;
}
.search-panel.collapsed .btn-collapse-panel {
    padding: 10px 0;
}
.search-panel.collapsed .btn-collapse-panel i {
    transform: rotate(180deg);
}

.search-group { position: relative; }

.search-field {
    display: flex; align-items: center; gap: 10px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px 6px 2px 12px;
    transition: border-color var(--transition);
}
.search-field:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.search-dot.origin { background: var(--safe); box-shadow: 0 0 6px var(--safe); }
.search-dot.destination { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

.search-field input {
    flex: 1; border: none; background: transparent;
    color: var(--text-primary); font-family: var(--font);
    font-size: 14px; padding: 10px 0;
    outline: none;
}
.search-field input::placeholder { color: var(--text-muted); }

.search-connector {
    width: 2px; height: 12px; margin: -2px 0 -2px 16px;
    background: linear-gradient(180deg, var(--safe), var(--danger));
    border-radius: 1px;
}

/* Waypoints */
.waypoint-add-row {
    display: flex; justify-content: center;
    padding: 2px 0;
}
.btn-add-waypoint {
    background: none; border: 1px dashed var(--border);
    color: var(--text-muted); font-size: 12px;
    padding: 4px 12px; border-radius: var(--radius-sm);
    cursor: pointer; transition: all var(--transition);
    font-family: var(--font);
}
.btn-add-waypoint:hover {
    color: var(--primary); border-color: var(--primary);
    background: var(--primary-bg);
}
.waypoint-item {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 12px; font-size: 13px;
    color: var(--text-secondary);
    border-left: 2px solid #f59e0b;
    margin-left: 15px;
}
.waypoint-dot {
    width: 20px; height: 20px; border-radius: 50%;
    background: #f59e0b; color: #000;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.waypoint-name {
    flex: 1; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap;
}
.waypoint-remove {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 14px; padding: 2px 4px;
    border-radius: 4px; transition: all var(--transition);
}
.waypoint-remove:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

.map-marker-waypoint {
    width: 26px; height: 26px; border-radius: 50%;
    background: #f59e0b; border: 2px solid #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px; color: #000;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.search-results {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 200px; overflow-y: auto;
    display: none; z-index: 10;
    box-shadow: var(--shadow);
}
.search-results.visible { display: block; }
.search-result-item {
    padding: 10px 14px;
    font-size: 13px; color: var(--text-secondary);
    cursor: pointer; border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}
.search-result-item:hover, .search-result-item:active {
    background: var(--primary-bg); color: var(--text-primary);
}
.search-result-item:last-child { border-bottom: none; }

/* Config Row */
.config-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
}
.config-group {
    min-width: 0;
}
.config-group:first-child {
    grid-column: 1 / -1; /* Vehicle selector takes full width */
}
.config-group label {
    display: block; font-size: 11px; font-weight: 600;
    color: var(--text-muted); margin-bottom: 6px;
    text-transform: uppercase; letter-spacing: 0.5px;
}

.vehicle-selector {
    display: flex; gap: 4px;
}
.vehicle-opt {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; gap: 3px;
    padding: 8px 4px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    font-size: 10px; font-family: var(--font); font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.vehicle-opt i { font-size: 16px; }
.vehicle-opt.active {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
}
.vehicle-opt:active { transform: scale(0.95); }

.roundtrip-toggle-row {
    display: flex; align-items: center; gap: 8px;
    height: 100%;
}
.roundtrip-toggle-hint {
    font-size: 11px; color: var(--text-muted); line-height: 1.3;
}

.datetime-input {
    width: 100%;
    padding: 8px 10px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-family: var(--font); font-size: 13px;
    outline: none;
    color-scheme: dark;
}
.datetime-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Primary Button */
.btn-primary {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 13px;
    margin-top: 12px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border: none; border-radius: var(--radius-sm);
    color: #fff; font-family: var(--font);
    font-size: 15px; font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(59, 130, 246, 0.4); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled {
    opacity: 0.4; cursor: not-allowed;
    transform: none; box-shadow: none;
}
.btn-primary.btn-nav {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.3);
    margin: 24px 0;
}
.btn-primary.btn-nav:hover { box-shadow: 0 6px 24px rgba(34, 197, 94, 0.4); }

.btn-secondary {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 12px;
    margin-top: 10px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: var(--radius-sm);
    color: var(--primary); font-family: var(--font);
    font-size: 14px; font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-secondary:hover { background: rgba(59, 130, 246, 0.18); }
.btn-secondary:active { transform: scale(0.98); }

/* Offline tile cache status */
.offline-status {
    padding: 8px 16px;
    margin-top: 4px;
}
.offline-progress {
    display: flex;
    align-items: center;
    gap: 10px;
}
.offline-progress i {
    font-size: 13px;
    color: var(--text-secondary);
    transition: color 0.3s;
}
.offline-progress i.done {
    color: #22c55e;
}
.offline-progress-bar {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.1);
    overflow: hidden;
}
.offline-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 2px;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    transition: width 0.3s ease;
}
.offline-progress-fill.done {
    background: linear-gradient(90deg, #22c55e, #4ade80);
}
.offline-progress-text {
    font-size: 11px;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: right;
    white-space: nowrap;
}

.btn-icon {
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer; font-size: 14px;
    transition: all var(--transition);
    flex-shrink: 0;
}
.btn-icon:active { transform: scale(0.9); }

.btn-small {
    padding: 4px 10px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-xs);
    color: var(--danger);
    font-family: var(--font); font-size: 11px; font-weight: 600;
    cursor: pointer;
}

/* Instructions */
.instructions {
    bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 10px 20px;
    font-size: 13px; color: var(--text-secondary);
    display: flex; align-items: center; gap: 8px;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    animation: floatUp 0.5s ease;
    pointer-events: none;
}

.marker-info {
    bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--bg-glass);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 8px 16px;
    display: flex; align-items: center; gap: 10px;
    font-size: 13px; color: var(--text-primary); font-weight: 500;
    box-shadow: var(--shadow-sm);
}

@keyframes floatUp {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ================================================
   SCREEN 2: ANALYSIS
   ================================================ */

.btn-back {
    top: 12px; left: 12px;
    background: var(--bg-glass);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    width: 42px; height: 42px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-primary); font-size: 16px;
    cursor: pointer; box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}
.btn-back:active { transform: scale(0.9); }

.btn-audio {
    top: 62px; left: 12px;
    background: var(--bg-glass);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    width: 42px; height: 42px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-primary); font-size: 16px;
    cursor: pointer; box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}
.btn-audio:active { transform: scale(0.9); }

.score-badge {
    top: 12px; right: 12px;
    background: var(--bg-glass);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: 2px;
}
.badge-line {
    display: flex; align-items: center; gap: 5px;
    font-size: 12px; font-weight: 700;
    white-space: nowrap;
}
.badge-line.safe  { color: #22c55e; }
.badge-line.caution { color: #f59e0b; }
.badge-line.danger  { color: #ef4444; }
.badge-dot { font-size: 8px; }

/* Bottom Sheet */
.bottom-sheet {
    position: absolute; bottom: 0; left: 0; right: 0;
    max-height: 70vh;
    background: var(--bg-sheet);
    border-radius: 20px 20px 0 0;
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: transform var(--transition);
    overflow: hidden;
    display: flex; flex-direction: column;
}
.bottom-sheet.collapsed { transform: translateY(calc(100% - 60px)); }

.sheet-handle {
    padding: 12px 0 8px;
    display: flex; justify-content: center;
    cursor: grab; flex-shrink: 0;
}
.handle-bar {
    width: 40px; height: 4px;
    background: var(--text-muted);
    border-radius: 2px;
}

.sheet-content {
    overflow-y: auto;
    padding: 0 16px 16px;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}

/* Report Sections */
.report-header {
    margin-bottom: 16px;
}
.report-header h2 {
    font-size: 18px; font-weight: 800;
    margin-bottom: 6px;
}
.report-meta {
    display: flex; gap: 14px;
    font-size: 13px; color: var(--text-secondary);
}
.report-meta i { margin-right: 4px; }

.conditions-row {
    display: flex; gap: 8px; margin-bottom: 16px;
    flex-wrap: wrap;
}
.condition-badge {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50px;
    font-size: 12px; color: var(--text-secondary);
}
.badge-icon { font-size: 14px; }

/* Score Dashboard */
.score-dashboard {
    display: flex; flex-direction: column; gap: 14px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}
.risk-distribution {
    display: flex; flex-direction: column; gap: 10px;
}
.risk-bar-container {
    display: flex; flex-direction: column; gap: 6px;
}
.risk-bar {
    display: flex; width: 100%; height: 24px;
    border-radius: 12px; overflow: hidden;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
}
.risk-bar-segment {
    height: 100%;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0;
}
.risk-bar-segment.safe { background: var(--safe); }
.risk-bar-segment.caution { background: var(--caution); }
.risk-bar-segment.danger { background: var(--danger); }
.risk-bar-labels {
    display: flex; justify-content: space-between; gap: 8px;
}
.risk-pct {
    font-size: 12px; font-weight: 700;
    display: flex; align-items: center; gap: 4px;
}
.risk-pct::before {
    content: ''; width: 8px; height: 8px;
    border-radius: 50%; flex-shrink: 0;
}
.risk-pct.safe { color: var(--safe); }
.risk-pct.safe::before { background: var(--safe); }
.risk-pct.caution { color: var(--caution); }
.risk-pct.caution::before { background: var(--caution); }
.risk-pct.danger { color: var(--danger); }
.risk-pct.danger::before { background: var(--danger); }
.risk-summary-label {
    font-size: 12px; font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    padding: 4px 12px;
    background: var(--bg-elevated);
    border-radius: 50px;
    align-self: center;
}

.score-stats {
    display: flex; flex-direction: column; gap: 8px; flex: 1;
}
.stat-box {
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    display: flex; align-items: center; justify-content: space-between;
}
.stat-box.danger { background: var(--danger-bg); }
.stat-box.caution { background: var(--caution-bg); }
.stat-box.safe { background: var(--safe-bg); }
.stat-val { font-size: 20px; font-weight: 800; }
.stat-box.danger .stat-val { color: var(--danger); }
.stat-box.caution .stat-val { color: var(--caution); }
.stat-box.safe .stat-val { color: var(--safe); }
.stat-lbl { font-size: 11px; color: var(--text-secondary); font-weight: 500; }

/* Report Sections */
.report-section {
    margin-bottom: 16px;
}
.section-title {
    font-size: 13px; font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: flex; align-items: center; gap: 6px;
}
.section-title i { color: var(--primary); }

#elevation-canvas {
    width: 100%; height: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.elevation-stats {
    display: flex; gap: 12px; margin-top: 8px;
    font-size: 11px; color: var(--text-secondary);
}

/* Surface Composition */
.surf-bar {
    display: flex; height: 12px;
    border-radius: 6px; overflow: hidden;
    margin-bottom: 10px;
    border: 1px solid var(--border);
}
.surf-bar-seg {
    min-width: 4px;
    transition: width 0.5s;
}
.surf-legend {
    display: flex; flex-wrap: wrap; gap: 6px 14px;
    margin-bottom: 10px;
}
.surf-legend-item {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text-secondary);
}
.surf-legend-dot {
    width: 8px; height: 8px; border-radius: 50%;
    flex-shrink: 0;
}
.surf-legend-label { font-weight: 600; color: var(--text-primary); }
.surf-legend-val { color: var(--text-muted); font-size: 11px; }

.surf-transitions-title {
    font-size: 11px; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
    margin: 8px 0 6px; padding-top: 8px;
    border-top: 1px solid var(--border-light);
}
.surf-transition {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 0;
    font-size: 12px; color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}
.surf-trans-km {
    font-weight: 700; color: var(--text-muted);
    min-width: 55px; text-align: right;
}
.surf-trans-change strong { color: var(--text-primary); }

/* Alert Timeline */
.alert-timeline {
    max-height: 300px; overflow-y: auto;
}
.timeline-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}
.timeline-km {
    font-size: 11px; font-weight: 700;
    color: var(--text-muted);
    min-width: 48px; text-align: right;
}
.timeline-dot {
    width: 10px; height: 10px; border-radius: 50%;
    flex-shrink: 0; margin-top: 3px;
}
.timeline-dot.danger { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.timeline-dot.caution { background: var(--caution); box-shadow: 0 0 6px var(--caution); }
.timeline-dot.safe { background: var(--safe); }
.timeline-body {
    flex: 1;
}
.timeline-title {
    font-size: 13px; font-weight: 600;
}
.timeline-desc {
    font-size: 11px; color: var(--text-muted); margin-top: 2px;
}
.timeline-score {
    font-size: 14px; font-weight: 800;
    min-width: 32px; text-align: center;
}
.timeline-empty {
    padding: 20px; text-align: center;
    color: var(--text-muted); font-size: 13px;
}

/* Critical Zones */
.critical-zone-card {
    padding: 10px 12px;
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-xs);
    margin-bottom: 8px;
    font-size: 12px;
}
.critical-zone-card strong { color: var(--danger); }

/* Geo Data */
.geo-item {
    padding: 6px 0;
    font-size: 12px; color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}
.geo-item strong { color: var(--text-primary); }

/* Trip Plan Grid */
.trip-plan-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.trip-plan-item {
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
}
.trip-plan-item.full { grid-column: 1 / -1; }
.trip-plan-label {
    font-size: 10px; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.trip-plan-value {
    font-size: 16px; font-weight: 800;
    color: var(--text-primary);
}
.trip-plan-value.warn { color: var(--caution); }
.trip-plan-value.danger { color: var(--danger); }
.trip-plan-value.ok { color: var(--safe); }
.trip-plan-note {
    font-size: 11px; color: var(--text-muted);
    margin-top: 4px;
}

/* ================================================
   SCREEN 3: MAP NAVIGATION + HUD OVERLAY
   ================================================ */

/* Fullscreen map */
.nav-map-container {
    position: absolute;
    inset: 0;
    z-index: 1;
}
/* Force MapLibre map below HUD overlays */
.nav-map-container .maplibregl-map {
    z-index: 1 !important;
}
.nav-map-container .maplibregl-control-container {
    z-index: 2 !important;
}

/* Common HUD overlay base */
.nav-hud {
    position: absolute;
    z-index: 500;
    pointer-events: auto;
}

/* Top Bar */
.nav-hud-top {
    top: 0; left: 0; right: 0;
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.95) 0%, rgba(15, 23, 42, 0.7) 60%, transparent 100%);
}
.hud-btn {
    border: none;
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.2s ease;
}
.hud-btn:hover { background: rgba(255, 255, 255, 0.25); }
.hud-meta {
    display: flex; align-items: center; gap: 10px;
    font-size: 12px; color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
}
.meta-item {
    display: flex; align-items: center; gap: 5px;
}
.meta-item.error { color: var(--danger); }

/* Center HUD — Semaphore + Speed (left side) */
.nav-hud-center {
    top: 90px; left: 10px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius);
    padding: 10px 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    max-width: 44vw;
}

/* Compact Semaphore (horizontal) */
.semaphore-compact {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 0;
    transition: background var(--transition);
}
.semaphore-compact .sem-light {
    width: 14px; height: 14px;
}
.semaphore-compact .sem-label {
    font-size: 10px; font-weight: 800;
    letter-spacing: 0.5px;
}
.semaphore.safe { background: var(--safe-bg); border: 1px solid rgba(34,197,94,0.2); }
.semaphore.caution { background: var(--caution-bg); border: 1px solid rgba(245,158,11,0.2); }
.semaphore.danger { background: var(--danger-bg); border: 1px solid rgba(239,68,68,0.2); animation: pulseDanger 1s infinite; }
@keyframes pulseDanger {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); }
    50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}
.sem-light {
    width: 22px; height: 22px; border-radius: 50%;
    opacity: 0.2; transition: all var(--transition);
}
.sem-light.red { background: var(--danger); }
.sem-light.yellow { background: var(--caution); }
.sem-light.green { background: var(--safe); }
.semaphore.safe .sem-light.green { opacity: 1; box-shadow: 0 0 12px var(--safe); }
.semaphore.caution .sem-light.yellow { opacity: 1; box-shadow: 0 0 12px var(--caution); }
.semaphore.danger .sem-light.red { opacity: 1; box-shadow: 0 0 12px var(--danger); }
.sem-label {
    font-size: 16px; font-weight: 800;
    letter-spacing: 1px; text-transform: uppercase;
}
.semaphore.safe .sem-label { color: var(--safe); }
.semaphore.caution .sem-label { color: var(--caution); }
.semaphore.danger .sem-label { color: var(--danger); }

/* Speed (compact) */
.speed-compact {
    text-align: center;
}
.speed-current-compact {
    font-size: 42px; font-weight: 900; line-height: 1;
    color: var(--text-primary);
    transition: color var(--transition);
}
.speed-current-compact.over-speed { color: var(--danger); }
.speed-current-compact.near-speed { color: var(--caution); }
.speed-unit-compact {
    font-size: 10px; color: var(--text-muted); font-weight: 600;
}
.speed-rec-compact {
    font-size: 11px; color: var(--text-muted);
    display: flex; gap: 4px;
}
.speed-rec-label-compact { font-weight: 400; }
.speed-rec-val-compact { font-weight: 700; color: var(--safe); }

/* Deviation Alert Banner — sits between top bar and side HUDs */
.nav-deviation-alert {
    top: 52px; left: 12px; right: 12px;
    background: rgba(220, 38, 38, 0.95);
    backdrop-filter: blur(12px);
    color: #fff;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px; font-weight: 700;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.5);
    animation: pulseDeviation 2s infinite;
}
.nav-arrival-alert {
    background: rgba(22, 163, 74, 0.95);
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.5);
    animation: none;
}
.deviation-msg {
    display: flex; align-items: center; gap: 8px;
    white-space: nowrap;
}
.btn-recalc {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    color: #fff;
    font-family: var(--font);
    font-size: 12px; font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.btn-recalc:active {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0.95);
}
@keyframes pulseDeviation {
    0%, 100% { box-shadow: 0 4px 16px rgba(239, 68, 68, 0.5); }
    50% { box-shadow: 0 4px 24px rgba(239, 68, 68, 0.8); }
}

/* Recalculation Overlay */
.recalc-overlay {
    position: absolute; inset: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex; align-items: center; justify-content: center;
}
.recalc-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    text-align: center;
    min-width: 240px;
    box-shadow: var(--shadow);
}
.recalc-spinner {
    width: 36px; height: 36px; margin: 0 auto 14px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.recalc-title {
    font-size: 15px; font-weight: 700;
    margin-bottom: 8px;
}
.recalc-status {
    font-size: 12px; color: var(--text-muted);
    font-weight: 500;
}

/* Next Alert Card (right side) — HIGH CONTRAST for driving */
.nav-hud-alert {
    top: 90px; right: 10px;
    max-width: 48vw;
    padding: 12px 14px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    transition: all var(--transition);
}
.nav-hud-alert.level-danger {
    background: rgba(180, 30, 30, 0.92);
    border-color: rgba(255, 100, 100, 0.6);
}
.nav-hud-alert.level-caution {
    background: rgba(140, 100, 0, 0.92);
    border-color: rgba(255, 200, 50, 0.6);
}
.alert-card-top {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 6px;
}
.alert-badge {
    font-size: 12px; font-weight: 800;
    padding: 3px 10px;
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}
.level-danger .alert-badge {
    background: rgba(255, 80, 80, 0.4);
    color: #ffd5d5;
}
.level-caution .alert-badge {
    background: rgba(255, 200, 50, 0.3);
    color: #fff3cd;
}
.alert-dist {
    font-size: 13px; color: rgba(255, 255, 255, 0.85); font-weight: 700;
}
.alert-body {
    font-size: 15px; font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.3;
    color: #fff;
}
.alert-detail {
    font-size: 12px; color: rgba(255, 255, 255, 0.7); font-weight: 500;
}

/* Bottom — Elevation Profile + Stats */
.nav-hud-bottom {
    bottom: 0; left: 0; right: 0;
    height: 80px;
    position: absolute;
    overflow: hidden;
}
#elev-profile-canvas {
    width: 100%;
    height: 100%;
    display: block;
}
.elev-stats-overlay {
    position: absolute;
    top: 4px; left: 0; right: 0;
    display: flex;
    justify-content: space-around;
    padding: 0 12px;
    pointer-events: none;
}
.elev-stat {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}
.elev-stat-alt {
    color: #60a5fa;
}

/* MapLibre Compass Control — enlarged for navigation visibility */
.nav-map-container .maplibregl-ctrl-bottom-right {
    bottom: 90px;   /* above the 80px elevation profile */
    right: 12px;
}
.nav-map-container .maplibregl-ctrl-group {
    background: rgba(15, 23, 42, 0.85) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 2px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 50% !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5) !important;
    overflow: hidden;
}
.nav-map-container .maplibregl-ctrl-group button {
    width: 50px !important;
    height: 50px !important;
}
.nav-map-container .maplibregl-ctrl-compass .maplibregl-ctrl-icon {
    /* Scale up the compass icon itself */
    background-size: 28px 28px !important;
    /* Improve contrast on dark background */
    filter: brightness(2.5);
}

/* GPS Marker Arrow */
.gps-arrow-container {
    background: none !important;
    border: none !important;
}
.gps-arrow {
    width: 32px; height: 32px;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
    transition: transform 0.3s ease;
}

/* ================================================
   LOADING OVERLAY
   ================================================ */
.loading-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
}
.loading-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    text-align: center;
    min-width: 280px;
    box-shadow: var(--shadow);
}
.loading-spinner {
    width: 40px; height: 40px; margin: 0 auto 16px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-title {
    font-size: 15px; font-weight: 700;
    margin-bottom: 14px;
}
.loading-steps {
    text-align: left;
    margin-bottom: 16px;
}
.loading-step {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 0;
    font-size: 12px; color: var(--text-muted);
}
.loading-step.active { color: var(--primary); font-weight: 600; }
.loading-step.done { color: var(--safe); }
.loading-step i { width: 16px; text-align: center; }

.loading-progress {
    height: 4px; background: var(--bg-primary);
    border-radius: 2px; overflow: hidden;
}
.loading-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 2px;
    transition: width 0.4s;
}

/* ================================================
   LEAFLET OVERRIDES
   ================================================ */
.leaflet-container {
    background: var(--bg-primary) !important;
    font-family: var(--font) !important;
}

/* Leaflet marker popups dark theme */
.leaflet-popup-content-wrapper {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow) !important;
    border: 1px solid var(--border) !important;
}
.leaflet-popup-tip { background: var(--bg-card) !important; }
.leaflet-popup-close-button { color: var(--text-muted) !important; }

/* Custom map markers */
.map-marker-origin, .map-marker-dest {
    width: 32px; height: 32px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    font-size: 14px; font-weight: 800;
    color: #fff;
}
.map-marker-origin {
    background: var(--safe);
}
.map-marker-dest {
    background: var(--danger);
}
.map-marker-origin span, .map-marker-dest span {
    transform: rotate(45deg);
}

/* ================================================
   LEAFLET LAYER CONTROL (dark theme)
   ================================================ */
.leaflet-control-layers {
    background: var(--bg-glass) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-sm) !important;
    color: var(--text-primary) !important;
}
.leaflet-control-layers-toggle {
    width: 36px !important; height: 36px !important;
    background-size: 20px 20px !important;
    background-color: var(--bg-glass) !important;
    border-radius: var(--radius-xs) !important;
    border: 1px solid var(--border) !important;
}
.leaflet-control-layers-expanded {
    padding: 8px 12px 8px 8px !important;
}
.leaflet-control-layers label {
    color: var(--text-primary) !important;
    font-family: var(--font) !important;
    font-size: 12px !important;
    font-weight: 500 !important;
}
.leaflet-control-layers-separator {
    border-top-color: var(--border) !important;
}

/* ================================================
   RESPONSIVE
   ================================================ */
@media (min-width: 768px) {
    .search-panel {
        max-width: 420px;
    }
    .bottom-sheet {
        max-width: 440px;
        left: auto; right: 12px;
        bottom: 12px;
        border-radius: var(--radius);
        max-height: calc(100vh - 80px);
    }
    .driving-hud {
        max-width: 440px;
        margin: 0 auto;
    }
}

/* --- Audio Test Button --- */
.btn-test-audio {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 6px;
}
.btn-test-audio:active {
    background: var(--safe-bg);
    border-color: var(--safe);
    color: var(--safe);
}
.btn-test-audio.audio-ok {
    border-color: var(--safe);
    color: var(--safe);
    background: var(--safe-bg);
}
.btn-install-pwa {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, rgba(56,189,248,0.15), rgba(2,132,199,0.15));
    color: #38bdf8;
    border: 1px solid rgba(56,189,248,0.4);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 6px;
}
.btn-install-pwa:active {
    background: rgba(56,189,248,0.25);
    transform: scale(0.98);
}

/* --- Update Toast --- */
.update-toast {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99999;
    display: flex;
    justify-content: center;
    padding: 12px 16px;
    animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.update-toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 400px;
    width: 100%;
}
.update-toast-content i {
    color: var(--safe);
    font-size: 16px;
    animation: spin 2s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.update-toast-content span {
    flex: 1;
}
.update-toast-content button {
    padding: 6px 14px;
    background: var(--safe);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s ease;
}
.update-toast-content button:active {
    transform: scale(0.95);
}

/* ===================== BRIEFING STEPPER MODAL ===================== */
.briefing-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: briefingFadeIn 0.3s ease;
}
@keyframes briefingFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.briefing-content {
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 100%;
    max-width: 420px;
    padding: 24px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5),
                0 0 40px rgba(59, 130, 246, 0.1);
    animation: briefingSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes briefingSlideUp {
    from { opacity: 0; transform: translateY(40px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.briefing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.briefing-step-num {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.btn-briefing-skip {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-briefing-skip:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}
.btn-briefing-skip i { margin-right: 4px; }

.briefing-body {
    text-align: center;
    padding: 10px 0 20px;
}
.briefing-icon {
    font-size: 52px;
    margin-bottom: 12px;
    display: inline-block;
    animation: briefingPulse 2s ease-in-out infinite;
    position: relative;
}
@keyframes briefingPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.08); }
}
.briefing-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 10px;
}
.briefing-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
}

/* Progress dots */
.briefing-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}
.briefing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transition: all 0.3s ease;
}
.briefing-dot.active {
    background: var(--primary);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
    transform: scale(1.3);
}
.briefing-dot.done {
    background: var(--safe);
}

/* Action buttons */
.briefing-actions {
    display: flex;
    gap: 10px;
}
.btn-briefing {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 12px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-briefing:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.btn-briefing-prev {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    flex: 0.7;
}
.btn-briefing-prev:not(:disabled):hover {
    background: rgba(255, 255, 255, 0.14);
}
.btn-briefing-next {
    background: var(--primary);
    color: #fff;
    flex: 1;
}
.btn-briefing-next:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}
.btn-briefing-next.finish {
    background: var(--safe);
}
.btn-briefing-next.finish:hover {
    background: #16a34a;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.4);
}

/* ================================================
   Surface Override Modal
   ================================================ */
.surface-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}
.surface-modal {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 1px solid rgba(148,163,184,0.25);
    border-radius: 20px;
    padding: 2rem 1.8rem;
    max-width: 380px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.08);
    animation: slideUp 0.35s ease;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}
.surface-modal-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.surface-modal h3 {
    color: var(--text);
    font-size: 1.2rem;
    margin: 0 0 0.6rem;
}
.surface-modal p {
    color: #cbd5e1;
    font-size: 0.9rem;
    margin: 0 0 0.4rem;
    line-height: 1.5;
}
.surface-modal-sub { font-style: italic; margin-bottom: 1.2rem !important; }
.surface-options {
    display: flex; gap: 0.7rem;
    justify-content: center;
    margin-bottom: 1rem;
}
.surface-opt {
    flex: 1;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(148,163,184,0.3);
    border-radius: 14px;
    padding: 0.9rem 0.4rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex; flex-direction: column;
    align-items: center; gap: 0.4rem;
}
.surface-opt:hover {
    border-color: var(--accent);
    background: rgba(59,130,246,0.1);
    transform: translateY(-2px);
}
.surface-opt.selected {
    border-color: var(--accent);
    background: rgba(59,130,246,0.25);
    box-shadow: 0 0 16px rgba(59,130,246,0.4);
}
.surface-opt-icon { font-size: 1.8rem; }
.surface-opt-label { font-size: 0.8rem; color: #f1f5f9; font-weight: 600; }
.surface-modal-divider {
    display: flex; align-items: center; gap: 0.8rem;
    margin: 0.8rem 0;
    color: var(--muted); font-size: 0.8rem;
}
.surface-modal-divider::before,
.surface-modal-divider::after {
    content: ''; flex: 1; height: 1px;
    background: var(--border);
}
.surface-default-btn {
    width: 100%;
    padding: 0.7rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.surface-default-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text);
}

/* Resume prompt */
.resume-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    width: min(90vw, 380px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    animation: slideUp 0.3s ease;
}
@keyframes slideUp {
    from { transform: translateX(-50%) translateY(100px); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0); opacity: 1; }
}
.resume-content {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}
.resume-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: #fff;
    flex-shrink: 0;
}
.resume-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
}
.resume-route {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.resume-age {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.resume-buttons {
    display: flex;
    gap: 8px;
}
.resume-btn {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.resume-yes {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
}
.resume-no {
    background: rgba(255,255,255,0.08);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* --- Report Danger Button & Popup --- */
.report-danger-btn {
    position: absolute; bottom: 110px; left: 16px; z-index: 600;
    width: 52px; height: 52px; border-radius: 50%;
    background: linear-gradient(135deg, #ff6b35, #f7c948);
    color: #fff; border: none; font-size: 1.4rem;
    box-shadow: 0 4px 18px rgba(255,107,53,.45);
    cursor: pointer;
    display: none; /* hidden by default */
    align-items: center; justify-content: center;
    transition: transform .15s, box-shadow .15s;
}
/* Show only when driving screen is active */
#screen-driving.active .report-danger-btn {
    display: flex;
}
.report-danger-btn:active {
    transform: scale(.92);
    box-shadow: 0 2px 8px rgba(255,107,53,.3);
}

.report-danger-popup {
    position: absolute; bottom: 170px; left: 16px; z-index: 700;
    background: rgba(30,30,46,.92); backdrop-filter: blur(18px);
    border-radius: 16px; padding: 16px; min-width: 220px;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
    animation: reportSlideUp .2s ease-out;
}
@keyframes reportSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.report-popup-header {
    font-weight: 700; font-size: .95rem; color: #fff;
    margin-bottom: 10px; text-align: center;
}
.report-popup-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.report-cat-btn {
    background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
    color: #fff; padding: 14px 8px; border-radius: 12px;
    font-size: 1.8rem; text-align: center; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    transition: background .15s;
    min-height: 70px;
}
.report-cat-btn span {
    font-size: .75rem; opacity: .85;
}
.report-cat-btn:active {
    background: rgba(255,255,255,.25);
    transform: scale(.95);
}
.report-cancel-btn {
    width: 100%; margin-top: 8px; padding: 8px;
    background: transparent; border: 1px solid rgba(255,255,255,.2);
    color: rgba(255,255,255,.6); border-radius: 10px;
    cursor: pointer; font-size: .85rem;
}
.report-cancel-btn:hover { color: #fff; }

/* --- Report Toast --- */
.report-toast {
    position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%);
    background: rgba(30,30,46,.92); backdrop-filter: blur(12px);
    color: #fff; padding: 12px 24px; border-radius: 12px;
    font-size: .95rem; font-weight: 600; z-index: 99999;
    box-shadow: 0 4px 18px rgba(0,0,0,.4);
    animation: reportSlideUp .2s ease-out;
    transition: opacity .5s;
}
.report-toast.fade-out { opacity: 0; }

/* --- TTS Setup Guide Modal --- */
.tts-setup-modal {
    position: fixed; inset: 0; z-index: 100000;
    background: rgba(0,0,0,.7); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.tts-setup-content {
    background: linear-gradient(160deg, #1a2234, #0f1623);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 18px; padding: 28px 24px; max-width: 420px; width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.tts-setup-icon { font-size: 2.5rem; text-align: center; margin-bottom: 8px; }
.tts-setup-content h3 {
    text-align: center; color: #fff; font-size: 1.2rem;
    font-weight: 700; margin-bottom: 10px;
}
.tts-setup-content > p {
    color: rgba(255,255,255,.75); font-size: .88rem;
    line-height: 1.5; margin-bottom: 16px; text-align: center;
}
.tts-instructions {
    background: rgba(255,255,255,.05); border-radius: 12px;
    padding: 14px 16px; margin-bottom: 16px;
}
.tts-platform-badge {
    display: inline-block; padding: 3px 10px; border-radius: 6px;
    background: rgba(59,130,246,.2); color: #60a5fa;
    font-size: .75rem; font-weight: 700; margin-bottom: 10px;
}
.tts-instructions ol {
    color: rgba(255,255,255,.85); font-size: .85rem;
    padding-left: 20px; line-height: 1.7;
}
.tts-tip {
    color: rgba(255,255,255,.6); font-size: .78rem;
    margin-top: 10px; line-height: 1.4;
}
.tts-setup-actions { display: flex; flex-direction: column; gap: 8px; }
.btn-tts-primary {
    width: 100%; padding: 12px; border: none; border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff; font-weight: 700; font-size: .9rem; cursor: pointer;
}
.btn-tts-secondary {
    width: 100%; padding: 10px; border: none; border-radius: 10px;
    background: transparent; color: rgba(255,255,255,.5);
    font-size: .82rem; cursor: pointer;
}

/* --- Alert Settings Modal --- */
.alert-settings-overlay {
    position: fixed; inset: 0; z-index: 100000;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.alert-settings-content {
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 100%; max-width: 460px; max-height: 85vh;
    display: flex; flex-direction: column;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.alert-settings-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 20px 0;
}
.alert-settings-header h3 {
    font-size: 17px; font-weight: 800; color: var(--text-primary);
    display: flex; align-items: center; gap: 8px;
}
.alert-settings-header h3 i { color: var(--primary); font-size: 15px; }
.btn-alert-settings-close {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,.06); border: none;
    color: var(--text-secondary); cursor: pointer; font-size: 14px;
    flex-shrink: 0;
}
.alert-settings-intro {
    font-size: 12.5px; color: var(--text-secondary); line-height: 1.5;
    padding: 10px 20px 4px;
}
.alert-settings-master {
    margin: 8px 20px 4px;
    padding: 12px 14px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 12px;
}
.alert-settings-master .alert-settings-row-label { font-size: 14.5px; }
.alert-settings-groups {
    overflow-y: auto; padding: 8px 20px 4px;
    flex: 1;
}
.alert-settings-group + .alert-settings-group { margin-top: 18px; }
.alert-settings-group-title {
    font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
    margin-bottom: 8px;
}
.alert-settings-group-title.critica { color: var(--danger); }
.alert-settings-group-title.precaucion { color: var(--caution); }
.alert-settings-group-title.informativa { color: var(--primary); }

.alert-settings-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}
.alert-settings-row:last-child { border-bottom: none; }
.alert-settings-row-text { min-width: 0; }
.alert-settings-row-label {
    font-size: 13.5px; font-weight: 600; color: var(--text-primary);
}
.alert-settings-row-desc {
    font-size: 11.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.4;
}

.toggle-switch {
    position: relative; flex-shrink: 0;
    width: 44px; height: 26px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.25);
    border: none; cursor: pointer; padding: 0;
    transition: background var(--transition);
}
.toggle-switch::after {
    content: '';
    position: absolute; top: 3px; left: 3px;
    width: 20px; height: 20px; border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: transform var(--transition);
}
.toggle-switch.on { background: var(--primary); }
.toggle-switch.on::after { transform: translateX(18px); }

.alert-settings-footer { padding: 14px 20px 20px; }
.btn-alert-settings-reset {
    width: 100%; padding: 11px; border-radius: 10px;
    background: rgba(255,255,255,.06); border: 1px solid var(--border);
    color: var(--text-secondary); font-family: var(--font);
    font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.btn-alert-settings-reset:active { transform: scale(0.98); }

/* --- Zoom Controls (Nav HUD) --- */
.hud-zoom-controls {
    display: flex; gap: 2px; align-items: center;
    background: rgba(0,0,0,.35); border-radius: 8px; padding: 2px;
    margin-left: 6px;
}
.hud-zoom-btn {
    width: 32px !important; height: 32px !important; min-width: 0 !important;
    padding: 0 !important; font-size: .75rem !important;
    border-radius: 6px !important;
}
.hud-zoom-btn.active {
    background: rgba(59,130,246,.5) !important;
    color: #fff !important;
}

/* --- Simulation Button & Controls --- */
.simulate-btn {
    position: absolute; bottom: 170px; left: 16px; z-index: 600;
    width: 52px; height: 52px; border-radius: 50%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 2px solid rgba(59,130,246,0.4);
    color: #60a5fa; font-size: 1.2rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    cursor: pointer;
    display: none; /* hidden by default */
    align-items: center; justify-content: center;
    transition: transform .15s, box-shadow .15s, border-color .2s;
}
#screen-driving.active .simulate-btn {
    display: flex;
}
.simulate-btn:active {
    transform: scale(.92);
}
.simulate-btn.simulating {
    background: rgba(59,130,246,0.25);
    border-color: rgba(59,130,246,0.7);
    color: #93c5fd;
    animation: pulseSimBtn 2s infinite;
}
@keyframes pulseSimBtn {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.3); }
    50% { box-shadow: 0 0 0 8px rgba(59,130,246,0); }
}

/* Simulation Controls Bar */
.sim-controls {
    position: absolute; bottom: 170px; left: 76px; z-index: 600;
    display: flex; align-items: center; gap: 6px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 28px;
    padding: 4px 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    animation: simControlsSlideIn .2s ease-out;
}
@keyframes simControlsSlideIn {
    from { opacity: 0; transform: translateX(-12px); }
    to   { opacity: 1; transform: translateX(0); }
}
.sim-ctrl-btn {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: none; color: #fff; font-size: 14px;
    cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    transition: all .15s;
}
.sim-ctrl-btn:active { transform: scale(.9); }
.sim-ctrl-stop { color: #ef4444; }
.sim-speed-group {
    display: flex; gap: 2px;
    background: rgba(0,0,0,0.3);
    border-radius: 6px; padding: 2px;
}
.sim-speed-btn {
    padding: 4px 8px; border: none;
    background: transparent; color: rgba(255,255,255,0.5);
    font-family: var(--font); font-size: 11px; font-weight: 700;
    border-radius: 4px; cursor: pointer;
    transition: all .15s;
}
.sim-speed-btn.active {
    background: rgba(59,130,246,.5);
    color: #fff;
}
