/* Printed-timetable look: hairline rules, a serif for names, Plex for every number. */
:root {
  color-scheme: light;
  --surface: #ffffff;
  --ink: #191919;
  --ink-2: #666666;
  --rule: #191919;
  --grid: #e7e7e7;
  --axis: #c2c2c2;
  --s1: #257de0;            /* categorical slot 1: today / peak */
  --s2: #f47230;            /* categorical slot 2: daily mean */
  --track: #cce3fd;         /* meter track, sequential step 100 */
  --band: rgba(102, 102, 102, 0.16);
  --critical: #dc3c3d;
  --focus: #1757ac;
  --heat-0: #eef5fe; --heat-1: #b6d5f8; --heat-2: #6aabf1; --heat-3: #257de0; --heat-4: #0f4a96; --heat-5: #0b2f61;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface: #191919;
    --ink: #efefef;
    --ink-2: #9c9c9c;
    --rule: #efefef;
    --grid: #303030;
    --axis: #474747;
    --s1: #338ced;
    --s2: #e76624;
    --track: #1d2b3d;
    --band: rgba(156, 156, 156, 0.2);
    --focus: #84b9f3;
    --heat-0: #1f2833; --heat-1: #1b4373; --heat-2: #1b64be; --heat-3: #338ced; --heat-4: #84b9f3; --heat-5: #cce3fd;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #191919; --ink: #efefef; --ink-2: #9c9c9c; --rule: #efefef; --grid: #303030;
  --axis: #474747; --s1: #338ced; --s2: #e76624; --track: #1d2b3d;
  --band: rgba(156, 156, 156, 0.2); --focus: #84b9f3;
  --heat-0: #1f2833; --heat-1: #1b4373; --heat-2: #1b64be; --heat-3: #338ced; --heat-4: #84b9f3; --heat-5: #cce3fd;
}

* { box-sizing: border-box; }
html { background: var(--surface); }
body {
  margin: 0; background: var(--surface); color: var(--ink);
  font: 400 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
.page { max-width: 1120px; margin: 0 auto; padding: 24px 16px 48px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; letter-spacing: -0.005em; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 22px; line-height: 1.2; }
h3 { font-size: 17px; }
a { color: inherit; text-underline-offset: 2px; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.nowrap, #as-of { white-space: nowrap; }
.note { color: var(--ink-2); margin: 6px 0 0; font-size: 13.5px; }
.note:empty { display: none; }
button.link {
  background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px;
}

/* masthead: title left, two text links right, closed by a double rule like a bulletin */
.mast {
  display: flex; gap: 16px 32px; justify-content: space-between; align-items: flex-end; flex-wrap: wrap;
  padding-bottom: 12px; border-bottom: 3px double var(--rule);
}
.dek { margin: 6px 0 0; color: var(--ink-2); max-width: 72ch; }
.mast-nav { display: flex; gap: 20px; align-items: baseline; color: var(--ink-2); font-size: 14px; }
.mast-nav form { margin: 0; }
.stale { display: flex; gap: 8px; align-items: center; margin: 12px 0 0; color: var(--critical); font-weight: 500; }
.stale[hidden] { display: none; }
.ico { width: 16px; height: 16px; flex: none; }

/* now: one row per counted area, venue names as serif subheads */
.now { margin-top: 28px; }
.venue { margin-top: 18px; }
.venue-head { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; border-bottom: 1px solid var(--rule); padding-bottom: 4px; }
.venue-head h3 { font-size: 18px; }
.venue-status { color: var(--ink-2); font-size: 13.5px; }
.row {
  display: grid; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  grid-template-columns: minmax(130px, 1.1fr) minmax(120px, 2fr) 96px 52px minmax(150px, 1.2fr) 132px;
  gap: 4px 16px; align-items: center;
  background: none; border: 0; border-bottom: 1px solid var(--grid); padding: 9px 0 9px 12px;
}
.row:hover .name, .row[aria-current="true"] .name { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.row[aria-current="true"] { box-shadow: inset 3px 0 0 var(--s1); }
.name { font-weight: 500; }
.meter { position: relative; height: 8px; background: var(--track); }
.meter .fill { position: absolute; inset: 0 auto 0 0; background: var(--s1); }
.meter .typ { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--ink); }
.fig { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fig b { font-weight: 600; font-size: 17px; }
.fig .cap { color: var(--ink-2); }
.pct { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.vs { color: var(--ink-2); font-size: 13.5px; }
.spark { width: 132px; height: 28px; display: block; }
.spark path { fill: none; stroke: var(--s1); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark line { stroke: var(--grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.closed { color: var(--ink-2); font-size: 13.5px; margin: 14px 0 0; }
.closed:empty { display: none; }

/* detail */
.detail { margin-top: 40px; border-top: 3px double var(--rule); padding-top: 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: center; margin-bottom: 16px; font-size: 14px; }
.filters select {
  font: inherit; color: var(--ink); background: var(--surface); margin-left: 6px;
  border: 1px solid var(--axis); border-radius: 0; padding: 4px 6px;
}
.period { border: 0; margin: 0; padding: 0; display: flex; gap: 18px; align-items: baseline; }
.period legend { float: left; margin-right: 6px; padding: 0; }
.period label { cursor: pointer; }
.period input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.period span { padding-bottom: 2px; border-bottom: 2px solid transparent; color: var(--ink-2); }
.period input:checked + span { color: var(--ink); border-bottom-color: var(--ink); font-weight: 500; }
.period input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
#area-csv { margin-left: auto; color: var(--ink-2); }

.chart { margin: 22px 0 0; padding-top: 10px; border-top: 1px solid var(--rule); }
.chart figcaption { display: flex; flex-wrap: wrap; gap: 4px 20px; align-items: baseline; margin-bottom: 8px; }
.legend { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--ink-2); font-size: 13.5px; }
.key { display: inline-flex; align-items: center; gap: 6px; }
.key i { display: inline-block; width: 18px; height: 0; border-top: 2px solid; }
.key i.dash { border-top-style: dashed; border-top-width: 2px; }
.key i.band { height: 10px; border: 0; background: var(--band); }
.plot { position: relative; min-height: 120px; transition: opacity .15s; }
.loading .plot, .loading .heat { opacity: .45; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; }
details { margin-top: 8px; font-size: 13.5px; color: var(--ink-2); }
summary { cursor: pointer; width: max-content; }
.tbl { max-height: 320px; overflow: auto; margin-top: 6px; }
.tbl table { border-collapse: collapse; font-variant-numeric: tabular-nums; color: var(--ink); }
.tbl th, .tbl td { padding: 3px 14px 3px 0; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl thead th { position: sticky; top: 0; background: var(--surface); font-weight: 500; color: var(--ink-2); }

/* heatmap: weekdays down, hours across, 2px surface gap between cells */
.heat { display: grid; gap: 2px; font-size: 12px; font-variant-numeric: tabular-nums; }
.heat .hd { color: var(--ink-2); text-align: center; }
.heat .wd { color: var(--ink-2); padding-right: 6px; align-self: center; }
.heat .cell { height: 26px; background: var(--heat-0); border: 0; padding: 0; cursor: default; }
.heat .cell.empty { background: transparent; box-shadow: inset 0 0 0 1px var(--grid); }
.heat .cell:hover, .heat .cell:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.scale { display: inline-flex; align-items: center; gap: 6px; }
.scale .ramp { width: 120px; height: 8px; }

/* uPlot chrome */
.uplot { font-family: var(--sans); }
.u-over { cursor: crosshair; }
.tip {
  position: fixed; z-index: 10; pointer-events: none; min-width: 150px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--axis);
  padding: 7px 10px; font-size: 13px; line-height: 1.35; font-variant-numeric: tabular-nums;
}
.tip .t { color: var(--ink-2); margin-bottom: 3px; }
.tip .r { display: flex; align-items: center; gap: 8px; }
.tip .r i { width: 12px; border-top: 2px solid; flex: none; }
.tip .r i.dash { border-top-style: dashed; }
.tip .r b { font-weight: 600; min-width: 2.5em; text-align: right; }
.tip .r span { color: var(--ink-2); }

.foot { margin-top: 44px; border-top: 1px solid var(--rule); padding-top: 10px; color: var(--ink-2); font-size: 13.5px; }
.foot p { max-width: 80ch; margin: 0; }

@media (max-width: 860px) {
  .row { grid-template-columns: 1fr auto auto; }
  .row .name { grid-column: 1 / -1; }
  .row .meter { grid-column: 1 / 2; }
  .row .vs { grid-column: 1 / -1; }
  .row .spark { display: none; }
  .pair { grid-template-columns: 1fr; }
  #area-csv { margin-left: 0; }
}
@media (max-width: 520px) {
  h1 { font-size: 25px; }
  .heat .cell { height: 20px; }
  .heat { font-size: 10.5px; }
}

/* login */
body.login .login-box { max-width: 340px; margin: 14vh auto 0; padding: 0 16px; }
.login-box h1 { padding-bottom: 8px; border-bottom: 3px double var(--rule); }
.login-box .muted { color: var(--ink-2); margin: 8px 0 20px; }
.login-box label { display: block; margin: 14px 0; font-size: 14px; color: var(--ink-2); }
.login-box input {
  display: block; width: 100%; margin-top: 4px; padding: 8px; font: inherit; font-size: 16px;
  color: var(--ink); background: var(--surface); border: 1px solid var(--axis); border-radius: 0;
}
.login-box button {
  margin-top: 8px; font: inherit; font-weight: 500; padding: 8px 18px; cursor: pointer;
  color: var(--surface); background: var(--ink); border: 0; border-radius: 0;
}
.error { color: var(--critical); }
