/* SafeGuard — light/dark tokens.
   Dark is a selected set of steps for the dark surface, not an inverted flip. */

:root {
  color-scheme: light;

  --page: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --surface-3: #f0f2f5;
  --sidenav-bg: #fbfcfd;
  --border: #dfe3e8;
  --border-strong: #c9cfd6;

  --text: #10131a;
  --text-secondary: #4a5261;
  --text-muted: #78808f;

  --accent: #2a78d6;
  --accent-hover: #1f66bc;
  --accent-soft: #eaf2fd;
  --accent-border: #bcd7f6;
  --accent-ink: #1a5199;

  --good-ink: #006300;
  --good-soft: #e9f6e9;
  --good-border: #bfe3bf;
  --critical-ink: #a82a2a;
  --critical-soft: #fdeceb;
  --critical-border: #f3c4c1;
  --warn-ink: #8a5a00;
  --warn-soft: #fdf3e0;
  --warn-border: #f0d9ab;
  --violet-ink: #4a3aa7;
  --violet-soft: #eeecfa;
  --violet-border: #cfc9ee;

  --chart-series: #2a78d6;
  --chart-grid: #e8eaee;
  --chart-axis: #cdd2d9;
  --chart-text: #78808f;
  --chart-surface: #ffffff;

  --code-bg: #f7f8fa;
  --shadow-sm: 0 1px 2px rgba(16, 19, 26, 0.05);
  --shadow-lg: 0 12px 32px rgba(16, 19, 26, 0.16);

  --radius: 3px;
  --radius-sm: 2px;
  --sidenav-w: 226px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;

    --page: #0d0f13;
    --surface: #16181d;
    --surface-2: #1b1e24;
    --surface-3: #21242b;
    --sidenav-bg: #121419;
    --border: #2a2e37;
    --border-strong: #3a3f4a;

    --text: #ffffff;
    --text-secondary: #b9c0cc;
    --text-muted: #868e9c;

    --accent: #3987e5;
    --accent-hover: #5598e7;
    --accent-soft: #172740;
    --accent-border: #2c4b75;
    --accent-ink: #8fbcf0;

    --good-ink: #4cc44c;
    --good-soft: #12240f;
    --good-border: #24471f;
    --critical-ink: #ef7a78;
    --critical-soft: #2a1414;
    --critical-border: #532626;
    --warn-ink: #e8b355;
    --warn-soft: #291f0e;
    --warn-border: #4d3a18;
    --violet-ink: #9085e9;
    --violet-soft: #1c1a33;
    --violet-border: #34305c;

    --chart-series: #3987e5;
    --chart-grid: #262a32;
    --chart-axis: #363b45;
    --chart-text: #868e9c;
    --chart-surface: #16181d;

    --code-bg: #12141a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --page: #0d0f13;
  --surface: #16181d;
  --surface-2: #1b1e24;
  --surface-3: #21242b;
  --sidenav-bg: #121419;
  --border: #2a2e37;
  --border-strong: #3a3f4a;

  --text: #ffffff;
  --text-secondary: #b9c0cc;
  --text-muted: #868e9c;

  --accent: #3987e5;
  --accent-hover: #5598e7;
  --accent-soft: #172740;
  --accent-border: #2c4b75;
  --accent-ink: #8fbcf0;

  --good-ink: #4cc44c;
  --good-soft: #12240f;
  --good-border: #24471f;
  --critical-ink: #ef7a78;
  --critical-soft: #2a1414;
  --critical-border: #532626;
  --warn-ink: #e8b355;
  --warn-soft: #291f0e;
  --warn-border: #4d3a18;
  --violet-ink: #9085e9;
  --violet-soft: #1c1a33;
  --violet-border: #34305c;

  --chart-series: #3987e5;
  --chart-grid: #262a32;
  --chart-axis: #363b45;
  --chart-text: #868e9c;
  --chart-surface: #16181d;

  --code-bg: #12141a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-shell { display: flex; min-height: 100vh; }

/* ------------------------------------------------------------- side nav */

.sidenav {
  width: var(--sidenav-w);
  flex-shrink: 0;
  background: var(--sidenav-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 20px;
}

.brand-mark { width: 30px; height: 30px; flex-shrink: 0; }
.brand-text { min-width: 0; }
.brand-name {
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.brand-tag {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 1px;
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 10px 6px;
}
.nav-label-li { list-style: none; padding-top: 14px; }

.nav-list { list-style: none; margin: 0; padding: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 500;
  user-select: none;
  border-left: 2px solid transparent;
  margin-bottom: 1px;
}
.nav-item { transition: background .12s ease, color .12s ease, border-color .12s ease; }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-left-color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  width: 16px; height: 16px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}

.sidenav-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.sidenav-footer:empty { border-top: 0; padding-top: 0; }
.sidenav-footer .btn { width: 100%; justify-content: center; }

/* ----------------------------------------------------------------- main */

.main { flex: 1; min-width: 0; padding: 24px 30px 48px; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.page-title { font-size: 19px; font-weight: 650; margin: 0; letter-spacing: -0.015em; }
.page-subtitle { color: var(--text-muted); margin: 3px 0 0; font-size: 12.5px; }
.header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 6px 11px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn { transition: background .12s ease, border-color .12s ease, box-shadow .12s ease; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--critical-ink); border-color: var(--border); }
.btn-danger:hover { background: var(--critical-soft); border-color: var(--critical-border); }
.btn-sm { padding: 4px 8px; font-size: 11.5px; }
.btn-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
}
/* Only stack cards that sit directly in the page flow — cards inside a grid
   get their spacing from the grid gap. */
.main > .card + .card { margin-top: 14px; }
.card-flush { padding: 0; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-title { font-size: 13px; font-weight: 650; margin: 0; letter-spacing: -0.005em; }
.card-note { font-size: 11.5px; color: var(--text-muted); margin: 3px 0 0; font-weight: 400; }

/* ------------------------------------------------------------ stat tiles */

/* Six tiles: an auto-fit track strands the last one on its own row at common
   widths, so the column count is stepped explicitly to keep rows balanced. */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
@media (max-width: 1600px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 820px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-label {
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.stat-value { font-size: 27px; font-weight: 650; margin-top: 5px; letter-spacing: -0.02em; line-height: 1.1; }
.stat-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

/* ---------------------------------------------------------------- charts */

.chart-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 1080px) { .chart-grid { grid-template-columns: 1fr; } }

.split-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; align-items: start; }
@media (max-width: 1080px) { .split-grid { grid-template-columns: 1fr; } }
.split-grid + .card { margin-top: 14px; }

.chart-box { position: relative; height: 268px; }
.chart-box canvas { width: 100% !important; height: 100% !important; }

.seg {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
}
.seg button {
  border: 0;
  background: var(--surface);
  color: var(--text-secondary);
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 9px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s ease; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-actions { text-align: right; white-space: nowrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1.5px 7px;
  border-radius: var(--radius-sm);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}
.badge-user { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-border); }
.badge-agent { background: var(--violet-soft); color: var(--violet-ink); border-color: var(--violet-border); }
.badge-active { background: var(--good-soft); color: var(--good-ink); border-color: var(--good-border); }
.badge-revoked { background: var(--critical-soft); color: var(--critical-ink); border-color: var(--critical-border); }
.badge-pattern { background: var(--warn-soft); color: var(--warn-ink); border-color: var(--warn-border); }
.badge-wordbag { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-border); }
.badge-neutral { background: var(--surface-3); color: var(--text-secondary); border-color: var(--border); }

.mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px;
}

.switch { display: inline-flex; align-items: center; cursor: pointer; }
.switch input { margin: 0; accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ----------------------------------------------------------------- forms */

.field { margin-bottom: 13px; }
.field label {
  display: block;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--text-secondary);
  margin-bottom: 5px;
}
.field-hint { font-size: 11.5px; color: var(--text-muted); margin: 5px 0 0; }
input[type="text"], input[type="password"], select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 12.5px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 160px; }
.form-card { max-width: 680px; }
.inline-row { display: flex; gap: 8px; align-items: center; }
.inline-row > :first-child { flex: 1; }

/* ---------------------------------------------------------------- modals */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(9, 11, 15, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 20px 22px;
  width: 440px;
  max-width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal h3 { margin: 0 0 16px; font-size: 15px; font-weight: 650; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ misc */

/* ------------------------------------------------------------------ login */

.login-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8vh;
}
.login-card { width: 380px; max-width: 100%; padding: 24px; }
.login-brand { display: flex; align-items: center; gap: 11px; }

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 16px;
  font-size: 12.5px;
}
.empty-chart {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text-muted); font-size: 12.5px;
}

.code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  margin: 0;
  color: var(--text-secondary);
}
.token-box {
  background: var(--code-bg);
  border: 1px solid var(--accent-border);
  color: var(--accent-ink);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  word-break: break-all;
  margin: 8px 0 0;
  line-height: 1.55;
}

.callout {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  padding: 11px 13px;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.callout-warn { background: var(--warn-soft); border-color: var(--warn-border); }

/* ---------------------------------------------------------- api explorer */

.flow {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-wrap: wrap;
  margin-top: 4px;
}
.flow-step {
  flex: 1;
  min-width: 150px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius);
  margin-right: 22px;
  position: relative;
}
.flow-step:last-child { margin-right: 0; }
.flow-step::after {
  content: "→";
  position: absolute;
  right: -16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
}
.flow-step:last-child::after { content: none; }
.flow-n {
  font-size: 10px; font-weight: 700; letter-spacing: 0.07em;
  color: var(--accent-ink); text-transform: uppercase;
}
.flow-t { font-weight: 650; font-size: 12.5px; margin-top: 3px; }
.flow-d { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; line-height: 1.45; }

.ep { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 8px; }
.ep-head {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; cursor: pointer; user-select: none;
}
.ep-head:hover { background: var(--surface-2); }
.ep.open .ep-head { border-bottom: 1px solid var(--border); background: var(--surface-2); }
.ep-body { display: none; padding: 14px; }
.ep.open .ep-body { display: block; }

.ep-chevron {
  width: 14px; height: 14px; flex-shrink: 0;
  fill: none; stroke: var(--text-muted); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  transition: transform 0.12s ease;
}
.ep.open .ep-chevron { transform: rotate(90deg); }

.method {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10.5px; font-weight: 700;
  padding: 2.5px 7px; border-radius: var(--radius-sm);
  border: 1px solid transparent; min-width: 46px; text-align: center;
}
.method-GET { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-border); }
.method-POST { background: var(--good-soft); color: var(--good-ink); border-color: var(--good-border); }
.method-PUT { background: var(--warn-soft); color: var(--warn-ink); border-color: var(--warn-border); }
.method-DELETE { background: var(--critical-soft); color: var(--critical-ink); border-color: var(--critical-border); }

.ep-path { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; font-weight: 600; }
.ep-summary {
  color: var(--text-muted); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.ep-lock { font-size: 10.5px; color: var(--text-muted); white-space: nowrap; }

.resp-head { display: flex; align-items: center; gap: 10px; margin: 14px 0 8px; }
.status-pill {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--radius-sm); border: 1px solid transparent;
}
.status-ok { background: var(--good-soft); color: var(--good-ink); border-color: var(--good-border); }
.status-err { background: var(--critical-soft); color: var(--critical-ink); border-color: var(--critical-border); }
.resp-time { font-size: 11.5px; color: var(--text-muted); }

.subhead {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-muted); margin: 0 0 6px;
}

.trace { display: grid; gap: 8px; margin-bottom: 12px; }
.trace-row {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 11px; background: var(--surface-2);
}
.trace-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px;
}
.trace-text {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px; line-height: 1.6; word-break: break-word;
}
/* PII highlight: the text keeps its ink token; the tint and rule carry the
   entity identity, and the legend names it so colour is never the only cue. */
mark.pii {
  background: transparent;
  color: inherit;
  border-bottom: 2px solid currentColor;
  border-radius: var(--radius-sm);
  padding: 0 2px;
  cursor: help;
}

.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.legend-item {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--text-secondary);
}
.legend-swatch { width: 10px; height: 10px; border-radius: var(--radius-sm); flex-shrink: 0; }

/* Log levels */
.badge-ERROR { background: var(--critical-soft); color: var(--critical-ink); border-color: var(--critical-border); }
.badge-WARN { background: var(--warn-soft); color: var(--warn-ink); border-color: var(--warn-border); }
.badge-INFO { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-border); }
.badge-DEBUG { background: var(--violet-soft); color: var(--violet-ink); border-color: var(--violet-border); }
.badge-TRACE { background: var(--surface-3); color: var(--text-secondary); border-color: var(--border-strong); }

.detail-row td { background: var(--surface-2); padding: 0; }
.detail-inner { padding: 12px 14px; display: grid; gap: 8px; }
.expander {
  background: none; border: 0; cursor: pointer; padding: 0;
  color: var(--accent-ink); font-size: 11.5px; font-weight: 650; font-family: inherit;
}
/* Gateway posture rows */
.posture { display: grid; gap: 2px; }
.posture-row {
  display: grid;
  grid-template-columns: 128px auto;
  gap: 4px 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.posture-row + .posture-row { margin-top: 6px; }
.posture-warn { border-color: var(--warn-border); background: var(--warn-soft); }
.posture-label { font-size: 12px; font-weight: 650; color: var(--text-secondary); }
.posture-note {
  grid-column: 1 / -1;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.level-help { display: grid; gap: 6px; margin: 10px 0 0; }
.level-help-row { display: flex; gap: 10px; align-items: baseline; font-size: 12px; color: var(--text-secondary); }
.level-help-row .badge { flex-shrink: 0; }

/* ------------------------------------------------- polish & accessibility */

/* A visible keyboard focus ring everywhere, without showing it on mouse use. */
:where(a, button, input, select, textarea, .nav-item):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus { outline: none; }

.card { transition: box-shadow 0.14s ease, border-color 0.14s ease; }

/* Interactive cards lift slightly; static ones stay put. */
.ep:hover { border-color: var(--border-strong); }

.seg button { transition: background 0.12s ease, color 0.12s ease; }
.expander:hover { text-decoration: underline; }

/* Stacked part-to-whole bar */
.stack-track {
  display: flex;
  height: 26px;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-3);
  gap: 2px; /* surface gap between segments rather than borders */
}
.stack-seg {
  height: 100%;
  min-width: 3px;
  transition: opacity 0.12s ease;
}
.stack-seg:hover { opacity: 0.82; }
.stacked-bar .legend-item { gap: 6px; }

/* Donut legend sits to the right, so give the box a little more room */
#donut-box { height: 236px; }

/* Restrained scrollbars so wide tables don't shout */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { height: 9px; width: 9px; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
