/*
  Praxas Observability — styles.

  Dense ops-dashboard look: system sans, tabular figures in tables and axes only, hairline
  borders, quiet chrome so the data is the loudest thing. Colours are tokens on :root with a dark
  set chosen (not flipped) for the dark surface; the OS setting applies unless the manual toggle
  sets <html data-theme>. Chart series tokens --s1..--s7 are a validated categorical palette
  (adjacent CVD ΔE ≥ 8 in both modes); status tokens are reserved for state and always ship with
  a text label.
*/

/* ---------------------------------------------------------------- tokens */
:root {
  color-scheme: light;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --page: #f3f3f0;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --surface-3: #e7e6e1;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6d6b66;
  --border: #dcdbd4;
  --hairline: rgba(11, 11, 11, 0.1);
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #1c5cab;
  --accent-ink: #ffffff;
  --accent-soft: #cde2fb;
  --focus: #2a78d6;
  --row-hover: #f0f4fa;
  --row-error: #fcebea;
  --row-warn: #fff6e0;
  --backdrop: rgba(10, 10, 10, 0.35);

  /* categorical series (validated light steps) */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --s6: #008300;
  --s7: #6250d6;
  --other: #a8a69e;

  /* status (fixed; always paired with a label) */
  --good: #0ca30c;
  --warn: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-ink: #006300;
  --warn-ink: #8a5a00;
  --serious-ink: #a8431a;
  --critical-ink: #b42318;

  --radius: 8px;
  --gutter: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --surface-3: #2e2e2b;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #9a988f;
    --border: #383835;
    --hairline: rgba(255, 255, 255, 0.1);
    --grid: #2c2c2a;
    --axis: #4a4a46;
    --accent: #5598e7;
    --accent-ink: #0b0b0b;
    --accent-soft: #184f95;
    --focus: #86b6ef;
    --row-hover: #222831;
    --row-error: #3a1715;
    --row-warn: #33280f;
    --backdrop: rgba(0, 0, 0, 0.55);
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --s5: #d55181;
    --s6: #008300;
    --s7: #9085e9;
    --other: #6d6b66;
    --good-ink: #0ca30c;
    --warn-ink: #fab219;
    --serious-ink: #ec835a;
    --critical-ink: #ff8f85;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --surface-3: #2e2e2b;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #9a988f;
  --border: #383835;
  --hairline: rgba(255, 255, 255, 0.1);
  --grid: #2c2c2a;
  --axis: #4a4a46;
  --accent: #5598e7;
  --accent-ink: #0b0b0b;
  --accent-soft: #184f95;
  --focus: #86b6ef;
  --row-hover: #222831;
  --row-error: #3a1715;
  --row-warn: #33280f;
  --backdrop: rgba(0, 0, 0, 0.55);
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --s5: #d55181;
  --s6: #008300;
  --s7: #9085e9;
  --other: #6d6b66;
  --good-ink: #0ca30c;
  --warn-ink: #fab219;
  --serious-ink: #ec835a;
  --critical-ink: #ff8f85;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 13px/1.45 var(--font);
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: 12px; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 6px 10px; border-radius: var(--radius); }
.skip-link:focus { left: 8px; }
.noscript { padding: var(--gutter); }

.icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -3px; }
.icon-sm { width: 13px; height: 13px; vertical-align: -2px; }

/* ---------------------------------------------------------------- buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 4px 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink); white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-small { min-height: 28px; padding: 2px 10px; font-size: 12px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border: 1px solid transparent; border-radius: 6px; background: transparent; cursor: pointer; color: var(--ink-2); font-size: 18px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }
input, select, textarea {
  min-height: 30px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); max-width: 100%;
}
input[type="checkbox"] { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent); }
label { color: var(--ink-2); font-size: 12px; }

/* ---------------------------------------------------------------- shell */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 8px var(--gutter);
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; color: var(--ink); white-space: nowrap; font-size: 14px; }
.brand:hover { text-decoration: none; }
.search { position: relative; flex: 1 1 320px; max-width: 520px; min-width: 0; }
.search input { width: 100%; }
.search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: 60vh; overflow: auto;
}
.search-list { list-style: none; margin: 0; padding: 0; }
.search-list a { display: block; padding: 6px 8px; border-radius: 6px; color: var(--ink); overflow-wrap: anywhere; }
.search-list a:hover, .search-list a:focus { background: var(--row-hover); text-decoration: none; }
.top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.user-name { color: var(--muted); font-size: 12px; white-space: nowrap; }

.nav {
  display: flex; gap: 2px; padding: 0 var(--gutter); background: var(--surface);
  border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin;
}
.nav a {
  padding: 8px 10px; color: var(--ink-2); white-space: nowrap; border-bottom: 2px solid transparent; font-weight: 500;
}
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

.filterbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px var(--gutter);
  border-bottom: 1px solid var(--border); background: var(--page);
}
.seg-ctl { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface); }
.seg-btn { border: 0; background: transparent; padding: 4px 10px; min-height: 28px; cursor: pointer; color: var(--ink-2); font-size: 12px; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.custom-range { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.check { display: inline-flex; align-items: center; gap: 6px; }
.check label { color: var(--ink); font-size: 12px; }
#project-filter, #service-filter { min-width: 0; max-width: 180px; }

.main { flex: 1; padding: var(--gutter); min-width: 0; outline: none; }
.main.is-refreshing > * { opacity: 0.6; transition: opacity 0.15s; }
.view-body { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.view-body > p { margin: 0; }
.view-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.view-title { font-size: 18px; font-weight: 650; outline: none; }
.crumbs { margin: 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; min-width: 0; display: flex; flex-direction: column; gap: 8px;
}
.card-title { font-size: 13px; font-weight: 650; color: var(--ink); }
.sub-title { font-size: 12px; font-weight: 650; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.03em; margin-top: 6px; }
.grid { display: grid; gap: 12px; min-width: 0; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }

.subtabs { display: flex; flex-wrap: wrap; gap: 4px; }
.subtabs a { padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; color: var(--ink-2); background: var(--surface); font-size: 12px; }
.subtabs a.is-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.subtabs a:hover { text-decoration: none; }

/* ---------------------------------------------------------------- states */
.state { display: flex; align-items: center; gap: 8px; padding: 16px; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface); }
.state-error { color: var(--critical-ink); border-style: solid; border-color: var(--critical); }
.empty { color: var(--muted); }
.spinner { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.form-error { color: var(--critical-ink); margin: 0; }

/* ---------------------------------------------------------------- tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tile {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--ink);
}
a.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile-label { font-size: 12px; color: var(--ink-2); }
.tile-value { font-size: 20px; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.tile-sub { font-size: 11px; color: var(--muted); }
.tile-tone, .badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; }
.tone-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--other); flex: none; }
.tone-good { color: var(--good-ink); } .tone-good .tone-dot { background: var(--good); }
.tone-warn { color: var(--warn-ink); } .tone-warn .tone-dot { background: var(--warn); }
.tone-bad { color: var(--critical-ink); } .tone-bad .tone-dot { background: var(--critical); }
.spark { margin-top: 4px; overflow: visible; }
.spark-line { fill: none; stroke: var(--other); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark-dot { fill: var(--s1); }

/* ---------------------------------------------------------------- badges & chips */
.badge { padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge-good { color: var(--good-ink); } .badge-good .tone-dot { background: var(--good); }
.badge-warn { color: var(--warn-ink); } .badge-warn .tone-dot { background: var(--warn); }
.badge-serious { color: var(--serious-ink); } .badge-serious .tone-dot { background: var(--serious); }
.badge-bad { color: var(--critical-ink); } .badge-bad .tone-dot { background: var(--critical); }
.badge-muted .tone-dot { background: var(--other); }
.chip { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--hairline); color: var(--ink-2); font-size: 11px; white-space: nowrap; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 3px; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 5px 8px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; white-space: nowrap; }
table.data tr.row-detail > td { white-space: normal; }
table.data thead th { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
table.data tbody tr:hover { background: var(--row-hover); }
table.data .num { text-align: right; white-space: nowrap; }
table.data tr.row-error { background: var(--row-error); }
table.data tr.row-warn { background: var(--row-warn); }
table.data tr.row-detail > td { background: var(--surface-2); }
table.dense th, table.dense td { padding: 3px 6px; font-size: 12px; }
.col-toggle { width: 36px; }
.clip { display: inline-block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.clip-wide { max-width: 560px; }
.id-list { display: inline-flex; flex-wrap: wrap; gap: 2px 8px; }
.id-pair { display: inline-flex; gap: 4px; align-items: baseline; white-space: nowrap; }
.id-key { color: var(--muted); font-size: 11px; }
table.kv { width: 100%; border-collapse: collapse; }
table.kv th, table.kv td { padding: 3px 6px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; }
table.kv th { font-weight: 500; color: var(--ink-2); width: 40%; overflow-wrap: anywhere; }
table.kv td { overflow-wrap: anywhere; }
.pre {
  margin: 0; padding: 8px; background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 6px;
  white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.45 var(--mono); max-height: 360px; overflow: auto;
}
.pre-error { border-color: var(--critical); }
.paged { display: flex; flex-direction: column; gap: 6px; }
.paged-foot { display: flex; align-items: center; gap: 10px; }
.paged-foot p { margin: 0; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: 12px; }
dl.facts dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
dl.facts-inline { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; }
dl.facts-inline dd { margin-right: 12px; }
ul.plain { list-style: none; margin: 0; padding: 0; }

/* ---------------------------------------------------------------- filter forms */
.filters { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-end; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.field { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 0 1 150px; }
.field input, .field select { width: 100%; }
.field-wide { flex: 1 1 260px; }
.field-check { flex-direction: row; align-items: center; gap: 6px; flex: 0 0 auto; min-height: 30px; }
.field-check input { width: 16px; }
.field-actions { flex-direction: row; gap: 6px; flex: 0 0 auto; }
fieldset.checks { border: 0; padding: 0; margin: 0; display: flex; flex-flow: row wrap; gap: 4px 12px; }
fieldset.checks legend { font-size: 12px; color: var(--ink-2); padding: 0; margin-bottom: 2px; width: 100%; }

/* ---------------------------------------------------------------- charts */
.chart { margin: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.chart-title { font-size: 13px; font-weight: 650; }
.chart-plot { width: 100%; min-width: 0; }
.chart-canvas { position: relative; }
.chart-svg { display: block; overflow: visible; }
.chart-empty { padding: 28px 8px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 6px; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--axis); stroke-width: 1; }
.tick { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.tick-y { text-anchor: end; }
.tick-x { text-anchor: middle; }
.series .line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series .area { fill: var(--c); opacity: 0.1; stroke: none; }
.series .end-dot, .hover-dot { fill: var(--c); stroke: var(--surface); stroke-width: 2; }
.crosshair { stroke: var(--axis); stroke-width: 1; pointer-events: none; }
.hit { fill: transparent; }
.chart-svg:focus-visible { outline-offset: 4px; }
.chart-tip {
  position: absolute; top: 4px; z-index: 5; pointer-events: none; min-width: 140px; max-width: 260px;
  padding: 6px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); font-size: 12px;
}
.tip-time { color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-row strong { font-variant-numeric: tabular-nums; }
.tip-name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; flex: none; background: var(--c); }
.key-line { width: 14px; height: 2px; border-radius: 1px; }
.key-rect { width: 10px; height: 10px; border-radius: 2px; }
.col .bar { fill: var(--s1); }
.col:hover .bar, .col:focus .bar { fill: var(--accent); }
.col:focus { outline: none; }
.col:focus .hit { fill: var(--row-hover); }
.chart-table summary { cursor: pointer; color: var(--muted); font-size: 12px; width: max-content; }
.chart-table[open] summary { margin-bottom: 4px; }
.chart-table .table-wrap { max-height: 240px; overflow: auto; }

.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 34%) 1fr; gap: 8px; align-items: center; min-width: 0; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.bar-track { position: relative; display: flex; align-items: center; gap: 6px; min-width: 0; height: 18px; }
.bar-fill { height: 14px; background: var(--s1); border-radius: 0 4px 4px 0; min-width: 2px; flex: none; }
.bar-value { font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }

.meter { display: flex; flex-direction: column; gap: 6px; }
.meter-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.meter-label { color: var(--ink-2); }
.meter-text { font-weight: 600; }
.meter-track { height: 10px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.meter-warn .meter-track { background: color-mix(in srgb, var(--warn) 25%, var(--surface)); }
.meter-warn .meter-fill { background: var(--warn); }
.meter-critical .meter-track { background: color-mix(in srgb, var(--critical) 25%, var(--surface)); }
.meter-critical .meter-fill { background: var(--critical); }
.meter p { margin: 0; }

.segbar-wrap { display: flex; flex-direction: column; gap: 6px; }
.segbar { display: flex; gap: 2px; height: 8px; border-radius: 999px; overflow: hidden; background: transparent; }
.segbar .seg { display: block; background: var(--c); flex: 0 1 0; min-width: 2px; }
.segbar .seg:first-child { border-radius: 999px 0 0 999px; }
.segbar .seg:last-child { border-radius: 0 999px 999px 0; }
.segbar .seg:only-child { border-radius: 999px; }
.segbar-dense { height: 6px; min-width: 120px; }
.col-seg { width: 30%; min-width: 120px; }

/* ---------------------------------------------------------------- overview health */
.health-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.health { border: 1px solid var(--border); border-left: 3px solid var(--other); border-radius: 6px; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.health-up { border-left-color: var(--good); }
.health-stale { border-left-color: var(--warn); }
.health-down { border-left-color: var(--critical); }
.health-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.health-name { font-weight: 600; overflow-wrap: anywhere; }
.health-stats { display: flex; flex-wrap: wrap; gap: 2px 10px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- waterfall */
.waterfall { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.wf-head, .wf-row { display: grid; grid-template-columns: minmax(180px, 38%) 1fr; align-items: center; min-width: 0; }
.wf-head { border-bottom: 1px solid var(--axis); padding-bottom: 2px; font-size: 11px; color: var(--muted); }
.wf-axis { position: relative; height: 16px; }
.wf-tick { position: absolute; transform: translateX(-50%); white-space: nowrap; font-variant-numeric: tabular-nums; }
.wf-tick:first-child { transform: none; }
.wf-rows { display: flex; flex-direction: column; }
.wf-row { border-bottom: 1px solid var(--grid); min-height: 30px; }
.wf-row:hover { background: var(--row-hover); }
.wf-row.is-selected { background: var(--row-hover); box-shadow: inset 3px 0 0 var(--accent); }
.wf-row.is-error .wf-name-text { color: var(--critical-ink); }
.wf-name-col { display: flex; align-items: center; gap: 2px; min-width: 0; padding-right: 8px; }
.wf-toggle { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--ink-2); cursor: pointer; flex: none; }
.wf-toggle:hover { background: var(--surface-3); }
.wf-toggle-spacer { width: 22px; flex: none; }
.wf-select { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; flex: 1; padding: 3px 4px; border: 0; background: transparent; text-align: left; cursor: pointer; border-radius: 4px; }
.wf-name { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
.wf-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.wf-meta { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.wf-err { display: inline-flex; align-items: center; gap: 2px; color: var(--critical-ink); font-size: 11px; font-weight: 600; flex: none; }
.wf-time-col { position: relative; height: 30px; }
.wf-bar { position: absolute; top: 9px; height: 12px; background: var(--c); border-radius: 3px; }
.wf-dur.wf-dur-in { top: 9px; padding: 0 3px; line-height: 12px; font-size: 10.5px; background: var(--surface); border-radius: 2px; }
.wf-dur { position: absolute; top: 7px; padding: 0 4px; font-size: 11px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge-muted { background: var(--surface-2); }

/* ---------------------------------------------------------------- lineage */
.lineage-scroll { overflow: auto; max-width: 100%; border: 1px solid var(--hairline); border-radius: 6px; background: var(--surface); }
.lineage-svg { display: block; }
.lin-edge { fill: none; stroke: var(--axis); stroke-width: 1.5; }
.lin-box { fill: var(--surface-2); stroke: var(--border); stroke-width: 1; }
.lin-node:hover .lin-box, .lin-node:focus .lin-box { stroke: var(--accent); stroke-width: 2; }
.lin-node:focus { outline: none; }
.lin-node.is-root .lin-box { stroke: var(--accent); stroke-width: 2; fill: var(--surface); }
.lin-stripe { fill: var(--c); }
.lin-kind { fill: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.lin-id { fill: var(--ink); font: 600 12px var(--mono); }
.lin-attr { fill: var(--ink-2); font-size: 11px; }

/* ---------------------------------------------------------------- timelines */
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--grid); display: flex; flex-direction: column; gap: 10px; }
.timeline > li { position: relative; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.timeline > li::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--axis); }
.turn-error::before, .turn-timeout::before { border-color: var(--critical) !important; }
.turn-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.turn-n { font-weight: 650; }
.tools, .llm-usage, .event-list, .log-mini { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.tool { border: 1px solid var(--grid); border-radius: 6px; padding: 6px 8px; min-width: 0; }
.tool-error, .tool-denied { border-color: var(--critical); }
.tool-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.tool details summary, .log-mini details summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.event-list > li, .log-mini > li { border-bottom: 1px solid var(--grid); padding-bottom: 6px; display: flex; flex-direction: column; gap: 4px; }

/* ---------------------------------------------------------------- drawer */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(560px, 100vw);
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
  display: flex; flex-direction: column;
}
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 10px var(--gutter); border-bottom: 1px solid var(--border); }
.drawer-title { font-size: 14px; flex: 1; overflow-wrap: anywhere; }
.drawer-body { flex: 1; overflow: auto; padding: 12px var(--gutter) 24px; }

/* ---------------------------------------------------------------- login & toasts */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--gutter); }
.login-card { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.login .brand { margin: 0; }
.login-title { font-size: 20px; }
.stack { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.login .field { flex: none; }
.toasts { position: fixed; bottom: 16px; right: 16px; z-index: 50; display: flex; flex-direction: column; gap: 6px; max-width: calc(100vw - 32px); }
.toast { padding: 8px 12px; border-radius: 6px; background: var(--ink); color: var(--surface); box-shadow: var(--shadow); font-size: 12px; }
.toast-bad { background: var(--critical); color: #fff; }

.switch { cursor: pointer; }

/* ---------------------------------------------------------------- data loads */
.explainer { align-items: flex-start; }
.explainer .stack { gap: 6px; }
.stack-tight { display: flex; flex-direction: column; gap: 4px; }
.plan-mini { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; }
.cov-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.cov-filter { display: inline-flex; align-items: center; gap: 8px; }
.cov-filter input { width: 180px; }
.sort-btn { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; white-space: nowrap; }
.sort-btn:hover { color: var(--ink); }
th[aria-sort="ascending"] .sort-btn, th[aria-sort="descending"] .sort-btn { color: var(--ink); }
.col-span { width: 28%; min-width: 140px; }
.span-track { position: relative; display: block; height: 8px; min-width: 120px; border-radius: 999px; background: var(--surface-3); }
.span-fill { position: absolute; top: 0; bottom: 0; min-width: 3px; border-radius: 999px; background: var(--s1); }
.span-fill.is-lagging { background: var(--warn); }
.span-asof { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--ink-2); }

/* ---------------------------------------------------------------- clients (fleet) */
.notice { display: flex; align-items: flex-start; gap: 8px; margin: 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--ink-2); font-size: 13px; }
.notice .icon { flex: none; margin-top: 1px; color: var(--muted); }
.info-btn { width: 24px; height: 24px; color: var(--muted); }
.info-text { flex: 0 0 100%; margin: 0; }
.info-text > span { display: block; max-width: 80ch; }
table.data tr.row-muted td { color: var(--muted); }
.problem { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; }
.fleet-title { min-width: 0; overflow-wrap: anywhere; }
.timeline > li.is-critical::before { border-color: var(--critical); }
.fleet-event details summary { cursor: pointer; font-size: 12px; color: var(--muted); width: max-content; }

/* ---------------------------------------------------------------- phone */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .brand span { font-size: 13px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .user-name { display: none; }
  .filterbar { gap: 6px; }
  #project-filter, #service-filter { flex: 1 1 40%; max-width: none; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-value { font-size: 17px; }
  .field { flex: 1 1 45%; }
  .field-wide { flex-basis: 100%; }
  .wf-head, .wf-row { grid-template-columns: minmax(130px, 46%) 1fr; }
  .bar-row { grid-template-columns: minmax(70px, 38%) 1fr; }
  .clip { max-width: 180px; }
  .clip-wide { max-width: 240px; }
}

@media (forced-colors: active) {
  .wf-bar, .bar-fill, .meter-fill, .segbar .seg, .key, .span-fill { forced-color-adjust: none; }
}
