/* ==========================================================================
   Tactical Fullscreen GIS & Glassmorphism HUD Stylesheet
   Project: 009-bkk-flood-public
   ========================================================================== */

:root {
    --bg-dark: #090d16;
    --hud-bg: rgba(15, 23, 42, 0.88);
    --hud-border: rgba(255, 255, 255, 0.12);
    --hud-hover: rgba(30, 41, 59, 0.95);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-blue: #38bdf8;
    --accent-red: #ef4444;
    --accent-orange: #f97316;
    --accent-yellow: #f59e0b;
    --accent-green: #10b981;
    --font-sans: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    overflow-x: hidden !important;
    background-color: var(--bg-dark);
    font-family: var(--font-sans);
    color: var(--text-primary);
}

/* --- 100vw x 100vh Map Canvas --- */
#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

/* Custom Leaflet Controls Placement */
.leaflet-top.leaflet-left {
    top: 68px;
    left: 12px;
}
.leaflet-control-layers {
    background: var(--hud-bg) !important;
    backdrop-filter: blur(12px) !important;
    border: 1px solid var(--hud-border) !important;
    color: var(--text-primary) !important;
    border-radius: 8px !important;
}
.leaflet-control-layers-base label {
    color: #e2e8f0 !important;
    font-size: 13px !important;
    margin-bottom: 4px !important;
}

/* --- Glassmorphic HUD Overlays --- */
.hud-panel {
    position: absolute;
    z-index: 100;
    background: var(--hud-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--hud-border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 1. Top Navigation Bar */
.hud-topbar {
    top: 10px;
    left: 12px;
    right: 12px;
    height: 50px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    box-sizing: border-box;
    overflow: hidden;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
}
.brand-pulse {
    width: 10px;
    height: 10px;
    background-color: var(--accent-red);
    border-radius: 50%;
    animation: beaconPulse 1.5s infinite;
    flex-shrink: 0;
}
.brand-text-long {
    display: inline;
}
.brand-text-short {
    display: none;
}

/* Responsive label toggles */
.tab-label-short {
    display: none;
}
.tab-label-full {
    display: inline;
}
.menu-label-short {
    display: none;
}
.menu-label-full {
    display: inline;
}
.sub-cur-badge {
    display: none;
}
.sub-full-text {
    display: inline;
}
.sheet-drag-handle {
    display: none;
    width: 38px;
    height: 4px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    margin: 2px auto 6px auto;
    cursor: grab;
}

.topbar-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    justify-content: flex-end;
    overflow: hidden;
}

.btn-hud.btn-menu {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
}

/* Preset selector */
.preset-select {
    background: rgba(30, 41, 59, 0.85);
    color: #f1f5f9;
    border: 1px solid var(--hud-border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    outline: none;
    cursor: pointer;
    max-width: 200px;
}

/* Action Buttons */
.btn-hud {
    background: rgba(30, 41, 59, 0.85);
    color: #f8fafc;
    border: 1px solid var(--hud-border);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: background 0.2s, border-color 0.2s, transform 0.1s;
}
.btn-hud:hover {
    background: var(--hud-hover);
    border-color: rgba(255, 255, 255, 0.25);
}
.btn-hud:active {
    transform: scale(0.98);
}
.btn-hud.btn-sos {
    background: #dc2626;
    border-color: #ef4444;
    color: white;
    font-weight: 700;
    animation: sosGlow 2s infinite alternate;
}
.btn-hud.btn-sos:hover {
    background: #b91c1c;
}
.btn-hud.btn-menu {
    background: #1e293b;
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}
.btn-hud.btn-menu.active {
    background: var(--accent-blue);
    color: #0f172a;
}

/* Single Consolidated Right Drawer (Tabbed) */
.hud-drawer-right {
    top: 68px;
    right: 12px;
    width: 380px;
    max-height: calc(100vh - 150px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, visibility 0.3s ease;
    opacity: 1;
    visibility: visible;
}
.hud-drawer-right.collapsed {
    transform: translateX(420px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Floating Drawer Toggle Knob */
.drawer-toggle-btn {
    position: absolute;
    width: 32px;
    height: 42px;
    background: var(--hud-bg);
    border: 1px solid var(--hud-border);
    backdrop-filter: blur(12px);
    color: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    z-index: 101;
    border-radius: 8px 0 0 8px;
    border-right: none;
    top: 76px;
    right: 392px;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.drawer-toggle-btn.collapsed {
    right: 0;
    border-radius: 8px 0 0 8px;
}

/* Drawer Header */
.drawer-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--hud-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.95);
}
.drawer-title {
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #f8fafc;
}
.drawer-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.drawer-close-btn:hover {
    color: white;
}

/* Drawer Selectable Tab Bar */
.drawer-tabs {
    display: flex;
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid var(--hud-border);
    padding: 4px 6px;
    gap: 3px;
    width: 100%;
    box-sizing: border-box;
}
.drawer-tabs::-webkit-scrollbar {
    display: none;
}
.drawer-tab-btn {
    flex: 1 1 0;
    min-width: 0;
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 7px 2px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: all 0.2s;
    box-sizing: border-box;
}
.drawer-tab-btn:hover {
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.05);
}
.drawer-tab-btn.active {
    background: var(--accent-blue);
    color: #090d16;
    font-weight: 700;
}
.drawer-tab-btn.admin-tab {
    color: #f59e0b;
}
.drawer-tab-btn.admin-tab.active {
    background: #f59e0b;
    color: #090d16;
}

/* Tab Panels Container */
.drawer-body {
    padding: 12px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.drawer-tab-panel {
    display: none;
    flex-direction: column;
    gap: 10px;
}
.drawer-tab-panel.active {
    display: flex;
}

/* Risk Summary Card */
.risk-card {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--hud-border);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.risk-score-badge {
    font-size: 24px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 8px;
    color: white;
}

/* Canal Cards */
.canal-card {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 8px 10px;
    transition: background 0.2s, border-color 0.2s;
    cursor: pointer;
}
.canal-card:hover {
    background: rgba(30, 41, 59, 0.85);
    border-color: var(--accent-blue);
}
.canal-card-header {
    display: flex;
    justify-content: space-between;
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 4px;
}
.canal-metrics {
    display: flex;
    justify-content: space-between;
    font-size: 11.5px;
    color: var(--text-secondary);
}

/* Radar Box */
.radar-box {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--hud-border);
    background: #000;
    height: 210px;
}
.radar-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.radar-station-badge {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: rgba(0, 0, 0, 0.75);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10.5px;
    color: #e2e8f0;
}
.radar-switcher {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.radar-switcher button {
    flex: 1;
    min-width: 90px;
    background: rgba(30, 41, 59, 0.8);
    color: #cbd5e1;
    border: 1px solid var(--hud-border);
    padding: 5px 6px;
    font-size: 11px;
    border-radius: 4px;
    cursor: pointer;
}
.radar-switcher button.active {
    background: var(--accent-blue);
    color: #0f172a;
    font-weight: 700;
}

/* 4. Bottom Timeline Scrubber & Forecast Bar */
.hud-bottom-timeline {
    bottom: 10px;
    left: 12px;
    right: 404px;
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 90;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s;
    max-height: calc(100vh - 65px);
    overflow: hidden;
}
.hud-drawer-right.collapsed ~ .hud-bottom-timeline {
    right: 12px;
}
.hud-bottom-timeline.collapsed {
    transform: translateY(120px);
}

.timeline-main-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.timeline-info {
    min-width: 220px;
    max-width: 280px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}
.timeline-title {
    font-size: 13px;
    font-weight: 700;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
    display: flex;
    align-items: center;
}
.tl-station-icon {
    font-size: 13px;
    line-height: 1;
    display: inline-block;
    margin-right: 4px;
    flex-shrink: 0;
}
.tl-station-name {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
}
.timeline-sub {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.25;
}

.timeline-controls {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    position: relative;
    height: 48px;
    display: flex;
    align-items: center;
}
#timelineChartBox {
    width: 100%;
    height: 100%;
    min-height: 48px;
    position: relative;
    user-select: none;
    touch-action: none;
    cursor: crosshair;
    overflow: hidden;
}

/* Global Chart Tooltip (Never clipped by container boundaries) */
.timeline-tooltip {
    position: fixed;
    z-index: 999999;
    pointer-events: none;
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid #38bdf8;
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 11.5px;
    color: #f8fafc;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.7), 0 0 12px rgba(56, 189, 248, 0.25);
    display: none;
    transform: translate(-50%, -100%);
    margin-top: -10px;
    white-space: nowrap;
    backdrop-filter: blur(12px);
    line-height: 1.4;
    transition: opacity 0.15s ease-out;
}
.timeline-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: rgba(15, 23, 42, 0.96) transparent transparent transparent;
}
.timeline-tooltip.tooltip-bottom {
    transform: translate(-50%, 0);
    margin-top: 10px;
}
.timeline-tooltip.tooltip-bottom::after {
    top: auto;
    bottom: 100%;
    border-color: transparent transparent rgba(15, 23, 42, 0.96) transparent;
}

.timeline-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.timeline-tabs {
    display: flex;
    gap: 2px;
}
.timeline-tab-btn {
    background: rgba(30, 41, 59, 0.8);
    color: #94a3b8;
    border: 1px solid var(--hud-border);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 10.5px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}
.timeline-tab-btn:hover {
    color: #f8fafc;
    background: rgba(51, 65, 85, 0.9);
}
.timeline-tab-btn.active {
    background: var(--accent-blue);
    color: #090d16;
    font-weight: 700;
    border-color: var(--accent-blue);
}
.sheet-timeframe-tabs {
    display: flex;
    margin-left: auto;
    margin-right: 6px;
}

/* Collapsible Detailed Timeline Table Drawer */
/* Interactive Bottom Sheet (55vh - 75vh) */
.timeline-detail-drawer {
    display: none;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid var(--hud-border);
    padding-top: 8px;
    max-height: 65vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-right: 4px;
}
.timeline-detail-drawer.expanded {
    display: flex;
}
.timeline-detail-drawer::-webkit-scrollbar {
    width: 6px;
}
.timeline-detail-drawer::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 3px;
}
.timeline-detail-drawer::-webkit-scrollbar-thumb {
    background: var(--accent-blue);
    border-radius: 3px;
}

/* Sheet Header & Station Switcher (Sticky at top of drawer) */
.detail-sheet-header {
    position: sticky;
    top: 0;
    background: #0f172a;
    z-index: 10;
    padding: 6px 0;
    border-bottom: 1px solid var(--hud-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.station-quick-pills {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
}
.station-quick-pills::-webkit-scrollbar {
    display: none;
}
.station-pill-btn {
    background: rgba(30, 41, 59, 0.7);
    color: #94a3b8;
    border: 1px solid var(--hud-border);
    border-radius: 20px;
    padding: 3px 9px;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    pointer-events: auto !important;
    position: relative;
    z-index: 5;
    user-select: none;
}
.station-pill-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    color: #f1f5f9;
    border-color: rgba(56, 189, 248, 0.5);
}
.station-pill-btn:active {
    transform: scale(0.96);
}
.station-pill-btn.active {
    background: var(--accent-blue);
    color: #090d16;
    font-weight: 700;
    border-color: var(--accent-blue);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

/* Tidal Peak Countdown Alert Banner */
.countdown-banner {
    background: linear-gradient(90deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.countdown-banner.critical {
    border-color: rgba(239, 68, 68, 0.6);
    border-left-color: #ef4444;
    background: linear-gradient(90deg, rgba(127, 29, 29, 0.4), rgba(15, 23, 42, 0.95));
}
.countdown-timer-box {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #f8fafc;
}
.countdown-pill {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.5);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11.5px;
    font-family: monospace;
}
.countdown-banner.critical .countdown-pill {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.5);
}

/* Middle Telemetry Split (Cross-Section + Stat Grid) */
.telemetry-split-grid {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 10px;
    align-items: stretch;
}

/* Visual Embankment Cross-Section Gauge */
.cross-section-card {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--hud-border);
    border-radius: 8px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.cross-section-header {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    display: flex;
    justify-content: space-between;
}
.cross-section-visual {
    position: relative;
    height: 48px;
    background: #0f172a;
    border: 1px solid var(--hud-border);
    border-radius: 6px;
    overflow: hidden;
    margin: 6px 0;
}
.cs-water-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
    transition: height 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0.85;
}
.cs-water-fill.critical {
    background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
}
.cs-water-fill.warning {
    background: linear-gradient(180deg, #f97316 0%, #c2410c 100%);
}
.cs-bank-line {
    position: absolute;
    top: 15%;
    left: 0;
    width: 100%;
    border-top: 1.5px dashed #ef4444;
    z-index: 2;
}
.cs-bank-tag {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 9.5px;
    color: #ef4444;
    z-index: 3;
    font-weight: 600;
}
.cs-current-tag {
    position: absolute;
    bottom: 4px;
    left: 6px;
    font-size: 11px;
    font-weight: 700;
    color: white;
    z-index: 3;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.stat-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.stat-box {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--hud-border);
    border-radius: 6px;
    padding: 6px 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.stat-box-title {
    font-size: 10.5px;
    color: var(--text-secondary);
}
.stat-box-val {
    font-size: 13.5px;
    font-weight: 700;
    margin-top: 2px;
}

/* Table Filter Bar & Scroll Container */
.table-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 2px;
}
.table-filter-tabs {
    display: flex;
    gap: 4px;
}
.table-filter-btn {
    background: rgba(30, 41, 59, 0.7);
    color: #94a3b8;
    border: 1px solid var(--hud-border);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    cursor: pointer;
}
.table-filter-btn.active {
    background: var(--accent-blue);
    color: #090d16;
    font-weight: 700;
}

.timeline-table-container {
    overflow-x: auto;
    border: 1px solid var(--hud-border);
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.6);
    min-height: 220px;
    margin-bottom: 6px;
}

/* Detailed table styling */
.timeline-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11.5px;
    text-align: left;
}
.timeline-table th {
    background: rgba(15, 23, 42, 0.95);
    color: #94a3b8;
    padding: 6px 10px;
    font-weight: 600;
    border-bottom: 1px solid var(--hud-border);
    position: sticky;
    top: 0;
    z-index: 2;
}
.timeline-table td {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
}
.timeline-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}
.timeline-table tr.row-peak {
    background: rgba(239, 68, 68, 0.18) !important;
    border-left: 3px solid #ef4444;
}

/* --- Pulsing SOS Map Markers --- */
.sos-beacon-marker {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sos-pulse-ring {
    position: absolute;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.4);
    animation: beacon-ring 1.8s infinite ease-out;
}

.sos-center-dot {
    position: absolute;
    width: 24px;
    height: 24px;
    background: #dc2626;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.8);
    border: 2px solid white;
}

.sos-beacon-marker.critical .sos-pulse-ring {
    background: rgba(239, 68, 68, 0.6);
    animation: beacon-ring 1.2s infinite ease-out;
}

.sos-beacon-marker.critical .sos-center-dot {
    background: #ef4444;
    width: 26px;
    height: 26px;
}

.sos-beacon-marker.dispatched .sos-pulse-ring {
    background: rgba(2, 132, 199, 0.4);
}

.sos-beacon-marker.dispatched .sos-center-dot {
    background: #0284c7;
    box-shadow: 0 0 8px rgba(2, 132, 199, 0.8);
}

.sos-beacon-marker.resolved .sos-pulse-ring {
    display: none;
}

.sos-beacon-marker.resolved .sos-center-dot {
    background: #059669;
    border-color: #a7f3d0;
    box-shadow: none;
}

@keyframes beacon-ring {
    0% { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(1.6); opacity: 0; }
}

.sos-pulsing-marker {
    position: relative;
    width: 32px;
    height: 32px;
}
.sos-dot {
    position: absolute;
    width: 16px;
    height: 16px;
    background: #ef4444;
    border: 2px solid #ffffff;
    border-radius: 50%;
    top: 8px;
    left: 8px;
    z-index: 2;
    box-shadow: 0 0 10px #ef4444;
}
.sos-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 32px;
    height: 32px;
    border: 2px solid #ef4444;
    border-radius: 50%;
    animation: beaconPulse 1.8s infinite cubic-bezier(0.2, 0.8, 0.2, 1);
    opacity: 0.8;
}

@keyframes beaconPulse {
    0% { transform: scale(0.6); opacity: 1; }
    100% { transform: scale(2.2); opacity: 0; }
}

@keyframes sosGlow {
    from { box-shadow: 0 0 8px rgba(239, 68, 68, 0.6); }
    to { box-shadow: 0 0 20px rgba(239, 68, 68, 1); }
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-card {
    background: #0f172a;
    border: 1px solid var(--hud-border);
    border-radius: 12px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
}
.modal-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--hud-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.modal-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--hud-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-label {
    font-size: 12.5px;
    font-weight: 600;
    color: #e2e8f0;
}
.form-input, .form-select, .form-textarea {
    background: #1e293b;
    border: 1px solid var(--hud-border);
    color: #f8fafc;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--accent-blue);
}

.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #1e293b;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12.5px;
    cursor: pointer;
}

/* Toast container */
.toast-box {
    position: fixed;
    top: 68px;
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    border: 1px solid var(--accent-blue);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.6);
    z-index: 3000;
    font-size: 13px;
    animation: fadeIn 0.3s;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* Responsive adjustments for Wide Desktop vs Medium Viewports */
@media (max-width: 1200px) {
    .topbar-xl-only {
        display: none !important;
    }
}

/* ==========================================================================
   Tablet Viewport Adjustments (768px - 1024px)
   ========================================================================== */
@media (min-width: 768px) and (max-width: 1024px) {
    .topbar-xl-only {
        display: none !important;
    }
    .topbar-desktop-only {
        display: inline-flex !important;
    }
    .brand-text-long {
        display: inline !important;
        font-weight: 800;
        font-size: 16px;
        color: #38bdf8;
    }
    .brand-text-short {
        display: none !important;
    }
    #liveClock {
        display: inline-block !important;
        font-size: 12px;
        color: var(--text-secondary);
        font-weight: 500;
        margin-left: 8px;
    }
    .menu-label-short {
        display: none !important;
    }
    .menu-label-full {
        display: inline !important;
    }

    /* Topbar - Elegant Tablet Header */
    .hud-topbar {
        top: 10px;
        left: 12px;
        right: 12px;
        height: 48px;
        padding: 0 14px;
        border-radius: 12px;
        background: rgba(15, 23, 42, 0.92);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.12);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        box-sizing: border-box;
        overflow: hidden;
    }
    .brand-section {
        gap: 8px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
    }
    .brand-pulse {
        width: 9px;
        height: 9px;
        flex-shrink: 0;
    }
    .topbar-controls {
        gap: 8px;
        display: flex;
        align-items: center;
        flex: 1;
        justify-content: flex-end;
        min-width: 0;
    }
    .btn-hud {
        padding: 6px 12px;
        font-size: 12px;
        font-weight: 600;
        border-radius: 8px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .btn-hud.btn-sos {
        padding: 6px 14px;
        font-size: 12px;
        font-weight: 700;
        border-radius: 8px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .btn-hud.btn-menu {
        padding: 6px 14px;
        font-size: 12px;
        font-weight: 700;
        border-radius: 8px;
        white-space: nowrap;
        flex-shrink: 0;
        margin-left: 4px;
    }

    /* Right Drawer - Tablet Right Panel (Slide drawer, fully hidden when collapsed) */
    .hud-drawer-right {
        top: 68px;
        right: 12px;
        width: 360px;
        max-width: calc(100vw - 24px);
        max-height: calc(100vh - 130px);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        border-radius: 12px;
        border: 1px solid var(--hud-border);
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, visibility 0.3s ease;
        z-index: 150;
    }
    .hud-drawer-right:not(.collapsed) {
        transform: translateX(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }
    .hud-drawer-right.collapsed {
        transform: translateX(calc(100% + 40px)) !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
    .drawer-toggle-btn {
        display: none !important;
    }
    .sheet-drag-handle {
        display: none !important;
    }

    /* Bottom Timeline in Tablet - Full width, takes no space from drawer */
    .hud-bottom-timeline {
        left: 12px !important;
        right: 12px !important;
        bottom: 10px !important;
        max-width: calc(100vw - 24px) !important;
        transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
}

/* ==========================================================================
   Mobile Viewport Adjustments (< 768px)
   ========================================================================== */
@media (max-width: 767.98px) {
    .topbar-xl-only {
        display: none !important;
    }
    .brand-text-long {
        display: none !important;
    }
    .brand-text-short {
        display: inline !important;
        font-size: 15px;
        font-weight: 800;
        color: #38bdf8;
    }
    #liveClock {
        display: none !important;
    }
    .topbar-desktop-only {
        display: none !important;
    }
    .preset-select {
        display: none !important;
    }
    .tab-label-short {
        display: inline !important;
    }
    .tab-label-full {
        display: none !important;
    }
    .menu-label-short {
        display: inline !important;
    }
    .menu-label-full {
        display: none !important;
    }
    .sub-cur-badge {
        display: inline-flex;
        align-items: center;
        gap: 3px;
        font-size: 11px;
        padding: 2px 7px;
        border-radius: 12px;
        font-weight: 600;
        white-space: nowrap;
    }
    .sub-full-text {
        display: none !important;
    }
    
    /* Topbar - Compact Glassmorphic Floating Header */
    .hud-topbar {
        top: 8px;
        left: 8px;
        right: 8px;
        height: 44px;
        padding: 0 10px;
        border-radius: 12px;
        background: rgba(15, 23, 42, 0.94);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.12);
        box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 6px;
        box-sizing: border-box;
        overflow: hidden;
        flex-wrap: nowrap;
    }
    .brand-section {
        gap: 6px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
    }
    .brand-pulse {
        width: 8px;
        height: 8px;
        flex-shrink: 0;
    }
    .topbar-controls {
        gap: 5px;
        display: flex;
        align-items: center;
        flex-shrink: 0;
    }
    .btn-hud {
        padding: 5px 9px;
        font-size: 11.5px;
        border-radius: 8px;
        border: 1px solid rgba(255, 255, 255, 0.12);
        white-space: nowrap;
        flex-shrink: 0;
    }
    .btn-hud.btn-sos {
        padding: 5px 10px;
        font-size: 11.5px;
        font-weight: 700;
        border-radius: 8px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .btn-hud.btn-menu {
        padding: 5px 10px;
        font-size: 11.5px;
        font-weight: 700;
        border-radius: 8px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Right Drawer - Mobile Full-Width Slide-Up Sheet */
    .hud-drawer-right {
        top: 56px;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        max-height: calc(100vh - 56px);
        border-radius: 20px 20px 0 0;
        border: 1px solid var(--hud-border);
        border-bottom: none;
        background: rgba(15, 23, 42, 0.97);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.9);
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease, visibility 0.35s ease;
        z-index: 180;
    }
    .hud-drawer-right:not(.collapsed) {
        transform: translateY(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }
    .hud-drawer-right.collapsed {
        transform: translateY(105vh) !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
    .drawer-toggle-btn {
        display: none !important;
    }
    .sheet-drag-handle {
        display: block !important;
    }
    .drawer-header {
        padding: 8px 14px;
    }
    .drawer-tabs {
        padding: 4px 6px;
        gap: 3px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .drawer-tabs::-webkit-scrollbar {
        display: none;
    }
    .drawer-tab-btn {
        padding: 6px 4px;
        font-size: 11px;
        border-radius: 14px;
        gap: 2px;
        white-space: nowrap;
        flex: 1 1 0;
        min-width: 0;
    }
    .drawer-body {
        padding: 10px 12px;
        gap: 8px;
    }

    /* Bottom Timeline Bar - Mobile Collapsed Floating Pill */
    .hud-bottom-timeline:not(.sheet-open) {
        left: 10px;
        right: 10px;
        bottom: 10px;
        padding: 0 12px 0 14px;
        border-radius: 9999px;
        height: 44px;
        max-height: 44px;
        background: rgba(15, 23, 42, 0.94);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(56, 189, 248, 0.35);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.65);
        cursor: pointer;
        overflow: hidden;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 100;
    }
    .hud-bottom-timeline:not(.sheet-open) .sheet-drag-handle {
        display: none !important;
    }
    .hud-bottom-timeline:not(.sheet-open) .timeline-main-row {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        width: 100%;
        height: 100%;
        margin: 0;
    }
    .hud-bottom-timeline:not(.sheet-open) .timeline-info {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        flex: 1;
        min-width: 0;
        height: 100%;
        margin: 0;
    }
    .hud-bottom-timeline:not(.sheet-open) .timeline-title {
        display: inline-flex;
        align-items: center;
        font-size: 12.5px;
        font-weight: 700;
        line-height: 1.25;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 145px;
        color: #f1f5f9;
        margin: 0;
        padding: 0;
    }
    .hud-bottom-timeline:not(.sheet-open) .tl-station-icon {
        font-size: 12.5px;
        line-height: 1;
        display: inline-block;
        margin-right: 3px;
        flex-shrink: 0;
    }
    .hud-bottom-timeline:not(.sheet-open) .tl-station-name {
        display: inline-block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.25;
    }
    .hud-bottom-timeline:not(.sheet-open) .timeline-sub {
        display: inline-flex;
        align-items: center;
        line-height: 1;
        margin: 0;
        padding: 0;
    }
    .hud-bottom-timeline:not(.sheet-open) .sub-cur-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 3px;
        font-size: 10.5px;
        line-height: 1;
        padding: 0 7px;
        height: 22px;
        border-radius: 11px;
        font-weight: 600;
        white-space: nowrap;
        box-sizing: border-box;
        margin: 0;
    }
    .hud-bottom-timeline:not(.sheet-open) .timeline-controls {
        display: none !important;
    }
    .hud-bottom-timeline:not(.sheet-open) .timeline-actions .timeline-tabs {
        display: none !important;
    }
    .hud-bottom-timeline:not(.sheet-open) #btnToggleDetailDrawer {
        font-size: 11px;
        padding: 0 10px;
        height: 26px;
        border-radius: 13px;
        background: rgba(56, 189, 248, 0.15);
        border: 1px solid var(--accent-blue);
        color: var(--accent-blue);
        font-weight: 600;
        white-space: nowrap;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
        margin: 0;
    }

    /* Bottom Timeline Bar - Mobile Expanded Bottom Sheet */
    .hud-bottom-timeline.sheet-open {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100vw;
        height: 75vh;
        max-height: 80vh;
        border-radius: 20px 20px 0 0;
        padding: 10px 14px 16px 14px;
        background: rgba(15, 23, 42, 0.98);
        border: 1px solid var(--hud-border);
        border-bottom: none;
        box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.92);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-direction: column;
        z-index: 150;
    }
    .hud-bottom-timeline.sheet-open .sheet-drag-handle {
        display: block !important;
        width: 36px;
        height: 4px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
        margin: 0 auto 8px auto;
        cursor: grab;
    }
    .hud-bottom-timeline.sheet-open .timeline-main-row {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        padding-bottom: 8px;
        height: auto;
    }
    .hud-bottom-timeline.sheet-open .timeline-info {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        min-width: 0;
    }
    .hud-bottom-timeline.sheet-open .timeline-title {
        font-size: 13.5px;
        font-weight: 700;
        color: #38bdf8;
    }
    .hud-bottom-timeline.sheet-open .timeline-controls {
        display: flex !important;
        height: 48px;
        width: 100%;
        position: relative;
    }
    .hud-bottom-timeline.sheet-open .timeline-actions {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
    .hud-bottom-timeline.sheet-open .timeline-tabs {
        display: flex !important;
        gap: 4px;
    }
    .hud-bottom-timeline.sheet-open .timeline-tab-btn {
        padding: 3px 8px;
        font-size: 10.5px;
        border-radius: 12px;
    }
    .hud-bottom-timeline.sheet-open #btnToggleDetailDrawer {
        font-size: 11px;
        padding: 3px 9px;
        border-radius: 14px;
    }

    /* Bottom Sheet Details Elements */
    .timeline-detail-drawer {
        gap: 8px;
        padding-top: 6px;
    }
    .detail-sheet-header {
        position: sticky;
        top: 0;
        background: rgba(15, 23, 42, 0.98);
        z-index: 10;
        padding: 4px 0 6px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }
    .station-pill-btn {
        font-size: 10px;
        padding: 2px 7px;
        border-radius: 14px;
    }
    .countdown-banner {
        padding: 6px 10px;
        font-size: 11px;
        border-radius: 8px;
        gap: 6px;
    }
    .countdown-timer-box {
        font-size: 11.5px;
        gap: 4px;
    }
    .countdown-pill {
        font-size: 10.5px;
        padding: 1px 5px;
    }
    #peakRiskAdvisory {
        font-size: 11px;
    }
    .telemetry-split-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .cross-section-card {
        padding: 6px 8px;
        border-radius: 8px;
    }
    .cross-section-visual {
        height: 30px;
        margin: 4px 0;
    }
    .cs-bank-tag, .cs-current-tag {
        font-size: 8.5px;
        padding: 1px 4px;
    }
    .stat-grid-4 {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 4px;
    }
    .stat-box {
        padding: 4px 2px;
        border-radius: 6px;
        text-align: center;
        background: rgba(30, 41, 59, 0.5);
    }
    .stat-box-title {
        font-size: 8.5px;
        color: #94a3b8;
        white-space: nowrap;
    }
    .stat-box-val {
        font-size: 11px;
        font-weight: 700;
        margin-top: 1px;
    }
    .table-filter-bar {
        padding: 2px 0;
        gap: 6px;
    }
    .table-filter-btn {
        padding: 3px 7px;
        font-size: 10px;
        border-radius: 12px;
    }
    .timeline-table-container {
        min-height: 200px;
        margin-bottom: 12px;
        border-radius: 6px;
    }
    .timeline-table th, .timeline-table td {
        padding: 4px 6px;
        font-size: 10.5px;
    }

    /* Map Controls adjustment */
    .leaflet-control-attribution {
        font-size: 8px !important;
        margin-bottom: 50px !important;
    }
}
