/* Formal Engines dashboard — one stylesheet, no imports, no external fonts.
 *
 * Tokens follow the workspace data-visualisation palette. Light values are declared on a
 * bare :root; the dark values are declared twice — once under prefers-color-scheme for the
 * OS setting, once under [data-theme="dark"] so the header toggle wins in both directions.
 * No colour is ever defined only inside a media query. */

:root {
  color-scheme: light;

  /* surfaces & ink */
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #f2f1ec;
  --surface-hover: rgba(11, 11, 11, 0.04);
  --surface-active: rgba(42, 120, 214, 0.10);
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);
  --focus: #2a78d6;

  /* categorical series slots — fixed order, never cycled */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  /* status — reserved, never reused as a series colour */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --delta-good: #006300;
  --delta-bad: #d03b3b;

  /* washes for banners; kept low-chroma so the text stays the loud part */
  --wash-good: rgba(12, 163, 12, 0.10);
  --wash-warning: rgba(250, 178, 25, 0.16);
  --wash-critical: rgba(208, 59, 59, 0.10);
  --wash-accent: rgba(42, 120, 214, 0.09);

  --radius: 8px;
  --radius-sm: 5px;
  --sidebar-w: 216px;
  --header-h: 52px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #141413;
    --surface-hover: rgba(255, 255, 255, 0.06);
    --surface-active: rgba(57, 135, 229, 0.16);
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.20);
    --focus: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --delta-good: #0ca30c;
    --delta-bad: #e66767;
    --wash-good: rgba(12, 163, 12, 0.16);
    --wash-warning: rgba(250, 178, 25, 0.14);
    --wash-critical: rgba(208, 59, 59, 0.18);
    --wash-accent: rgba(57, 135, 229, 0.14);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #141413;
  --surface-hover: rgba(255, 255, 255, 0.06);
  --surface-active: rgba(57, 135, 229, 0.16);
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.20);
  --focus: #3987e5;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --delta-good: #0ca30c;
  --delta-bad: #e66767;
  --wash-good: rgba(12, 163, 12, 0.16);
  --wash-warning: rgba(250, 178, 25, 0.14);
  --wash-critical: rgba(208, 59, 59, 0.18);
  --wash-accent: rgba(57, 135, 229, 0.14);
}

/* ---------------------------------------------------------------- base --- */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 400 13px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 15px; }
h2 { font-size: 14px; }
h3 { font-size: 13px; }

a { color: var(--focus); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--surface-1); color: var(--text-primary);
  padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }

.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* -------------------------------------------------------------- layout --- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--header-h) minmax(0, 1fr);
  grid-template-areas: "sidebar header" "sidebar main";
  height: 100dvh;
}

.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 10px 12px;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  min-width: 0;
}

.brand {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px 12px;
  color: var(--text-primary); text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; flex: none; }
.brand-mark rect { fill: var(--series-1); }
.brand-mark path { stroke: #fff; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-size: 12.5px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { font-size: 10.5px; color: var(--text-muted); letter-spacing: 0.04em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12.5px;
  text-decoration: none;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text-primary); text-decoration: none; }
.nav-item[aria-current="page"] {
  background: var(--surface-active);
  color: var(--text-primary);
  font-weight: 550;
}
.nav-icon { width: 15px; height: 15px; flex: none; stroke: currentColor; fill: none; }
.nav-item .nav-icon rect { fill: currentColor; stroke: none; }

.sidebar-foot {
  margin-top: auto;
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px;
  font-size: 10.5px; color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.sidebar-foot-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.header {
  grid-area: header;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px;
  background: var(--page);
  border-bottom: 1px solid var(--border);
}
.header-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.header-sub { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-tools { display: flex; align-items: center; gap: 8px; flex: none; }

/* Read-only demo marker. Stated once in the header rather than repeated as a disabled
   control in every view: the mutating buttons are simply absent, and this says why. */
.ro-chip {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  font-size: 11.5px; line-height: 1.5; white-space: nowrap;
  color: var(--text-muted); background: var(--surface-2);
}
.ro-chip[hidden] { display: none; }

.conn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 9px 4px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11.5px; color: var(--text-secondary);
  cursor: pointer;
}
.conn:hover { background: var(--surface-hover); }
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); flex: none; }
.conn-dot[data-state="ok"] { background: var(--status-good); }
.conn-dot[data-state="warn"] { background: var(--status-warning); }
.conn-dot[data-state="down"] { background: var(--status-critical); }
.conn-dot[data-state="unknown"] { background: var(--text-muted); }

.icon-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
}
.icon-button:hover { background: var(--surface-hover); }
.icon-button svg { width: 15px; height: 15px; stroke: currentColor; fill: none; }

.main { grid-area: main; overflow: auto; padding: 18px 20px 48px; }
.main:focus { outline: none; }
.outlet { display: flex; flex-direction: column; gap: 16px; max-width: 1400px; }

/* --------------------------------------------------------- page header --- */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.page-head h2 { font-size: 16px; }
.page-head-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 12px; color: var(--text-secondary); }
.page-head-actions { display: flex; align-items: center; gap: 8px; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-muted); }
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--text-primary); }

.meta-pair { display: inline-flex; align-items: baseline; gap: 6px; }
.meta-key { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.meta-val { color: var(--text-primary); }

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

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 12.5px; }
.card-head-actions { display: flex; align-items: center; gap: 6px; }
.card-body { padding: 14px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 14px; }
.grid-cards { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-charts { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.stat {
  display: flex; flex-direction: column; gap: 3px;
  padding: 13px 14px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat-label { font-size: 11.5px; color: var(--text-secondary); }
/* Proportional figures on standalone values — tabular-nums is for aligned columns. */
.stat-value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.stat-hint { font-size: 11.5px; color: var(--text-muted); }
.stat[data-tone="critical"] .stat-value { color: var(--status-critical); }
.stat[data-tone="good"] .stat-value { color: var(--delta-good); }

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

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th {
  text-align: left; font-weight: 550; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface-1);
  position: sticky; top: 0; z-index: 1;
}
table.data td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.center, table.data th.center { text-align: center; }
table.data tbody tr[data-clickable] { cursor: pointer; }
table.data tbody tr[data-clickable]:hover { background: var(--surface-hover); }
table.data tbody tr[data-clickable]:focus-visible { background: var(--surface-hover); }
table.data caption {
  caption-side: top; text-align: left;
  padding: 8px 12px; font-size: 11.5px; color: var(--text-muted);
}

/* --------------------------------------------------------------- pills --- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  font-size: 11.5px; line-height: 1.5; white-space: nowrap;
  color: var(--text-secondary);
}
.pill-glyph { width: 10px; height: 10px; flex: none; }
.pill-label { color: var(--text-primary); }
.pill[data-tone="running"] { border-color: color-mix(in srgb, var(--series-1) 45%, var(--border)); background: var(--wash-accent); }
.pill[data-tone="running"] .pill-glyph { color: var(--series-1); }
.pill[data-tone="good"] { border-color: color-mix(in srgb, var(--status-good) 40%, var(--border)); background: var(--wash-good); }
.pill[data-tone="good"] .pill-glyph { color: var(--status-good); }
.pill[data-tone="critical"] { border-color: color-mix(in srgb, var(--status-critical) 45%, var(--border)); background: var(--wash-critical); }
.pill[data-tone="critical"] .pill-glyph { color: var(--status-critical); }
.pill[data-tone="warning"] { border-color: color-mix(in srgb, var(--status-warning) 55%, var(--border)); background: var(--wash-warning); }
.pill[data-tone="warning"] .pill-glyph { color: var(--status-serious); }
.pill[data-tone="idle"] .pill-glyph { color: var(--text-muted); }

.pill-pulse { animation: fe-pulse 1.6s ease-in-out infinite; transform-origin: center; }
@keyframes fe-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .pill-pulse { animation: none; } }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; border-radius: 4px;
  font-size: 11px; line-height: 1.6;
  border: 1px solid var(--border); color: var(--text-secondary);
  background: var(--surface-2);
}
.badge[data-tone="best"] { border-color: color-mix(in srgb, var(--status-good) 45%, var(--border)); color: var(--delta-good); background: var(--wash-good); }
.badge[data-tone="accent"] { border-color: color-mix(in srgb, var(--series-1) 45%, var(--border)); color: var(--series-1); background: var(--wash-accent); }

/* ------------------------------------------------------------- stepper --- */

.stepper { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.step {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
}
.step[data-phase="done"] { color: var(--text-secondary); border-color: var(--border-strong); }
.step[data-phase="done"] .step-dot { background: var(--series-1); }
.step[data-phase="current"] {
  color: var(--text-primary); font-weight: 550;
  background: var(--wash-accent);
  border-color: color-mix(in srgb, var(--series-1) 45%, var(--border));
}
.step[data-phase="current"] .step-dot { background: var(--series-1); animation: fe-pulse 1.6s ease-in-out infinite; }
.step[data-phase="failed"] { color: var(--status-critical); background: var(--wash-critical); border-color: color-mix(in srgb, var(--status-critical) 45%, var(--border)); }
.step[data-phase="failed"] .step-dot { background: var(--status-critical); }
.step[data-phase="canceled"] { color: var(--text-secondary); background: var(--wash-warning); border-color: color-mix(in srgb, var(--status-warning) 55%, var(--border)); }
.step[data-phase="canceled"] .step-dot { background: var(--status-serious); }
.step-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--axis); flex: none; }
.step-sep { color: var(--axis); font-size: 11px; }
@media (prefers-reduced-motion: reduce) { .step[data-phase="current"] .step-dot { animation: none; } }

/* ---------------------------------------------------------------- meter --- */

.meter { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.meter-track {
  position: relative; flex: 1 1 auto; height: 6px; min-width: 60px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--series-1) 16%, var(--surface-2));
  overflow: hidden;
}
.meter-fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--series-1); }
.meter-fill[data-tone="good"] { background: var(--status-good); }
.meter-fill[data-tone="critical"] { background: var(--status-critical); }
.meter-fill[data-tone="warning"] { background: var(--status-serious); }
.meter-label { font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--text-secondary); white-space: nowrap; }

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

.chart {
  margin: 0;
  display: flex; flex-direction: column;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
}
.chart-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 10px 12px 6px;
}
.chart-titles { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.chart-title { font-size: 12.5px; font-weight: 600; }
.chart-sub { font-size: 11px; color: var(--text-muted); }
.chart-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.chart-latest { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-secondary); }

/* No horizontal padding: the SVG viewBox is measured from this box, so any padding
   would scale the drawing away from 1:1 and blur the hairlines. */
.chart-plot { position: relative; padding: 0; }
.chart-plot:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: 4px; }
.chart-plot svg { display: block; width: 100%; }

.chart-grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-axis line { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart-axis text { fill: var(--text-muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart-series path { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-series circle { stroke: var(--surface-1); stroke-width: 2; }
.chart-cross line { stroke: var(--axis); stroke-width: 1; }
.chart-cross circle { stroke: var(--surface-1); stroke-width: 2; }
.chart-empty text { fill: var(--text-muted); font-size: 11.5px; }
.chart-endlabel { fill: var(--text-secondary); font-size: 10.5px; font-variant-numeric: tabular-nums; }

.chart-tooltip {
  position: absolute; z-index: 5; pointer-events: none;
  min-width: 116px; max-width: 260px;
  padding: 7px 9px;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);
  font-size: 11.5px;
}
.chart-tooltip[hidden] { display: none; }
.chart-tip-head { color: var(--text-muted); font-size: 10.5px; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.chart-tip-row { display: flex; align-items: baseline; gap: 7px; justify-content: space-between; }
.chart-tip-key { display: inline-flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-secondary); }
.chart-tip-stroke { width: 11px; height: 2px; border-radius: 1px; flex: none; }
.chart-tip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-tip-value { font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 4px 12px 10px; }
.chart-legend:empty { display: none; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-secondary); }
.legend-stroke { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.legend-value { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.legend-item[data-empty="true"] { color: var(--text-muted); }

.chart-table { border-top: 1px solid var(--border); max-height: 220px; overflow: auto; }
.chart-table[hidden] { display: none; }

.sparkline { display: block; width: 100%; height: 28px; }
.sparkline path { fill: none; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.sparkline circle { stroke: var(--surface-1); stroke-width: 1.5; }

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

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
}
.button:hover { background: var(--surface-hover); }
.button:disabled { opacity: 0.5; cursor: default; }
.button[data-variant="primary"] { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.button[data-variant="primary"]:hover { filter: brightness(1.06); }
.button[data-variant="danger"] { border-color: color-mix(in srgb, var(--status-critical) 55%, var(--border)); color: var(--status-critical); }
.button[data-variant="danger"]:hover { background: var(--wash-critical); }
.button[data-size="sm"] { padding: 3px 8px; font-size: 11.5px; }
.button svg { width: 13px; height: 13px; stroke: currentColor; fill: none; }

.linkish {
  background: none; border: none; padding: 0;
  color: var(--focus); cursor: pointer; font-size: inherit;
}
.linkish:hover { text-decoration: underline; }

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

.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filter-group { display: inline-flex; align-items: center; gap: 7px; }
.filter-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chip {
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 11.5px; cursor: pointer; white-space: nowrap;
}
.chip:hover { background: var(--surface-hover); color: var(--text-primary); }
.chip[aria-pressed="true"] {
  background: var(--surface-active);
  border-color: color-mix(in srgb, var(--series-1) 45%, var(--border));
  color: var(--text-primary); font-weight: 550;
}

select.select, input.input {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  color: var(--text-primary);
  font: inherit; font-size: 12px;
  max-width: 320px;
}

/* ------------------------------------------------------- state blocks --- */

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 34px 20px; text-align: center;
}
.empty-title { font-size: 13px; font-weight: 550; }
.empty-hint { font-size: 12px; color: var(--text-muted); max-width: 46ch; }

.loading { display: flex; align-items: center; gap: 9px; padding: 26px 16px; color: var(--text-muted); font-size: 12.5px; }
.spinner {
  width: 13px; height: 13px; flex: none;
  border: 2px solid var(--grid); border-top-color: var(--series-1);
  border-radius: 50%; animation: fe-spin 0.7s linear infinite;
}
@keyframes fe-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2), var(--surface-hover), var(--surface-2));
  border-radius: 4px; height: 11px; animation: fe-shimmer 1.4s ease-in-out infinite;
}
@keyframes fe-shimmer { 0%, 100% { opacity: 0.55; } 50% { opacity: 0.95; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* Refetch keeps the frame: hold the previous render, dimmed. No skeleton flash. */
[data-busy="true"] { opacity: 0.55; transition: opacity 120ms ease-out; }

.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-1);
}
.banner-icon { width: 15px; height: 15px; flex: none; margin-top: 1px; stroke: currentColor; fill: none; }
.banner-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; }
.banner-title { font-size: 12.5px; font-weight: 600; }
.banner-text { font-size: 12px; color: var(--text-secondary); }
.banner[data-tone="critical"] { background: var(--wash-critical); border-color: color-mix(in srgb, var(--status-critical) 40%, var(--border)); }
.banner[data-tone="critical"] .banner-icon, .banner[data-tone="critical"] .banner-title { color: var(--status-critical); }
.banner[data-tone="good"] { background: var(--wash-good); border-color: color-mix(in srgb, var(--status-good) 35%, var(--border)); }
.banner[data-tone="good"] .banner-icon, .banner[data-tone="good"] .banner-title { color: var(--delta-good); }
.banner[data-tone="warning"] { background: var(--wash-warning); border-color: color-mix(in srgb, var(--status-warning) 50%, var(--border)); }
.banner[data-tone="warning"] .banner-icon { color: var(--status-serious); }

.banner-verdict { padding: 15px 16px; }
.banner-verdict .banner-title { font-size: 15px; }

details.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); }
details.panel > summary {
  padding: 9px 13px; cursor: pointer; font-size: 12.5px; font-weight: 550;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  list-style: none;
}
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: "▾"; color: var(--text-muted); font-size: 10px; }
details.panel[open] > summary { border-bottom: 1px solid var(--border); }
details.panel[open] > summary::after { content: "▴"; }
.panel-body { padding: 12px 13px; }
.panel-body.flush { padding: 0; }

.logs {
  margin: 0; padding: 10px 13px;
  max-height: 340px; overflow: auto;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55;
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
  white-space: pre-wrap; word-break: break-word;
}
.log-line { display: block; }
.log-line[data-stream="stderr"] { color: var(--status-serious); }
.log-time { color: var(--text-muted); margin-right: 8px; }

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 12.5px; }
.kv dt { color: var(--text-muted); font-size: 11.5px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.timeline { display: flex; flex-direction: column; }
.timeline-item {
  display: grid; grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-step { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12.5px; }
.timeline-step-label { display: block; font-size: 10.5px; color: var(--text-muted); font-weight: 400; letter-spacing: 0.04em; text-transform: uppercase; }
.timeline-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.timeline-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.metric-chips { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.metric-chip {
  display: inline-flex; align-items: baseline; gap: 5px;
  padding: 1px 7px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 11px;
}
.metric-chip .k { color: var(--text-muted); }
.metric-chip .v { font-variant-numeric: tabular-nums; color: var(--text-primary); }

.delta { display: inline-flex; align-items: baseline; gap: 5px; font-variant-numeric: tabular-nums; }
.delta-mark { font-size: 11px; }
.delta-word { font-size: 11px; color: var(--text-muted); }
.delta[data-dir="good"] .delta-mark, .delta[data-dir="good"] .delta-value { color: var(--delta-good); }
.delta[data-dir="bad"] .delta-mark, .delta[data-dir="bad"] .delta-value { color: var(--delta-bad); }
.delta[data-dir="flat"] .delta-mark { color: var(--text-muted); }

.copy {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: none; padding: 0 2px; cursor: pointer;
  color: var(--text-muted); font-size: 11px;
}
.copy:hover { color: var(--text-primary); }
.copy svg { width: 11px; height: 11px; stroke: currentColor; fill: none; }

/* -------------------------------------------------------------- toasts --- */

.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 10px 12px;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-left-width: 3px;
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
  font-size: 12px;
  animation: fe-toast-in 140ms ease-out;
}
@keyframes fe-toast-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
.toast[data-kind="error"] { border-left-color: var(--status-critical); }
.toast[data-kind="warn"] { border-left-color: var(--status-warning); }
.toast[data-kind="success"] { border-left-color: var(--status-good); }
.toast[data-kind="info"] { border-left-color: var(--series-1); }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; margin-bottom: 2px; }
.toast-text { color: var(--text-secondary); overflow-wrap: anywhere; }
.toast-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 14px; line-height: 1; padding: 0 2px; }
.toast-close:hover { color: var(--text-primary); }

/* -------------------------------------------------------------- dialog --- */

.dialog-host {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(11, 11, 11, 0.45);
}
.dialog-host[hidden] { display: none; }
.dialog {
  width: min(430px, 100%);
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.30);
  padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.dialog h2 { font-size: 14px; }
.dialog-text { font-size: 12.5px; color: var(--text-secondary); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------------------------------------------------------- responsive --- */

@media (max-width: 900px) {
  :root { --sidebar-w: 54px; }
  .brand-text, .nav-item > span, .sidebar-foot { display: none; }
  .nav-item { justify-content: center; padding: 8px 0; }
  .brand { justify-content: center; padding: 6px 0 12px; }
}

@media (max-width: 640px) {
  .main { padding: 14px 12px 40px; }
  .header { padding: 0 12px; }
  .conn .conn-label { display: none; }
}

@media print {
  .sidebar, .header-tools, .chart-tooltip, .toasts { display: none; }
}
