:root {
    --bg-dark: #f8fafc;
    --sidebar-bg: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.9);
    --border-color: rgba(0, 0, 0, 0.08);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-cyan: #0891b2;
    --accent-indigo: #4f46e5;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --btn-gradient: linear-gradient(135deg, #0891b2 0%, #4f46e5 100%);
    --overridden-bg: #fffbeb;
    --overridden-border: #f59e0b;
}

@keyframes pulseRed {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.glass-panel {
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
}

.glass-card-mini {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card-mini:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.sidebar-header {
    padding: 2rem 1.5rem;
}

.logo {
    font-size: 1.4rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    background: var(--btn-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    transition: 0.2s;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(79, 70, 229, 0.05);
    color: var(--accent-indigo);
}

.nav-item.active {
    box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.2);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Changed from auto to allow internal views to manage scroll */
    position: relative;
    padding: 1.5rem 2rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.topbar h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.75rem;
    color: #111827;
}

/* Views Visibility */
.content-view {
    display: none;
    height: 100%;
    flex-direction: column;
    overflow-y: auto;
}

.content-view.active {
    display: flex !important;
}

/* Bridge Layout */
.bridge-container {
    display: flex;
    flex-direction: column;
    /* dvh accounts for mobile browser chrome; falls back to vh */
    height: calc(100dvh - 100px);
    min-height: 560px;
    position: relative;
    transition: all 0.7s cubic-bezier(0.19, 1, 0.22, 1);
}

@supports not (height: 100dvh) {
    .bridge-container {
        height: calc(100vh - 100px);
    }
}

/* SETUP MODE */
.bridge-container.setup-mode {
    justify-content: center;
    align-items: center;
}

.bridge-container.setup-mode .control-panel {
    width: 480px;
    transform: scale(1.05);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
}

.bridge-container.setup-mode .display-area {
    display: none;
}

/* RESULT MODE */
.bridge-container.result-mode {
    display: flex;
    flex-direction: row;
    /* Sidebar left, Content right */
    gap: 1.5rem;
}

.bridge-container.result-mode .control-panel {
    width: 320px;
    flex-shrink: 0;
    transition: all 0.5s ease;
}

.bridge-container.result-mode .display-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    height: 100%;
    min-width: 0;
    /* Important for flex children to shrink/reflow */
    overflow: hidden;
}

/* When monitoring tab is active — full-width immersive mode */
.bridge-container.result-mode:has(#tab-monitoring.active) .control-panel {
    display: none;
}

/* ── Monitoring: full-height immersive mode ── */

/* Hide the KPI summary bar (fuel/dist/time) to free vertical space */
.bridge-container.result-mode:has(#tab-monitoring.active) .display-area {
    gap: 0;
}

.bridge-container.result-mode:has(#tab-monitoring.active) .result-summary-bar {
    display: none !important;
}

/* #calc-result fills entire display-area */
.bridge-container.result-mode:has(#tab-monitoring.active) #calc-result {
    position: relative;
    flex: 1;
    min-height: 0;
    gap: 0;
}

/* Tabs nav floats as a centred pill over the map */
.bridge-container.result-mode:has(#tab-monitoring.active) #calc-result .result-tabs-nav {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    padding: 0.25rem 0.4rem;
    gap: 0.2rem;
    width: auto;
    white-space: nowrap;
    border-radius: 0.75rem;
}

.bridge-container.result-mode:has(#tab-monitoring.active) #calc-result .tab-btn {
    padding: 0.28rem 0.85rem;
    font-size: 0.76rem;
}

/* Cards & Forms */
.control-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: all 0.6s cubic-bezier(0.19, 1, 0.22, 1);
}

.control-panel form {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-step {
    display: none;
    flex-direction: column;
    gap: 1.25rem;
}

.form-step.active {
    display: flex;
    animation: slideUp 0.4s ease-out;
}

/* Tabs Results */
.result-tabs-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.03);
    padding: 0.4rem;
    border-radius: 0.75rem;
}

.tab-btn {
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: 0.2s;
    white-space: nowrap;
}

.tab-btn.active {
    background: #ffffff;
    color: var(--accent-indigo);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.tab-content {
    display: none;
    flex: 1;
    overflow: auto;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
    min-height: 0;
}

/* ════════════════════════════════════════════
   MONITORING TRIPTYCH: Past | Present | Future
   ════════════════════════════════════════════ */

/* Monitoring tab fills available space */
#tab-monitoring.active {
    flex: 1;
    min-height: 0;
}

/* Main 3-column container */
.monitoring-triptych {
    display: flex;
    width: 100%;
    height: 100%;
    gap: 0;
    min-height: 0;
}

/* Generic column */
.tri-col {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Left & Right side panels */
.tri-past,
.tri-future {
    width: clamp(200px, 18vw, 260px);
    flex-shrink: 0;
    background: rgba(248, 250, 252, 0.97);
    backdrop-filter: blur(8px);
    border: 1px solid #e2e8f0;
    padding: 12px;
    gap: 10px;
    overflow-y: auto;
    overflow-x: hidden;
}

.tri-past {
    border-radius: 1rem 0 0 1rem;
    border-right: none;
}

.tri-future {
    border-radius: 0 1rem 1rem 0;
    border-left: none;
}

/* Center map column */
.tri-present {
    flex: 1;
    min-width: 0;
    position: relative;
}

.tri-map-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.tri-map-wrapper #monitoring-map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Column headers */
.tri-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 0 6px;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 4px;
    flex-shrink: 0;
}

.tri-header-icon {
    color: var(--accent-indigo);
    font-weight: 900;
}

/* Vessel badge in left column */
.tri-vessel-badge {
    background: #fff;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
}

/* Scrollable legs list */
.tri-legs-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 2px;
    scroll-behavior: smooth;
}

.tri-legs-scroll::-webkit-scrollbar {
    width: 4px;
}

.tri-legs-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.tri-empty-state {
    text-align: center;
    color: #94a3b8;
    padding: 20px 8px;
    font-size: 0.7rem;
    font-style: italic;
}

/* Leg card in side columns */
.tri-leg-card {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #f1f5f9;
    background: #fff;
    transition: all 0.2s;
    cursor: default;
}

.tri-leg-card:hover {
    border-color: #a5b4fc;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
    transform: translateX(2px);
    cursor: pointer;
}

.tri-leg-card.current {
    border-color: #86efac;
    background: #f0fdf4;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
}

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

.tri-leg-name {
    font-size: 0.65rem;
    font-weight: 700;
    color: #1e293b;
}

.tri-leg-dist {
    font-size: 0.5rem;
    color: #94a3b8;
}

.tri-leg-detail {
    font-size: 0.58rem;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tri-leg-bar {
    flex: 1;
    height: 3px;
    background: #e2e8f0;
    border-radius: 1.5px;
    overflow: hidden;
}

.tri-leg-bar-fill {
    height: 100%;
    border-radius: 1.5px;
    transition: width 0.3s;
}

/* Summary blocks (bottom of columns) */
.tri-summary,
.tri-forecast {
    background: #fff;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.tri-summary-title {
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 6px;
}

.tri-summary-grid,
.tri-forecast-grid {
    display: grid;
    gap: 4px;
}

.tri-summary-grid {
    grid-template-columns: 1fr 1fr 1fr;
}

.tri-forecast-grid {
    grid-template-columns: 1fr 1fr;
}

.tri-label {
    font-size: 0.55rem;
    color: #94a3b8;
    display: block;
}

.tri-val {
    font-size: 0.75rem;
    font-weight: 800;
    color: #1e293b;
    display: block;
}

/* Recommendation card */
.tri-recommendation {
    background: linear-gradient(135deg, #6366f1dd, #8b5cf6bb);
    padding: 10px 12px;
    border-radius: 10px;
    color: white;
    flex-shrink: 0;
}

.tri-rec-label {
    font-size: 0.55rem;
    text-transform: uppercase;
    opacity: 0.7;
    font-weight: 700;
    margin-bottom: 3px;
}

.tri-rec-text {
    font-size: 0.75rem;
    font-weight: 700;
}

/* Fuel bar */
.tri-fuel-bar {
    background: #fff7ed;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #ffedd5;
    flex-shrink: 0;
}

.tri-fuel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #9a3412;
    margin-bottom: 4px;
}

.tri-fuel-input {
    width: 45px;
    padding: 2px 4px;
    border: 1px solid #fdba74;
    border-radius: 4px;
    font-weight: 700;
    color: #9a3412;
    font-size: 0.7rem;
    text-align: center;
}

.tri-fuel-track {
    height: 4px;
    background: #ffedd5;
    border-radius: 2px;
    overflow: hidden;
}

.tri-fuel-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #f59e0b, #ef4444);
    border-radius: 2px;
    transition: width 1s;
}

.tri-fuel-pct {
    text-align: right;
    font-size: 0.6rem;
    font-weight: 700;
    color: #c2410c;
    margin-top: 2px;
}

/* Notes block */
.tri-notes-block {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.tri-notes-block textarea {
    flex: 1;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    font-size: 0.7rem;
    resize: none;
    font-family: inherit;
}

.tri-notes-block button {
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--accent-indigo);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.8rem;
}

/* ═══ MAP HUD (floating over map) ═══ */
.tri-hud {
    position: absolute;
    top: 54px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 5;
}

.tri-hud-card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    min-width: 120px;
}

.tri-hud-label {
    font-size: 0.5rem;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.tri-hud-value {
    font-size: 1.1rem;
    font-weight: 900;
    color: #1e293b;
    line-height: 1.2;
}

.tri-hud-value small {
    font-size: 0.55rem;
    font-weight: 500;
    color: #64748b;
}

.tri-hud-sub {
    font-size: 0.6rem;
    color: #64748b;
    font-weight: 600;
}

/* ═══ PROGRESS BAR OVERLAY (bottom of map) ═══ */
.tri-progress-overlay {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    z-index: 5;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border-radius: 10px;
    padding: 8px 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.tri-progress-bar-bg {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.tri-progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 3px;
    transition: width 2s ease;
}

.tri-progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.6rem;
    color: #64748b;
    font-weight: 600;
    margin-top: 3px;
}

/* ═══ PROJECTION SLIDER (top-left of map, below OL zoom controls) ═══ */
.tri-proj-slider {
    position: absolute;
    top: 90px;
    left: 12px;
    z-index: 6;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border-radius: 10px;
    padding: 6px 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tri-proj-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: #64748b;
    white-space: nowrap;
}

.tri-proj-slider input[type="range"] {
    width: 100px;
    cursor: pointer;
    accent-color: var(--accent-indigo);
}

.tri-proj-val {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--accent-indigo);
    min-width: 40px;
    text-align: right;
}

/* ═══ HISTORY PLAYER ═══ */
.tri-history-player {
    display: none;
    position: absolute;
    bottom: 72px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    padding: 10px 14px;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    z-index: 10;
    width: auto;
    min-width: 300px;
    max-width: 440px;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.tri-play-btn {
    background: var(--accent-indigo);
    color: white;
    border: none;
    border-radius: 10px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 3px 10px rgba(79, 70, 229, 0.3);
    flex-shrink: 0;
}

.tri-player-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.tri-player-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.tri-player-time {
    font-size: 0.9rem;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.tri-player-sub {
    font-size: 0.62rem;
    color: #64748b;
    line-height: 1.2;
}

.tri-player-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

.tri-player-slider {
    width: 100%;
    accent-color: var(--accent-indigo);
    display: block;
}

.tri-speed-select {
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-size: 0.75rem;
    font-weight: 600;
    background: white;
}

.tri-live-btn {
    background: #fef2f2;
    color: #ef4444;
    border: 1px solid #fee2e2;
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.75rem;
    cursor: pointer;
}

/* ═══ SPEED HEATMAP LEGEND ═══ */
.tri-speed-legend {
    position: absolute;
    bottom: 70px;
    right: 12px;
    z-index: 5;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    padding: 6px 10px;
    transition: bottom 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    min-width: 100px;
}

.tri-legend-title {
    font-size: 0.5rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 4px;
    text-align: center;
    letter-spacing: 0.05em;
}

.tri-legend-gradient {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #ef4444, #f97316, #eab308, #10b981, #06b6d4, #3b82f6);
}

.tri-legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.45rem;
    color: #94a3b8;
    font-weight: 600;
    margin-top: 2px;
}

/* ═══ SIGNAL LOST STATE ═══ */
.signal-lost .tri-hud-card {
    opacity: 0.6;
    border-color: #94a3b8;
}

.signal-lost .tri-hud-speed {
    border-left: 3px solid #94a3b8;
}

@keyframes pulse-signal {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ═══ RESPONSIVE: FHD / Laptop Adaptations ═══ */

/* Narrow viewports (≤1400px): tighten side panels */
@media (max-width: 1400px) {
    .tri-past,
    .tri-future {
        padding: 8px;
        gap: 7px;
    }

    .tri-header {
        padding: 6px 0 4px;
        font-size: 0.65rem;
    }

    .tri-summary,
    .tri-forecast {
        padding: 8px;
    }

    .tri-recommendation {
        padding: 8px 10px;
    }

    .tri-fuel-bar {
        padding: 7px 9px;
    }

    .tri-leg-card {
        padding: 5px 7px;
    }
}

/* Short viewports (≤800px height): compress vertical spacing */
@media (max-height: 800px) {
    .tri-header {
        padding: 5px 0 3px;
        font-size: 0.62rem;
    }

    .tri-vessel-badge {
        padding: 6px 8px;
    }

    .tri-summary,
    .tri-forecast {
        padding: 7px 8px;
    }

    .tri-recommendation {
        padding: 7px 9px;
    }

    .tri-fuel-bar {
        padding: 6px 8px;
    }

    .tri-notes-block textarea {
        rows: 1;
        min-height: 32px;
    }

    /* HUD: smaller cards */
    .tri-hud-card {
        padding: 6px 9px;
        min-width: 100px;
    }

    .tri-hud-value {
        font-size: 0.95rem;
    }

    .tri-hud {
        gap: 4px;
    }
}

/* Very short viewports (≤680px): HUD switches to horizontal row at top */
@media (max-height: 680px) {
    .tri-hud {
        flex-direction: row;
        flex-wrap: wrap;
        top: 54px;
        right: 8px;
        left: auto;
        max-width: 65%;
        gap: 4px;
        align-items: flex-start;
    }

    .tri-hud-card {
        padding: 4px 8px;
        min-width: 80px;
        flex-shrink: 0;
    }

    .tri-hud-value {
        font-size: 0.85rem;
    }

    .tri-hud-sub {
        display: none;
    }

    .tri-past,
    .tri-future {
        width: clamp(170px, 16vw, 220px);
        padding: 6px;
        gap: 5px;
    }

    .tri-proj-slider {
        top: 70px;
        padding: 4px 8px;
    }

    .tri-speed-legend {
        bottom: 60px;
    }

    .tri-history-player {
        bottom: 62px;
        padding: 8px 12px;
    }
}

/* When history player is active, push speed-legend above it if needed on narrow maps.
   Proj-slider is now at top-left, so it never conflicts with the bottom overlays.
   Player is ~94px tall at bottom 72px → top at ~166px; legend goes above at 180px. */
@media (max-width: 1100px) {
    .tri-map-wrapper.playback-active .tri-speed-legend {
        bottom: 180px;
    }
}

/* ─── Width-based responsive breakpoints ─── */

/* Moderate narrow (≤1200px): slightly tighter panels */
@media (max-width: 1200px) {
    .tri-past,
    .tri-future {
        width: clamp(180px, 16vw, 220px);
    }
}

/* Laptop (≤1024px): reduce panels, compress HUD */
@media (max-width: 1024px) {
    .tri-past,
    .tri-future {
        width: clamp(160px, 15vw, 195px);
        padding: 8px 6px;
        gap: 6px;
    }
    .tri-hud {
        top: 54px;
        right: 8px;
        gap: 4px;
    }
    .tri-hud-card {
        padding: 6px 8px;
        min-width: 100px;
    }
    .tri-hud-value {
        font-size: 0.95rem;
    }
    .tri-leg-name {
        font-size: 0.62rem;
    }
    .tri-leg-detail {
        font-size: 0.55rem;
    }
    .tri-history-player {
        max-width: 400px;
        padding: 8px 12px;
    }
    .tri-proj-slider input[type="range"] {
        width: 80px;
    }
}

/* Small laptop / tablet landscape (≤900px): minimal panels */
@media (max-width: 900px) {
    .tri-past,
    .tri-future {
        width: clamp(130px, 14vw, 160px);
        padding: 6px 5px;
        gap: 5px;
    }
    .tri-vessel-badge {
        display: none;
    }
    .tri-notes-block {
        display: none;
    }
    .tri-history-player {
        max-width: 360px;
        min-width: 280px;
        padding: 7px 10px;
    }
    .tri-proj-slider {
        padding: 4px 8px;
    }
    .tri-proj-slider input[type="range"] {
        width: 60px;
    }
    .tri-proj-label {
        display: none;
    }
    .tri-hud-card {
        min-width: 85px;
        padding: 5px 6px;
    }
    .tri-hud-value {
        font-size: 0.85rem;
    }
}

/* Mobile / very narrow (≤768px): stack vertically */
@media (max-width: 768px) {
    .monitoring-triptych {
        flex-direction: column;
    }
    .tri-past,
    .tri-future {
        width: 100%;
        max-height: 120px;
        min-height: 80px;
        flex-shrink: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        overflow-y: hidden;
    }
    .tri-past {
        border-top: 1px solid #e2e8f0;
        border-bottom: none;
        border-radius: 0;
    }
    .tri-future {
        border-top: none;
        border-bottom: 1px solid #e2e8f0;
        border-radius: 0;
    }
    .tri-legs-scroll {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 6px;
    }
    .tri-leg-card {
        flex-shrink: 0;
        width: 140px;
    }
    .tri-summary,
    .tri-forecast,
    .tri-recommendation,
    .tri-fuel-bar {
        display: none;
    }
    .tri-present {
        min-height: 280px;
        flex: 1;
    }
    .tri-hud {
        flex-direction: row;
        flex-wrap: wrap;
        top: 54px;
        right: 6px;
        max-width: 75%;
        gap: 3px;
    }
    .tri-hud-card {
        min-width: 80px;
        padding: 4px 6px;
        flex-shrink: 0;
    }
    .tri-hud-sub {
        display: none;
    }
    .tri-history-player {
        width: calc(100% - 24px);
        max-width: none;
        min-width: 0;
        bottom: 60px;
        padding: 8px 10px;
    }
    .tri-progress-overlay {
        bottom: 4px;
        padding: 5px 8px;
    }
    .tri-proj-slider,
    .tri-speed-legend {
        display: none;
    }
}

/* Map Popup Redesign */
.ol-popup {
    position: absolute;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    padding: 1.25rem;
    border-radius: 1.25rem;
    border: 1px solid var(--border-color);
    bottom: 45px;
    left: -50px;
    min-width: 240px;
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ol-popup:after,
.ol-popup:before {
    top: 100%;
    border: solid transparent;
    content: " ";
    height: 0;
    width: 0;
    position: absolute;
    pointer-events: none;
}

.ol-popup:after {
    border-top-color: rgba(255, 255, 255, 0.9);
    border-width: 10px;
    left: 48px;
    margin-left: -10px;
}

.ol-popup:before {
    border-top-color: var(--border-color);
    border-width: 11px;
    left: 48px;
    margin-left: -11px;
}

.popup-title {
    font-weight: 800;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.popup-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.popup-stat span {
    color: var(--text-secondary);
}

.popup-stat b {
    color: var(--text-primary);
}

.popup-stat input {
    width: 60px;
    padding: 4px 8px;
    font-size: 0.85rem;
    height: auto;
    text-align: right;
    border-radius: 6px;
}

.popup-closer {
    position: absolute;
    top: 12px;
    right: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.popup-closer:hover {
    color: var(--text-primary);
}

/* Legend Dots */
.dot {
    height: 10px;
    width: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
}

.dot.super {
    background-color: #06b6d4;
    box-shadow: 0 0 5px #06b6d4;
}

.dot.fast {
    background-color: #22c55e;
    box-shadow: 0 0 5px #22c55e;
}

.dot.mid {
    background-color: #eab308;
    box-shadow: 0 0 5px #eab308;
}

.dot.slow {
    background-color: #ef4444;
    box-shadow: 0 0 5px #ef4444;
}

.dot.lock {
    background-color: #0f172a;
    border: 1px solid white;
}

/* Tab Content Fixes */
/* Overrides Tracker Panel */
.overrides-panel {
    background: #ffffff;
    border: 1px solid var(--overridden-border);
    border-radius: 1rem;
    padding: 1rem;
    margin-bottom: 0;
    max-height: 200px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.1);
}

.overrides-panel .panel-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    color: #92400e;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.overrides-panel .badge {
    background: #f59e0b;
    color: white;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 0.7rem;
}

.overrides-list {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.override-chip {
    flex-shrink: 0;
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: 0.2s;
    font-weight: 500;
}

.override-chip:hover {
    background: #fef3c7;
    border-color: #f59e0b;
}

.map-view {
    position: relative;
    flex: 1;
    border-radius: 1.25rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
    min-height: 0;
    background: #f1f5f9;
}

.map-view #map,
.map-view #map-audit {
    width: 100%;
    height: 100%;
    min-height: 450px;
}

.table-view {
    flex: 1;
    overflow-y: auto;
    background: var(--card-bg);
    border-radius: 1.25rem;
    border: 1px solid var(--border-color);
    min-height: 0;
    padding-bottom: 2rem;
}

/* Ensure table cards fill height and scroll internally */
.table-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--card-bg);
    border-radius: 1.25rem;
    border: 1px solid var(--border-color);
}

.table-responsive {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    position: sticky;
    top: 0;
    background: #f1f5f9;
    padding: 1rem;
    text-align: left;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: #334155;
    transition: background 0.2s;
}

/* Interactive Row Highlighting */
tr.overridden td {
    background: var(--overridden-bg) !important;
    color: #92400e;
}

tr.highlighted td {
    background: rgba(79, 70, 229, 0.1) !important;
}

/* Inline Inputs */
.editable-cell {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid transparent;
    transition: 0.2s;
}

.editable-cell:hover {
    background: rgba(0, 0, 0, 0.02);
    border-color: var(--border-color);
}

.editable-cell:focus {
    outline: none;
    background: #ffffff;
    border-color: var(--accent-indigo);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.charts-view {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding-bottom: 2rem;
}

.chart-card {
    background: var(--card-bg);
    border-radius: 1.25rem;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 380px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.chart-card h3 {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0;
}

.chart-container {
    flex: 1;
    min-height: 0;
}

/* Summary */
.result-summary-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.summary-item {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.summary-item .value {
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
}

/* Buttons & Utils */
.btn {
    padding: 0.85rem 1.5rem;
    border-radius: 0.75rem;
    border: none;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: 0.2s;
}

.btn-primary {
    background: var(--btn-gradient);
    color: white;
}

.btn-sm {
    background: #ffffff;
    color: #475569;
    border: 1px solid var(--border-color);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Map & Legend */
.map-legend {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 10px;
    display: flex;
    gap: 15px;
    z-index: 10;
    font-size: 0.7rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
}

.form-group label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

input,
select {
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 0.8rem;
    padding: 0.85rem 1rem;
    color: #1e293b;
    transition: 0.2s;
}

input:focus,
select:focus {
    border-color: var(--accent-indigo);
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Map layer inversion REMOVED for light theme */
.ol-layer canvas {
    filter: none;
}

/* Admin Enhancements */
.admin-users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    padding: 1rem 0;
}

.user-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 1.25rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.user-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 20px -8px rgba(0, 0, 0, 0.08);
    border-color: var(--accent-indigo);
}

.user-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.user-card-avatar {
    width: 48px;
    height: 48px;
    background: var(--btn-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
}

.user-card-info h4 {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.user-card-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.user-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
}

/* Glass Modal Update */
.modal-content.glass-modal {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

.role-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 2rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.role-admin {
    background: #fee2e2;
    color: #991b1b;
}

.role-manager {
    background: #e0f2fe;
    color: #075985;
}

.role-captain {
    background: #f0fdf4;
    color: #166534;
}

.role-sa {
    background: #faf5ff;
    color: #6b21a8;
}

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

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
}

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

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

input:focus+.slider {
    box-shadow: 0 0 1px var(--accent-indigo);
}

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

/* Rounded sliders */
.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Dashboard 2.0 Styles */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card-premium {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 160px;
}

.stat-card-premium:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: var(--accent-indigo);
}

.stat-card-premium.highlight {
    background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
    color: white;
    border: none;
}

.stat-card-premium.highlight .stat-label {
    color: rgba(255, 255, 255, 0.8);
}

.stat-card-premium.highlight .stat-value {
    color: white;
}

.stat-card-premium.highlight .stat-icon {
    color: rgba(255, 255, 255, 0.2);
}

.stat-icon {
    position: absolute;
    right: -10px;
    bottom: -10px;
    font-size: 5rem;
    color: rgba(0, 0, 0, 0.03);
    transform: rotate(-15deg);
    transition: 0.3s;
    pointer-events: none;
}

.stat-card-premium:hover .stat-icon {
    transform: rotate(0deg) scale(1.1);
    color: rgba(79, 70, 229, 0.1);
}

.stat-card-premium.highlight:hover .stat-icon {
    color: rgba(255, 255, 255, 0.3);
}

.stat-label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    z-index: 2;
}

.stat-value {
    font-family: 'Outfit', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    margin-top: 0.5rem;
    color: var(--text-primary);
    z-index: 2;
}

.stat-trend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: auto;
    z-index: 2;
}

.trend-up {
    color: var(--accent-success);
}

.trend-down {
    color: var(--accent-warning);
    /* Using warning as generic down, red is too harsh */
}

/* Analytics Dashboard */
.analytics-header {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

.analytics-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}

.analytics-title-row h2 {
    font-size: 1.35rem;
    margin: 0;
    font-weight: 700;
}

.analytics-period-btns {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.period-btn {
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: #f8fafc;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.period-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #2563eb;
}

.period-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
    font-weight: 600;
}

.analytics-filter-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.analytics-date-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.analytics-date-input {
    width: 145px;
    font-size: 0.875rem;
}

.analytics-date-sep {
    color: var(--text-secondary);
}

.analytics-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

@media (max-width: 900px) {
    .analytics-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

.analytics-kpi-card {
    background: var(--kpi-bg, #f8fafc);
    border: 1px solid color-mix(in srgb, var(--kpi-color, #94a3b8) 20%, transparent);
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: box-shadow 0.2s;
}

.analytics-kpi-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.analytics-kpi-card .kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--kpi-color, #94a3b8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.analytics-kpi-card .kpi-body {
    flex: 1;
    min-width: 0;
}

.analytics-kpi-card .kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    font-family: 'Outfit', sans-serif;
}

.analytics-kpi-card .kpi-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 2px;
}

.analytics-charts-3col {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}

@media (max-width: 900px) {
    .analytics-charts-3col { grid-template-columns: 1fr; }
}

.analytics-chart-wide,
.analytics-chart-narrow {
    height: auto;
    min-height: 420px;
}

/* Chart card variants: flex-start prevents last child sticking to bottom */
.stat-card-premium.analytics-chart-wide,
.stat-card-premium.analytics-chart-narrow {
    justify-content: flex-start;
    gap: 12px;
}

.chart-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 14px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-container {
    position: relative;
    width: 100%;
}

/* ── Voyage Analytics Period Filter ── */
.voyage-period-filter {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.voyage-period-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* ── Utility Classes ── */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.gap-8 { gap: 32px; }

.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }

.text-xs { font-size: 0.75rem; line-height: 1.1; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }

.upper {
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent-indigo); }
.text-success { color: var(--accent-success); }
.text-warning { color: var(--accent-warning); }

.opacity-70 { opacity: 0.7; }
.opacity-50 { opacity: 0.5; }
.w-full { width: 100%; }

/* Economy Section */
.economy-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-placeholder {
    width: 100%;
    height: 200px;
    background: linear-gradient(to right, #f1f5f9 0%, #f8fafc 100%);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 0.9rem;
    position: relative;
    overflow: hidden;
}

/* Simple CSS Bar Chart for "System Load" */
.css-bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 120px;
    padding-top: 20px;
}

.css-bar {
    flex: 1;
    background: var(--accent-indigo);
    border-radius: 4px 4px 0 0;
    opacity: 0.2;
    transition: 0.3s;
}

.css-bar:hover {
    opacity: 0.8;
}

.css-bar.active {
    opacity: 1;
    background: var(--btn-gradient);
}



.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Modal Overlay */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 5000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ffffff;
    border-radius: 1.25rem;
    padding: 1.5rem 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 90%;
    max-width: 600px;
    animation: slideUp 0.3s ease-out;
}

.modal-content h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.modal-content .close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

.modal-content .close:hover {
    color: var(--text-primary);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }

}

/* Map Picker */
.map-picker-btn {
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 0;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    width: 42px;
    min-width: 42px;
    flex-shrink: 0;
    color: #64748b;
}

.map-picker-btn:hover {
    background: #f1f5f9;
    color: var(--accent-indigo);
    border-color: var(--accent-indigo);
}

#map-picker-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
}

.map-picker-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 900px;
    height: 80%;
    background: white;
    border-radius: 1.5rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.map-picker-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.map-picker-body {
    flex: 1;
    position: relative;
    background: #f8fafc;
}

#map-picker-canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.map-picker-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
}

.map-picker-info {
    font-size: 0.9rem;
    color: #475569;
}

.map-picker-hint {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.8);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 10;
}
/* ---- Round-trip toggle ---- */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #cbd5e1;
    border-radius: 22px;
    transition: .2s;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px; width: 16px;
    left: 3px; bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: .2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent-cyan); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); }

/* ---- Map direction filter bar ---- */
.map-direction-filter-bar {
    display: none; /* shown via JS only for round-trip */
    padding: 6px 10px;
    gap: 6px;
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.map-dir-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-right: 4px;
    white-space: nowrap;
}
.map-dir-btn {
    padding: 4px 12px;
    font-size: 0.78rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .15s;
    line-height: 1.4;
}
.map-dir-btn:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); background: rgba(6,182,212,0.06); }
.map-dir-btn.active { background: var(--accent-cyan); color: white; border-color: var(--accent-cyan); font-weight: 600; }

/* ---- Return leg divider in table ---- */
.return-leg-divider td {
    background: rgba(6,182,212,0.08);
    color: var(--accent-cyan);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    text-align: left;
    border-top: 2px dashed var(--accent-cyan);
    border-bottom: 1px solid var(--accent-cyan);
}
