/* saero.org: public sAERO pool guide. Dark, phone first. */
:root {
  --bg: #0b1118; --panel: #111a24; --panel2: #16212d; --line: #22303e; --ink: #e6edf3; --muted: #8fa1b3; --faint: #5f7385;
  --accent: #74a9ff; --accent-soft: #172a45; --teal: #2fd4c4;
  --up: #3fcf8e; --up-soft: #12301f; --down: #ff7d74; --down-soft: #3a1817; --warn: #f2b84b; --warn-soft: #362810;
  --display: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--body); -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
.wrap { max-width: 1100px; margin: 0 auto; padding-block: 18px 40px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; grid-template-columns: minmax(0, 1fr); gap: 30px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; letter-spacing: .01em; text-wrap: balance; }
h1 { font-size: 2rem; line-height: 1.05; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.08rem; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.small { font-size: .86rem; }
.label { font-family: var(--display); font-weight: 600; font-size: .74rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.pos { color: var(--up); } .neg { color: var(--down); } .wrn { color: var(--warn); }

/* header */
.head { display: grid; gap: 10px; }
.tagline { color: var(--muted); max-width: 70ch; }
.status { color: var(--muted); font-size: .9rem; }
.status b { color: var(--ink); font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--up); margin-right: 6px; vertical-align: middle; }
.dot.stale { background: var(--warn); } .dot.bad { background: var(--down); }
.jump { display: flex; flex-wrap: wrap; gap: 6px; }
.jump a { font: 600 .86rem var(--body); color: var(--muted); text-decoration: none; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; }
.jump a:hover { color: var(--ink); border-color: var(--faint); }

section { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; scroll-margin-top: 16px; min-width: 0; }
.sec-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; }
.sec-sub { color: var(--muted); font-size: .93rem; max-width: 72ch; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 14px; }
.grid2 > * { min-width: 0; }

/* controls */
.chip { display: inline-block; font-size: .75rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; line-height: 1.6; }
.chip.up { background: var(--up-soft); color: var(--up); } .chip.down { background: var(--down-soft); color: var(--down); }
.chip.warn { background: var(--warn-soft); color: var(--warn); } .chip.flat { background: var(--panel2); color: var(--muted); }
.chip.acc { background: var(--accent-soft); color: var(--accent); } .chip.teal { background: #0f2e2c; color: var(--teal); }
button, .btn { font: 600 .92rem var(--body); color: var(--ink); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 14px; cursor: pointer; min-height: 40px; }
button:hover { border-color: var(--faint); }
button.pri { background: var(--accent); color: #08111d; border-color: var(--accent); }
button.link { background: none; border: 0; padding: 0 2px; min-height: 0; color: var(--faint); font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }
button.link:hover { color: var(--ink); }
button.x { background: none; border: 0; color: var(--faint); font-size: 1.2rem; padding: 4px 8px; min-height: 36px; }
button.x:hover { color: var(--down); }
input, select { font: 600 16px var(--body); color: var(--ink); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; min-width: 0; font-variant-numeric: tabular-nums; min-height: 42px; }
input::placeholder { color: var(--faint); font-weight: 500; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, tr:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.field { display: grid; gap: 5px; min-width: 0; }
.controls { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; }
.check { display: flex; gap: 8px; align-items: center; font-size: .94rem; }
.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); flex: none; }
.err { color: var(--down); font-size: .92rem; }

/* planner */
.planform { display: grid; gap: 14px; }
.amt-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.amt-row .field { flex: 1 1 220px; max-width: 340px; }
#amt { font-size: 1.3rem; font-family: var(--display); }
.curlist { display: grid; gap: 8px; max-width: 640px; }
.currow { display: grid; grid-template-columns: minmax(0, 1fr) 5.5rem auto; gap: 8px; align-items: center; }
.currow select { width: 100%; }
.pctbox { position: relative; }
.pctbox input { width: 100%; padding-right: 26px; }
.pctbox span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.rowbtns { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
details.sub > summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: .95rem; padding: 4px 0; }
details.sub[open] { display: grid; gap: 10px; }
.wform { display: flex; flex-wrap: wrap; gap: 8px; }
.wform input { flex: 1 1 260px; }
.locklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.locklist li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.plan-card { display: grid; gap: 10px; border-color: var(--accent-soft); background: linear-gradient(180deg, var(--accent-soft), var(--panel) 65%); }
.plan-card .big { font-size: 1.14rem; }
.verdict { padding: 11px 13px; border-radius: 8px; background: var(--panel2); display: grid; gap: 3px; border-left: 3px solid var(--faint); }
.verdict.go { background: var(--up-soft); border-left-color: var(--up); }
.verdict b { font-family: var(--display); font-size: 1.08rem; }
.kpis { display: flex; flex-wrap: wrap; gap: 10px 30px; align-items: baseline; }
.kpi b { display: block; font-family: var(--display); font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.kpi.hl b { color: var(--accent); }
.kpi b small { font-size: .8rem; color: var(--muted); font-weight: 600; margin-left: 2px; }

/* lists of pools (plan split, programs, moves) */
.allocs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.allocs li { display: grid; grid-template-columns: 3.3rem minmax(0, 1fr) auto; gap: 2px 10px; align-items: baseline; padding-top: 7px; border-top: 1px solid var(--line); }
.allocs .pct { font-family: var(--display); font-weight: 700; font-size: 1.22rem; color: var(--accent); }
.allocs .pn { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.allocs li > .num { text-align: right; white-space: nowrap; }
.allocs .sub { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; color: var(--muted); font-size: .85rem; }
button.copy { justify-self: start; }

/* coming up */
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.events li { display: grid; grid-template-columns: 8.6rem minmax(0, 1fr); gap: 2px 14px; padding: 10px 0; border-top: 1px solid var(--line); }
.events li:first-child { border-top: 0; padding-top: 2px; }
.events .when { font-family: var(--display); font-weight: 600; color: var(--ink); }
.events .when small { display: block; font-family: var(--body); font-weight: 500; color: var(--faint); font-size: .8rem; }
.events .what { min-width: 0; overflow-wrap: anywhere; }
.events .pools { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.chart { width: 100%; min-height: 60px; }

/* tables */
.tablebox { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th { font-family: var(--display); font-weight: 600; font-size: .72rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); text-align: right; padding: 10px 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); user-select: none; vertical-align: bottom; }
th[data-k] { cursor: pointer; }
th.sorted { color: var(--ink); }
td { padding: 9px 9px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; }
td:first-child { white-space: normal; min-width: 9rem; }
tbody tr[data-id] { cursor: pointer; }
tbody tr[data-id]:hover td { background: var(--panel2); }
tr.open td { background: var(--panel2); }
td .pn { font-weight: 600; color: var(--ink); }
td .pk { color: var(--faint); font-size: .78rem; }
tr.detail td { white-space: normal; cursor: default; background: var(--bg) !important; padding: 14px 12px 18px; text-align: left; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters input { flex: 1 1 200px; max-width: 300px; }
.more { justify-self: start; }

/* how it works */
.play .panel { display: grid; gap: 8px; }
.play ul { margin: 0; padding-left: 1.15rem; display: grid; gap: 7px; max-width: 78ch; }
.src { color: var(--faint); font-size: .83rem; }

/* help bubbles */
details.help { position: relative; }
details.help summary { list-style: none; cursor: pointer; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); color: var(--muted); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
details.help summary::-webkit-details-marker { display: none; }
details.help[open] p { position: absolute; right: 0; top: 32px; z-index: 50; width: min(340px, 86vw); margin: 0; padding: 10px 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-size: .9rem; box-shadow: 0 8px 24px rgba(0,0,0,.35); }

footer { color: var(--faint); font-size: .85rem; display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 16px; }
footer p { max-width: 80ch; }

/* uPlot on dark */
.uplot { font-family: var(--body); }
.u-legend { color: var(--muted); font-size: .8rem; }

@media (max-width: 640px) {
  h1 { font-size: 1.65rem; }
  .kpi b { font-size: 1.45rem; }
  td, th { padding: 8px 7px; }
  .hide-sm { display: none; }
  .events li { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } html { scroll-behavior: auto; } }
