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

/* ── Theme custom properties ── */
:root {
    --accent: #DA5C57;
    --accent-dark: #B84743;
    --bg: #ffffff;
    --bg-hover: #f5f5f5;
    --surface: #f8f9fa;
    --surface-2: #f0f9ff;
    --text: #333333;
    --text-muted: #666666;
    --text-light: #9ca3af;
    --border: #e5e7eb;
    --border-hover: #d1d5db;
    --border-light: #f0f0f0;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-md: rgba(0, 0, 0, 0.15);
    --gallery-bg: rgba(255, 255, 255, 0.3);
}

[data-theme="night"] {
   /* --accent: #cc2200;
    --accent-dark: #991a00; */
    --bg: #0d0000;
    --bg-hover: #1f0505;
    --surface: #1a0505;
    --surface-2: #200808;
    --text: #f0f0f0;
    --text-muted: #aaaaaa;
    --text-light: #666666;
    --border: #330808;
    --border-hover: #440a0a;
    --border-light: #1f0505;
    --shadow: rgba(0, 0, 0, 0.4);
    --shadow-md: rgba(0, 0, 0, 0.5);
    --gallery-bg: rgba(13, 0, 0, 0.5);
    /* Tell the browser this is a dark UI so its native widgets
       (date/time picker indicators, select chevrons, scrollbars,
       and any other UA-controlled chrome) render their dark-theme
       variants. Without this the calendar/clock icons inside the
       planning modal's <input type="date|time"> stay dark-on-dark
       and become invisible. */
    color-scheme: dark;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--bg);
    padding: 0.6rem 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1100;
    position: relative;
}

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

.logo-link {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.header-logo {
    height: 38px;
    width: auto;
}

.logo h1 {
    font-size: 1.4rem;
    color: var(--accent);
    margin-bottom: 0.1rem;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Hamburger Menu */
.header-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.header-menu {
    display: flex;
    align-items: center;
}

.menu-btn {
    flex-shrink: 0;
}

/* Side panel (desktop) */
.menu-dropdown {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    background: var(--bg);
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
}

.menu-dropdown.open {
    transform: translateX(0);
}

.menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

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

.menu-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.menu-panel-title {
    font-weight: 600;
    color: var(--text);
    font-size: 1rem;
}

.menu-close-btn {
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 0.3rem;
    transition: color 0.15s ease;
}

.menu-close-btn:hover {
    color: var(--text);
}

.menu-item {
    display: block;
    width: 100%;
    padding: 0.9rem 1.1rem;
    text-align: left;
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease;
}

.menu-item:hover {
    background: var(--surface);
}

.menu-item + .menu-item {
    border-top: 1px solid var(--border);
}

/* Mobile: full-screen menu */
@media (max-width: 1000px) {
    .menu-dropdown {
        width: 100vw;
        border-right: none;
    }
    .menu-backdrop {
        display: none;
    }
}

/* Icon Button */
.btn-icon {
    background: var(--bg);
    color: var(--accent);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-icon:active {
    transform: translateY(0) scale(0.98);
}

/* Language Selector */
/* ── Language switcher ─────────────────────────────────────────── */
.lang-switcher {
    position: relative;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    border: none;
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.2s;
    white-space: nowrap;
}

.lang-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.lang-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

/* Remove the browser's default focus rectangle that appears around an SVG
   polyline (Leaflet path) for one frame after a click — it shows up as a
   thin black bounding box around the selected route leg. */
.leaflet-interactive:focus,
.leaflet-container svg path:focus,
.leaflet-container svg:focus {
    outline: none;
}

.lang-flag {
    width: 1.5em;
    height: 1.1em;
    border-radius: 2px;
    flex-shrink: 0;
    vertical-align: middle;
}

.lang-code {
    letter-spacing: 0.04em;
}

.lang-chevron {
    opacity: 0.6;
    transition: transform 0.2s;
}

.lang-switcher[aria-expanded="true"] .lang-chevron {
    transform: rotate(180deg);
}

.lang-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    list-style: none;
    margin: 0;
    padding: 0.3rem;
    min-width: 90px;
    z-index: 3000;
    animation: fadeIn 0.15s ease;
}

.lang-switcher[aria-expanded="true"] .lang-dropdown {
    display: block;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.65rem;
    border-radius: 7px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    transition: background 0.15s;
    list-style: none;
}

.lang-option::marker,
.lang-dropdown li::marker {
    content: '';
    display: none;
}

.lang-option:hover,
.lang-option[aria-selected="true"] {
    background: var(--bg-secondary, rgba(102,126,234,0.1));
}

.lang-option[aria-selected="true"] {
    font-weight: 700;
    color: var(--accent);
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #4ade80;
    color: white;
}

.btn-secondary:hover {
    background: #22c55e;
    transform: translateY(-2px);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* Responsive Header */
@media (max-width: 480px) {
    .header {
        padding: 0.5rem 1rem;
    }

    .logo h1 {
        font-size: 1.2rem;
    }

    .subtitle {
        font-size: 0.7rem;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Sidebar - now positioned at top */
.sidebar {
    width: 100%;
    background: var(--bg);
    padding: 0;
    overflow-y: visible;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 500;
    display: none; /* Hidden by default on desktop */
}

/* Show sidebar only when it has been revealed */
.sidebar.visible {
    display: block;
}

/* Hide sidebar when planning modal is active on desktop */
body:has(.planning-modal.active) .sidebar {
    display: none;
}

/* Floating "Plan a route" button (desktop fallback when no route is set
   and the planning modal is closed). Lets the user reopen the planner. */
.open-planner-fab {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 600;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 999px;
    padding: 0.65rem 1.1rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    display: none; /* hidden by default; shown via JS / state classes */
    transition: background 0.15s ease, transform 0.1s ease;
}

.open-planner-fab:hover {
    background: var(--accent-dark);
}

.open-planner-fab:active {
    transform: translateY(1px);
}

/* Hide the FAB whenever the modal is open or sidebar is showing route info */
body:has(.planning-modal.active) .open-planner-fab,
body:has(.sidebar.route-active) .open-planner-fab,
body:has(.sidebar.editing-mode) .open-planner-fab {
    display: none !important;
}

/* Bottom Panel */
.bottom-panel {
    position: absolute;
    bottom: 0;
    right: 0;
    left: 0;
    background: var(--bg);
    padding: 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
}

.panel {
    background: var(--bg);
    padding: 0.7rem;
    border-radius: 0;
    margin-bottom: 0;
    box-shadow: none;
    border-bottom: none;
}

.panel:last-child {
    border-bottom: none;
}

.panel h2 {
    font-size: 1rem;
    color: var(--accent);
    margin-bottom: 0.6rem;
}

.panel h2 {
    font-size: 1.3rem;
    color: var(--accent);
    margin-bottom: 1.5rem;
}

.panel h3 {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 1rem;
}

/* Route Inputs with Swap Button */
.route-inputs {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
}

.swap-btn {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg);
    border: 2px solid var(--accent);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--accent);
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.swap-btn:hover {
    background: var(--accent);
    color: white;
    transform: translate(-50%, -50%) rotate(180deg);
}

.swap-btn:active {
    transform: translate(-50%, -50%) scale(0.95);
}

/* Form Elements */
.form-group {
    margin-bottom: 0.5rem;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.form-control {
    width: 100%;
    padding: 0.4rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.8rem;
    transition: border-color 0.3s ease;
    background: var(--bg);
    color: var(--text);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
}

input[type="checkbox"] {
    margin-right: 0.5rem;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    min-width: 48px;
    height: 26px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

input[type="date"],
input[type="time"],
input[type="number"] {
    width: 100%;
    padding: 0.4rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.8rem;
    transition: border-color 0.3s ease;
    background: var(--bg);
    color: var(--text);
}

input[type="date"]:focus,
input[type="time"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
}

.form-hint {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Settings modal — section + toggle styling ───────────────────────── */
/* Consistent look across all sections (Vessel Profile, Visualization, …):
   uppercase accent heading, divider above (except first), uniform spacing
   for labelled inputs and toggle rows. */
.settings-section {
    margin: 1.25rem 0 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
}
.settings-section:first-of-type,
.modal-body > .settings-section:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}
.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    padding: 0.55rem 0.75rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    transition: border-color 0.2s ease, background 0.2s ease;
}
.settings-toggle-row:hover {
    border-color: var(--accent);
}
.settings-toggle-row label.toggle-label {
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1.3;
    margin: 0;
    flex: 1;
    /* Override .form-group label rules for the toggle's text label. */
    display: inline;
    font-weight: 500;
    color: var(--text);
    text-transform: none;
    letter-spacing: 0;
}
.settings-toggle-row .toggle-label-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.settings-toggle-row .toggle-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.3;
}
.settings-toggle-row.settings-toggle-sub {
    margin-left: 1.5rem;
    background: var(--surface-2, transparent);
    border-style: dashed;
}

.settings-storage-note {
    margin-top: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    font-size: 0.82rem;
    line-height: 1.4;
    text-align: center;
}
.settings-storage-note--loggedin {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    color: var(--text-secondary);
}
.settings-storage-note--guest {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    color: var(--text-secondary);
}
.btn-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    text-decoration: underline;
}

/* Route Info Panel — collapsible (collapsed by default) */
.route-info-panel {
    background: var(--surface-2) !important;
    border-left: 4px solid var(--accent) !important;
    border-bottom: none !important;
    display: none; /* Hidden by default until a route exists */
    padding: 0 !important;          /* summary/body manage their own padding */
    overflow: hidden;
}

.route-info-panel h3 {
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
    color: var(--accent);
}

/* Clickable summary that acts as the footer-style toggle bar. */
.route-info-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    cursor: pointer;
    user-select: none;
    list-style: none;               /* hide native ▶ marker (Firefox/Chrome) */
    color: var(--accent);
    font-weight: 700;
    font-size: 0.9rem;
}
.route-info-summary::-webkit-details-marker { display: none; }
.route-info-summary::marker { content: ''; }

.route-info-summary:hover {
    background: rgba(0, 0, 0, 0.04);
}

.route-info-chevron {
    display: inline-block;
    transition: transform 0.2s ease;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.route-info-panel[open] > .route-info-summary .route-info-chevron {
    transform: rotate(180deg);
}

/* Expanded body — scrollable so it never pushes the bottom panel off-screen. */
.route-info-body {
    padding: 0.4rem 1rem 0.9rem 1rem;
    max-height: 60vh;
    overflow-y: auto;
    border-top: 1px solid var(--border);
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}

.info-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.info-item .label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.info-item .value {
    font-weight: 700;
    color: var(--text);
    font-size: 0.85rem;
}

.info-item .value.eco {
    color: #22c55e;
}

/* Weather Panel */
.weather-panel {
    background: var(--bg);
    color: var(--text);
    border-bottom: none !important;
    padding: 0.8rem 1.5rem !important;
}

.weather-panel h3 {
    color: var(--accent);
    margin-bottom: 1rem;
    font-size: 1rem;
}

.bottom-panel-grid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.plan-data-column,
.weather-data-column {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.plan-data-column {
    flex: 1;
}

.weather-data-column {
    flex-shrink: 0;
}

/* Hide all weather items except temp (SST already carries its own
   thermometer emoji — no need for the redundant sun decoration that
   used to sit before the column). */
.weather-data-column .weather-item {
    display: none;
}

.weather-data-column .weather-item:nth-child(3) {
    display: flex;
    flex-direction: row;
    gap: 0.3rem;
    align-items: center;
}

.weather-info {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
}

.weather-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.3rem;
}

.weather-item span {
    font-size: 0.75rem;
    display: none;
}

.weather-item strong {
    font-size: 0.85rem;
    font-weight: 600;
}

/* Map Container */
.map-container {
    flex: 1;
    position: relative;
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    /* Stop the map at the top of the bottom panel instead of letting it
       render underneath. --bottom-panel-height is set in JS from the
       panel's measured height (0 when there's no panel). */
    bottom: var(--bottom-panel-height, 0px);
}

/* Warnings Side Panel (Desktop) */
.warnings-side-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 350px;
    background: transparent;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Adjust POI gallery when warnings panel is visible */
.container:has(.warnings-side-panel[style*="display: block"]) .poi-gallery-container,
.container:has(.warnings-side-panel[style*="display: flex"]) .poi-gallery-container,
.container:has(.warnings-side-panel:not([style*="display: none"])) .poi-gallery-container {
    right: 350px;
}

.warnings-panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.warnings-list {
    list-style: none;
    margin: 0;
    padding: 1rem;
    min-height: 100%;
    background: transparent;
}

.warnings-panel-content::-webkit-scrollbar {
    width: 12px;
}

.warnings-panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.warnings-panel-content::-webkit-scrollbar-thumb {
    background: #f59e0b;
    border-radius: 6px;
}

.warnings-panel-content::-webkit-scrollbar-thumb:hover {
    background: #d97706;
}

.warning-item {
    background: rgba(254, 243, 199, 0.75);
    backdrop-filter: blur(4px);
    border-left: 4px solid #f59e0b;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: 6px;
    list-style: none;
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.warning-item--active {
    background: rgba(254, 215, 170, 0.95);
    box-shadow: 0 0 0 2px #f59e0b, 0 2px 8px rgba(245, 158, 11, 0.3);
    transform: translateX(-3px);
}

.warning-item:last-child {
    margin-bottom: 0;
}

.warning-type {
    font-weight: 600;
    color: #92400e;
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
}

.warning-description {
    font-size: 0.875rem;
    color: #78350f;
    line-height: 1.5;
}

.warning-range {
    font-size: 0.825rem;
    color: #92400e;
    margin-top: 0.4rem;
    font-style: italic;
}

.warning-suggestion {
    font-size: 0.85rem;
    color: #15803d;
    margin-top: 0.6rem;
    padding: 0.5rem;
    background: #dcfce7;
    border-left: 3px solid #22c55e;
    border-radius: 4px;
    line-height: 1.4;
}

/* Leg hover tooltip */
.leaflet-tooltip.leg-tooltip {
    padding: 0;
    background: rgba(15, 23, 42, 0.93);
    border: none;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    color: #f1f5f9;
    max-width: 260px;
    pointer-events: none;
}
.leaflet-tooltip.leg-tooltip::before {
    border-top-color: rgba(15, 23, 42, 0.93);
}
.leg-tooltip-inner {
    padding: 0.55rem 0.75rem 0.6rem;
    font-size: 0.78rem;
    line-height: 1.5;
}
.leg-tooltip-inner strong {
    display: block;
    font-size: 0.82rem;
    margin-bottom: 0.35rem;
    color: #e2e8f0;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    padding-bottom: 0.25rem;
}
.ltt-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    color: #94a3b8;
}
.ltt-row span:last-child {
    color: #f1f5f9;
    font-weight: 600;
    text-align: right;
}
.ltt-warnings {
    margin-top: 0.35rem;
    padding-top: 0.35rem;
    border-top: 1px solid rgba(255,255,255,0.12);
}
.ltt-warn {
    font-size: 0.74rem;
    color: #fbbf24;
}
.ltt-ok {
    font-size: 0.74rem;
    color: #34d399;
}

/* Warnings Summary (Mobile) */
.warnings-summary-mobile {
    background: #fef3c7;
    border-top: 2px solid #f59e0b;
    border-bottom: 2px solid #f59e0b;
    padding: 0.6rem 1rem;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 0.5rem;
    z-index: 500;
    flex-shrink: 0;
    transition: background 0.3s ease;
}

.warnings-summary-mobile:hover {
    background: #fde68a;
}

.warning-icon {
    font-size: 1.2rem;
}

.warning-text {
    font-size: 0.85rem;
    color: #92400e;
}

.warning-text strong {
    color: #78350f;
}

/* Map Controls */
.map-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.map-btn {
    background: var(--bg);
    color: var(--text);
    border: none;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
}

.map-btn:hover {
    background: var(--accent);
    color: white;
    transform: translateX(-5px);
}

.map-btn.active {
    background: var(--accent);
    color: white;
}

/* Legend */
.legend {
    position: absolute;
    bottom: 20px;
    left: 370px;
    background: var(--bg);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    display: flex;
    gap: 2rem;
    z-index: 1000;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.legend-icon {
    font-size: 1.2rem;
}

.legend-icon.route {
    color: var(--accent);
    font-weight: bold;
}

/* Custom Leaflet Popup */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    padding: 0;
    pointer-events: auto;
}

.leaflet-popup-content {
    margin: 0;
    padding: 1rem;
    min-width: 200px;
    pointer-events: auto;
}

.leaflet-popup {
    pointer-events: none;
}

.popup-content h3 {
    color: var(--text);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.popup-content p {
    margin: 0.3rem 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.popup-content .facilities {
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.popup-content button {
    pointer-events: auto;
}

/* Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--accent-dark);
}

/* Responsive */
@media (max-width: 1000px) {
    .sidebar {
        width: 300px;
    }
    
    .legend {
        left: 320px;
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 2px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: white;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
}

.planning-modal-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.planning-modal-intro {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--text-muted);
    background: var(--surface);
    border-left: 3px solid var(--accent);
    padding: 0.75rem 1rem;
    border-radius: 6px;
}

.planning-modal-intro strong {
    color: var(--text);
}

/* Same intro paragraph used inside the mobile full-screen planning panel */
.planning-panel-intro {
    margin: 0 0 1rem 0;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--text-muted);
    background: var(--surface);
    border-left: 3px solid var(--accent);
    padding: 0.75rem 1rem;
    border-radius: 6px;
}

.planning-panel-intro strong {
    color: var(--text);
}

.modal-route-row {
    display: flex;
    align-items: stretch;
    gap: 1rem;
}

.modal-ports-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.modal-ports-column .form-group {
    margin-bottom: 0;
}

.modal-swap-btn {
    align-self: center;
    background: var(--bg);
    border: 2px solid var(--accent);
    color: var(--accent);
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.18);
}

.modal-swap-btn:hover {
    background: var(--accent);
    color: white;
    transform: rotate(180deg);
}

.modal-swap-btn:active {
    transform: scale(0.95);
}

.modal-schedule-grid {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.modal-schedule-grid .form-group {
    flex: 1 1 220px;
    margin-bottom: 0;
}

.planning-modal-body .btn-block {
    margin-top: 0.5rem;
}

/* Profile Summary */
.profile-summary {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: 12px;
    border-left: 4px solid var(--accent);
}

.profile-summary h3 {
    font-size: 1.1rem;
    color: var(--accent);
    margin-bottom: 1rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

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

.summary-value {
    font-size: 1.1rem;
    color: var(--text);
    font-weight: 700;
}

.summary-value {
    font-size: 1.1rem;
    color: var(--text);
    font-weight: 700;
}

/* Route Summary Mobile */
.route-summary-mobile {
    display: none;
}

.route-summary {
    display: none;
}

.compact-panel {
    padding: 0.4rem 0.5rem !important;
    margin-bottom: 0 !important;
    border-bottom: none !important;
}

.compact-route {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    width: 100%;
}

.datetime-column {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    align-items: center;
    justify-content: center;
    padding-right: 0.5rem;
    border-right: 2px solid var(--border);
    min-width: 50px;
}

.time-display {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
}

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

.route-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 0.6rem;
    flex: 1 1 0;
    /* Without an explicit min-width, this flex item would expand to its
       intrinsic content width and push the buttons-column off-screen. */
    min-width: 0;
    overflow: hidden;
}

.ports-column {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
}

.port-display {
    display: flex;
    align-items: center;
    font-size: 0.8rem;
    overflow: hidden;
}

.port-display strong {
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.buttons-column {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-left: auto;
    flex-shrink: 0;
}

.swap-btn-compact {
    background: transparent;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 0.2rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(90deg);
    flex-shrink: 0;
}

.swap-btn-compact:hover {
    color: var(--accent-dark);
    transform: rotate(90deg) scale(1.1);
}

.swap-btn-compact:active {
    transform: rotate(90deg) scale(0.95);
}

/* Refresh-plan icon button — same chromeless style as .swap-btn-compact
 * but without the 90° rotation (the reload glyph is naturally
 * oriented). Sits between swap and edit in the .buttons-column. */
.refresh-btn-compact {
    background: transparent;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 0.2rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.refresh-btn-compact:hover {
    color: var(--accent-dark);
    transform: rotate(-90deg) scale(1.1);
}

.refresh-btn-compact:active {
    transform: scale(0.95);
}

.refresh-btn-compact[disabled] {
    opacity: 0.5;
    cursor: progress;
    pointer-events: none;
}

.btn-edit {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.btn-edit:hover {
    background: var(--accent-dark);
    transform: scale(1.05);
}

.info-line {
    display: flex;
    gap: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    padding-top: 0.3rem;
    border-top: 1px solid var(--border);
}

.info-line span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

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

/* Mobile Planning Panel Header */
.panel-header-mobile {
    display: none;
}

.btn-close-mobile {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--accent);
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.btn-close-mobile:hover {
    background: var(--border-light);
    transform: rotate(90deg);
}

.desktop-only {
    display: block;
}

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

.summary-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--accent);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.summary-content {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem;
    background: var(--surface);
    border-radius: 6px;
}

.summary-row .label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.summary-row .value {
    font-weight: 700;
    color: var(--text);
    font-size: 0.9rem;
}

.summary-row.eco-highlight {
    background: var(--surface-2);
    border-left: 3px solid var(--accent);
}

.summary-row.eco-highlight .value {
    color: var(--accent);
}

/* Fullscreen planning panel for mobile only */
@media (max-width: 1000px) {
    /* Fix viewport height on mobile to account for browser UI */
    body {
        height: 100dvh;
    }
    
    .container {
        height: 100dvh;
    }
    
    .sidebar.editing-mode {
        position: fixed !important;
        top: 0;
        left: 0;
        width: 100vw !important;
        height: 100dvh;
        max-height: 100dvh;
        z-index: 1500;
        background: white;
        overflow-y: clip;
        padding: 0;
        display: flex !important;
        flex-direction: column !important;
    }

    .sidebar.editing-mode .planning-panel {
        flex: 1;
        padding: 0;
        max-width: none !important;
        width: 100%;
    }

    .sidebar.editing-mode .panel {
        max-width: 100%;
        width: 100%;
        height: 100%;
    }

    .sidebar.editing-mode .form-group {
        width: 100%;
    }

    .sidebar.editing-mode .form-control,
    .sidebar.editing-mode input[type="date"],
    .sidebar.editing-mode input[type="time"],
    .sidebar.editing-mode select {
        width: 100% !important;
    }

    .sidebar.editing-mode .btn-block {
        width: 100% !important;
    }

    .sidebar.editing-mode .panel-header-mobile {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 1rem 1.5rem;
        background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
        color: white;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .sidebar.editing-mode .panel-header-mobile h2 {
        margin: 0;
        color: white;
        font-size: 1.3rem;
    }

    .sidebar.editing-mode .btn-close-mobile {
        color: white;
        display: block !important;
    }

    .sidebar.editing-mode .btn-close-mobile:hover {
        background: rgba(255, 255, 255, 0.2);
    }

    .sidebar.editing-mode .desktop-only {
        display: none !important;
    }

    .sidebar.editing-mode .route-summary-mobile {
        display: none !important;
    }

    .sidebar.editing-mode .route-summary {
        display: none !important;
    }
}

@media (max-width: 1000px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 60vh;
        overflow-y: auto;
        padding: 0;
        background: white;
        display: block; /* Visible on mobile by default */
    }

    /* When the user closed the planner without computing a route, hide the
       sidebar entirely on mobile so the floating planner button can be used
       to reopen it (mirrors desktop behaviour). */
    .sidebar:not(.editing-mode):not(.route-active) {
        display: none;
    }

    .sidebar.collapsed {
        max-height: none;
    }
    
    .map-container {
        flex: 1;
        min-height: 40vh;
    }

    .bottom-panel {
        position: relative !important;
        left: 0;
        width: 100%;
        display: block !important;
        visibility: visible !important;
        z-index: 500 !important;
    }

    .weather-panel {
        padding: 0.5rem 1rem !important;
    }

    .weather-info {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.8rem;
    }

    /* Hide mobile header in normal mode */
    .panel-header-mobile {
        display: none;
    }

    .sidebar:not(.editing-mode) .panel-header-mobile {
        display: none !important;
    }

    /* Route active state (after calculation) */
    .sidebar.route-active {
        max-height: none;
        overflow-y: visible;
    }

    .sidebar.route-active .map-container {
        height: calc(100vh - 150px);
    }
    
    .legend {
        left: 10px;
        font-size: 0.75rem;
        bottom: 10px;
    }

    .modal-content {
        width: 95%;
        max-height: 85vh;
    }

    /* Profile/settings modal goes full-screen on mobile */
    #profile-modal.active {
        align-items: stretch;
        justify-content: stretch;
    }

    #profile-modal .modal-content {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    #profile-modal .modal-header {
        border-radius: 0;
    }

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

    /* Show route summary, hide planning panel when route is active */
    .sidebar.route-active .route-summary {
        display: block !important;
    }

    .sidebar.route-active .planning-panel {
        display: none !important;
    }

    .sidebar.route-active .route-info-panel {
        display: block !important;
    }

    /* Hide desktop warnings panel, show mobile summary */
    .warnings-panel {
        display: none !important;
    }
}

@media (min-width: 1001px) {
    /* Show route summary, hide planning panel when route is active */
    .sidebar.route-active .route-summary {
        display: block !important;
    }

    .sidebar.route-active .planning-panel {
        display: none !important;
    }

    .sidebar.route-active .route-info-panel {
        display: block !important;
    }

    /* Planning failed: hide the sidebar form so the error modal isn't
       layered on top of the inputs. The FAB is shown from JS for retry. */
    .sidebar.planning-error .planning-panel,
    .sidebar.planning-error .route-info-panel {
        display: none !important;
    }

    /* Adjust sidebar to be horizontal container */
    .sidebar {
        display: flex;
        flex-direction: row;
        align-items: stretch;
    }
    
    /* Keep sidebar hidden until visible class is added */
    .sidebar:not(.visible) {
        display: none !important;
    }
    
    /* Show sidebar when it has the visible class */
    .sidebar.visible {
        display: flex !important;
    }
    
    /* Planning panel takes full width */
    .planning-panel {
        flex: 1;
        width: 100%;
    }
    
    /* Route summary takes full width */
    .route-summary {
        flex: 1;
        width: 100%;
    }
    
    /* Route info panel positioned below in bottom panel */
    .route-info-panel {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 501;
    }

    /* Route loading overlay: fixed full-screen so it shows above the
       editing-mode sidebar (z-index 1500) during route calculation */
    .route-loading-overlay {
        position: fixed;
        z-index: 2000;
    }
}

/* Suggestions Modal - Full screen on all devices */
.modal.active .suggestions-modal-content {
    max-width: 100% !important;
    width: 100% !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

.modal.active .suggestions-modal-header {
    padding: 1.5rem 2rem !important;
    background: var(--bg) !important;
    border-bottom: 1px solid var(--border) !important;
    border-radius: 0 !important;
}

.modal.active .suggestions-modal-header h2 {
    font-size: 1.2rem !important;
    font-weight: 600 !important;
    color: var(--text) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

.modal.active .suggestions-modal-header .close-btn {
    color: var(--text) !important;
    font-size: 2rem !important;
}

.modal.active .suggestions-modal-body {
    padding: 0 !important;
    flex: 1 !important;
    overflow: hidden !important;
    min-height: 0 !important;
}

/* Suggestions Modal - Mobile specific styles */
@media (max-width: 1000px) {
    /* Ensure bottom panel stays visible even when modal is active */
    body:has(.modal.active) .bottom-panel {
        display: block !important;
        visibility: visible !important;
        position: relative !important;
    }
    
    .modal.active .suggestions-modal-content {
        height: 100dvh !important;
        max-height: 100dvh !important;
    }

    .modal.active .suggestions-modal-header {
        padding: 1rem 1.5rem !important;
    }

    .modal.active .suggestions-modal-header h2 {
        font-size: 1rem !important;
    }

    .modal.active .suggestions-modal-header .close-btn {
        font-size: 1.5rem !important;
    }
}

.suggestions-modal-footer {
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
}

.suggestions-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.suggestions-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.suggestions-checkbox-label:hover {
    color: var(--text);
}

/* Route Error Modal — red-themed variant of the base modal */
.route-error-modal-content {
    max-width: 480px;
}

.route-error-modal-header {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
}

.route-error-icon {
    margin-right: 0.4rem;
}

.route-error-modal-body {
    padding: 1.75rem 2rem 1.5rem;
}

.route-error-message {
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
    line-height: 1.5;
    color: var(--text);
}

.route-error-detail {
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    background: #fef2f2;
    border-left: 3px solid #dc2626;
    border-radius: 4px;
    font-size: 0.92rem;
    line-height: 1.45;
    color: #7f1d1d;
}

.route-error-tech-details {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.route-error-tech-details summary {
    cursor: pointer;
    user-select: none;
}

.route-error-tech-details code {
    display: block;
    margin-top: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: var(--surface);
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8rem;
    color: var(--text);
}

.route-error-modal-footer {
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Warnings Modal - Same Layout as Suggestions */
/* Warnings Modal - Mobile specific styles */
@media (max-width: 1000px) {
    .modal.active .warnings-modal-content {
        max-width: 100% !important;
        width: 100% !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .modal.active .warnings-modal-header {
        padding: 1rem 1.5rem !important;
        background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
        border-bottom: 2px solid #b45309 !important;
        border-radius: 0 !important;
    }

    .modal.active .warnings-modal-header h2 {
        font-size: 1rem !important;
        font-weight: 600 !important;
        color: white !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
    }

    .modal.active .warnings-modal-header .close-btn {
        color: white !important;
    }

    .modal.active .warnings-modal-body {
        padding: 1rem !important;
        flex: 1 !important;
        overflow-y: auto !important;
        min-height: 0 !important;
        background: #fffbeb !important;
    }

    .modal.active .warnings-modal-body .warnings-list {
        max-height: none !important;
        padding: 0 !important;
    }
}

.suggestions-swiper {
    width: 100% !important;
    height: 100% !important;
}

.swiper-slide {
    display: flex !important;
    flex-direction: row !important;
    padding: 2rem !important;
    background: var(--bg) !important;
    overflow-y: auto !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 2rem !important;
}

.suggestion-slide-image {
    width: 45%;
    min-width: 400px;
    height: 60vh;
    max-height: 500px;
    object-fit: cover;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    flex-shrink: 0;
}

.suggestion-slide-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--surface) 0%, var(--border) 100%);
    color: var(--accent);
}

.suggestion-slide-placeholder-icon {
    font-size: 4rem;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.suggestion-slide-placeholder-label {
    font-size: 0.9rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 1px;
    opacity: 0.7;
}

.poi-gallery-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--surface) 0%, var(--border) 100%);
    font-size: 1.8rem;
    border-radius: inherit;
}

.suggestion-slide-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    text-align: left;
    max-width: 600px;
}

.suggestion-slide-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.3rem;
    line-height: 1.3;
}

.suggestion-slide-category {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 1px;
    margin-bottom: 0.4rem;
    opacity: 0.8;
}

.suggestion-slide-location {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.6rem;
}

.suggestion-slide-description {
    font-size: 1.1rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 0.8rem;
}

.suggestion-slide-distance {
    font-size: 1rem;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 0.8rem;
}

.suggestion-slide-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-start;
    margin-top: 0;
}

.suggestion-slide-action-compact {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    padding: 1rem 1.5rem;
    background-image: url('./Images/Map%20background.png');
    background-size: cover;
    background-position: center;
    border: 2px solid rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    color: #4a4a4a;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 90px;
    height: 70px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.suggestion-slide-action-compact span {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.suggestion-slide-action-compact:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
    border-color: rgba(255, 255, 255, 0.5);
}

.suggestion-slide-action-compact.read-more {
    background-image: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    background-size: 100% 100%;
    color: white;
}

.suggestion-slide-action-compact.read-more:hover {
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.suggestion-slide-action-compact.read-more span {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.suggestion-slide-footer {
    display: none;
}

.suggestion-slide-action {
    display: none;
}

.swiper-pagination {
    bottom: 20px !important;
}

.swiper-pagination-bullet {
    background: var(--accent) !important;
    opacity: 0.4 !important;
    width: 8px !important;
    height: 8px !important;
}

.swiper-pagination-bullet-active {
    opacity: 1 !important;
    width: 24px !important;
    border-radius: 4px !important;
}

.swiper-button-next,
.swiper-button-prev {
    color: var(--accent) !important;
    background: var(--bg);
    width: 50px !important;
    height: 50px !important;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
}

.swiper-button-next:after,
.swiper-button-prev:after {
    font-size: 20px !important;
    font-weight: bold;
}

.swiper-button-next:hover,
.swiper-button-prev:hover {
    background: var(--accent);
    color: white !important;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.swiper-button-next.swiper-button-disabled,
.swiper-button-prev.swiper-button-disabled {
    opacity: 0.3;
}

.suggestions-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    max-height: 60vh;
    overflow-y: auto;
}

.suggestion-card {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.suggestion-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.3);
    border-color: var(--accent);
}

.suggestion-card-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.suggestion-card-content {
    padding: 1rem;
}

.suggestion-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.suggestion-card-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.suggestion-card-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.suggestion-card-distance {
    font-size: 0.8rem;
    color: var(--accent);
    margin-top: 0.5rem;
    font-weight: 500;
}

/* POI Gallery */
.poi-gallery-container {
    position: absolute;
    bottom: 80px;
    left: 0;
    right: 0;
    background: transparent;
    padding: 0.8rem;
    z-index: 499;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.poi-gallery {
    display: flex;
    gap: 0.8rem;
    overflow-x: auto;
    flex: 1;
    scroll-behavior: smooth;
    padding: 0.2rem 0;
}

.poi-gallery::-webkit-scrollbar {
    height: 6px;
}

.poi-gallery::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.poi-gallery::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

.poi-gallery-item {
    flex-shrink: 0;
    width: 120px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
}

.poi-gallery-item:hover {
    transform: scale(1.05);
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.poi-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.poi-gallery-item-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: white;
    padding: 0.3rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
}

.show-suggestions-btn {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    font-size: 24px;
}

.show-suggestions-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

@media (max-width: 1000px) {
    .poi-gallery-container {
        /* Position will be set dynamically via JavaScript */
        padding: 0.4rem 0.6rem;
    }
    
    .poi-gallery {
        gap: 0.5rem;
        padding: 0.1rem 0;
    }
    
    .poi-gallery-item {
        width: 90px;
        height: 60px;
    }
    
    .suggestions-list {
        grid-template-columns: 1fr;
    }
    
    .swiper-slide {
        flex-direction: column !important;
        gap: 0 !important;
        padding: 1rem !important;
    }
    
    .suggestion-slide-image {
        width: 100% !important;
        min-width: unset !important;
        height: 40vh !important;
        max-height: 300px !important;
        margin-bottom: 1rem !important;
    }
    
    .suggestion-slide-content {
        text-align: center !important;
    }
    
    .suggestion-slide-title {
        font-size: 1.5rem !important;
    }
    
    .suggestion-slide-description {
        font-size: 1rem !important;
    }
    
    .suggestion-slide-actions {
        justify-content: center !important;
    }
    
    .suggestion-slide-footer {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.6rem 1rem;
    }
    
    .suggestion-slide-distance {
        text-align: center;
        font-size: 0.9rem;
    }
    
    .suggestion-slide-action-compact {
        min-width: 60px;
        height: 50px;
        font-size: 0.7rem;
        background-size: 24px 24px;
    }
    
    .swiper-button-next,
    .swiper-button-prev {
        width: 40px !important;
        height: 40px !important;
    }
    
    .swiper-button-next:after,
    .swiper-button-prev:after {
        font-size: 16px !important;
    }
}

/* ── Phase 13: Routing integration styles ─────────────────────────────── */

/* Disclaimer banner */
.disclaimer-banner {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    font-size: 0.82rem;
    color: #92400e;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

/* Phase 23 — Privacy link inside disclaimer banner */
.disclaimer-legal-link {
    display: inline-block;
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: #92400e;
    text-decoration: underline;
    font-weight: 600;
}
.disclaimer-legal-link:hover { color: #78350f; }

/* Cost breakdown grid */
.cost-breakdown {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
}

.cost-label {
    color: var(--text-muted);
}

.cost-value {
    font-weight: 600;
    color: var(--text);
}

/* ── Feasibility report (Phase 1 instrumentation) ───────────────────── */
.feasibility-report {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.3rem;
}

.feasibility-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.feasibility-badge.feasibility-ok {
    background: #d1fae5;
    color: #065f46;
}

.feasibility-badge.feasibility-warn {
    background: #fef3c7;
    color: #92400e;
}

.feasibility-detail {
    font-size: 0.75rem;
    color: var(--text-muted, #6b7280);
}

/* ── Combined-suggestion card (safer destination + departure_time) ──
 * Lives at the top of the warnings panel (desktop) and the warnings
 * modal (mobile). The background colour communicates the state — the
 * old 💡 icon is gone; the spinner sits inline in the title only while
 * the alternatives fetch is in flight.
 *   state-loading  → cyan
 *   state-loaded   → light green (validated alternatives available)
 *   state-empty    → light red   (none found)
 *   state-error    → light red   (fetch failed)
 * Per-state palette is set on the card; everything below references
 * the chosen accent via the matching block. */
.suggestions-card {
    border-radius: 6px;
    /* Matches .warning-item padding; 1rem all-around margin gives the
     * card visible breathing room from the warnings panel edges and
     * the warning-list below it. */
    padding: 1rem;
    margin: 1rem;
    border: 1px solid transparent;
    border-left-width: 4px;
}

.suggestions-card[hidden] { display: none; }

.suggestions-card.state-loading {
    background: #f0f9ff;
    border-color: #bae6fd;
    border-left-color: #0ea5e9;
}
.suggestions-card.state-loaded {
    background: #f0fdf4;
    border-color: #bbf7d0;
    border-left-color: #22c55e;
}
.suggestions-card.state-empty,
.suggestions-card.state-error {
    background: #fef2f2;
    border-color: #fecaca;
    border-left-color: #ef4444;
}

.suggestions-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
}

.suggestions-card.state-loading .suggestions-title { color: #075985; }
.suggestions-card.state-loaded  .suggestions-title { color: #166534; }
.suggestions-card.state-empty   .suggestions-title,
.suggestions-card.state-error   .suggestions-title { color: #991b1b; }

.suggestions-hint {
    font-size: 0.8rem;
    color: #15803d;          /* loaded state is the only state that shows the hint */
    line-height: 1.4;
    margin: 0 0 0.6rem 0;
}

.suggestions-body[hidden] { display: none; }

/* Spinner — sits in the title row only while loading. Stroke colour
 * picks up the loading-state accent. */
.suggestions-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(14, 165, 233, 0.25);
    border-top-color: #0ea5e9;
    border-radius: 50%;
    animation: suggestionsSpin 0.8s linear infinite;
    display: inline-block;
    flex: 0 0 auto;
}
.suggestions-spinner[hidden] { display: none; }

@keyframes suggestionsSpin {
    to { transform: rotate(360deg); }
}

/* TomSelect option rendering — three-row stack:
 *   1. destination port name
 *   2. departure date + time
 *   3. detour and delay/advance
 * Same template for the visible selected item AND the dropdown options
 * so the user sees the same shape they'll be picking from. */
.suggestion-option {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.4rem 0.1rem;
    line-height: 1.3;
}

.suggestion-row {
    display: block;
    width: 100%;
}

.suggestion-row-dest {
    font-weight: 600;
    color: var(--text, #1a2a4a);
    font-size: 0.95rem;
}

.suggestion-row-time {
    font-size: 0.82rem;
    color: var(--text-muted, #475569);
}

.suggestion-row-deviation {
    font-size: 0.8rem;
    color: #166534;          /* loaded-state accent → reinforces what the badge used to do */
    font-weight: 600;
}

/* Selected-item rendering inside the closed select: same template, but
 * the surrounding TomSelect chrome is its own concern. */
.suggestions-body .ts-control {
    padding-right: 2.25rem;        /* room for the caret button below */
    cursor: pointer;
}

/* Drop-down chevron — explicit SVG element sitting absolutely over the
 * right edge of the select. Drawn ON TOP of TomSelect's own decoration
 * (z-index + pointer-events:none so clicks still reach the control).
 * Cosmetic only — clicking anywhere on the wrapped select still opens
 * the TomSelect dropdown via its own handler.
 *
 * TomSelect 2.x ships a default arrow rendered via a background-image
 * on .ts-control; the rule below blanks that out so we don't show
 * two chevrons stacked on top of each other. */
.suggestions-select-wrap {
    position: relative;
}
.suggestions-select-icon {
    position: absolute;
    right: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: #22c55e;
    pointer-events: none;
    z-index: 2;
    transition: transform 0.15s ease;
}
/* Rotate the chevron when the dropdown is open — visual cue mirroring
 * other dropdowns in the app (language picker etc.). */
.suggestions-select-wrap .ts-wrapper.dropdown-active ~ .suggestions-select-icon,
.suggestions-select-wrap:has(.ts-wrapper.dropdown-active) .suggestions-select-icon {
    transform: translateY(-50%) rotate(180deg);
}
/* Suppress TomSelect 2.x's default caret (a background-image on the
 * control) so the explicit SVG above is the only chevron visible. */
.suggestions-body .ts-control,
.suggestions-body .ts-wrapper.single .ts-control {
    background-image: none !important;
}
/* Reserve room on the right of the input so the chevron doesn't
 * overlap the displayed option text. */
.suggestions-body .ts-control {
    padding-right: 2.4rem;
}

/* Tighter spacing on dropdown options themselves so 5 entries don't
 * overflow the sidebar height. */
.suggestions-body .ts-dropdown .option {
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid #e2e8f0;
}
.suggestions-body .ts-dropdown .option:last-child {
    border-bottom: none;
}
.suggestions-body .ts-dropdown .option.active,
.suggestions-body .ts-dropdown .option:hover {
    background: #f0fdf4;
}

.suggestions-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
    margin-top: 0.65rem;
}

.suggestions-actions .btn {
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
}

/* ── Savings UI (modal + banner) ────────────────────────────────────
 * Lives in two surfaces: a post-route modal (#savings-modal) that auto-
 * pops unless the user opts out, and a persistent slim banner
 * (#savings-banner) below the bottom-panel. Per-row sign colouring
 * (positive green / negative amber / neutral grey) is reused from
 * the sidebar-card era — the .savings-rows + .savings-row* rules below
 * survive the relocation. */

/* Modal-content sizing — mirrors .suggestions-modal-content. */
.savings-modal-content {
    max-width: 520px;
    width: 90%;
}
.savings-modal-body { padding: 1rem 1.25rem; }
.savings-modal-hint {
    margin: 0 0 0.85rem 0;
    font-size: 0.85rem;
    color: var(--text-muted, #475569);
    line-height: 1.4;
}
.savings-modal-footer {
    padding: 0.75rem 1.25rem;
}
.savings-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text, #1a2a4a);
    cursor: pointer;
}

/* Persistent footer banner — slim strip rendered as the last row of
 * the bottom panel after a route is computed. Green tinted to read as
 * "win"; trade-off / neutral copy is handled inside the modal, the
 * banner stays green to avoid alarm fatigue. */
.savings-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.85rem;
    background: #f0fdf4;
    border-top: 1px solid #bbf7d0;
    color: #166534;
    font-size: 0.85rem;
    line-height: 1.3;
}
.savings-banner[hidden] { display: none; }

/* Sign dot for the single saving shown in the bar — mirrors the
   per-row dot in the modal. Green = improvement, amber = trade-off. */
.savings-banner::before {
    content: "";
    flex: 0 0 auto;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--text-muted, #94a3b8);
}
.savings-banner.savings-positive::before { background: #16a34a; }
.savings-banner.savings-negative::before { background: #f59e0b; }
.savings-banner.savings-neutral::before  { background: #94a3b8; }

.savings-banner-text {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.savings-banner-btn {
    flex: 0 0 auto;
    padding: 0.25rem 0.75rem;
    border: 1px solid #22c55e;
    background: transparent;
    color: #166534;
    border-radius: 9999px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}
.savings-banner-btn:hover { background: #dcfce7; }

.savings-rows {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.savings-row {
    font-size: 0.85rem;
    line-height: 1.35;
    padding: 0.3rem 0.25rem;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    color: var(--text, #1e293b);
}

.savings-row::before {
    content: "";
    flex: 0 0 auto;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--text-muted, #94a3b8);
    /* Nudge the dot down so it aligns with the text's x-height
       instead of the baseline. */
    transform: translateY(0.1rem);
}

.savings-row.savings-positive::before { background: #16a34a; }
/* Amber, not red — this is a trade-off, not a failure. */
.savings-row.savings-negative::before { background: #f59e0b; }
.savings-row.savings-neutral {
    color: var(--text-muted, #475569);
    font-style: italic;
}

/* ── Forecast window helper + reliability badge ───────────────────── */

.forecast-window-help {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.forecast-reliability-badge {
    margin-top: 0.4rem;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    font-size: 0.78rem;
    line-height: 1.35;
    font-weight: 500;
}

.reliability-warning-yellow {
    background: #fef3c7;
    color: #92400e;
    border-left: 3px solid #f59e0b;
}

.reliability-warning-orange {
    background: #fed7aa;
    color: #9a3412;
    border-left: 3px solid #ea580c;
}

/* ── Data provenance ──────────────────────────────────────────────── */

.data-provenance-section {
    margin-top: 0.9rem;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--surface);
    padding: 0.5rem 0.75rem;
}

.data-provenance-summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    list-style: none;
    user-select: none;
    padding: 0.25rem 0;
}

.data-provenance-summary::-webkit-details-marker {
    display: none;
}

.data-provenance-summary::after {
    content: ' ▾';
    color: var(--text-muted);
    font-size: 0.8rem;
}

.data-provenance-section[open] .data-provenance-summary::after {
    content: ' ▴';
}

.data-provenance-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0 0;
}

.provenance-item {
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border-light);
}

.provenance-item:last-child {
    border-bottom: none;
}

.provenance-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.provenance-glyph {
    font-size: 1rem;
    line-height: 1.2;
    flex: 0 0 1.2rem;
}

.provenance-full .provenance-glyph {
    color: #16a34a;
}

.provenance-partial .provenance-glyph {
    color: #d97706;
}

.provenance-unavailable .provenance-glyph {
    color: #dc2626;
}

.provenance-partial-note {
    font-size: 0.75rem;
    color: #9a3412;
    margin-top: 0.2rem;
}

.provenance-body {
    flex: 1;
    min-width: 0;
}

.provenance-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.provenance-caption {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
    word-break: break-word;
}

.provenance-notes {
    font-size: 0.75rem;
    color: #9a3412;
    margin-top: 0.2rem;
    font-style: italic;
}

/* Weather popup on map click */
.weather-popup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
    font-size: 0.85rem;
    min-width: 200px;
}

.weather-popup-grid .wp-label {
    color: var(--text-muted);
}

.weather-popup-grid .wp-value {
    font-weight: 600;
    text-align: right;
}

/* ── Route loading overlay ── */
.route-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* App-level boot overlay: shown until the backend is ready. Critical
   styles are also inlined on the element so it appears before this
   stylesheet finishes loading. */
.app-loading-overlay {
    transition: opacity 0.35s ease;
}
.app-loading-overlay.app-loading-hidden {
    opacity: 0;
    pointer-events: none;
}

/* Backend data-quality banner — surfaces /v1/meta/status.data_sources
   when any upstream is degraded. Sits at the top of the container,
   above the header. */
.data-quality-banner {
    background: #fef3c7;          /* amber-100 */
    border-bottom: 1px solid #fbbf24; /* amber-400 */
    color: #78350f;               /* amber-900 */
    font-size: 0.85rem;
    line-height: 1.35;
}
.data-quality-banner[hidden] {
    display: none !important;
}
.dqb-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
}
.dqb-icon { flex: 0 0 auto; }
.dqb-text { flex: 1 1 auto; }
.dqb-toggle, .dqb-close {
    flex: 0 0 auto;
    background: transparent;
    border: 1px solid #fbbf24;
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
    color: #78350f;
    cursor: pointer;
    font: inherit;
}
.dqb-toggle:hover, .dqb-close:hover { background: #fde68a; }
.dqb-close {
    border: none;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0 0.4rem;
}
.dqb-details {
    margin: 0;
    padding: 0.25rem 1.5rem 0.6rem;
    list-style: disc;
}
.dqb-details[hidden] {
    display: none;
}
.dqb-details li {
    margin: 0.15rem 0;
}
.dqb-details li .dqb-source {
    font-weight: 600;
    margin-right: 0.3rem;
}
.dqb-details li .dqb-reason {
    opacity: 0.85;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
}
.dqb-details li.dqb-status-link {
    list-style: none;
    margin-top: 0.4rem;
}
.dqb-details li.dqb-status-link a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}
.route-loading-content {
    text-align: center;
    color: #fff;
}
.route-loading-spinner {
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
    border: 4px solid rgba(255,255,255,0.25);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.route-loading-text {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 4px;
}
.route-loading-sub {
    font-size: 0.85rem;
    opacity: 0.7;
    margin: 0;
}

/* Routing API status indicator */
.routing-status {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
}

.routing-status.online {
    background: #d1fae5;
    color: #065f46;
}

.routing-status.offline {
    background: #fee2e2;
    color: #991b1b;
}

.routing-status .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.routing-status.online .status-dot {
    background: #10b981;
}

.routing-status.offline .status-dot {
    background: #ef4444;
}

/* Route refresh indicator */
.refresh-indicator {
    font-size: 0.75rem;
    color: var(--text-light);
    text-align: center;
    padding: 0.3rem 0;
}

/* Warning list improvements for real API */
.warning-item .warning-type {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.warning-severity-critical {
    color: #dc2626;
    font-weight: 700;
}

.warning-severity-warning {
    color: #f59e0b;
    font-weight: 600;
}

/* ── Unified popup styles ── */
.popup-unified {
    max-width: 300px;
}

.popup-unified .popup-image {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.popup-unified .popup-location {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0.2rem 0;
}

.popup-unified .popup-category {
    font-size: 0.75rem;
    color: var(--accent);
    letter-spacing: 0.5px;
    margin: 0.2rem 0 0.4rem;
}

.popup-unified .popup-description {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin: 0.3rem 0 0;
    /* Clamp to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.popup-unified .popup-readmore {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: var(--surface);
    color: var(--accent);
    border: 1px solid var(--border);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.popup-unified .popup-readmore:hover {
    background: var(--border);
    text-decoration: none;
}

/* Inline action row sitting under the description: read-more link + Website chip */
.popup-unified .popup-inline-actions {
    margin-top: 0.15rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.popup-unified .popup-website-chip {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: var(--surface);
    color: var(--accent);
    border: 1px solid var(--border);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.popup-unified .popup-website-chip:hover {
    background: var(--border);
}

.popup-unified .popup-hours {
    margin-top: 0.5rem;
    font-size: 0.88rem;
}

.popup-unified .popup-occupancy {
    margin-top: 0.2rem;
    font-size: 0.88rem;
}

.popup-unified .popup-facilities {
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.popup-unified .popup-distance {
    margin-top: 0.5rem;
    font-size: 0.82rem;
    color: var(--accent);
}

.popup-unified .popup-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.8rem;
}

.popup-btn {
    flex: 1;
    padding: 0.55rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.popup-btn-close {
    background: var(--border);
    color: var(--text);
}

.popup-btn-close:hover {
    background: var(--border-hover);
    transform: translateY(-1px);
}

.popup-btn-link {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
}

.popup-btn-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Port-only route shortcut buttons (sit alongside Close in the buttons row) */
.popup-btn-route {
    font-size: 0.82rem;
    padding: 0.5rem 0.4rem;
}

.popup-btn-from {
    background: var(--accent);
    color: white;
}

.popup-btn-from:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
}

.popup-btn-to {
    background: var(--accent);
    color: white;
}

.popup-btn-to:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
}

/* When route shortcuts are present, keep Close compact so the row stays balanced */
.popup-unified .popup-buttons:has(.popup-btn-route) .popup-btn-close {
    flex: 0 0 auto;
    padding: 0.5rem 0.7rem;
}

/* ── Full-screen Description Modal ── */
.description-modal-content {
    max-width: 700px;
    width: 95%;
    max-height: 90vh;
}

.description-modal-body {
    padding: 1.5rem 2rem !important;
    overflow-y: auto;
}

.description-modal-image {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 1.2rem;
}

.description-modal-text {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text);
}

.description-modal-text h4 {
    margin: 1.2rem 0 0.4rem;
    font-size: 1.05rem;
    color: var(--accent);
}

.description-modal-text p {
    margin: 0 0 0.6rem;
}

.description-modal-text a {
    color: #2980b9;
    word-break: break-all;
}

/* ── Help Modal ── */
.help-modal-content {
    max-width: 700px;
    width: 95%;
    max-height: 90vh;
}

/* Force help modal to always render in light mode */
[data-theme="night"] .help-modal-content {
    --accent: #DA5C57;
    --accent-dark: #B84743;
    --bg: #ffffff;
    --bg-hover: #f5f5f5;
    --surface: #f8f9fa;
    --surface-2: #f0f9ff;
    --text: #333333;
    --text-muted: #666666;
    --text-light: #9ca3af;
    --border: #e5e7eb;
    --border-hover: #d1d5db;
    --border-light: #f0f0f0;
    --shadow: rgba(0,0,0,0.1);
    --shadow-md: rgba(0,0,0,0.15);
    --gallery-bg: rgba(255,255,255,0.3);
    background: #ffffff;
    color: #333333;
}

.help-modal-body {
    padding: 1.5rem 2rem !important;
    overflow-y: auto;
}

.help-section {
    margin-bottom: 1.8rem;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h3 {
    font-size: 1.1rem;
    color: var(--accent);
    margin-bottom: 0.6rem;
}

.help-section p,
.help-section li {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-muted);
}

.help-section ul,
.help-section ol {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.help-section li {
    margin-bottom: 0.35rem;
}

.help-disclaimer {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 1rem 1.2rem;
    border-radius: 6px;
}

.help-disclaimer h3 {
    color: #92400e;
}

.help-disclaimer p {
    color: #78350f;
}

/* Mobile responsiveness for new modals */
@media (max-width: 600px) {
    .description-modal-content,
    .help-modal-content {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .description-modal-content .modal-header,
    .help-modal-content .modal-header {
        border-radius: 0;
    }

    .description-modal-body,
    .help-modal-body {
        padding: 1rem !important;
    }
}

/* ── Tom Select port dropdown overrides ── */
.ts-wrapper.form-control {
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 0;
    min-height: 34px;
}

.ts-wrapper.form-control .ts-control {
    border: none;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 0.8rem;
    min-height: 30px;
    background: var(--bg);
    color: var(--text);
}

.ts-wrapper.form-control.input-active .ts-control,
.ts-wrapper.form-control.focus .ts-control,
.ts-wrapper.form-control .ts-control input {
    background: var(--bg) !important;
    color: var(--text) !important;
}

.ts-wrapper.form-control .ts-control > .item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.ts-wrapper.form-control.focus .ts-control {
    border: none;
    box-shadow: none;
}

.ts-wrapper.form-control.focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(102,126,234,0.15);
}

.ts-dropdown {
    border: 2px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.13);
    z-index: 9999;
    background: var(--bg);
    color: var(--text);
}

.ts-dropdown .option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    font-size: 0.8rem;
}

.ts-dropdown .option.active {
    background: var(--surface);
    color: var(--text);
}

.ts-dropdown .option:hover {
    background: var(--surface-2);
    color: var(--text);
}

/* Flag images inside Tom Select */
.ts-flag {
    height: 14px;
    border-radius: 2px;
    flex-shrink: 0;
    margin-right: 4px;
}

.ts-locality {
    color: var(--text-muted);
    font-size: 0.72rem;
    margin-left: 2px;
}

/* ── Site Footer ── */
.site-footer {
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 0.35rem 1.5rem;
    z-index: 1100;
    flex-shrink: 0;
}   

.footer-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.footer-text {
    font-size: 0.65rem;
    color: var(--text);
    line-height: 1.3;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.footer-more {
    font-size: 0.65rem;
    color: var(--accent);
    white-space: nowrap;
    flex-shrink: 0;
    text-decoration: none;
}

.footer-more:hover {
    text-decoration: underline;
}

.footer-modal-content {
    max-width: 600px;
    width: 90%;
}

/* Force about modal to always render in light mode */
[data-theme="night"] .footer-modal-content {
    --accent: #DA5C57;
    --accent-dark: #B84743;
    --bg: #ffffff;
    --bg-hover: #f5f5f5;
    --surface: #f8f9fa;
    --surface-2: #f0f9ff;
    --text: #333333;
    --text-muted: #666666;
    --text-light: #9ca3af;
    --border: #e5e7eb;
    --border-hover: #d1d5db;
    --border-light: #f0f0f0;
    --shadow: rgba(0,0,0,0.1);
    --shadow-md: rgba(0,0,0,0.15);
    background: #ffffff;
    color: #333333;
}

/* ── Leaflet popup: always light mode ── */
[data-theme="night"] .leaflet-popup-content-wrapper {
    --surface: #f8f9fa;
    --text: #333333;
    --text-muted: #666666;
    --border: #e5e7eb;
    --border-hover: #d1d5db;
    background: #ffffff;
    color: #333333;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

[data-theme="night"] .leaflet-popup-tip {
    background: #ffffff;
}

/* ── Welcome Modal ───────────────────────────────────────────── */
.welcome-modal-content {
    max-width: 680px;
    width: 92%;
    overflow: hidden; /* keeps cover corners clipped */
}

/* Cover image area */
.welcome-cover-area {
    position: relative;
    width: 100%;
    height: 185px;
    overflow: hidden;
}

.welcome-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 60%;
    display: block;
}

.welcome-cover-inline {
    margin: 0;
    overflow: hidden;
    height: 260px;
}

/* Title strip */
.welcome-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.75rem;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);  
    color: white;
    border-radius: 16px 16px 0 0;
}

.welcome-modal-header h2 {
    margin: 0;
    font-size: 1.35rem;
}

/* Partner logos row */
.welcome-logos-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.welcome-partner-logo {
    width: auto;
    max-width: 90%;
    display: block;
    object-fit: contain;
}

.welcome-modal-body {
    padding: 1.5rem 1.75rem 0.75rem;
    overflow-y: auto;
    max-height: 45vh;
}

.welcome-section {
    margin-bottom: 1.25rem;
}

.welcome-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.welcome-section-no-top-border {
    border-top: none;
    padding-top: 1.25rem;
}

.welcome-section h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    margin: 0 0 0.6rem;
}

.welcome-section p {
    margin: 0 0 0.5rem;
    font-size: 0.93rem;
    line-height: 1.55;
    color: var(--text);
}

.welcome-section ul, .welcome-section ol {
    margin: 0.25rem 0 0.5rem 1.25rem;
    padding: 0;
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--text);
}

/* CTA buttons area */
.welcome-modal-actions {
    padding: 1rem 1.75rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border-top: 1px solid var(--border);
    background: var(--bg);
    border-radius: 0 0 16px 16px;
}

.welcome-cta-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.6rem;
}

.welcome-btn-start,
.welcome-btn-signin,
.welcome-btn-tour,
.welcome-btn-close {
    flex: 1 1 0;
    min-width: 0;
    white-space: nowrap;
    font-size: 0.82rem;
    padding-left: 0.6rem;
    padding-right: 0.6rem;
    justify-content: center;
}

/* Ghost / tertiary button variant */
.btn-ghost {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    border-radius: 8px;
    padding: 0.5rem 1.1rem;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.btn-ghost:hover {
    background: var(--bg-secondary, #f3f4f6);
    border-color: var(--border-hover);
    color: var(--text);
}

.btn-secondary {
    background: var(--bg-secondary, #f0f4f8);
    border: 1.5px solid var(--accent);
    color: var(--accent);
    border-radius: 8px;
    padding: 0.55rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-secondary:hover {
    background: var(--accent);
    color: #fff;
}

/* "Don't show" checkbox row */
.welcome-dont-show-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.welcome-dont-show-label input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .welcome-modal-content {
        width: 96%;
    }

    .welcome-modal-body {
        max-height: 44vh;
    }

    .welcome-cta-buttons {
        flex-direction: column;
    }

    .welcome-btn-start,
    .welcome-btn-signin,
    .welcome-btn-tour,
    .welcome-btn-close {
        width: 100%;
        font-size: 0.88rem;
        padding-left: 1.1rem;
        padding-right: 1.1rem;
    }
}

/* ── Auth / User button ────────────────────────────────────────────────────── */

.user-btn {
    position: relative;
    border: 1.5px solid transparent;
    transition: border-color 0.2s;
}

.user-btn.logged-in {
    border-color: var(--accent);
}

.user-initial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    line-height: 1;
    text-transform: uppercase;
    user-select: none;
    pointer-events: none;
}

/* ── Auth modal ────────────────────────────────────────────────────────────── */

.auth-modal-content {
    max-width: 440px;
    width: 96%;
}

/* Explainer: guest vs registered */
.auth-explainer {
    background: var(--bg-secondary, rgba(0,0,0,0.04));
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.1rem;
    font-size: 0.85rem;
    color: var(--text-secondary, var(--text-muted));
    line-height: 1.5;
    text-align: center;
    margin: 0 0 1.1rem 0;
}

/* Tab switcher */
.auth-tabs {
    display: flex;
    gap: 0;
    border: 1.5px solid var(--accent);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 1.1rem;
}

.auth-tab {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--accent);
    transition: background 0.15s, color 0.15s;
}

.auth-tab.active {
    background: var(--accent);
    color: #fff;
}

.auth-tab:not(.active):hover {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* Form rows */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* Password field with reveal toggle */
.password-field {
    position: relative;
    display: flex;
    align-items: center;
}

.password-field .form-control {
    padding-right: 2.4rem;
    flex: 1;
}

.password-reveal {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2.2rem;
    height: 100%;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: color 0.15s;
}

.password-reveal:hover {
    color: var(--accent);
}

.eye-icon {
    pointer-events: none;
    flex-shrink: 0;
}

.auth-submit-btn {
    width: 100%;
    margin-top: 0.5rem;
}

/* GDPR consent */
.auth-gdpr-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary, var(--text));
    margin-top: 0.6rem;
    margin-bottom: 0.1rem;
    cursor: pointer;
    line-height: 1.4;
}

.auth-gdpr-label input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: var(--accent);
}

/* Forgot / back links */
.auth-link-btn {
    display: block;
    width: 100%;
    background: none;
    border: none;
    padding: 0.5rem 0;
    text-align: center;
    font-size: 0.82rem;
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
}

.auth-link-btn:hover {
    opacity: 0.8;
}

/* Small helper text */
.auth-hint {
    font-size: 0.85rem;
    color: var(--text-secondary, var(--text));
    margin: 0 0 0.75rem;
}

/* Status / feedback */
.auth-status {
    margin-top: 0.85rem;
    padding: 0.6rem 0.85rem;
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1.4;
}

.auth-status.error {
    background: rgba(220,53,69,0.12);
    color: #b91c2c;
    border: 1px solid rgba(220,53,69,0.3);
}

.auth-status.success {
    background: rgba(25,135,84,0.12);
    color: #146c3e;
    border: 1px solid rgba(25,135,84,0.3);
}

.auth-status.info {
    background: rgba(13,110,253,0.1);
    color: #084298;
    border: 1px solid rgba(13,110,253,0.25);
}

/* Account modal */
.account-modal-content {
    max-width: 340px;
}

.account-email {
    font-size: 0.9rem;
    word-break: break-all;
    margin-bottom: 1rem;
    color: var(--text);
    text-align: center;
}

/* Dark theme tweaks */
[data-theme="night"] .auth-status.error {
    color: #f87171;
}

[data-theme="night"] .auth-status.success {
    color: #4ade80;
}

[data-theme="night"] .auth-status.info {
    color: #93c5fd;
}

@media (max-width: 480px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    /* auth-explainer is already block, no change needed */
}

/* ── Bottom-panel KPI chips (Comfort / Traffic / Data Sources) ──────── */
/*
 * Row of glanceable chips that replaced the deleted route-info card.
 * Sits inside .bottom-panel between the weather grid and the savings
 * banner. Hidden when no route is planned.
 */
.bottom-panel-kpis {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    border-top: 1px solid var(--surface-border, #e2e8f0);
    background: var(--surface, #f8fafc);
}
.bottom-panel-kpis[hidden] { display: none; }

.kpi-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: var(--bg, #fff);
    border: 1px solid var(--surface-border, #e2e8f0);
    font-size: 0.82rem;
    line-height: 1.2;
    color: var(--text, #1e293b);
    cursor: default;
}
button.kpi-chip {
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}
button.kpi-chip:hover  { background: var(--surface, #f1f5f9); }
button.kpi-chip:active { transform: scale(0.97); }
button.kpi-chip:focus-visible {
    outline: 2px solid var(--accent, #667eea);
    outline-offset: 2px;
}

/* Disabled state — upstream data source for this KPI is reporting
   ok=false (status endpoint). Greyed out and non-clickable (click is
   suppressed in JS), but still hoverable so the native title tooltip —
   rewritten by _applyKpiAvailability to name the missing source and its
   reason — can show. */
.kpi-chip.kpi-disabled {
    opacity: 0.45;
    background: var(--surface, #f1f5f9);
    color: var(--text-muted, #94a3b8);
    cursor: not-allowed;
}
button.kpi-chip.kpi-disabled:hover { background: var(--surface, #f1f5f9); }
button.kpi-chip.kpi-disabled:active { transform: none; }
/* Keep pointer-events enabled so the native title tooltip shows on hover;
   the click is suppressed in JS and cursor:not-allowed signals non-interactivity. */

/* ── KPI detail modal — per-leg primary-vs-baseline line chart ─── */
.kpi-detail-modal-content { max-width: 640px; }
.kpi-chart-svg {
    width: 100%;
    height: auto;
    display: block;
}
.kpi-chart-frame {
    fill: none;
    stroke: var(--surface-border, #cbd5e1);
    stroke-width: 0.8;
}
.kpi-chart-tick {
    stroke: var(--surface-border, #cbd5e1);
    stroke-width: 0.8;
}
.kpi-chart-axis-text {
    font-size: 9px;
    fill: var(--text-muted, #64748b);
    font-family: var(--font-sans, system-ui), sans-serif;
}
.kpi-chart-axis-title {
    font-size: 9px;
    fill: var(--text, #1e293b);
    font-weight: 500;
}
.kpi-chart-primary {
    stroke: var(--accent, #667eea);
    stroke-width: 2.2;
    stroke-linejoin: round;
    stroke-linecap: round;
}
.kpi-chart-baseline {
    stroke: #94a3b8;
    stroke-width: 1.6;
    stroke-dasharray: 5 3;
    stroke-linejoin: round;
}
.kpi-chart-threshold-comfort {
    stroke: #f59e0b;        /* amber */
    stroke-width: 1.2;
    stroke-dasharray: 3 3;
}
.kpi-chart-threshold-safety {
    stroke: #dc2626;        /* red */
    stroke-width: 1.4;
    stroke-dasharray: 6 3;
}
.kpi-chart-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1rem;
    margin: 0.5rem 0 0.4rem;
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
}
.kpi-chart-legend-swatch {
    display: inline-block;
    width: 18px;
    height: 3px;
    margin-right: 0.25rem;
    vertical-align: middle;
}
.kpi-chart-legend-primary  { background: var(--accent, #667eea); height: 3px; }
.kpi-chart-legend-baseline {
    background: repeating-linear-gradient(to right, #94a3b8 0 5px, transparent 5px 8px);
}
.kpi-chart-legend-comfort  {
    background: repeating-linear-gradient(to right, #f59e0b 0 3px, transparent 3px 6px);
}
.kpi-chart-legend-safety   {
    background: repeating-linear-gradient(to right, #dc2626 0 6px, transparent 6px 9px);
}
.kpi-stars-formula {
    margin: 0.6rem 0 0;
    padding: 0.5rem 0.7rem;
    background: var(--surface, #f1f5f9);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text, #1e293b);
    line-height: 1.45;
}
.kpi-detail-empty {
    margin: 0.5rem 0;
    color: var(--text-muted, #64748b);
    font-size: 0.85rem;
    font-style: italic;
}

.kpi-label { font-weight: 600; }
.kpi-value { font-variant-numeric: tabular-nums; color: var(--text-muted, #64748b); }

/* Stars are coloured per-tier so the rating reads at a glance.
   Container's data-stars attribute (set by _renderStars) drives the
   colour. Tier-5 = green, tier-1 = red. */
.kpi-stars {
    font-family: monospace;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
}
.kpi-stars[data-stars="5"] { color: #16a34a; }
.kpi-stars[data-stars="4"] { color: #65a30d; }
.kpi-stars[data-stars="3"] { color: #d97706; }
.kpi-stars[data-stars="2"] { color: #ea580c; }
.kpi-stars[data-stars="1"] { color: #dc2626; }

/* ── Advanced settings (weights + hard limits) ─────────────────────── */

.advanced-settings {
    margin: 0.75rem 0 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--surface-border, #e2e8f0);
    border-radius: 8px;
    background: var(--surface, #f8fafc);
}
.advanced-settings[hidden] { display: none; }
.advanced-settings > summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text, #1e293b);
    margin-bottom: 0.5rem;
}
.advanced-settings h4 {
    margin: 0.75rem 0 0.25rem;
    font-size: 0.88rem;
    color: var(--text, #1e293b);
}
.advanced-hint {
    margin: 0 0 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
    line-height: 1.4;
}

.weight-row {
    display: grid;
    grid-template-columns: 7rem 1fr 3rem;
    align-items: center;
    gap: 0.5rem;
    margin: 0.3rem 0;
}
.weight-row > label { font-size: 0.85rem; color: var(--text, #1e293b); }
.weight-row > input[type="range"] { width: 100%; }
.weight-readout {
    font-family: monospace;
    font-size: 0.85rem;
    text-align: right;
    color: var(--text-muted, #64748b);
    font-variant-numeric: tabular-nums;
}

.advanced-thresholds-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: 0.85rem;
}
.advanced-thresholds-table thead th {
    font-weight: 600;
    text-align: right;
    padding: 0.35rem 0.4rem;
    border-bottom: 1px solid var(--surface-border, #cbd5e1);
    color: var(--text, #1e293b);
}
.advanced-thresholds-table thead th:first-child {
    text-align: left;
}
.advanced-thresholds-table tbody td {
    padding: 0.3rem 0.4rem;
    vertical-align: middle;
}
.advanced-thresholds-table tbody td:first-child {
    color: var(--text, #1e293b);
}
.advanced-thresholds-table input[type="number"] {
    width: 100%;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--surface-border, #cbd5e1);
    border-radius: 4px;
    font: inherit;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.advanced-error {
    margin: 0.5rem 0;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    background: #fef2f2;
    color: #991b1b;
    font-size: 0.82rem;
    border: 1px solid #fecaca;
}
.advanced-error[hidden] { display: none; }

#reset-advanced {
    margin-top: 0.75rem;
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--surface-border, #cbd5e1);
    background: var(--bg, #fff);
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
}
#reset-advanced:hover { background: var(--surface, #f1f5f9); }

/* ── Cost polar widget (advanced mode, map overlay) ────────────────── */
/*
 * Floats in the map's bottom-right corner. Two visual states driven
 * by .collapsed / .expanded class on the widget:
 *   - collapsed: 120 × 120 px thumbnail, click-to-expand
 *   - expanded:  min(80vw, 480px) square, with a reduce button
 * Hidden via the [hidden] attribute when advanced mode is off, or
 * when the viewport is too small to host the widget comfortably.
 */
.cost-polar-widget {
    position: absolute;
    z-index: 800;                    /* above map controls, below modals */
    background: transparent;
    border: none;
    border-radius: 8px;
    box-shadow: none;
    transition: width 0.2s ease, height 0.2s ease, right 0.2s ease;
    overflow: hidden;
    cursor: pointer;                 /* whole diagram toggles its size */
    /* Always render the diagram with the dark palette — it reads best as
       a dark translucent disc, so we pin the night-mode theme variables
       here regardless of the page theme. The SVG children inherit these
       via var(--bg)/--surface/--text. */
    --bg: #0d0000;
    --surface: #1a0505;
    --text: #f0f0f0;
}
.cost-polar-widget[hidden] { display: none; }
.cost-polar-widget.collapsed {
    width: 120px;
    height: 120px;
    right: 0.75rem;
    bottom: calc(var(--bottom-panel-height, 0px) + 0.75rem);
}
.cost-polar-widget.expanded {
    width: min(80vw, 480px);
    height: min(80vw, 480px);
    right: 0.75rem;
    bottom: calc(var(--bottom-panel-height, 0px) + 0.75rem);
}
/* When the desktop warnings side panel (350px, pinned right) is open it
   sits above the polar (z-index 1000 > 800) and hides it in the
   bottom-right corner. Shift the polar left of the panel so the two sit
   side by side instead of overlapping — mirrors the POI-gallery shift. */
.container:has(.warnings-side-panel[style*="display: block"]) .cost-polar-widget,
.container:has(.warnings-side-panel[style*="display: flex"]) .cost-polar-widget,
.container:has(.warnings-side-panel:not([style*="display: none"])) .cost-polar-widget {
    right: calc(350px + 0.75rem);
}
.cost-polar-widget svg {
    width: 100%;
    height: 100%;
    display: block;
}
/* SVG inner styles — match Leaflet's vector aesthetic. */
.polar-bg {
    /* Round translucent backing disc — adapts to the active theme via
       --bg (white in light mode, dark in night mode). */
    fill: var(--bg, #ffffff);
    fill-opacity: 0.72;
    stroke: var(--surface-border, #e2e8f0);
    stroke-width: 0.6;
}
.polar-chip {
    /* Pill background behind each axis title. Solid surface so the
       label reads clearly over the map; theme-aware via --surface. */
    fill: var(--surface, #f1f5f9);
    stroke: var(--surface-border, #cbd5e1);
    stroke-width: 0.6;
}
.polar-chip-dim {
    opacity: 0.4;
}
.polar-grid {
    fill: none;
    stroke: var(--surface-border, #e2e8f0);
    stroke-width: 0.6;
}
.polar-spoke {
    stroke: var(--surface-border, #cbd5e1);
    stroke-width: 0.6;
}
.polar-spoke-dim {
    stroke-dasharray: 2 3;
    opacity: 0.4;
}
.polar-label {
    font-size: 8px;
    fill: var(--text, #1e293b);
    font-family: var(--font-sans, system-ui), sans-serif;
    text-transform: capitalize;
}
.polar-label-dim {
    opacity: 0.4;
}
.polar-primary {
    fill: var(--accent, #667eea);
    fill-opacity: 0.25;
    stroke: var(--accent, #667eea);
    stroke-width: 2;
    stroke-linejoin: round;
}
.polar-baseline {
    fill: #94a3b8;
    fill-opacity: 0.15;
    stroke: #94a3b8;
    stroke-width: 1;
    stroke-dasharray: 4 3;
    stroke-linejoin: round;
}

/* ── Data sources modal (sized so the provenance list scrolls) ────── */
.data-sources-modal-content {
    max-width: 540px;
}
.data-sources-modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

/* On narrow phones, shrink the collapsed thumbnail a touch so it stays
   clear of the map controls, but keep it visible — tapping expands it to
   ~80vw, which is readable even on a phone. */
@media (max-width: 480px) {
    .cost-polar-widget.collapsed {
        width: 96px;
        height: 96px;
    }
}
