/* EcoSentinel Aqua System, styled after the Uzbekhydroenergo slide system:
   blue header band, gradient section bars, dense figures on a light sheet. */
:root {
  color-scheme: light;
  --fs: 1;
  --band: #0070C0; --band-deep: #005A9C;
  --green: #29AD7E; --cyan: #0CADC9;
  --sheet: #F2F5F8; --panel: #FFFFFF; --hover: #F5F9FD; --sel: #EAF3FB; --th: #F4F7FA; --seg: #E6ECF2; --chip: #ECF1F6; --map-bg: #E6EEF3;
  --line: #D3DDE6; --line-soft: #E6ECF1; --line-strong: #8FB6D8; --muted: #8C99A6;
  --ink: #17222E; --ink-2: #44535F; --ink-3: #5A6874;
  --accent: #0068B3; --accent-2: #005A9C;
  --s1: #0070C0; --s2: #A87700;
  --ok: #1F7A49; --ok-bg: #E1F2E8; --near: #9A5200; --over: #C02626; --idle: #5E7389;
  --g-bg: #E4F4EC; --g-line: #B5DCC8; --g-ink: #155F42; --g-hover: #D3EEDF;
  --b-bg: #E5EEF7; --b-ink: #2A5885;
  --brand-sub: #1A7F5A; --btn-green: #1A7F5A;
  --bar-blue: linear-gradient(90deg, #005A9C 0%, #0068B3 55%, #087A9E 100%);
  --bar-green: linear-gradient(90deg, #1A7F5A 0%, #137766 55%, #087A9E 100%);
  --shadow: 0 4px 14px rgba(20,40,60,.14);
  --ch-grid: #E3E9EF; --ch-text: #5A6874; --ch-axis: #B4C1CC; --ch-ink2: #44535F; --ch-ink: #17222E;
  --focus: #F2B705;
  --r: 8px;
  --head: 'Fira Sans Condensed', 'Arial Narrow', sans-serif;
  --body: 'Fira Sans', 'Segoe UI', sans-serif;
}
/* dark screen mode */
:root[data-theme="dark"] {
  color-scheme: dark;
  --band: #0B3A61; --band-deep: #072B49;
  --sheet: #0E1620; --panel: #16212D; --hover: #1C2A38; --sel: #1F3346; --th: #1A2734; --seg: #223242; --chip: #22303E; --map-bg: #1A2530;
  --line: #2C3D4E; --line-soft: #243443; --line-strong: #4E7EA8; --muted: #6F8293;
  --ink: #E6EEF5; --ink-2: #B8C7D4; --ink-3: #9AABBA;
  --accent: #6DB8F2; --accent-2: #8CC8F5;
  --s1: #6DB8F2; --s2: #E3B341;
  --ok: #5CC98C; --ok-bg: #173527; --near: #F0A64B; --over: #FF7B72; --idle: #6F8293;
  --g-bg: #183A2C; --g-line: #2B5E47; --g-ink: #8FDDB5; --g-hover: #1F4A37;
  --b-bg: #1D3348; --b-ink: #9CCBF2;
  --brand-sub: #1A7F5A; --btn-green: #1A7F5A;
  --bar-blue: linear-gradient(90deg, #0B3A61 0%, #0F4B7C 55%, #0A5A73 100%);
  --bar-green: linear-gradient(90deg, #135C43 0%, #0F5A50 55%, #0A5A73 100%);
  --shadow: 0 4px 16px rgba(0,0,0,.5);
  --ch-grid: #263646; --ch-text: #9AABBA; --ch-axis: #3D5164; --ch-ink2: #B8C7D4; --ch-ink: #E6EEF5;
}
/* high contrast (works with light and dark) */
:root[data-contrast="high"] {
  --sheet: #FFFFFF; --panel: #FFFFFF; --hover: #FFF7D6; --sel: #FFF1B8; --th: #FFFFFF; --seg: #FFFFFF; --chip: #FFFFFF;
  --line: #000000; --line-soft: #000000; --line-strong: #000000; --muted: #000000;
  --ink: #000000; --ink-2: #000000; --ink-3: #1A1A1A;
  --accent: #003F7D; --accent-2: #00306B; --band: #002B57; --band-deep: #001F40;
  --ok: #005C2E; --near: #6B3A00; --over: #A30000;
  --g-bg: #FFFFFF; --g-line: #000000; --g-ink: #003B22; --b-bg: #FFFFFF; --b-ink: #002B57;
  --bar-blue: #002B57; --bar-green: #003B22; --btn-green: #003B22; --brand-sub: #003B22;
  --ch-grid: #9A9A9A; --ch-text: #000000; --ch-axis: #000000; --ch-ink2: #000000; --ch-ink: #000000;
  --focus: #FF8C00;
}
:root[data-theme="dark"][data-contrast="high"] {
  --sheet: #000000; --panel: #000000; --hover: #1A1A00; --sel: #262600; --th: #000000; --seg: #000000; --chip: #000000;
  --line: #FFFFFF; --line-soft: #FFFFFF; --line-strong: #FFFF00; --muted: #FFFFFF;
  --ink: #FFFFFF; --ink-2: #FFFFFF; --ink-3: #E6E6E6;
  --accent: #FFFF00; --accent-2: #FFFF00; --band: #000000; --band-deep: #000000;
  --ok: #7CFF9E; --near: #FFC861; --over: #FF8A80;
  --g-bg: #000000; --g-line: #FFFFFF; --g-ink: #7CFF9E; --b-bg: #000000; --b-ink: #FFFF00;
  --bar-blue: #000000; --bar-green: #000000; --btn-green: #000000; --brand-sub: #1A7F5A;
  --ch-grid: #666666; --ch-text: #FFFFFF; --ch-axis: #FFFFFF; --ch-ink2: #FFFFFF; --ch-ink: #FFFFFF;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--sheet); color: var(--ink); font: 400 calc(14px * var(--fs))/1.45 var(--body); overflow-x: hidden; }
a { color: var(--accent-2); }
button, input, select { font: inherit; color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid #F2B705; outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 6px 10px; z-index: 2000; }
.skip:focus { left: 8px; }

/* ---------- header band ---------- */
.band {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 20px;
  background: var(--band); color: #fff; padding: 10px 24px 10px 0; min-height: 68px;
}
.brand {
  display: flex; align-items: center; gap: 10px; background: var(--panel); color: var(--accent);
  align-self: stretch; margin: -10px 0; text-decoration: none; padding: 10px 34px 10px 20px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 18px) 100%, 0 100%);
}
.brand-name { font: 700 calc(19px * var(--fs))/1 var(--head); letter-spacing: .01em; display: flex; flex-direction: column; }
.brand-name small { font: 600 calc(12px * var(--fs))/1.3 var(--head); color: var(--brand-sub); letter-spacing: .08em; }
.band-mid { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.band-title { margin: 0; text-align: center; font: 700 calc(clamp(17px, 2.1vw, 26px) * var(--fs))/1.15 var(--head); text-transform: uppercase; letter-spacing: .02em; }
.netpick { display: inline-flex; align-items: center; gap: 8px; font: 500 calc(13px * var(--fs)) var(--head); color: #fff; }
.netpick select { border: 1px solid rgba(255,255,255,.7); background: rgba(0,30,60,.35); color: #fff; border-radius: 5px; padding: 3px 24px 3px 8px; font: 600 calc(13px * var(--fs)) var(--head); max-width: 70vw; cursor: pointer; }
.netpick select option { color: var(--ink); background: var(--panel); }
.band-tools { display: flex; align-items: center; gap: 14px; }
.lang { display: flex; border: 1px solid rgba(255,255,255,.55); border-radius: 6px; overflow: hidden; }
.lang button { background: none; border: 0; color: #fff; padding: 7px 11px; cursor: pointer; font: 600 calc(13px * var(--fs)) var(--head); }
.lang button[aria-pressed="true"] { background: var(--panel); color: var(--accent); }
.btn-report { color: #fff; font: 600 calc(14px * var(--fs)) var(--head); text-decoration: none; border-bottom: 2px solid rgba(255,255,255,.5); padding-bottom: 1px; white-space: nowrap; }
.btn-report:hover { border-color: #fff; }

.statusline { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: center; padding: 8px 24px; color: var(--ink-2); font-size: calc(13px * var(--fs)); }
.src { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
.src .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--near); flex: none; }
.src.live .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(35,130,79,.18); animation: live 2.4s ease-in-out infinite; }
@keyframes live { 50% { box-shadow: 0 0 0 6px rgba(35,130,79,0); } }
.refresh { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--accent-2); border-radius: 14px; padding: 3px 12px 3px 10px; font: 600 calc(12.5px * var(--fs)) var(--head); cursor: pointer; }
.refresh::before { content: ''; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; }
.refresh:hover { border-color: var(--line-strong); background: var(--sel); }
.refresh.spin::before { animation: spin .7s linear infinite; }
.refresh:disabled { cursor: default; opacity: .75; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- sheet grid ---------- */
.sheet { display: grid; gap: 14px; padding: 0 24px 24px; grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 0 16px 14px; min-width: 0; }
.figures { grid-column: 1 / -1; }
.p-map, .p-current, .p-profile, .p-method { grid-column: span 8; }
.p-stations, .p-alerts, .p-ai { grid-column: span 4; }
.p-api { grid-column: 1 / -1; }
.p-trend, .p-about { grid-column: 1 / -1; }

.bar {
  display: flex; align-items: center; justify-content: center; gap: 12px; position: relative;
  margin: 10px -6px 12px; padding: 7px 14px; min-height: 38px; border-radius: 6px;
  color: #fff; font: 700 calc(16px * var(--fs))/1.2 var(--head); text-align: center;
}
.bar-blue { background: var(--bar-blue); }
.bar-green { background: var(--bar-green); }
.bar .seg, .bar .bar-select { position: absolute; right: 8px; }
.bar:has(.bar-select) { justify-content: space-between; text-align: left; }
.bar:has(.bar-select) .bar-select { position: static; max-width: 60%; }
.bar-tools { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 70%; justify-content: flex-end; }
.bar-tools .bar-select { max-width: 100%; min-width: 0; }
.tour { border: 1px solid #fff; background: rgba(0,60,110,.25); color: #fff; border-radius: 5px; padding: 4px 10px; font: 600 calc(13px * var(--fs)) var(--head); cursor: pointer; white-space: nowrap; }
.tour[aria-pressed="true"] { background: var(--panel); color: var(--accent); }
.bar-select { max-width: 46%; border: 0; border-radius: 5px; padding: 4px 26px 4px 10px; background: var(--panel); color: var(--accent-2); font: 600 calc(13px * var(--fs)) var(--head); cursor: pointer; }
.seg { display: inline-flex; background: rgba(255,255,255,.18); border-radius: 5px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: none; color: #fff; padding: 4px 10px; border-radius: 4px; cursor: pointer; font: 600 calc(13px * var(--fs)) var(--head); white-space: nowrap; }
.seg button[aria-checked="true"], .seg button[aria-pressed="true"], .seg button.on { background: var(--panel); color: var(--accent); }
.seg-light { background: var(--seg); }
.seg-light button { color: var(--ink-2); }
.seg-light button[aria-checked="true"] { background: var(--band); color: #fff; }
.note { color: var(--ink-3); font-size: calc(12px * var(--fs)); margin: 8px 0 0; }
h3 { font: 600 calc(15px * var(--fs)) var(--head); margin: 14px 0 4px; color: var(--accent-2); }

/* ---------- figure strip ---------- */
.figures { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 6px; }
.fig { padding: 2px 14px; border-left: 3px solid var(--green); margin-left: 10px; }
.fig b { display: block; font: 700 calc(30px * var(--fs))/1.05 var(--head); color: var(--accent); white-space: nowrap; }
.fig span { font-size: calc(12.5px * var(--fs)); color: var(--ink-2); line-height: 1.25; display: block; margin-top: 3px; }

/* ---------- map ---------- */
.map { height: 470px; border-radius: 6px; border: 1px solid var(--line); background: var(--map-bg); }
.leaflet-container { font: calc(13px * var(--fs)) var(--body); }
.stn-pin { width: 28px; height: 28px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); display: grid; place-items: center; }
.stn-pin span { transform: rotate(45deg); color: #fff; font: 700 calc(12px * var(--fs)) var(--head); }
.stn-pin.sel { width: 36px; height: 36px; border-width: 3px; }
.stn-pin.sel span { font-size: calc(14px * var(--fs)); }
.stn-pin.alarm { animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(198,40,40,.55); } 100% { box-shadow: 0 0 0 16px rgba(198,40,40,0); } }
@media (prefers-reduced-motion: reduce) { .stn-pin.alarm { animation: none; box-shadow: 0 0 0 4px rgba(198,40,40,.5); } .src.live .dot, .refresh.spin::before { animation: none; } }

/* ---------- station list ---------- */
.stlist { display: grid; gap: 4px; max-height: 470px; overflow: auto; padding-right: 2px; }
.strow {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 2px 10px; align-items: center;
  width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); padding: 7px 9px; cursor: pointer;
}
.strow:hover, .strow.hl { border-color: var(--line-strong); background: var(--hover); }
.strow[aria-selected="true"] { border-color: var(--band); box-shadow: inset 3px 0 0 var(--band); background: var(--sel); }
.strow .num { grid-row: 1 / span 2; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 700 calc(13px * var(--fs)) var(--head); background: var(--idle); }
.strow .nm { font: 600 calc(14px * var(--fs))/1.2 var(--head); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strow .sub { grid-column: 2; font-size: calc(12px * var(--fs)); color: var(--ink-3); line-height: 1.3; }
.strow .vals { grid-column: 3; grid-row: 1 / span 2; text-align: right; font-size: calc(12px * var(--fs)); color: var(--ink-2); white-space: nowrap; }
.strow .vals b { font: 600 calc(16px * var(--fs)) var(--head); color: var(--accent); }
.sens { display: inline-flex; align-items: center; gap: 4px; }
.sens i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; }
.sens.on i { background: var(--ok); }

/* ---------- current readings ---------- */
.stmeta { margin: -4px 0 4px; color: var(--ink-2); font-size: calc(13px * var(--fs)); }
h3.group { margin: 12px 0 6px; font-size: calc(14px * var(--fs)); color: var(--ink-2); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.opentiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 4px 8px; }
.tile .t-name { grid-column: 1 / -1; font: 500 calc(13px * var(--fs)) var(--body); color: var(--ink-2); }
.tile .t-val { font: 600 calc(28px * var(--fs))/1 var(--head); color: var(--accent); white-space: nowrap; }
.tile .t-val small { font: 500 calc(12px * var(--fs)) var(--head); color: var(--ink-2); margin-left: 3px; }
.tile .t-sub { grid-column: 1 / -1; font-size: calc(12.5px * var(--fs)); color: var(--ink-3); }
.tile, .rd { cursor: pointer; transition: border-color .15s, background-color .15s; }
.tile:hover { border-color: var(--line-strong); background: var(--hover); }
.rd:hover { background: var(--hover); }
.rd { border-radius: 4px; }
.readings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; }
.rd { display: grid; grid-template-columns: minmax(0, 1fr) auto 72px; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.rd-name { font: 500 calc(13.5px * var(--fs))/1.2 var(--body); color: var(--ink); }
.rd-lim { grid-row: 2; font-size: calc(12.5px * var(--fs)); color: var(--ink-3); }
.rd-val { grid-row: 1 / span 2; grid-column: 2; font: 600 calc(24px * var(--fs))/1 var(--head); color: var(--accent); text-align: right; white-space: nowrap; }
.rd-val.empty { color: var(--muted); font-size: calc(20px * var(--fs)); }
.rd-val small { font: 500 calc(12px * var(--fs)) var(--head); color: var(--ink-2); margin-left: 3px; }
.rd-spark { grid-row: 1 / span 2; grid-column: 3; height: 30px; }
.rd-st { display: inline-flex; align-items: center; gap: 4px; font-size: calc(12.5px * var(--fs)); font-weight: 500; margin-left: 6px; }
.rd-st svg { width: 12px; height: 12px; flex: none; }
.st-ok { color: var(--ok); } .st-near { color: var(--near); } .st-over { color: var(--over); } .st-none { color: var(--ink-3); }

/* ---------- alerts ---------- */
.alerts { list-style: none; margin: 10px 0 0; padding: 0; max-height: 520px; overflow: auto; }
.al { border: 1px solid var(--line); border-left-width: 4px; border-radius: 6px; padding: 9px 11px; margin-bottom: 8px; }
.al.sev-critical { border-left-color: var(--over); }
.al.sev-high { border-left-color: var(--near); }
.al.sev-medium { border-left-color: var(--cyan); }
.al.sev-low { border-left-color: var(--muted); }
.al-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.al-type { font: 600 calc(15px * var(--fs)) var(--head); }
.al-time { font-size: calc(12px * var(--fs)); color: var(--ink-3); white-space: nowrap; }
.al-meta { font-size: calc(12.5px * var(--fs)); color: var(--ink-2); margin: 2px 0 6px; }
.al-sev { font-weight: 600; }
.al-params { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: calc(12.5px * var(--fs)); }
.al-params b { font: 600 calc(14px * var(--fs)) var(--head); color: var(--ink); }
.al-params .over b { color: var(--over); }
.al-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px; margin-top: 8px; }
.rev { font-size: calc(12px * var(--fs)); font-weight: 500; padding: 2px 8px; border-radius: 10px; background: var(--chip); color: var(--ink-2); }
.rev.verified { background: var(--ok-bg); color: var(--ok); }
.rev.dismissed { text-decoration: line-through; }
.al-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.al-actions button, .link { border: 1px solid var(--line); background: var(--panel); border-radius: 5px; padding: 4px 9px; font-size: calc(12.5px * var(--fs)); cursor: pointer; }
.al-actions button:hover, .link:hover { border-color: var(--band); color: var(--accent); }
.empty { color: var(--ink-2); padding: 14px 4px; }

/* ---------- trend chart ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin-bottom: 8px; }
.filters select { border: 1px solid var(--line); border-radius: 5px; padding: 5px 8px; background: var(--panel); max-width: 100%; }
#paramSel { min-width: 220px; }
.cmp { display: inline-flex; align-items: center; gap: 6px; font-size: calc(13px * var(--fs)); color: var(--ink-2); }
.filters .link { margin-left: auto; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart.loading { opacity: .5; }
.chart-empty { display: grid; place-items: center; min-height: 220px; color: var(--ink-2); border: 1px dashed var(--line); border-radius: 6px; text-align: center; padding: 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: calc(12.5px * var(--fs)); color: var(--ink-2); margin-top: 4px; }
.legend i { display: inline-block; width: 16px; height: 2px; vertical-align: middle; margin-right: 6px; }
.legend i.dash { background: none; border-top: 2px dashed var(--ink-3); height: 0; }
.legend i.tri { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 9px solid var(--over); }
.chart-table { max-height: 320px; overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: calc(13px * var(--fs)); }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
th { font: 600 calc(13px * var(--fs)) var(--head); color: var(--ink-2); background: var(--th); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tooltip { position: fixed; z-index: 1500; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; box-shadow: var(--shadow); font-size: calc(12.5px * var(--fs)); min-width: 150px; }
.tooltip .tt-time { color: var(--ink-3); margin-bottom: 3px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
.tooltip .tt-row i { width: 12px; height: 2px; display: inline-block; }
.tooltip .tt-row b { font: 600 calc(15px * var(--fs)) var(--head); margin-right: 2px; }

/* ---------- AI assistant ---------- */
.chat { min-height: 150px; max-height: 340px; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; }
.msg { max-width: 90%; padding: 8px 11px; border-radius: 10px; white-space: pre-wrap; font-size: calc(13.5px * var(--fs)); }
.msg.user { align-self: flex-end; background: var(--band); color: #fff; border-bottom-right-radius: 3px; }
.msg.bot { align-self: flex-start; background: var(--chip); border-bottom-left-radius: 3px; }
.msg.bot small { display: block; color: var(--ink-3); margin-top: 4px; font-size: calc(12.5px * var(--fs)); }
.msg.wait { color: var(--ink-3); font-style: italic; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips button { border: 1px solid var(--g-line); background: var(--g-bg); color: var(--g-ink); border-radius: 14px; padding: 5px 10px; font-size: calc(12.5px * var(--fs)); cursor: pointer; text-align: left; }
.chips button:hover { background: var(--g-hover); }
.ask { display: flex; gap: 6px; }
.ask input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; }
.ask button { border: 0; background: var(--btn-green); color: #fff; border-radius: 6px; padding: 9px 16px; font: 600 calc(14px * var(--fs)) var(--head); cursor: pointer; }
.ask button:disabled { opacity: .5; }

/* ---------- support and API ---------- */
.p-api p { margin: 6px 0; }
.about p { margin: 8px 0; max-width: 78ch; line-height: 1.55; color: var(--ink); }
.about a { font-weight: 500; }
.p-profile .bar { justify-content: space-between; text-align: left; }
.p-profile .bar .seg { position: static; }
.chart.profile { min-height: 210px; margin-top: 6px; }
.chart.profile .pp { cursor: pointer; outline: none; }
.chart.profile .pp .pp-dot { transition: r .15s; }
.chart.profile .pp:hover .pp-dot, .chart.profile .pp:focus-visible .pp-dot { r: 9; }
.chart.profile .pp:focus-visible .pp-dot { stroke: #F2B705; }
.stn-pin.hl { box-shadow: 0 0 0 4px rgba(0,112,192,.3), 0 1px 4px rgba(0,0,0,.35); }
.to-top { position: fixed; right: 18px; bottom: 18px; z-index: 1200; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--band); color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: 0 4px 14px rgba(0,60,110,.3); transition: transform .2s, background-color .2s; }
.to-top svg { width: 22px; height: 22px; }
.to-top:hover { background: var(--band-deep); transform: translateY(-2px); }
.to-top[hidden] { display: none; }
.lockup { display: block; width: 100%; height: auto; margin: 12px 0 4px; }
.code { background: #0F2537; color: #D7E8F5; border-radius: 6px; padding: 10px 12px; font: calc(12px * var(--fs))/1.5 ui-monospace, Consolas, monospace; overflow: auto; white-space: pre; }

.foot { padding: 18px 24px 30px; color: var(--ink-2); font-size: calc(13px * var(--fs)); border-top: 1px solid var(--line); margin: 0 24px; }
.foot p { margin: 3px 0; }
.foot-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px 40px; }
.foot-title { font: 700 calc(14px * var(--fs)) var(--head); color: var(--accent-2); margin-bottom: 4px !important; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .figures { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 12px; }
}
@media (max-width: 1100px) {
  .p-map, .p-current, .p-trend, .p-profile, .p-about, .p-method, .p-stations, .p-alerts, .p-ai, .p-api { grid-column: 1 / -1; }
  .stlist { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: none; }
  .map { height: 420px; }
  .alerts { max-height: 420px; }
}
@media (max-width: 760px) {
  .band { grid-template-columns: 1fr; padding: 0 0 10px; gap: 8px; }
  .brand { margin: 0; clip-path: none; justify-content: center; padding: 10px; }
  .band-title { padding: 0 12px; font-size: calc(17px * var(--fs)); }
  .band-tools { justify-content: center; flex-wrap: wrap; }
  .statusline { padding: 8px 12px; }
  .sheet { padding: 0 10px 16px; gap: 10px; }
  .panel { padding: 0 12px 12px; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 10px 2px; }
  .fig { padding: 2px 8px; margin-left: 8px; }
  .fig b { font-size: calc(24px * var(--fs)); }
  .bar { flex-direction: column; gap: 6px; padding: 8px 10px; }
  .bar .seg, .bar .bar-select { position: static; max-width: 100%; }
  .bar-select { width: 100%; }
  .stlist { grid-template-columns: 1fr; }
  .opentiles { grid-template-columns: 1fr; }
  .tile { grid-template-columns: auto 1fr; }
  .readings { grid-template-columns: 1fr; }
  .rd-val { font-size: calc(22px * var(--fs)); }
  .map { height: 340px; }
  .filters { display: grid; grid-template-columns: 1fr; }
  #paramSel, .cmp, .cmp select { width: 100%; min-width: 0; }
  .cmp { display: grid; gap: 4px; }
  .filters .link { margin-left: 0; justify-self: start; }
  .chat { max-height: 300px; }
  .foot { margin: 0 10px; padding: 14px 4px 24px; }
  .foot-grid { grid-template-columns: 1fr; }
  .p-profile .bar { justify-content: center; text-align: center; }
  .p-profile .seg { flex-wrap: wrap; justify-content: center; }
  .netpick select { max-width: 60vw; }
  .to-top { right: 12px; bottom: 12px; }
}

/* ---------- estimates, WPI, methodology ---------- */
.wpi { display: inline-flex; align-items: center; gap: 4px; font: 600 calc(12px * var(--fs)) var(--head); color: var(--ink-2); white-space: nowrap; }
.wpi::before { content: ''; width: 9px; height: 9px; border-radius: 2px; background: var(--c); box-shadow: 0 0 0 1px var(--panel); }
.wpi-card { display: flex; align-items: center; gap: 12px; margin: 2px 0 6px; min-height: 44px; }
.wpi-num { flex: none; width: 46px; height: 46px; border-radius: 8px; display: grid; place-items: center; background: var(--c); color: #fff; font: 700 calc(20px * var(--fs)) var(--head); box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); transition: background-color .3s; }
.wpi-txt { font-size: calc(13px * var(--fs)); color: var(--ink-2); line-height: 1.35; }
.wpi-txt b { font: 600 calc(15px * var(--fs)) var(--head); color: var(--ink); }
.tag { display: inline-block; font: 600 calc(12px * var(--fs))/1 var(--head); padding: 3px 5px; border-radius: 3px; vertical-align: 1px; margin-left: 4px; letter-spacing: .01em; }
.tag.sensor { background: var(--g-bg); color: var(--g-ink); }
.tag.model { background: var(--b-bg); color: var(--b-ink); }
.tag.open { background: var(--chip); color: var(--ink-2); }
.tag.none { background: transparent; color: var(--ink-3); padding-left: 0; font-weight: 500; }
.qc { font: 600 calc(12px * var(--fs)) var(--head); color: var(--near); margin-left: 4px; }
.qc.fail { color: var(--over); }
.rd.off { cursor: default; }
.rd.off:hover { background: none; }
.rd.off .rd-name { color: var(--ink-3); }
.method p { margin: 8px 0; max-width: 82ch; line-height: 1.55; }
.refs { margin: 10px 0 0; padding-left: 20px; font-size: calc(12.5px * var(--fs)); color: var(--ink-2); }
.refs li { margin: 4px 0; }
.refs a { color: var(--ink-2); text-decoration-color: var(--line-strong); }
.refs a:hover { color: var(--accent-2); }
@media (max-width: 760px) {
  .bar-tools { max-width: 100%; width: 100%; }
  .bar-tools .bar-select { flex: 1; }
}

/* ---------- touch targets (WCAG 2.5.8) ---------- */
.lang button { min-width: 40px; min-height: 36px; }
.seg button { min-height: 32px; padding: 6px 12px; }
.bar-select, .tour, .refresh, .netpick select { min-height: 34px; }
.al-actions button, .link { min-height: 34px; padding: 6px 12px; }
.chips button { min-height: 36px; padding: 7px 12px; }
.btn-report { display: inline-flex; align-items: center; min-height: 36px; padding: 0 2px; }
.ask input, .ask button { min-height: 42px; }
.filters select { min-height: 36px; }
.leaflet-touch .leaflet-bar a { width: 36px; height: 36px; line-height: 36px; }

/* ---------- screen modes and accessibility options ---------- */
:root[data-contrast="high"] .bar { border: 2px solid var(--line); }
:root[data-contrast="high"] .panel, :root[data-contrast="high"] .tile, :root[data-contrast="high"] .strow { border-width: 2px; }
:root[data-contrast="high"] a { text-decoration: underline; text-decoration-thickness: 2px; }
:root[data-contrast="high"] .band { border-bottom: 3px solid var(--line); }
:root[data-theme="dark"] .brand { background: #E9F1F8; color: #005A9C; --brand-sub: #146B4B; }
:root[data-theme="dark"][data-contrast="high"] .brand { background: #FFFFFF; color: #002B57; --brand-sub: #003B22; }
:root[data-theme="dark"] .leaflet-tile-pane .tiles-base { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9); }
:root[data-theme="dark"] .leaflet-container { background: var(--map-bg); }
:root[data-theme="dark"] .leaflet-bar a, :root[data-theme="dark"] .leaflet-control-layers { background: var(--panel); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] .leaflet-control-attribution { background: rgba(22,33,45,.85); color: var(--ink-2); }
:root[data-theme="dark"] .leaflet-control-attribution a { color: var(--accent); }
:root[data-theme="dark"] .leaflet-popup-content-wrapper, :root[data-theme="dark"] .leaflet-popup-tip, :root[data-theme="dark"] .leaflet-tooltip { background: var(--panel); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] .code { background: #0A121B; }
:root[data-theme="dark"] .lockup, :root[data-theme="dark"] .rlogo { background: #fff; border-radius: 6px; padding: 6px; }
:root[data-spacing="wide"] body { letter-spacing: .04em; word-spacing: .16em; line-height: 1.8; }
:root[data-spacing="wide"] p, :root[data-spacing="wide"] li { line-height: 1.9; }
:root[data-font="readable"] { --head: Verdana, Tahoma, 'Segoe UI', sans-serif; --body: Verdana, Tahoma, 'Segoe UI', sans-serif; }
:root[data-links="on"] a { background: #FFF27A; color: #000 !important; text-decoration: underline !important; outline: 2px solid #000; border-radius: 2px; }
:root[data-motion="off"] *, :root[data-motion="off"] *::before, :root[data-motion="off"] *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
:root[data-gray="on"] { filter: grayscale(1); }
:root[data-cursor="big"], :root[data-cursor="big"] * { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpath d='M4 2l26 18-12 2 7 13-5 3-7-13-9 8z' fill='%23000' stroke='%23fff' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E") 4 2, auto !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
:root[data-contrast="high"] :focus-visible { outline-width: 4px; }

/* header tools: screen mode and accessibility */
.tool-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 40px; min-height: 36px; padding: 0 10px; border: 1px solid rgba(255,255,255,.7); border-radius: 6px; background: transparent; color: #fff; cursor: pointer; font: 600 calc(13px * var(--fs)) var(--head); }
.tool-btn svg { width: 20px; height: 20px; flex: none; }
.tool-btn:hover, .tool-btn[aria-expanded="true"] { background: rgba(255,255,255,.18); }
.a11y { position: fixed; z-index: 2500; top: 76px; right: 16px; width: min(380px, calc(100vw - 24px)); max-height: calc(100vh - 92px); overflow: auto; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 0 0 12px; }
.a11y[hidden] { display: none; }
.a11y header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.a11y h2 { margin: 0; font: 700 calc(17px * var(--fs)) var(--head); }
.a11y .x { min-width: 40px; min-height: 40px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); cursor: pointer; font-size: calc(20px * var(--fs)); line-height: 1; }
.a11y fieldset { border: 0; margin: 0; padding: 10px 14px 4px; }
.a11y legend { font: 600 calc(13.5px * var(--fs)) var(--head); color: var(--ink-2); padding: 0; margin-bottom: 6px; }
.a11y .opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 6px; }
.a11y .opts button, .a11y .row button { min-height: 44px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); cursor: pointer; font: 600 calc(13px * var(--fs)) var(--head); padding: 6px 8px; display: flex; align-items: center; justify-content: center; gap: 6px; text-align: center; }
.a11y .opts button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--panel); }
.a11y .opts button svg { width: 18px; height: 18px; flex: none; }
.a11y .row { display: flex; gap: 6px; padding: 10px 14px 0; flex-wrap: wrap; }
.a11y .row button { flex: 1 1 140px; }
.a11y .hint { font-size: calc(12.5px * var(--fs)); color: var(--ink-3); margin: 8px 14px 0; }
@media (max-width: 760px) { .a11y { top: auto; bottom: 0; right: 0; left: 0; width: 100%; max-height: 82vh; border-radius: 14px 14px 0 0; } }

/* scroll to top with reading progress */
.to-top { width: 52px; height: 52px; right: 20px; bottom: 20px; background: var(--panel); color: var(--accent); border: 1px solid var(--line); box-shadow: var(--shadow); }
.to-top svg.ring { position: absolute; inset: -1px; width: 52px; height: 52px; transform: rotate(-90deg); }
.to-top svg.ring circle { fill: none; stroke-width: 3; }
.to-top svg.ring .track { stroke: var(--line-soft); }
.to-top svg.ring .prog { stroke: var(--accent); stroke-linecap: round; }
.to-top svg.arrow { width: 22px; height: 22px; position: relative; }
.to-top:hover { background: var(--hover); color: var(--accent); }
.to-top { opacity: 1; transform: none; transition: opacity .2s, transform .2s; }
.to-top.off { opacity: 0; transform: translateY(12px); pointer-events: none; }
.speak-bar { position: fixed; z-index: 2400; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 30px; padding: 6px 8px 6px 16px; font: 600 calc(13px * var(--fs)) var(--head); max-width: calc(100vw - 100px); }
.speak-bar[hidden] { display: none; }
.speak-bar button { min-height: 38px; border: 0; border-radius: 20px; background: var(--accent); color: var(--panel); padding: 0 14px; cursor: pointer; font: inherit; }
.reading { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 4px; }

/* Header on mid widths, or with large text: logo and tools on the first row, title and network below. */
@media (min-width: 761px) and (max-width: 1100px) {
  .band { grid-template-columns: auto 1fr; grid-template-areas: "brand tools" "mid mid"; row-gap: 8px; padding-bottom: 12px; }
  .brand { grid-area: brand; margin-bottom: 0; } .band-tools { grid-area: tools; justify-content: flex-end; flex-wrap: wrap; } .band-mid { grid-area: mid; }
}
@media (min-width: 761px) {
  :root[data-fsbig] .band { grid-template-columns: auto 1fr; grid-template-areas: "brand tools" "mid mid"; row-gap: 8px; padding-bottom: 12px; }
  :root[data-fsbig] .brand { grid-area: brand; margin-bottom: 0; }
  :root[data-fsbig] .band-tools { grid-area: tools; justify-content: flex-end; flex-wrap: wrap; row-gap: 8px; }
  :root[data-fsbig] .band-mid { grid-area: mid; }
}
:root[data-fsbig] .netpick { flex-wrap: wrap; justify-content: center; }
:root[data-fsbig] .netpick select { max-width: 100%; }
.foot a { display: inline-block; padding: 6px 0; overflow-wrap: anywhere; }
.filters > * { max-width: 100%; min-width: 0; }
.filters select { max-width: 100%; }
@media (max-width: 760px) { .filters { min-width: 0; } .filters #paramSel, .filters .cmp select { width: 100%; box-sizing: border-box; } .cmp { width: 100%; box-sizing: border-box; } }
@media (max-width: 760px) { .filters .seg { display: flex; width: 100%; box-sizing: border-box; } .filters .seg button { flex: 1 1 0; min-width: 0; padding-left: 4px; padding-right: 4px; white-space: normal; } }
.a11y .opts[data-opt="fs"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.a11y fieldset { padding-top: 14px; }

/* ---------- sources page ---------- */
.src-page { padding-top: 14px; }
.src-page > .panel { grid-column: 1 / -1; }
.src-page .src-toc { grid-column: span 4; position: sticky; top: 14px; }
.src-page .src-sec { grid-column: 5 / -1; }
.src-toc ol { margin: 10px 0 4px; padding-left: 22px; font: 600 calc(14px * var(--fs)) var(--head); }
.src-toc li { margin: 2px 0; }
.src-toc a { display: inline-block; padding: 5px 0; color: var(--accent); }
.src-lead { color: var(--ink-2); font-size: calc(13.5px * var(--fs)); line-height: 1.55; margin: 8px 0 4px; }
.src-sec .method p, .src-sec .note { max-width: 78ch; }
.src-sec .note { font-size: calc(13px * var(--fs)); color: var(--ink-2); line-height: 1.5; }
.src-sec .refs { font-size: calc(13.5px * var(--fs)); }
.src-sec .refs li { margin: 6px 0; line-height: 1.45; }
.tablewrap { overflow-x: auto; }
.src-table { width: 100%; border-collapse: collapse; margin: 10px 0 2px; font-size: calc(13.5px * var(--fs)); }
.src-table th, .src-table td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); line-height: 1.45; }
.src-table thead th { background: var(--th); color: var(--ink-2); font: 600 calc(12.5px * var(--fs)) var(--head); border-bottom: 1px solid var(--line); white-space: nowrap; }
.src-table tbody th { font-weight: 600; color: var(--ink); }
.src-table a { color: var(--accent); }
.wpi-chip { display: inline-grid; place-items: center; min-width: 34px; height: 26px; padding: 0 6px; border-radius: 5px; background: var(--c); color: #fff; font: 700 calc(13px * var(--fs)) var(--head); }
.portals { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.portals li { padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 8px; line-height: 1.5; font-size: calc(13.5px * var(--fs)); color: var(--ink-2); }
.portals a { font: 600 calc(14px * var(--fs)) var(--head); color: var(--accent); }
.p-current .note a { color: var(--accent); }
@media (max-width: 1100px) { .src-page .src-toc, .src-page .src-sec { grid-column: 1 / -1; position: static; } }
@media (max-width: 760px) { .src-table thead { display: none; } .src-table tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--line-soft); } .src-table th, .src-table td { display: block; border: 0; padding: 2px 4px; } .src-table td[data-h]::before { content: attr(data-h) ": "; color: var(--ink-3); font-weight: 600; } }
@media (max-width: 760px) { .src-table td:empty { display: none; } .src-table tbody th { background: none; padding-top: 4px; } }

/* About: text spans the panel in three columns, matching the width of the partner lockup */
.about-text { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 32px; }
.about-text p { max-width: none; margin: 8px 0; }
@media (max-width: 1100px) { .about-text { grid-template-columns: 1fr; } .about-text p { max-width: 78ch; } }
.src-table code { font: 600 calc(12.5px * var(--fs)) ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); background: var(--chip); padding: 1px 5px; border-radius: 4px; }
