/* Tokens: one place for light and dark. Charts use the --series-* and chart chrome variables. */
:root {
  color-scheme: light;
  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --border: rgba(11, 11, 11, 0.10);
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --brand: #053a58;          /* navy: text, buttons, links */
  --brand-contrast: #ffffff;
  --accent: #cedc00;         /* lime: small fills only, never text */
  --soft: #e6f3f9;
  --series-1: #2a78d6;
  --good: #0ca30c;
  --good-ink: #006300;
  --warn: #fab219;
  --bad: #d03b3b;
  --radius: 10px;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --border: rgba(255, 255, 255, 0.10);
    --grid: #2c2c2a;
    --axis: #383835;
    --brand: #84cff0;
    --brand-contrast: #06202e;
    --soft: #13303f;
    --series-1: #3987e5;
    --good-ink: #0ca30c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--plane); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0; text-wrap: balance; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
h3 { font-size: .95rem; margin: 1.25rem 0 .25rem; }
p { margin: .5rem 0; }
.muted { color: var(--ink-2); }
.hint { color: var(--ink-2); font-size: .875rem; }
.lead { margin-top: -.5rem; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.top-inner { max-width: 1240px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: .5rem 1.25rem; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: .5rem; }
.brand-mark { width: 12px; height: 12px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 0 1px var(--border); }
nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
nav a { padding: .35rem .7rem; border-radius: 999px; text-decoration: none; color: var(--ink-2); }
nav a:hover { background: var(--soft); color: var(--ink); }
nav a[aria-current="page"] { background: var(--brand); color: var(--brand-contrast); }
.health { font-size: .85rem; text-decoration: none; color: var(--ink-2); display: inline-flex; gap: .35rem; align-items: center; white-space: nowrap; }
.health.ok .health-icon { color: var(--good); }
.health.down { color: var(--ink); font-weight: 600; }
.health.down .health-icon { color: var(--bad); }

main { max-width: 1240px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head.sub { align-items: center; margin: 1.5rem 0 .5rem; }
.page-head.sub h2 { margin: 0; }
.page-head p { margin: .25rem 0 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.crumbs { font-size: .875rem; color: var(--ink-2); margin: 0 0 .5rem; }
.section { margin: 2rem 0 .5rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin: 0 0 1rem; }
.card.narrow { max-width: 360px; margin: 4rem auto; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 0 1rem; }
.card .two-col { gap: 0 2rem; }

/* controls */
button, .button, input, select { font: inherit; }
.button, button { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .8rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer; white-space: nowrap; }
.button:hover, button:hover { background: var(--soft); }
button.primary { background: var(--brand); color: var(--brand-contrast); border-color: transparent; font-weight: 600; }
button.primary:hover { filter: brightness(1.12); background: var(--brand); }
button.link { border: 0; background: none; padding: 0; color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
form.inline { display: inline-flex; gap: .4rem; align-items: center; margin: 0; }
input, select { padding: .45rem .6rem; border-radius: 8px; border: 1px solid var(--axis); background: var(--surface); color: var(--ink); min-width: 0; max-width: 100%; }
label { display: block; font-size: .8rem; color: var(--ink-2); margin-bottom: .2rem; }
.stack { display: grid; gap: .5rem; }
.row { display: flex; gap: .5rem; }
.row input { flex: 1; }
.add-form label { font-size: .95rem; font-weight: 600; color: var(--ink); }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; align-items: end; }
.filters input, .filters select { width: 100%; }
.filters .pair { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.filter-actions { display: flex; gap: .75rem; align-items: center; }
.filter { width: min(100%, 260px); }

.flash { padding: .6rem .8rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); border-left: 4px solid var(--axis); }
.flash.ok { border-left-color: var(--good); }
.flash.error { border-left-color: var(--bad); }
.flash.warn { border-left-color: var(--warn); }

/* figures */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin: 0 0 1rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .9rem; min-width: 0; }
.card .tile { background: var(--plane); }
.tile-label { font-size: .8rem; color: var(--ink-2); }
.tile-value { font-size: 1.35rem; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.tile-hint { font-size: .8rem; color: var(--ink-2); }
.auction-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: .75rem; }
.auction-head h2 { margin: 0; font-size: 1.15rem; }
.auction-head p { margin: .15rem 0 0; }
.auction-card .tiles { margin-bottom: 0; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .6rem 1.5rem; margin: 0 0 .75rem; }
.facts.compact { grid-template-columns: 1fr; gap: .15rem; }
.fact dt { font-size: .8rem; color: var(--ink-2); }
.fact dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.facts.compact .fact { display: flex; justify-content: space-between; gap: 1rem; padding: .25rem 0; border-bottom: 1px solid var(--grid); }
.facts.compact .fact dt { font-size: .875rem; }
.facts.compact .fact dt { flex: 1 1 auto; min-width: 0; }
/* Values keep their width and never break inside a number; the label wraps instead. */
.facts.compact .fact dd { text-align: right; font-weight: 600; white-space: normal; flex: 0 0 auto; max-width: 62%; overflow-wrap: normal; }
.prose { white-space: pre-line; max-width: 75ch; }
.prose.small { font-size: .875rem; color: var(--ink-2); }
.notes { max-width: 75ch; padding-left: 1.2rem; margin: .25rem 0; }
.notes li + li { margin-top: .35rem; }
.context-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 0 2rem; }
.context-grid h3 { margin-top: .75rem; }

/* badges: always icon + label, colour only supports */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .05rem .5rem; border-radius: 999px; font-size: .8rem; white-space: nowrap;
  border: 1px solid var(--border); background: var(--plane); color: var(--ink); }
.badge.good > span { color: var(--good-ink); }
.badge.warn > span { color: var(--ink); background: var(--warn); border-radius: 50%; width: 1em; height: 1em; display: inline-grid; place-items: center; font-size: .7em; }
.badge.bad > span { color: var(--bad); }
.badge.running > span { color: var(--series-1); font-size: .7em; }
.badge.muted { color: var(--ink-2); }
.tag { font-size: .72rem; padding: .05rem .4rem; border-radius: 4px; background: var(--soft); color: var(--ink); white-space: nowrap; }
.tag.warn { background: none; border: 1px solid var(--warn); }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.card .table-wrap { margin-top: .5rem; }
table.data { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.data th, table.data td { padding: .45rem .7rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--grid); }
table.data th.num, table.data td.num { text-align: right; }
table.data thead th { font-size: .8rem; font-weight: 600; color: var(--ink-2); background: var(--plane); white-space: nowrap; position: sticky; top: 0; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--soft); }
table.data td.title { min-width: 16rem; }
table.data td.auction-col { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--ink); }
th[aria-sort="ascending"]::after { content: " ▲"; font-size: .7em; }
th[aria-sort="descending"]::after { content: " ▼"; font-size: .7em; }
.thumb-col { width: 76px; padding-right: 0 !important; }
.thumb-col img { display: block; width: 64px; height: 48px; object-fit: cover; border-radius: 6px; background: var(--grid); }
details > summary { cursor: pointer; padding: .5rem 0; color: var(--brand); }

/* gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
.gallery-item { display: block; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: var(--grid); }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-item:first-child { grid-column: span 2; grid-row: span 2; }
dialog#lightbox { border: 0; padding: 0; background: rgba(0, 0, 0, .92); width: 100vw; height: 100vh; max-width: none; max-height: none; }
dialog#lightbox[open] { display: grid; place-items: center; }
dialog#lightbox::backdrop { background: rgba(0, 0, 0, .9); }
dialog#lightbox img { max-width: 94vw; max-height: 88vh; object-fit: contain; }
dialog#lightbox button { position: fixed; background: rgba(255, 255, 255, .14); color: #fff; border: 0; font-size: 1.6rem; width: 44px; height: 44px; border-radius: 50%; justify-content: center; padding: 0; }
.lb-close { top: 12px; right: 12px; }
.lb-prev { left: 12px; top: 50%; }
.lb-next { right: 12px; top: 50%; }
.lb-count { position: fixed; bottom: 8px; left: 0; right: 0; text-align: center; color: #fff; margin: 0; }

/* charts */
svg.chart { width: 100%; height: auto; display: block; overflow: visible; outline-offset: 4px; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .ref { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .value { fill: var(--ink); font-size: 12px; font-weight: 600; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.s1 { stroke: var(--series-1); }
.chart .area.s1 { fill: var(--series-1); opacity: .1; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .dot.s1 { fill: var(--series-1); }
.chart .bar.s1 { fill: var(--series-1); }
.chart .band { fill: var(--ink-2); }
.chart .cross { stroke: var(--axis); stroke-width: 1; pointer-events: none; }
.chart .focus { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.chart[data-kind="scatter"] { cursor: pointer; }
.chart-empty { padding: 1.5rem 0; }
.small-multiples { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 1rem 2rem; }
.small-multiples h3 { margin-bottom: 0; }
.small-multiples p { margin-top: 0; font-size: .85rem; }

.bars { display: grid; gap: 6px; margin-top: .5rem; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 11rem) 1fr 4.5rem; gap: .6rem; align-items: center; font-size: .875rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.bar-track { height: 14px; display: block; }
.bar-fill { display: block; height: 100%; min-width: 2px; background: var(--series-1); border-radius: 0 4px 4px 0; }
.bar-row:hover .bar-fill { filter: brightness(1.15); }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; }

.ranges { display: grid; gap: 8px; margin-top: .5rem; }
.range-row { display: grid; grid-template-columns: minmax(90px, 9rem) 1fr 5rem; gap: .6rem; align-items: center; font-size: .875rem; }
.range-track { position: relative; display: block; height: 14px; background: linear-gradient(var(--grid), var(--grid)) center / 100% 1px no-repeat; }
.range-fill { position: absolute; top: 3px; bottom: 3px; min-width: 2px; border-radius: 4px; background: var(--series-1); opacity: .35; }
.range-mid { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--series-1); }
.range-row:hover .range-fill { opacity: .5; }
.switch label { font-size: .875rem; color: var(--ink-2); }
.pager { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: .75rem; font-size: .875rem; }
.assign { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; margin-top: .25rem; }
.assign input { width: 7.5rem; padding: .25rem .45rem; }
.assign-col { max-width: 15rem; }
.channels-col { max-width: 9.5rem; }
.assign button { padding: .25rem .6rem; }
.ad-text { max-width: 34ch; }

.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--ink); color: var(--plane); padding: .35rem .55rem; border-radius: 6px;
  font-size: .8rem; line-height: 1.35; max-width: 280px; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.tip b { display: block; font-size: .95rem; }

@media (max-width: 640px) {
  body { font-size: 14px; }
  .top-inner { gap: .4rem .75rem; }
  nav { order: 3; flex-basis: 100%; }
  .gallery { grid-template-columns: repeat(3, 1fr); }
  .bar-row { grid-template-columns: 7rem 1fr 3.5rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .button, button, nav a { transition: background-color .12s; }
}
