/* Tubig admin. Side navigation (a top strip on phones), tiles, cards, tables and
   server-drawn SVG charts. Tokens first: light by default, dark when the system asks. */
:root {
  --ground: #f3f6fb; --surface: #ffffff; --ink: #14223b; --muted: #5d6b84; --line: #dde4ef;
  --accent: #1f4e99; --accent-soft: #e5edfa;
  --ok: #16794d; --ok-soft: #e2f4ea; --warn: #a2620a; --warn-soft: #fcf0d9;
  --bad: #b42318; --bad-soft: #fbe5e3; --quiet: #5d6b84; --quiet-soft: #eceff5;
  --amber: #d08a1c; --nino: #c2410c; --nina: #2563eb;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0c1525; --surface: #131f34; --ink: #e5ecf7; --muted: #94a3bc; --line: #24334d;
    --accent: #8fb8ff; --accent-soft: #1b2c4a;
    --ok: #5fd39a; --ok-soft: #12352a; --warn: #f2b85a; --warn-soft: #3a2c12;
    --bad: #ff8a80; --bad-soft: #3d1b1b; --quiet: #94a3bc; --quiet-soft: #1d2a40;
    --amber: #f2b85a; --nino: #ff9b6a; --nina: #7fb0ff;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--ink); background: var(--ground); font-variant-numeric: tabular-nums; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
code { font-size: 12.5px; }
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: baseline; gap: 6px; padding: 0 10px 18px; }
.brand b { font-size: 17px; }
.brand span { color: var(--muted); font-size: 13px; }
.side ul { list-style: none; margin: 0 0 6px; padding: 0; }
.side a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.side a:hover { background: var(--ground); }
.side a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-group { margin: 16px 10px 6px; color: var(--muted); font-size: 12px; }
.side-foot { margin: 20px 10px 0; color: var(--muted); font-size: 12px; }
/* The public history's invitation to the app: a small window onto the app's own sky
   (sun, a cloud, and a water line along the bottom). Night sky in dark mode. The layers
   are tokens, so dark mode and the phone strip only change values. */
.promo {
  --promo-ink: #0f2a4a; --promo-text: #1f4166; --promo-button: #0f4c8a; --promo-button-hover: #0b3a6b;
  --promo-button-ink: #ffffff; --promo-edge: rgba(15, 76, 138, 0.18);
  --promo-wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 20'%3E%3Cpath fill='%235aa6ea' fill-opacity='.5' d='M0 7c20 0 20 6 40 6s20-6 40-6 20 6 40 6v7H0z'/%3E%3Cpath fill='%232f7fd4' fill-opacity='.75' d='M0 12c20 0 20-5 40-5s20 5 40 5 20-5 40-5v13H0z'/%3E%3C/svg%3E");
  --promo-cloud: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 28'%3E%3Cpath fill='%23ffffff' fill-opacity='.92' d='M15 27a8 8 0 0 1-1.5-15.9A11 11 0 0 1 34.6 6.4 9 9 0 0 1 49 13.2 7 7 0 0 1 50 27z'/%3E%3C/svg%3E");
  --promo-sun: #fff7d1; --promo-glow: rgba(255, 230, 140, 0.55); --promo-glow-end: rgba(255, 230, 140, 0);
  --promo-sky: linear-gradient(180deg, #8fcaf6 0%, #bfe1fb 55%, #e3f2fe 100%);
  --sun-at: calc(100% - 22px) 22px;
  position: relative; display: grid; gap: 6px; padding: 14px 14px 30px; border-radius: 14px;
  border: 1px solid var(--promo-edge); color: var(--promo-text); overflow: hidden;
  background:
    var(--promo-wave) left bottom / 120px 20px repeat-x,
    var(--promo-cloud) right 10px top 26px / 52px 23px no-repeat,
    radial-gradient(circle at var(--sun-at), var(--promo-sun) 0 9px, var(--promo-glow) 10px, var(--promo-glow-end) 24px),
    var(--promo-sky);
}
@media (prefers-color-scheme: dark) {
  .promo {
    --promo-ink: #f1f6fd; --promo-text: #c9d9ee; --promo-button: #9ccbff; --promo-button-hover: #c4e0ff;
    --promo-button-ink: #0b2140; --promo-edge: rgba(156, 203, 255, 0.2);
    --promo-wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 20'%3E%3Cpath fill='%232a5d9c' fill-opacity='.55' d='M0 7c20 0 20 6 40 6s20-6 40-6 20 6 40 6v7H0z'/%3E%3Cpath fill='%231d4a85' fill-opacity='.9' d='M0 12c20 0 20-5 40-5s20 5 40 5 20-5 40-5v13H0z'/%3E%3C/svg%3E");
    --promo-cloud: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 28'%3E%3Cpath fill='%23b9c9e0' fill-opacity='.28' d='M15 27a8 8 0 0 1-1.5-15.9A11 11 0 0 1 34.6 6.4 9 9 0 0 1 49 13.2 7 7 0 0 1 50 27z'/%3E%3C/svg%3E");
    --promo-sun: #e9eef8; --promo-glow: rgba(200, 215, 240, 0.25); --promo-glow-end: rgba(200, 215, 240, 0);
    --promo-sky: linear-gradient(180deg, #0c1f3d 0%, #13305a 60%, #1a3f72 100%);
  }
}
.promo-title { margin: 0; padding-right: 48px; color: var(--promo-ink); font-size: 15px; font-weight: 700; line-height: 1.25; }
.promo-text { margin: 0; font-size: 12.5px; line-height: 1.4; }
.promo .promo-link {
  justify-self: start; margin-top: 4px; padding: 6px 12px; border-radius: 999px;
  background: var(--promo-button); color: var(--promo-button-ink); font-size: 12.5px; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.promo .promo-link:hover { background: var(--promo-button-hover); }
.promo .promo-link:focus-visible { outline: 2px solid var(--promo-ink); outline-offset: 2px; }
.side-promo { margin: 16px 4px 0; }
.promo-strip { display: none; }
.page-foot { margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
main { padding: 24px 28px 40px; display: grid; gap: 18px; align-content: start; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 4px; align-content: start; min-width: 0; }
.tile h2 { margin: 0; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.tile p { margin: 0; }
.tile .big { font-size: 16px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.tile .muted { font-size: 12.5px; overflow-wrap: anywhere; }
.dot-state { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot-state.ok { background: var(--ok); } .dot-state.warn { background: var(--warn); }
.dot-state.bad { background: var(--bad); } .dot-state.quiet { background: var(--quiet); }
.row-title { margin: 6px 0 -6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.minis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; min-width: 0; display: grid; gap: 10px; align-content: start; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.card h2 { margin: 0; font-size: 15px; }
.card.mini { padding: 14px 16px; gap: 8px; }
.card.mini h2 { font-size: 14.5px; }
.muted { color: var(--muted); }
.note { margin: 0; color: var(--muted); font-size: 12.5px; }
.empty { margin: 0; color: var(--muted); }
.facts { display: flex; gap: 22px; flex-wrap: wrap; margin: 0; }
.facts div { display: grid; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 0; font-weight: 600; }
.facts.stack { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.swatch.accent { background: var(--accent); } .swatch.amber { background: var(--amber); } .swatch.muted { background: var(--muted); }
.swatch.ok { background: var(--ok); } .swatch.bad { background: var(--bad); } .swatch.round { border-radius: 50%; }
.button { display: inline-flex; align-items: center; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font: inherit; cursor: pointer; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters label { display: grid; gap: 4px; color: var(--muted); font-size: 12.5px; }
.filters select, .filters input { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; max-width: 100%; }
.filters input[type="search"] { width: 260px; }
.table-wrap { overflow-x: auto; }
/* A long list in a box of its own; the header stays in view. */
.table-wrap.scroll { max-height: 420px; overflow-y: auto; }
.table-wrap.scroll thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; border-top: 0; }
td.num { white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: 12.5px; }
td.wrap { min-width: 220px; max-width: 360px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.quiet { background: var(--quiet-soft); color: var(--quiet); }
.pill.water { background: var(--accent-soft); color: var(--accent); }
.fails { color: var(--bad); margin-left: 4px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); flex-wrap: wrap; }
.pager-links { display: flex; gap: 8px; }
.feed { list-style: none; margin: 0; padding: 0; display: grid; }
.feed li { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); align-items: start; }
.feed li:first-child { border-top: 0; }
.feed li .pill { justify-self: start; }
.feed-main { display: grid; min-width: 0; }
.feed-main strong { font-weight: 600; }
.feed-when { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.quote { margin: 0; padding: 8px 12px; border-left: 3px solid var(--line); color: var(--muted); }
.storm { display: grid; gap: 12px; border-top: 1px solid var(--line); padding-top: 14px; }
.storm:first-of-type { border-top: 0; padding-top: 0; }
.storm-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.storm-grid > div { display: grid; gap: 12px; min-width: 0; }
.drought { font-size: 12px; padding: 2px 6px; border-radius: 6px; white-space: nowrap; }
.drought.d0 { background: var(--ok-soft); color: var(--ok); } .drought.d1 { background: var(--quiet-soft); color: var(--ink); }
.drought.d2 { background: var(--warn-soft); color: var(--warn); } .drought.d3 { background: var(--bad-soft); color: var(--bad); }
code { font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
pre.code { margin: 0; padding: 12px 14px; overflow-x: auto; background: var(--ground); border: 1px solid var(--line); border-radius: 8px; font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; }
.rules { margin: 0; display: grid; gap: 4px 0; }
.rules dt { font-weight: 600; margin-top: 8px; }
.rules dt:first-child { margin-top: 0; }
.rules dd { margin: 0; color: var(--muted); }
/* Charts (tubig/admin/charts.py) */
svg { width: 100%; height: auto; display: block; }
.grid { stroke: var(--line); stroke-width: 1; } .grid.thin { stroke-dasharray: 2 3; }
.t-tick { fill: var(--muted); font-size: 11px; } .t-tick.today { fill: var(--accent); font-weight: 600; }
.t-name { fill: var(--ink); font-size: 11.5px; } .t-sub { fill: var(--muted); font-size: 10.5px; }
.t-end { font-size: 10.5px; font-weight: 600; } .t-end.main { fill: var(--accent); } .t-end.normal { fill: var(--muted); } .t-end.nino { fill: var(--nino); }
.limit { stroke-width: 1.2; stroke-dasharray: 5 4; fill: none; }
.limit.warn { stroke: var(--warn); } .limit.bad { stroke: var(--bad); } .limit.ok { stroke: var(--ok); } .limit.muted { stroke: var(--muted); }
.limit-label { font-size: 11px; } .limit-label.warn { fill: var(--warn); } .limit-label.bad { fill: var(--bad); }
.limit-label.ok { fill: var(--ok); } .limit-label.muted { fill: var(--muted); }
.area { fill: var(--accent); fill-opacity: 0.1; }
.line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; } .line.gap { stroke-dasharray: 3 5; stroke-width: 1.6; }
.dot { fill: var(--surface); stroke: var(--accent); stroke-width: 1.4; }
.end { fill: var(--accent); stroke: var(--surface); stroke-width: 2; } .end-label { fill: var(--ink); font-size: 12px; font-weight: 600; }
.col.accent, .bar.accent, .win.accent, .fill { fill: var(--accent); }
.col.amber, .bar.amber, .win.amber { fill: var(--amber); }
.col.muted, .bar.muted { fill: var(--muted); fill-opacity: 0.5; }
.col.ok { fill: var(--ok); } .col.bad { fill: var(--bad); }
.track { fill: var(--ground); } .stuck { fill: var(--muted); fill-opacity: 0.35; } .fill.over { fill: var(--bad); }
.mark { stroke-width: 2; } .mark.bad { stroke: var(--bad); } .mark.warn { stroke: var(--warn); } .mark.ok { stroke: var(--ok); }
.ln-main { fill: none; stroke: var(--accent); stroke-width: 2; } .ln-normal { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.band { fill: var(--accent); fill-opacity: 0.14; }
.nino { fill: var(--nino); } .nina { fill: var(--nina); } .neutral { fill: var(--muted); fill-opacity: 0.4; }
.nowline { stroke: var(--bad); stroke-width: 1.5; }
.range { fill: var(--accent); fill-opacity: 0.18; stroke: var(--accent); stroke-width: 1; }
.rec { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.ring { fill: none; stroke: var(--line); } .me { fill: var(--ink); }
.storm-dot { fill: var(--ok); stroke: var(--surface); stroke-width: 2; }
.track-line { fill: none; stroke: var(--ok); stroke-width: 1.5; stroke-dasharray: 3 3; }
.heading { stroke: var(--ink); stroke-width: 1.5; } .arrowhead { fill: var(--ink); }
@media (max-width: 1100px) { .minis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols, .storm-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); display: flex; gap: 6px; overflow-x: auto; align-items: center; }
  .brand { padding: 0 8px 0 4px; } .nav-group, .side-foot, .side-promo { display: none; }
  /* The strip: the sun leads the heading on the left, the button keeps the right. */
  .promo-strip {
    --promo-cloud: none; --sun-at: 24px 26px;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 12px;
    padding: 12px 14px 24px 46px;
  }
  .promo-strip .promo-text { display: none; }
  .promo-strip .promo-title { padding-right: 0; font-size: 14px; }
  .promo-strip .promo-link { margin-top: 0; }
  .side ul { display: flex; gap: 2px; margin: 0; } .side a { white-space: nowrap; }
  main { padding: 18px 16px 32px; }
  .minis { grid-template-columns: minmax(0, 1fr); }
  .feed li { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}
