/* Weather station, theme "instrument".
   Dark-first lab-instrument look: hairlines, corner ticks, tabular numerals, one colour per quantity.
   Quantity colours are also read by the charts (js/charts.js), so change them here only. */

@font-face {
    font-family: 'Inter';
    src: url('/weather/fonts/inter-latin-wght.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: ui-monospace, 'SFMono-Regular', 'Cascadia Mono', Consolas, 'Liberation Mono', monospace;
    --r: 3px;
    --gap: 14px;
    --max: 1320px;
}
:root[data-theme='dark'] {
    color-scheme: dark;
    --bg: #090c10;
    --bg-grid: rgba(120, 160, 200, 0.045);
    --panel: #0f141a;
    --panel-2: #141a22;
    --line: #1f2731;
    --line-2: #2b3542;
    --tick: #3a4656;
    --text: #e6edf3;
    --text-2: #a3b0bd;
    --text-3: #66727f;
    --accent: #4cc9f0;
    --c-temp: #ff7a45;
    --c-dew: #3ddc97;
    --c-feels: #ffb86b;
    --c-cold: #6aa9ff;
    --c-hum: #5ab0ff;
    --c-press: #b392f0;
    --c-wind: #4cc9f0;
    --c-gust: #f778ba;
    --c-rain: #3d8bfd;
    --c-sun: #ffd166;
    --c-moon: #d6dde5;
    --c-night: #1a2230;
    --ok: #3fb950;
    --warn: #e3b341;
    --bad: #f85149;
    --suspect: #c9a227;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px -18px rgba(0, 0, 0, 0.8);
}
:root[data-theme='light'] {
    color-scheme: light;
    --bg: #f3f5f8;
    --bg-grid: rgba(30, 60, 100, 0.05);
    --panel: #ffffff;
    --panel-2: #f7f9fb;
    --line: #e1e6ec;
    --line-2: #cfd6de;
    --tick: #9aa6b2;
    --text: #0f1720;
    --text-2: #4a5867;
    --text-3: #7d8a97;
    --accent: #0a84b8;
    --c-temp: #e8590c;
    --c-dew: #099268;
    --c-feels: #d9480f;
    --c-cold: #1c7ed6;
    --c-hum: #1971c2;
    --c-press: #7048e8;
    --c-wind: #0b7fa8;
    --c-gust: #c2255c;
    --c-rain: #1864ab;
    --c-sun: #f08c00;
    --c-moon: #495057;
    --c-night: #dfe6ee;
    --ok: #2f9e44;
    --warn: #e67700;
    --bad: #e03131;
    --suspect: #b8860b;
    --shadow: 0 1px 2px rgba(15, 23, 32, 0.04), 0 8px 24px -16px rgba(15, 23, 32, 0.25);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font: 14px/1.45 var(--font);
    font-feature-settings: 'tnum' 1, 'cv11' 1;
    color: var(--text);
    background-color: var(--bg);
    background-image:
        linear-gradient(var(--bg-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
    background-size: 24px 24px;
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-feature-settings: 'tnum' 1, 'zero' 1; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* ---------- header */
.top {
    position: sticky; top: 0; z-index: 20;
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.top-in {
    max-width: var(--max); margin: 0 auto; padding: 10px 20px;
    display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none !important; }
.brand-mark { width: 28px; height: 28px; fill: none; stroke: var(--accent); stroke-width: 2; }
.brand-mark .dot { fill: var(--c-temp); stroke: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-weight: 650; letter-spacing: 0.14em; text-transform: uppercase; font-size: 13px; }
.brand-text small { color: var(--text-3); font-size: 11px; letter-spacing: 0.02em; }
.tabs { display: flex; gap: 2px; justify-self: center; }
.tabs a {
    color: var(--text-2); padding: 7px 12px; border-radius: var(--r); font-weight: 500;
    letter-spacing: 0.02em; text-decoration: none; position: relative;
}
.tabs a:hover { color: var(--text); background: var(--panel-2); }
.tabs a[aria-current='page'] { color: var(--text); }
.tabs a[aria-current='page']::after {
    content: ''; position: absolute; left: 12px; right: 12px; bottom: -11px; height: 2px; background: var(--accent);
}
.tools { display: flex; gap: 8px; align-items: center; }
.pill {
    display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px;
    border: 1px solid var(--line-2); border-radius: 999px; font-size: 12px; color: var(--text-2); white-space: nowrap;
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.pill.live i { background: var(--ok); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); animation: pulse 2.4s infinite; }
.pill.late i { background: var(--warn); }
.pill.offline i, .pill.error i { background: var(--bad); }
.pill.offline, .pill.error { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line-2)); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; height: 28px; }
.seg button { background: none; border: 0; padding: 0 10px; color: var(--text-3); cursor: pointer; font-size: 12px; font-weight: 600; }
.seg button[aria-pressed='true'] { background: var(--panel-2); color: var(--text); }
.icon-btn { width: 28px; height: 28px; border: 1px solid var(--line-2); border-radius: var(--r); background: none; cursor: pointer; display: grid; place-items: center; padding: 0; }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: var(--text-2); stroke-width: 1.6; }
.icon-btn svg .fill { fill: var(--text-2); stroke: none; }
.banner { background: color-mix(in srgb, var(--bad) 16%, var(--panel)); color: var(--text); border-top: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); padding: 8px 20px; text-align: center; font-size: 13px; }

/* ---------- main layout */
main { flex: 1; width: 100%; max-width: var(--max); margin: 0 auto; padding: 20px 20px 40px; outline: none; }
.loading { color: var(--text-3); padding: 60px 0; text-align: center; letter-spacing: 0.08em; }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.s3 { grid-column: span 3; } .s4 { grid-column: span 4; } .s5 { grid-column: span 5; } .s6 { grid-column: span 6; }
.s7 { grid-column: span 7; } .s8 { grid-column: span 8; } .s12 { grid-column: span 12; }
@media (max-width: 1100px) { .s3, .s4, .s5 { grid-column: span 6; } .s7, .s8 { grid-column: span 12; } }
@media (max-width: 760px) {
    .grid > * { grid-column: span 12 !important; }
    .top-in { grid-template-columns: 1fr auto; padding: 8px 14px; }
    .tabs { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; overflow-x: auto; }
    .tabs a[aria-current='page']::after { bottom: -9px; }
    .brand-text small { display: none; }
    main { padding: 14px 12px 32px; }
}
@media (max-width: 460px) { .pill span { display: none; } .pill { padding: 0 9px; } }

.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 2px 2px 14px; }
.page-head h1 { font-size: 20px; font-weight: 600; margin: 0; letter-spacing: 0.01em; }
.page-head p { margin: 0; color: var(--text-3); font-size: 12px; }

/* ---------- cards with corner ticks */
.card {
    position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
    padding: 16px 18px; box-shadow: var(--shadow); min-width: 0;
}
.card::before {
    content: ''; position: absolute; inset: -1px; pointer-events: none; border-radius: var(--r);
    background:
        linear-gradient(var(--tick), var(--tick)) top left / 9px 1px, linear-gradient(var(--tick), var(--tick)) top left / 1px 9px,
        linear-gradient(var(--tick), var(--tick)) top right / 9px 1px, linear-gradient(var(--tick), var(--tick)) top right / 1px 9px,
        linear-gradient(var(--tick), var(--tick)) bottom left / 9px 1px, linear-gradient(var(--tick), var(--tick)) bottom left / 1px 9px,
        linear-gradient(var(--tick), var(--tick)) bottom right / 9px 1px, linear-gradient(var(--tick), var(--tick)) bottom right / 1px 9px;
    background-repeat: no-repeat;
}
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.label { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); }
.label .sw { display: inline-block; width: 8px; height: 8px; border-radius: 1px; margin-right: 7px; vertical-align: 0; }
.card-h .aside { font-size: 12px; color: var(--text-3); }

.big { font-size: clamp(46px, 5.2vw, 68px); font-weight: 250; letter-spacing: -0.03em; line-height: 1; font-feature-settings: 'tnum' 1, 'zero' 1; }
.big .u { font-size: 0.34em; font-weight: 400; letter-spacing: 0; color: var(--text-2); margin-left: 4px; vertical-align: 0.95em; }
.mid { font-size: 26px; font-weight: 300; letter-spacing: -0.02em; line-height: 1.1; }
.mid .u { font-size: 13px; color: var(--text-2); margin-left: 3px; font-weight: 400; letter-spacing: 0; }
.trend { font-size: 13px; color: var(--text-2); white-space: nowrap; }
.trend .arr { display: inline-block; width: 1em; text-align: center; }
.up { color: var(--c-temp); } .down { color: var(--c-cold); }

/* key/value lists */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px 16px; margin: 14px 0 0; }
.kv > div { min-width: 0; }
.kv dt { font-size: 11px; color: var(--text-3); letter-spacing: 0.04em; margin: 0 0 1px; }
.kv dd { margin: 0; font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv dd small { color: var(--text-3); font-weight: 400; font-size: 11px; margin-left: 4px; }

/* suspect values: present but marked, with the reason as tooltip */
.sus { color: var(--suspect) !important; text-decoration: underline dashed color-mix(in srgb, var(--suspect) 70%, transparent); text-underline-offset: 3px; cursor: help; }
.sus::after { content: ' ⚑'; font-size: 0.75em; }
.note { font-size: 12px; color: var(--text-3); margin-top: 8px; }
.note b { color: var(--text-2); font-weight: 500; }

/* sparkline */
.spark { display: block; width: 100%; height: 44px; margin-top: 12px; overflow: visible; }
.spark-cap { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-3); letter-spacing: 0.05em; margin-top: 2px; }

/* svg instruments */
svg.inst { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font); }
svg.inst text { fill: var(--text-3); font-size: 10px; font-feature-settings: 'tnum' 1; }
svg.inst .tk { stroke: var(--tick); stroke-width: 1; }
svg.inst .tk.major { stroke: var(--text-3); }
svg.inst .ring { fill: none; stroke: var(--line-2); }

/* tables */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl thead th { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); border-bottom-color: var(--line-2); }
.tbl td.at { color: var(--text-3); font-size: 12px; }
.tbl tr:hover td { background: var(--panel-2); }
.tbl .grp td { color: var(--text-3); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; padding-top: 14px; border-bottom-color: var(--line-2); background: none !important; }
.scroll-x { overflow-x: auto; }

/* buttons, segmented controls inside views */
.ctl { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { border: 1px solid var(--line-2); background: var(--panel); color: var(--text-2); border-radius: var(--r); padding: 5px 10px; font-size: 12px; cursor: pointer; }
.btn:hover { color: var(--text); border-color: var(--tick); }
.btn[aria-pressed='true'] { color: var(--text); background: var(--panel-2); border-color: var(--accent); }
select.btn { padding-right: 6px; }

/* uPlot overrides */
.chart { width: 100%; }
.uplot { font-family: var(--font); }
.u-title { display: none; }
.u-legend { font-size: 12px; color: var(--text-2); text-align: left; margin-top: 4px; }
.u-legend .u-marker { width: 9px; height: 9px; border-radius: 1px; }
.u-legend th { font-weight: 500; }
.u-legend td.u-value { font-feature-settings: 'tnum' 1; color: var(--text); min-width: 5.5em; }
.u-legend .u-series:first-child th { color: var(--text-3); font-weight: 400; }
.u-legend .u-off > * { opacity: 0.35; }
.u-select { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.u-cursor-x, .u-cursor-y { border-color: var(--tick) !important; }

/* footer */
.foot { border-top: 1px solid var(--line); color: var(--text-3); font-size: 12px; }
.foot-in { max-width: var(--max); margin: 0 auto; padding: 14px 20px; display: flex; gap: 8px 24px; flex-wrap: wrap; justify-content: space-between; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- view: now */
.hero { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 6px; }
.hero-side { display: flex; flex-direction: column; gap: 4px; padding-bottom: 6px; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 4px 0 2px; }
.big-mid { font-size: clamp(34px, 3.4vw, 44px); }
.sub-label { font-size: 12px; color: var(--text-2); margin: 12px 0 4px; }
.wind-in { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 8px 18px; align-items: center; }
.wind-in .kv { grid-template-columns: 1fr 1fr; margin: 0; }
.compass-wrap svg { max-width: 300px; margin: 0 auto; width: 100%; }
@media (max-width: 1100px) { .wind-in { grid-template-columns: 1fr; } .wind-in .kv { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); } }
.legend-mini { display: flex; gap: 14px; font-size: 10px; color: var(--text-3); margin-top: 4px; letter-spacing: 0.04em; }
.legend-mini .k::before { content: ''; display: inline-block; width: 12px; height: 0; border-top: 2px solid; vertical-align: 3px; margin-right: 5px; }
.legend-mini .k.t::before { border-color: var(--c-temp); }
.legend-mini .k.d::before { border-color: var(--c-dew); border-top-style: dashed; }
.sky-row { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; }
.sky-row .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.moon-box { display: flex; gap: 12px; align-items: center; padding: 8px 4px 0 0; }
.moon-box > div { font-size: 13px; }
@media (max-width: 460px) { .sky-row { grid-template-columns: 1fr; } }
svg.gauge { max-width: 340px; margin: 6px auto 0; }
.moon-box svg.moon { width: 72px; height: 72px; flex: none; }

/* ---------- view: history */
.heat-wrap { width: 100%; margin-top: 10px; }
canvas.heat { display: block; cursor: crosshair; }
.heat-legend { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-3); }
.heat-legend canvas { width: 160px; height: 8px; border-radius: 1px; }
.heat-readout { min-height: 1.4em; }

/* ---------- view: records */
.tbl.rec td:nth-child(even):not(:first-child) { font-weight: 500; }
.tbl.mgrid th, .tbl.mgrid td { text-align: center; padding: 5px 6px; font-size: 12px; }
.tbl.mgrid td:first-child { text-align: left; color: var(--text-2); }
.tbl.mgrid th.cur { color: var(--accent); }
.tbl.mgrid td.cur { box-shadow: inset 1px 0 0 var(--accent), inset -1px 0 0 var(--accent); }
.tbl.mgrid td.bad {
    background: repeating-linear-gradient(135deg, transparent 0 4px, color-mix(in srgb, var(--suspect) 18%, transparent) 4px 6px);
}

/* ---------- view: reports */
.rep { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--gap); align-items: start; }
@media (max-width: 760px) { .rep { grid-template-columns: 1fr; } }
.rep-nav { position: sticky; top: 76px; max-height: calc(100vh - 100px); overflow: auto; }
.rep-year { padding: 6px 0 10px; border-bottom: 1px solid var(--line); }
.rep-year:last-child { border-bottom: 0; }
.rep-y { font-weight: 600; color: var(--text); display: inline-block; margin-bottom: 6px; }
.rep-months { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.rep-months a, .rep-y { padding: 3px 6px; border-radius: var(--r); font-size: 12px; text-decoration: none; }
.rep-months a { color: var(--text-2); text-align: center; border: 1px solid var(--line); }
.rep-months a:hover, .rep-y:hover { border-color: var(--tick); color: var(--text); }
.rep-nav a[aria-current='page'] { background: var(--panel-2); color: var(--accent); border-color: var(--accent); }
pre.rep-text { font: 12.5px/1.45 var(--mono); color: var(--text); margin: 0; white-space: pre; tab-size: 8; }

/* refinements after first screenshots */
.kv dd { white-space: normal; }
.kv dd small { display: block; margin: 1px 0 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.tbl.compact th, .tbl.compact td { padding: 4px 6px; font-size: 12.5px; }
.tbl.compact td:first-child { white-space: normal; }
.tbl.left th, .tbl.left td { text-align: left; }
