﻿/* ==========================================================================
   NB Flood Watch  Glassmorphism Theme (inspired by nbfiremap.ca)
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
    /* Status colors: blue > green > yellow > orange > red */
    --c-normal:   #3b82f6;   /* blue */
    --c-advisory: #22c55e;   /* green */
    --c-watch:    #eab308;   /* yellow */
    --c-warning:  #f97316;   /* orange */
    --c-flood:    #dc2626;   /* red */
    --c-nodata:   #6b7280;   /* slate gray */
    --c-record:   #a855f7;   /* purple */

    /* Glass surfaces */
    --glass-dark:    rgba(0,0,0,0.45);
    --glass-light:   rgba(255,255,255,0.42);
    --glass-medium:  rgba(255,255,255,0.20);
    --glass-blur:    blur(20px);
    --glass-blur-sat: blur(20px) saturate(1.4);

    /* Text */
    --text-primary:   #ffffff;
    --text-secondary: rgba(255,255,255,0.75);
    --text-muted:     rgba(255,255,255,0.50);
    --text-dark:      #1e293b;
    --text-dark-muted:#64748b;

    /* Layout */
    --bottom-h: 86px;
    --ctrl-size: 44px;
    --panel-radius: 16px;

    /* Misc */
    --shadow: 0 8px 32px rgba(0,0,0,0.25);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.15);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    /* z-index layers */
    --z-controls: 2000;
    --z-logo:     2200;
    --z-bottom:   2500;
    --z-legend:   3000;
    --z-panel:    3500;
    --z-modal:    4000;
    --z-toast:    5000;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: 'Open Sans', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    letter-spacing: .1px;
    color: var(--text-primary);
    background: #1a1a2e;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
ul { list-style: none; }
button { cursor: pointer; font: inherit; border: none; background: none; color: inherit; }
a { color: var(--c-normal); }

/* ---------- Full-screen map ---------- */
#map {
    position: fixed;
    inset: 0;
    z-index: 1;
}

/* Remove leaflet default zoom control (we have our own) */
.leaflet-control-zoom { display: none !important; }

/* ---------- Logo ---------- */
.map-logo {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-logo);
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Open Sans', system-ui, -apple-system, sans-serif;
    font-size: 42px;
    font-weight: 500;
    letter-spacing: -0.02em;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
    pointer-events: none;
    user-select: none;
}
.logo-icon { filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5)); }

/* ---------- Left controls ---------- */
.left-controls {
    position: fixed;
    top: 80px;
    left: 20px;
    z-index: var(--z-controls);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ctrl-btn {
    width: var(--ctrl-size);
    height: var(--ctrl-size);
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.ctrl-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}
.ctrl-btn:active { transform: translateY(0); }
.ctrl-btn:focus-visible { box-shadow: 0 0 0 3px rgba(255,255,255,.5); outline: none; }

/* ---------- Legend / Stations panel ---------- */
.legend-panel {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 300px;
    max-height: calc(100vh - var(--bottom-h) - 48px);
    z-index: var(--z-legend);
    background: var(--glass-light);
    backdrop-filter: var(--glass-blur-sat);
    -webkit-backdrop-filter: var(--glass-blur-sat);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--panel-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity var(--transition), transform var(--transition);
}
.legend-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(20px);
}

/* ---------- Layers panel ---------- */
.layers-panel {
    position: fixed;
    top: 80px;
    left: 72px;
    width: 300px;
    max-height: calc(100vh - var(--bottom-h) - 100px);
    z-index: var(--z-legend);
    background: var(--glass-light);
    backdrop-filter: var(--glass-blur-sat);
    -webkit-backdrop-filter: var(--glass-blur-sat);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--panel-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overflow-y: auto;
    transition: opacity var(--transition), transform var(--transition);
}
.layers-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-20px);
}

.legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
}
.legend-title {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: var(--text-dark);
}
.legend-close-btn {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-dark-muted);
    transition: background var(--transition);
}
.legend-close-btn:hover { background: rgba(0,0,0,0.08); }

/* Legend rows */
.legend-colors { padding: 0 16px 12px; }
.legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 13px;
    color: var(--text-dark);
}
.legend-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.7);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.legend-count {
    margin-left: auto;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    min-width: 20px;
    text-align: right;
}

/* Collapsible section headers */
.legend-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    cursor: pointer;
    border-top: 1px solid rgba(0,0,0,0.08);
    user-select: none;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: var(--text-dark);
    transition: background var(--transition);
}
.legend-section-header:hover { background: rgba(0,0,0,0.04); }
.legend-section-header .chevron {
    transition: transform var(--transition);
    color: var(--text-dark-muted);
}
.legend-section-header.collapsed .chevron {
    transform: rotate(-90deg);
}

/* Station section */
.station-section {
    overflow-y: auto;
    max-height: 45vh;
    transition: max-height var(--transition);
}
.station-section.collapsed-content {
    max-height: 0;
    overflow: hidden;
}
.basemap-section {
    padding: 8px 16px 12px;
    transition: max-height var(--transition);
}
.basemap-section.collapsed-content {
    max-height: 0;
    overflow: hidden;
    padding: 0 16px;
}

/* Sort bar */
.station-sort-bar {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
}
.sort-btn {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(0,0,0,0.06);
    color: var(--text-dark-muted);
    transition: all var(--transition);
}
.sort-btn:hover { background: rgba(0,0,0,0.12); }
.sort-btn.active {
    background: var(--c-normal);
    color: #fff;
}

/* Station list items */
#station-list {
    padding: 0 8px 8px;
}
.station-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background var(--transition);
}
.station-item:hover { background: rgba(0,0,0,0.06); }
.station-item.selected { background: rgba(0,0,0,0.10); }
.station-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.5);
}
.station-name {
    flex: 1;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.station-level {
    font-size: 11px;
    font-family: 'Inter', sans-serif;
    font-variant-numeric: tabular-nums;
    color: var(--text-dark-muted);
}
.station-trend {
    font-size: 14px;
    width: 16px;
    text-align: center;
}

/* Basemap options */
.basemap-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
    color: var(--text-dark);
    cursor: pointer;
}
.basemap-opt input { accent-color: var(--c-normal); }

/* Overlay layer toggles */
.overlay-section {
    padding: 8px 16px 12px;
    transition: max-height var(--transition);
}
.overlay-section.collapsed-content {
    max-height: 0;
    overflow: hidden;
    padding: 0 16px;
}
.overlay-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
    color: var(--text-dark);
    cursor: pointer;
}
.overlay-opt input { accent-color: var(--c-normal); }

/* Legend footer */
.legend-footer {
    padding: 8px 16px 12px;
    border-top: 1px solid rgba(0,0,0,0.08);
}
.legend-ts {
    font-size: 11px;
    color: var(--text-dark-muted);
}

/* ---------- Station detail panel (bottom sheet) ---------- */
.station-panel {
    position: fixed;
    bottom: calc(var(--bottom-h) + 12px);
    left: 50%;
    transform: translateX(-50%);
    width: min(94vw, 900px);
    max-height: 55vh;
    z-index: var(--z-panel);
    background: var(--glass-dark);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--panel-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity var(--transition), transform var(--transition);
}
.station-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(30px);
}

.sp-drag-handle {
    width: 36px; height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    margin: 8px auto 4px;
}
.sp-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 4px 16px 8px;
}
.sp-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.sp-title-row h2 {
    font-family: 'Inter', sans-serif;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
}
.sp-badge {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 10px;
    border-radius: 20px;
}
.sp-badge.normal   { background: var(--c-normal);   color: #fff; }
.sp-badge.advisory { background: var(--c-advisory); color: #fff; }
.sp-badge.watch    { background: var(--c-watch);    color: #fff; }
.sp-badge.warning  { background: var(--c-warning);  color: #fff; }
.sp-badge.flood    { background: var(--c-flood);    color: #fff; }
.sp-badge.nodata   { background: var(--c-nodata);   color: #fff; }

.sp-close {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: rgba(255,255,255,0.7);
    transition: background var(--transition);
    flex-shrink: 0;
}
.sp-close:hover { background: rgba(255,255,255,0.15); }

/* Meta bar */
.sp-meta {
    display: flex;
    gap: 20px;
    padding: 0 16px 10px;
}
.sp-meta-item { display: flex; flex-direction: column; }
.sp-meta-val {
    font-family: 'Inter', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
}
.sp-meta-lbl {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 1px;
}

/* Chart */
.sp-chart-wrap {
    flex: 1;
    min-height: 180px;
    max-height: 260px;
    padding: 0 12px;
    position: relative;
}
.sp-chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Footer */
.sp-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 12px;
    flex-wrap: wrap;
    gap: 8px;
}
.sp-thresholds {
    display: flex;
    gap: 10px;
    font-size: 11px;
    flex-wrap: wrap;
}
.sp-th {
    display: flex;
    align-items: center;
    gap: 3px;
    color: var(--text-secondary);
}
.sp-th[data-level="advisory"] b { color: var(--c-advisory); }
.sp-th[data-level="watch"]    b { color: var(--c-watch); }
.sp-th[data-level="warning"]  b { color: var(--c-warning); }
.sp-th[data-level="flood"]    b { color: var(--c-flood); }
.sp-th[data-level="record"]   b { color: var(--c-record); }

.sp-wsc-link {
    font-size: 12px;
    color: var(--c-normal);
    text-decoration: none;
}
.sp-wsc-link:hover { text-decoration: underline; }

/* ---------- Bottom pill bar ---------- */
.bottom-bar {
    position: fixed;
    bottom: calc(30px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-bottom);
    display: flex;
    align-items: center;
    gap: 30px;
    padding: 15px 25px;
    background: rgba(0,0,0,0.45);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: none;
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
.bb-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    color: white;
    text-decoration: none;
    transition: background var(--transition), transform var(--transition);
    white-space: nowrap;
}
.bb-btn:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-1px);
}
.bb-btn:focus-visible { box-shadow: 0 0 0 3px rgba(255,255,255,.5); outline: none; }
.bb-btn svg { flex-shrink: 0; margin-bottom: 2px; }

/* ---------- Modals ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    transition: opacity var(--transition);
}
.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.modal-card {
    width: min(92vw, 540px);
    max-height: 80vh;
    background: rgba(15,23,42,0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--panel-radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    overflow: auto;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.modal-header h3 {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #f1f5f9;
}
.modal-close {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: rgba(255,255,255,0.6);
}
.modal-close:hover { background: rgba(255,255,255,0.1); color: #fff; }

.modal-body {
    padding: 16px 20px 20px;
    font-size: 13px;
    line-height: 1.6;
    color: #e2e8f0;
}
.modal-body p { margin-bottom: 10px; }
.modal-body ul { padding-left: 18px; margin-bottom: 10px; list-style: disc; }
.modal-body li { margin-bottom: 4px; }
.modal-body a { color: #60a5fa; }
.modal-body h4 {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    margin: 16px 0 6px;
}
.modal-body h4:first-of-type { margin-top: 8px; }
.modal-body .status-list { list-style: none; padding-left: 0; }
.modal-body .status-list li { display: flex; align-items: center; gap: 8px; }
.help-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.help-disclaimer {
    font-size: 11px;
    opacity: 0.65;
    margin-top: 14px;
    line-height: 1.5;
}

/* ---------- Splash Screen ---------- */
.splash-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.4s ease;
}
.splash-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.splash-card {
    width: min(92vw, 420px);
    background: #fff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.18);
    padding: 32px 28px 24px;
    text-align: center;
    color: #334155;
}
.splash-icon {
    margin-bottom: 8px;
    color: var(--c-normal);
}
.splash-title {
    font-family: 'Open Sans', sans-serif;
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #0f172a;
    margin-bottom: 4px;
}
.splash-subtitle {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 18px;
}
.splash-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    text-align: left;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    line-height: 1.5;
    color: #92400e;
}
.splash-notice svg { color: #d97706; }
.splash-official-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    background: #2563eb;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    border-radius: 10px;
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s;
    margin-bottom: 18px;
}
.splash-official-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(37,99,235,0.35);
}
.splash-thanks {
    border-top: 1px solid #e2e8f0;
    padding-top: 14px;
    margin-bottom: 16px;
}
.splash-thanks p {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    font-weight: 600;
    margin-bottom: 8px;
}
.splash-providers {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
}
.splash-providers span {
    font-size: 12px;
    line-height: 1.4;
    color: #475569;
}
.splash-providers strong {
    font-size: 12px;
    color: #1e293b;
}
.splash-enter-btn {
    width: 100%;
    padding: 13px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #0f172a;
    font-size: 14px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
}
.splash-enter-btn:hover {
    background: #e2e8f0;
}

/* Summary table inside modal */
.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin: 10px 0;
}
.summary-table th,
.summary-table td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}
.summary-table th {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.3px;
    color: var(--text-dark-muted);
}
.summary-table .status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
    vertical-align: middle;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: calc(var(--bottom-h) + 24px);
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-toast);
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
    color: #fff;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 13px;
    box-shadow: var(--shadow-sm);
    transition: opacity 0.3s, transform 0.3s;
}
.toast-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(10px);
}

/* ---------- Leaflet map marker overrides ---------- */
.flood-marker {
    border-radius: 50%;
    border: 2.5px solid rgba(255,255,255,0.85);
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    transition: transform var(--transition), box-shadow var(--transition);
}
.flood-marker:hover {
    transform: scale(1.3);
    box-shadow: 0 3px 12px rgba(0,0,0,0.5);
}
.flood-marker.normal   { background: var(--c-normal); }
.flood-marker.advisory { background: var(--c-advisory); }
.flood-marker.watch    { background: var(--c-watch); }
.flood-marker.warning  { background: var(--c-warning); }
.flood-marker.flood    { background: var(--c-flood); }
.flood-marker.nodata   { background: var(--c-nodata); }

/* Selected marker pulse */
.flood-marker.selected {
    animation: marker-pulse 1.5s ease-in-out infinite;
}
@keyframes marker-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0.5); }
    50% { box-shadow: 0 0 0 10px rgba(255,255,255,0); }
}

/* ---------- City / Town Labels (matching nbfiremap.ca) ---------- */
.city-marker-icon {
    background: none !important;
    border: none !important;
}
.city-label-tooltip {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}
.city-label-tooltip::before,
.city-label-tooltip::after {
    display: none !important;
}
.city-label {
    font-size: 15px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 2px rgba(0,0,0,.7), 0 0 8px rgba(0,0,0,.6), 1px 1px 0 rgba(0,0,0,.9);
    white-space: nowrap;
    pointer-events: none;
}

/* Leaflet tooltip */
.station-tooltip {
    background: var(--glass-dark) !important;
    backdrop-filter: var(--glass-blur) !important;
    border: 1px solid rgba(255,255,255,0.15) !important;
    border-radius: 10px !important;
    color: #fff !important;
    padding: 8px 12px !important;
    font-family: 'Open Sans', sans-serif !important;
    font-size: 12px !important;
    box-shadow: var(--shadow-sm) !important;
}
.station-tooltip .popup-name { font-weight: 700; margin-bottom: 2px; }
.station-tooltip .popup-level { font-size: 11px; opacity: 0.8; }
.station-tooltip::before { border-top-color: rgba(0,0,0,0.45) !important; }
.leaflet-tooltip-top::before { border-top-color: rgba(0,0,0,0.45) !important; }

/* Leaflet attribution */
.leaflet-control-attribution {
    background: rgba(255,255,255,0.5) !important;
    backdrop-filter: blur(4px);
    border-radius: 4px;
    font-size: 10px !important;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    .left-controls { top: 70px; left: 12px; gap: 6px; }
    .ctrl-btn { width: 48px; height: 48px; }

    .legend-panel {
        width: calc(100vw - 24px);
        right: 12px;
        top: 12px;
        max-height: calc(100vh - var(--bottom-h) - 36px);
    }

    .station-panel {
        width: calc(100vw - 16px);
        bottom: calc(var(--bottom-h) + 8px);
        max-height: 60vh;
    }

    .bottom-bar { bottom: calc(20px + env(safe-area-inset-bottom, 0px)); padding: 12px 20px; gap: 20px; }
    .bb-btn { padding: 6px 10px; font-size: 11px; }
    .bb-btn svg { width: 18px; height: 18px; }

    .map-logo { top: 12px; font-size: 26px; gap: 4px; }
}

@media (max-width: 480px) {
    .ctrl-btn { width: 44px; height: 44px; }
    .ctrl-btn svg { width: 15px; height: 15px; }
    .bottom-bar { gap: 15px; padding: 10px 15px; }
    .sp-meta { gap: 12px; }
    .sp-meta-val { font-size: 15px; }
    .sp-thresholds { gap: 6px; }
}

/* ---------- Loading spinner ---------- */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
}
.loading-overlay.hidden { display: none; }
.spinner-ring {
    width: 40px; height: 40px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: var(--c-normal);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Chart no-data overlay */
.chart-no-data {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 5;
}
.chart-no-data span {
    background: rgba(15,23,42,0.65);
    color: rgba(255,255,255,0.55);
    font: 600 13px/1.4 'Inter', sans-serif;
    padding: 8px 18px;
    border-radius: 8px;
    letter-spacing: 0.03em;
    backdrop-filter: blur(6px);
}
