:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --raised: #ffffff;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11, 11, 11, .10);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --rest: #c3c2b7;
  --accent: #2a78d6; --accent-ink: #1c5cab; --accent-wash: #cde2fb;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-ink: #006300; --crit-ink: #b02a2a;
  --mark: #fff1c2;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --raised: #202020;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, .10);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --rest: #4a4945;
    --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: #184f95;
    --good-ink: #0ca30c; --crit-ink: #e66767;
    --mark: #4a3d12;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --raised: #202020;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, .10);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --rest: #4a4945;
  --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: #184f95;
  --good-ink: #0ca30c; --crit-ink: #e66767;
  --mark: #4a3d12;
}

* { box-sizing: border-box; }
html { background: var(--page); }
body { margin: 0; background: var(--page); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent-ink); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.25rem; font-weight: 650; }
h2 { font-size: 1rem; font-weight: 600; }
.muted { color: var(--muted); }
button, input, select { font: inherit; color: inherit; }

.top { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: 1rem clamp(1rem, 3vw, 2rem) .5rem; max-width: 1280px; margin: 0 auto; }
.brand p { margin: .1rem 0 0; font-size: .85rem; }
.tabs { display: flex; gap: .25rem; margin-left: auto; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: .45rem .8rem; border-radius: 8px;
  color: var(--ink-2); cursor: pointer; font-weight: 500; }
.tabs button:hover { background: var(--border); }
.tabs button[aria-selected="true"] { background: var(--accent-wash); color: var(--ink); }
.ghost { background: none; border: 1px solid var(--border); border-radius: 8px; width: 2.2rem;
  height: 2.2rem; cursor: pointer; color: var(--ink-2); }

.filters { max-width: 1280px; margin: 0 auto; padding: .5rem clamp(1rem, 3vw, 2rem) .75rem;
  position: sticky; top: 0; z-index: 5; background: var(--page); border-bottom: 1px solid var(--border); }
@media (max-width: 820px) { .filters { position: static; } }
.filter-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.filter-row input, .filter-row select, .inline-controls input, .list-head select {
  background: var(--raised); border: 1px solid var(--border); border-radius: 8px;
  padding: .45rem .6rem; min-width: 0; }
.filter-row input { flex: 1 1 16rem; }
.filter-row select { flex: 0 1 auto; max-width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .6rem; }
.chip { border: 1px solid var(--border); background: var(--raised); color: var(--ink-2);
  border-radius: 999px; padding: .2rem .7rem; font-size: .82rem; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent-wash); border-color: var(--accent); color: var(--ink); }
.chip.focus::before { content: "★ "; color: var(--accent); }
.chip.clear { border-style: dashed; }

main { max-width: 1280px; margin: 0 auto; padding: 1rem clamp(1rem, 3vw, 2rem) 4rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: .75rem; margin-bottom: .75rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .9rem 1rem; }
.tile .label { color: var(--ink-2); font-size: .82rem; }
.tile .value { font-size: 1.7rem; font-weight: 650; margin-top: .15rem; }
.tile .sub { color: var(--muted); font-size: .8rem; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 1rem 1.1rem 1.1rem; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card > header { margin-bottom: .75rem; }
.card > header p { margin: .2rem 0 0; font-size: .85rem; }
@media (max-width: 820px) { .grid { grid-template-columns: minmax(0, 1fr); } }

.legend { display: flex; flex-wrap: wrap; gap: .9rem; font-size: .82rem; color: var(--ink-2); margin-bottom: .6rem; }
.legend span::before { content: ""; display: inline-block; width: .7rem; height: .7rem; border-radius: 3px;
  background: var(--c); margin-right: .35rem; vertical-align: -1px; }

/* Horizontal bars: label | track | value */
.hbars { display: grid; grid-template-columns: minmax(6rem, 13rem) minmax(0, 1fr) auto; gap: .3rem .75rem;
  align-items: center; font-size: .85rem; }
.hbars .lbl { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbars .lbl.em { color: var(--ink); font-weight: 550; }
.hbars .lbl small { color: var(--muted); }
.hbars .val { color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; min-width: 2.5rem; }
.track { display: flex; gap: 2px; height: 14px; }
.seg { height: 100%; background: var(--c, var(--s1)); min-width: 2px; }
.seg:last-child { border-radius: 0 4px 4px 0; }
.seg:hover, .col:hover { filter: brightness(1.12); }
.hbars .empty, .columns .empty { grid-column: 1 / -1; color: var(--muted); padding: .5rem 0; }
.hbars.scroll { max-height: 34rem; overflow-y: auto; padding-right: .25rem; }

/* Vertical columns (histogram) */
.columns { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; align-items: end;
  height: 13rem; border-bottom: 1px solid var(--axis); padding-top: 1.2rem; }
.col-wrap { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; }
.col { background: var(--s1); border-radius: 4px 4px 0 0; min-height: 2px; }
.col-val { font-size: .75rem; color: var(--ink-2); text-align: center; font-variant-numeric: tabular-nums; }
.col-axis { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; font-size: .72rem;
  color: var(--muted); text-align: center; margin-top: .3rem; }

/* Line chart */
.linechart { position: relative; }
.linechart svg { display: block; width: 100%; height: auto; overflow: visible; }
.linechart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.linechart .gridline { stroke: var(--grid); stroke-width: 1; }
.linechart .baseline { stroke: var(--axis); stroke-width: 1; }
.linechart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.linechart .cross { stroke: var(--axis); stroke-width: 1; }

.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--raised); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; padding: .45rem .6rem; font-size: .8rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .14); max-width: 18rem; }
.tooltip .t { font-weight: 600; margin-bottom: .15rem; }
.tooltip .r { display: flex; gap: .6rem; justify-content: space-between; color: var(--ink-2); }
.tooltip .r b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.tooltip .sw { display: inline-block; width: .6rem; height: .6rem; border-radius: 2px; background: var(--c); margin-right: .3rem; }

table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th { text-align: left; color: var(--ink-2); font-weight: 550; border-bottom: 1px solid var(--axis); padding: .35rem .5rem; }
td { border-bottom: 1px solid var(--grid); padding: .35rem .5rem; vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-view { margin-top: .75rem; font-size: .85rem; }
.table-view summary { color: var(--muted); cursor: pointer; }
.table-view > div { max-height: 20rem; overflow: auto; margin-top: .4rem; }

/* Listings */
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .5rem; }
.listings { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.item { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .85rem 1rem; }
.item h3 { font-size: .98rem; font-weight: 600; overflow-wrap: anywhere; }
.item h3 a { color: var(--ink); text-decoration: none; }
.item h3 a:hover { text-decoration: underline; }
.meta { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .8rem; color: var(--ink-2); margin: .3rem 0; }
.meta .src { font-weight: 600; color: var(--ink); }
.meta .money { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.desc { color: var(--ink-2); font-size: .86rem; margin: .35rem 0 0; white-space: pre-line; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.desc.open { -webkit-line-clamp: unset; display: block; }
.tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.tag { font-size: .74rem; padding: .05rem .5rem; border-radius: 999px; background: var(--border); color: var(--ink-2); }
.tag.focus { background: var(--accent-wash); color: var(--ink); }
.secondary { display: block; margin: 1rem auto; background: var(--raised); border: 1px solid var(--border);
  border-radius: 8px; padding: .5rem 1.2rem; cursor: pointer; }
.secondary:disabled { opacity: .5; cursor: default; }

/* Categories */
.inline-controls { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: .75rem; font-size: .85rem; color: var(--ink-2); }
.inline-controls input[type="search"] { flex: 0 1 18rem; }
.tree details { border-top: 1px solid var(--grid); padding: .45rem 0; }
.tree summary { cursor: pointer; }
.tree summary .n { color: var(--muted); font-size: .8rem; margin-left: .35rem; }
.tree .subs { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: .6rem 1.25rem; padding: .5rem 0 .4rem 1.1rem; }
.tree .sub h3 { font-size: .86rem; font-weight: 600; }
.tree .sub h3 a { color: var(--ink); text-decoration: none; }
.tree .sub h3 a:hover { text-decoration: underline; }
.tree .sub ul { list-style: none; margin: .2rem 0 0; padding: 0; font-size: .8rem; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: .1rem .6rem; }
.tree .sub ul a { color: inherit; text-decoration: none; }
.tree .sub ul a:hover { text-decoration: underline; }
.hit { background: var(--mark); border-radius: 3px; padding: 0 .15rem; color: var(--ink); }

/* Sources */
.sources { display: grid; gap: 0; }
.srow { display: grid; grid-template-columns: minmax(10rem, 1.2fr) 7.5rem minmax(9rem, 1fr) 11rem minmax(12rem, 1.2fr) auto;
  gap: .4rem 1rem; align-items: center; padding: .7rem 0; border-top: 1px solid var(--grid); font-size: .85rem; }
.srow.head { color: var(--ink-2); font-weight: 550; border-top: 0; border-bottom: 1px solid var(--axis); padding: .3rem 0; }
.srow .notes { grid-column: 1 / -1; color: var(--muted); font-size: .8rem; margin-top: -.15rem; }
.srow .name a { color: var(--ink); font-weight: 600; text-decoration: none; }
.srow .name a:hover { text-decoration: underline; }
.srow .kind { color: var(--muted); font-size: .78rem; display: block; }
.status { display: inline-flex; align-items: center; gap: .3rem; font-weight: 550; }
.status .ic { display: inline-grid; place-items: center; width: 1.05rem; height: 1.05rem; border-radius: 50%;
  color: #fff; font-size: .68rem; font-weight: 700; background: var(--c); }
.status.ok { --c: var(--good); color: var(--good-ink); }
.status.blocked { --c: var(--serious); color: var(--ink); }
.status.error { --c: var(--critical); color: var(--crit-ink); }
.status.pending { --c: var(--muted); color: var(--ink-2); }
.hist { display: flex; gap: 2px; }
.hist i { width: 6px; height: 16px; border-radius: 2px; background: var(--c); }
.hist i.ok { --c: var(--good); } .hist i.blocked { --c: var(--serious); } .hist i.error { --c: var(--critical); }
.srow .msg { color: var(--ink-2); overflow-wrap: anywhere; }
.srow button { background: var(--raised); border: 1px solid var(--border); border-radius: 8px; padding: .3rem .7rem; cursor: pointer; font-size: .8rem; }
@media (max-width: 900px) {
  .srow { grid-template-columns: 1fr 1fr; }
  .srow.head { display: none; }
}
.loading { opacity: .55; transition: opacity .2s; }
.meta .place { color: var(--ink); font-weight: 600; }
