/* AirSense Monitor — adapted from /design/design_index.html.
   Layout: top bar → hero (snapshot + Leaflet map) → sensor card grid.
   The card / modal / sparkline visuals are unchanged from the mockup. */

:root {
    --bg: oklch(98.8% 0.004 230);
    --surface: oklch(100% 0 0);
    --surface-2: oklch(96.5% 0.006 230);
    --fg: oklch(20% 0.018 245);
    --muted: oklch(50% 0.014 245);
    --border: oklch(90% 0.008 245);
    --accent: oklch(57% 0.13 180);
    --accent-strong: oklch(50% 0.15 190);
    --good: oklch(58% 0.15 150);
    --warn: oklch(70% 0.16 75);
    --danger: oklch(59% 0.18 28);
    --info: oklch(56% 0.15 245);
    --shadow: 0 18px 50px color-mix(in oklch, var(--fg), transparent 88%);
    --radius: 18px;
    --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html {
    min-width: 320px;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at top left, color-mix(in oklch, var(--accent), transparent 82%), transparent 32rem),
        linear-gradient(180deg, var(--bg) 0%, oklch(97% 0.008 218) 100%);
}

button, select { font: inherit; }
button { cursor: pointer; }

.app {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 24px clamp(16px, 3vw, 40px) 48px;
}

/* ── Top bar ────────────────────────────────────────────────────────── */
.topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    margin-bottom: 24px;
}

.brand { display: flex; gap: 14px; align-items: center; min-width: 0; }

.brand-mark {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: white;
    background: linear-gradient(145deg, var(--accent), var(--info));
    box-shadow: 0 14px 36px color-mix(in oklch, var(--accent), transparent 66%);
}

.brand h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 2vw, 2rem);
    letter-spacing: 0;
    line-height: 1.05;
}

.brand p { margin: 4px 0 0; color: var(--muted); font-size: 0.95rem; }

.toolbar { display: flex; align-items: center; gap: 10px; justify-content: end; }

.search-wrap {
    min-height: 44px;
    border: 1px solid var(--border);
    background: color-mix(in oklch, var(--surface), transparent 4%);
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    color: var(--muted);
    box-shadow: 0 1px 0 color-mix(in oklch, white, transparent 20%) inset;
    min-width: min(250px, 30vw);
}

.search-wrap input {
    border: 0;
    background: transparent;
    outline: 0;
    min-width: 0;
    width: 100%;
    color: var(--fg);
    font: inherit;
}

/* ── Hero panel: snapshot text + map ────────────────────────────────── */
.hero-panel {
    background: color-mix(in oklch, var(--surface), transparent 5%);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: clamp(18px, 3vw, 30px);
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
    gap: 24px;
    margin-bottom: 20px;
}

.overview h2 {
    font-family: var(--font-display);
    font-size: clamp(1.9rem, 3vw, 3.05rem);
    letter-spacing: 0;
    line-height: 1.02;
    margin: 0 0 18px;
    text-wrap: balance;
}

.overview p {
    max-width: 62ch;
    color: var(--muted);
    font-size: clamp(1rem, 1.4vw, 1.16rem);
    line-height: 1.65;
    margin: 0;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 24px;
}

.summary-card {
    min-height: 124px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.summary-card span {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 800;
}

.summary-card strong {
    font-family: var(--font-display);
    font-size: 2.1rem;
    line-height: 1;
    letter-spacing: 0;
}

.chart-anomaly-count {
    color: var(--danger);
    font-weight: 700;
}

.chart-legend {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    color: var(--muted);
    font-size: 0.85rem;
}

.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }

.ma-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.ma-checkbox {
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Dim the swatch + label when the overlay is off, so the legend doubles as
   a visual on/off indicator without needing a separate cue. */
.ma-toggle:has(input:not(:checked)) { opacity: 0.45; }

.ma-swatch {
    display: inline-block;
    width: 26px;
    height: 0;
    border-top: 2px dashed var(--muted);
    vertical-align: middle;
}

.ma-swatch.ma-5s      { border-top-color: var(--info);   border-top-style: dashed; }
.ma-swatch.ma-30m     { border-top-color: var(--accent); border-top-style: dashed; }
.ma-swatch.ma-1h      { border-top-color: var(--good);   border-top-style: dashed; }
.ma-swatch.ma-anomaly { border-top-color: var(--danger); border-top-style: dotted; }

/* ── Distribution histogram ────────────────────────────────────────── */
.histogram-panel {
    background: color-mix(in oklch, var(--surface), transparent 5%);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: clamp(16px, 2vw, 22px);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.histogram-panel header { margin-bottom: 12px; }
.histogram-panel h2 { margin: 0 0 4px; font-family: var(--font-display); font-size: 1.2rem; }
.histogram-panel p  { margin: 0; color: var(--muted); font-size: 0.9rem; }

.histogram-wrap {
    position: relative;
    width: 100%;
}

.histogram-chart {
    width: 100%;
    height: 220px;
    display: block;
}

/* ── Correlation grid ──────────────────────────────────────────────── */
.correlation-panel {
    background: color-mix(in oklch, var(--surface), transparent 5%);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: clamp(16px, 2vw, 22px);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.correlation-panel header { margin-bottom: 12px; }
.correlation-panel h2 { margin: 0 0 4px; font-family: var(--font-display); font-size: 1.2rem; }
.correlation-panel p  { margin: 0; color: var(--muted); font-size: 0.9rem; }
.correlation-panel em { font-style: italic; }

.correlation-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr));
    gap: 6px 24px;
}

.correlation-grid li {
    display: grid;
    grid-template-columns: minmax(120px, 0.8fr) minmax(0, 1.4fr) auto;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid color-mix(in oklch, var(--border), transparent 50%);
}

.corr-name {
    color: var(--fg);
    font-weight: 600;
    text-decoration: none;
}
.corr-name:hover { color: var(--accent-strong); }
.corr-name small { display: block; color: var(--muted); font-weight: 500; font-size: 0.78rem; }

.corr-bar-wrap {
    background: var(--surface-2);
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.corr-bar {
    display: block;
    height: 100%;
    border-radius: 999px;
}

.corr-bar.positive { background: var(--good); }
.corr-bar.negative { background: var(--warn); }
.corr-bar.strong   { opacity: 1; }
.corr-bar.moderate { opacity: 0.7; }
.corr-bar.weak     { opacity: 0.4; }

.corr-r {
    font-variant-numeric: tabular-nums;
    text-align: right;
    font-weight: 700;
    font-size: 0.92rem;
    min-width: 72px;
}
.corr-r small { display: block; color: var(--muted); font-weight: 500; font-size: 0.72rem; }
.corr-na { color: var(--muted); font-weight: 600; }

/* ── Module switcher chips ─────────────────────────────────────────── */
.module-switcher {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 4px;
    border: 1px solid var(--border);
    background: color-mix(in oklch, var(--surface), transparent 4%);
    border-radius: 999px;
    box-shadow: 0 1px 0 color-mix(in oklch, white, transparent 20%) inset;
}

.module-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.92rem;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.module-chip:hover { color: var(--fg); background: color-mix(in oklch, var(--surface-2), transparent 20%); }

.module-chip.active {
    color: white;
    background: var(--accent);
    box-shadow: 0 8px 18px color-mix(in oklch, var(--accent), transparent 70%);
}

.module-chip .chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.45;
}

.module-chip.active .chip-dot { opacity: 1; }

/* Map panel — replaces the location dropdown / tabs from the mockup. */
.map-panel {
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface-2);
    overflow: hidden;
    min-height: 320px;
    display: flex;
}

#moduleMap { flex: 1 1 auto; min-height: 320px; }

/* ── Status row + sensor grid ───────────────────────────────────────── */
.status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 20px 0 14px;
}

.status-row h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.25rem;
    letter-spacing: 0;
}

.timestamp {
    color: var(--muted);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

.sensor-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.sensor-card {
    position: relative;
    min-height: 222px;
    background: color-mix(in oklch, var(--surface), transparent 2%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    text-align: left;
    color: inherit;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    gap: 14px;
    box-shadow: 0 8px 26px color-mix(in oklch, var(--fg), transparent 94%);
    transition: transform 200ms cubic-bezier(0.23, 1, 0.32, 1),
                border-color 200ms cubic-bezier(0.23, 1, 0.32, 1),
                box-shadow 200ms cubic-bezier(0.23, 1, 0.32, 1);
}

.sensor-card:hover,
.sensor-card:focus-visible {
    transform: translateY(-3px);
    border-color: color-mix(in oklch, var(--accent), white 42%);
    box-shadow: 0 18px 42px color-mix(in oklch, var(--accent), transparent 84%);
    outline: 0;
}

.sensor-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.sensor-title { display: grid; gap: 2px; }

.sensor-title strong {
    font-family: var(--font-display);
    font-size: 1.12rem;
    letter-spacing: 0;
}

.sensor-title span,
.sensor-meta { color: var(--muted); font-size: 0.88rem; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    min-height: 28px;
    padding: 0 10px;
    font-size: 0.78rem;
    font-weight: 800;
    border: 1px solid currentColor;
    background: color-mix(in oklch, currentColor, transparent 90%);
}

.badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.good   { color: var(--good); }
.warn   { color: var(--warn); }
.danger { color: var(--danger); }
.info   { color: var(--info); }

.reading {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-variant-numeric: tabular-nums;
}

.reading strong {
    font-family: var(--font-display);
    font-size: clamp(2.4rem, 4vw, 3.7rem);
    line-height: 0.95;
    letter-spacing: -0.01em;
}

.reading span { color: var(--muted); font-weight: 750; }

.spark { width: 100%; height: 54px; overflow: visible; }
.spark path.area { opacity: 0.13; }
.spark path.line {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.trend {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 0.86rem;
    font-variant-numeric: tabular-nums;
}

.trend strong { color: var(--fg); }

/* ── Modal ──────────────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: color-mix(in oklch, var(--fg), transparent 70%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 180ms cubic-bezier(0.23, 1, 0.32, 1),
                visibility 180ms cubic-bezier(0.23, 1, 0.32, 1);
    /* Leaflet's own panes climb to z-index 700 (popups). The modal has to
       sit above all of them or the map pokes through the backdrop. */
    z-index: 1000;
}

.modal-backdrop.open { opacity: 1; visibility: visible; }

.modal {
    width: min(980px, 100%);
    max-height: min(760px, calc(100vh - 40px));
    overflow: auto;
    background: var(--surface);
    color: var(--fg);
    border: 1px solid color-mix(in oklch, var(--border), white 20%);
    border-radius: 24px;
    box-shadow: 0 30px 90px color-mix(in oklch, black, transparent 72%);
    transform: translateY(12px) scale(0.98);
    transition: transform 200ms cubic-bezier(0.23, 1, 0.32, 1);
}

.modal-backdrop.open .modal { transform: translateY(0) scale(1); }

.modal-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 16px;
    align-items: start;
    padding: 22px 22px 14px;
    border-bottom: 1px solid var(--border);
}

.modal-head .badge { align-self: center; }

.modal-head h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3vw, 2.35rem);
    letter-spacing: 0;
    line-height: 1.05;
}

.modal-head p { margin: 6px 0 0; color: var(--muted); line-height: 1.45; }

.close-btn {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--fg);
    transition: background 160ms cubic-bezier(0.23, 1, 0.32, 1),
                transform 160ms cubic-bezier(0.23, 1, 0.32, 1);
}

.close-btn:hover {
    background: color-mix(in oklch, var(--danger), white 88%);
    transform: rotate(90deg);
}

.modal-body { padding: 20px 22px 22px; }

.modal-stub {
    color: var(--muted);
    font-style: italic;
    line-height: 1.5;
}

/* ── Modal quick-look ──────────────────────────────────────────────── */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.quick-stat {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.quick-stat span {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.quick-stat strong {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--fg);
}

.spark.spark-lg {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 1;
    margin-bottom: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 6px;
}

/* The modal chart reuses the page's trend-chart renderer at a smaller size.
   The wrapper is the positioning context for the absolute hover tooltip. */
.modal-chart-wrap {
    position: relative;
    margin-bottom: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px;
}

.modal-chart {
    width: 100%;
    height: auto;
    aspect-ratio: 1000 / 320;
    display: block;
    color: var(--fg);
}

.chart-loading,
.chart-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-style: italic;
    pointer-events: none;
}

/* Author CSS for `display: grid` ties with the UA rule for `[hidden]`, so
   `hidden` gets ignored without this override — the two overlays were
   stacking on top of each other in the middle of the chart. */
.chart-loading[hidden],
.chart-empty[hidden] { display: none; }

.chart-empty {
    color: color-mix(in oklch, var(--muted), white 10%);
}

.modal-target {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 0.92rem;
}

.modal-target[hidden] { display: none; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--accent-strong);
    color: white;
    font-weight: 600;
    text-decoration: none;
    transition: background 160ms cubic-bezier(0.23, 1, 0.32, 1),
                transform 160ms cubic-bezier(0.23, 1, 0.32, 1);
}

.btn-primary:hover {
    background: color-mix(in oklch, var(--accent-strong), black 12%);
    transform: translateX(2px);
}

@media (max-width: 640px) {
    .quick-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 1060px) {
    .hero-panel        { grid-template-columns: 1fr; }
    .summary-grid      { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .sensor-grid       { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
    .app               { padding-top: 16px; }
    .topbar            { grid-template-columns: 1fr; }
    .toolbar           { justify-content: stretch; flex-wrap: wrap; }
    .search-wrap       { flex: 1 1 180px; }
    .summary-grid,
    .sensor-grid       { grid-template-columns: 1fr; }
    .status-row        { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 460px) {
    .hero-panel        { border-radius: 18px; padding: 16px; }
    .brand p           { font-size: 0.86rem; }
    .overview h2       { font-size: 2rem; }
    .sensor-card       { min-height: 210px; }
    .modal-backdrop    { padding: 0; align-items: end; }
    .modal             { max-height: 92vh; border-radius: 22px 22px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ── Sensor detail page ───────────────────────────────────────────── */
.sensor-page { padding-top: 24px; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--fg);
    text-decoration: none;
    font-weight: 600;
    transition: background 160ms cubic-bezier(0.23, 1, 0.32, 1),
                transform 160ms cubic-bezier(0.23, 1, 0.32, 1);
}

.back-link:hover {
    background: color-mix(in oklch, var(--accent), white 86%);
    transform: translateX(-2px);
}

.range-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 18px 0;
}

.range-tab {
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--fg);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
}

.range-tab:hover { background: var(--surface-2); }

.range-tab.active {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: white;
}

.sensor-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.chart-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    margin-bottom: 22px;
}

.chart-panel header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.chart-panel h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.6rem;
}

.chart-meta {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.chart-wrap {
    position: relative;
}

.trend-chart {
    width: 100%;
    height: auto;
    aspect-ratio: 1000 / 320;
    display: block;
    color: var(--fg);
}

/* Hover tooltip — anchored to the cursor by chart.js. The translate(-50%, …)
   centres it horizontally on the hovered point, and the -100% pulls it above
   the dot so it doesn't sit under the cursor. */
.chart-tooltip {
    position: absolute;
    transform: translate(-50%, -100%) translateY(-10px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    box-shadow: 0 8px 24px color-mix(in oklch, var(--fg), transparent 86%);
    pointer-events: none;
    font-size: 0.86rem;
    white-space: nowrap;
    display: grid;
    gap: 2px;
    z-index: 2;
}

.chart-tooltip strong {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--fg);
}

.chart-tooltip span {
    color: var(--muted);
    font-size: 0.78rem;
}

.chart-tooltip[hidden] { display: none; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stats-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stats-block h3 {
    margin: 0 0 14px;
    font-family: var(--font-display);
    font-size: 1.15rem;
}

.stats-block dl {
    margin: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 18px;
}

.stats-block dl > div {
    display: contents;
}

.stats-block dt {
    color: var(--muted);
    font-size: 0.85rem;
}

.stats-block dd {
    margin: 0;
    font-family: var(--font-mono);
    font-weight: 600;
    text-align: right;
}

.zone-bar {
    display: flex;
    width: 100%;
    height: 24px;
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface-2);
    margin-bottom: 14px;
}

.zone { display: block; height: 100%; }
.zone.good   { background: var(--good); }
.zone.warn   { background: var(--warn); }
.zone.danger { background: var(--danger); }

.zone-legend {
    list-style: none;
    margin: 0 0 10px;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    color: var(--muted);
    font-size: 0.9rem;
}

.zone-legend .dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.zone-legend .dot.good   { background: var(--good); }
.zone-legend .dot.warn   { background: var(--warn); }
.zone-legend .dot.danger { background: var(--danger); }

.zone-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.45;
}

.stats-future ul {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    line-height: 1.6;
}

@media (max-width: 1060px) {
    .sensor-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stats-grid     { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .sensor-summary { grid-template-columns: 1fr; }
}
