:root {
    --bg: #f4f5f7;
    --panel: #ffffff;
    --text: #1b1f24;
    --muted: #68727d;
    --line: #e2e6ea;
    --accent: #1b1f24;
    --temp: #e8590c;
    --hum: #1c7ed6;
    --co2: #0ca678;
    --band-1: #2f9e44;
    --band-2: #94d82d;
    --band-3: #fcc419;
    --band-4: #f76707;
    --band-5: #c92a2a;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

:root[data-theme="dark"] {
    --bg: #111418;
    --panel: #1a1e24;
    --text: #e6e9ed;
    --muted: #8b95a1;
    --line: #2a3038;
    --accent: #e6e9ed;
    --temp: #ff922b;
    --hum: #4dabf7;
    --co2: #38d9a9;
    --shadow: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #111418;
        --panel: #1a1e24;
        --text: #e6e9ed;
        --muted: #8b95a1;
        --line: #2a3038;
        --accent: #e6e9ed;
        --temp: #ff922b;
        --hum: #4dabf7;
        --co2: #38d9a9;
        --shadow: none;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
h2 { margin: 0; font-size: 16px; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin-top: 8px; }

.top, .toolbar, main, footer {
    max-width: 1280px;
    margin: 0 auto;
    padding-left: 16px;
    padding-right: 16px;
}

.top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding-top: 24px;
    padding-bottom: 12px;
}

.toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    padding-top: 10px;
    padding-bottom: 10px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

.group { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

button, select, input[type="date"] {
    font: inherit;
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 11px;
    cursor: pointer;
}

input[type="date"] { cursor: text; padding: 5px 8px; }
button:hover, select:hover { border-color: var(--muted); }
button:focus-visible, select:focus-visible, input:focus-visible, .link:focus-visible { outline: 2px solid var(--hum); outline-offset: 1px; }
button.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
button.ghost { background: transparent; font-size: 18px; padding: 4px 10px; }
.small button { font-size: 13px; padding: 4px 9px; }
.years button { font-size: 13px; padding: 4px 8px; font-variant-numeric: tabular-nums; }

main { padding-top: 16px; padding-bottom: 32px; display: flex; flex-direction: column; gap: 16px; }

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

.card, .panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.card { padding: 16px 18px; cursor: pointer; border-top: 3px solid var(--c); text-align: left; display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; width: 100%; }
.card.active, .card.active:hover { background: var(--panel); color: var(--text); border-color: var(--c); outline: 2px solid var(--c); outline-offset: -1px; }
.card:hover { border-color: var(--line); border-top-color: var(--c); }
.card .label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.card .value { font-size: 34px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.card .value small { font-size: 16px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.card .extremes { display: flex; gap: 18px; font-size: 13px; color: var(--muted); margin-top: 2px; flex-wrap: wrap; }
.card .extremes b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.bands { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin-top: 12px; background: var(--line); }
.bands span { display: block; height: 100%; }
.band-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 7px; font-size: 12px; color: var(--muted); }
.band-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.band-legend b { color: var(--text); font-weight: 600; }

.panel { padding: 16px 18px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.panel-head p { font-size: 13px; }

.chart { width: 100%; height: 300px; }
.chart.tall { height: 620px; }

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

.metric-bar { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.divider { margin-top: 16px; font-size: 20px; letter-spacing: -.01em; }

table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 600; font-size: 13px; color: var(--muted); }
th:first-child, td:first-child { text-align: left; }
tr:last-child td { border-bottom: 0; }
td .sub { color: var(--muted); font-size: 12px; }
.scroll { overflow-x: auto; }

.link { color: inherit; background: none; border: 0; padding: 0; border-radius: 3px; text-decoration: underline; text-decoration-color: var(--muted); text-underline-offset: 2px; cursor: pointer; font: inherit; }
.link:hover { text-decoration-color: currentColor; }

.records { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px 28px; }
.records h3 { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.records ol { margin: 0; padding: 0; list-style: none; }
.records li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-variant-numeric: tabular-nums; }
.records li b { font-weight: 600; }

#gaps ul { margin: 0; padding: 0; list-style: none; columns: 2 300px; }
#gaps li { padding: 3px 0; break-inside: avoid; }

footer { padding-bottom: 32px; font-size: 13px; }

.empty { padding: 48px 0; text-align: center; color: var(--muted); }

@media (max-width: 860px) {
    .cards, .grid.two { grid-template-columns: minmax(0, 1fr); }
    .chart.tall { height: 540px; }
    .toolbar { position: static; }
    h1 { font-size: 22px; }
}
