/* Sada DB Console — design system.

   Direction: "Ledger". Technical utility with an instrument-panel identity, drawn from the material itself: the
   console is a record of cluster state (phases, ops, timestamps, identifiers), so the surface behaves like a
   ledger sheet — hairline rules, a visible rhythm, monospace where the value is an identifier, tabular figures
   where the value is a number. One accent (cobalt ink) and one bold element per view; everything else is quiet.

   Contract with the templates and public/js/*.js:
   - Every class name the ported views use stays. This file restyles them; it never renames them.
   - Tokens are the only source of colour. No component invents a hex value.
   - Theme is driven by data-theme on <html> (app.js resolves "system" first) plus color-scheme.
   - The dashboard donut reads --chart-1…5, --success, --info, --warning, --destructive, --muted and
     --muted-foreground through getComputedStyle, so those must stay real colours in both themes. */

:root {
  /* ---------- palette (OKLch) ---------- */
  --bg-canvas: oklch(98.6% 0.003 250);
  --bg-surface: oklch(100% 0 0);
  --bg-sunken: oklch(96.6% 0.004 250);
  --fg: oklch(20% 0.014 260);
  --muted-fg: oklch(47% 0.014 260);
  --border: oklch(90.5% 0.006 260);
  --border-strong: oklch(82% 0.008 260);

  /* ---------- brand: the one accent ----------
     Cobalt ink. Deep enough to carry white text, and the only saturated colour in the chrome. */
  --brand: oklch(52% 0.16 258);
  --brand-hover: oklch(46% 0.16 258);
  --brand-fg: oklch(99% 0.002 250);
  --brand-soft: oklch(95.5% 0.028 258);

  --success: oklch(56% 0.135 155);
  --warning: oklch(66% 0.145 72);
  --danger: oklch(53% 0.2 22);
  --info: oklch(58% 0.13 240);

  /* ---------- tones: a tinted background with a foreground that clears 4.5:1 on it ---------- */
  --tone-success-bg: oklch(96% 0.032 155); --tone-success-fg: oklch(42% 0.115 155);
  --tone-warning-bg: oklch(96.5% 0.04 85); --tone-warning-fg: oklch(44% 0.1 65);
  --tone-danger-bg: oklch(96% 0.03 20);    --tone-danger-fg: oklch(45% 0.185 25);
  --tone-info-bg: oklch(96% 0.03 250);     --tone-info-fg: oklch(43% 0.14 255);
  --tone-neutral-bg: oklch(96.4% 0.004 260); --tone-neutral-fg: oklch(45% 0.012 260);

  /* ---------- shadcn-compatible aliases (kept so module stylesheets keep working) ---------- */
  --background: var(--bg-canvas);
  --foreground: var(--fg);
  --card: var(--bg-surface);
  --card-foreground: var(--fg);
  --card-bg: var(--bg-surface);
  --surface-2: var(--bg-sunken);
  --soft: color-mix(in oklab, var(--bg-sunken) 70%, var(--bg-surface));
  --popover: var(--bg-surface);
  --popover-foreground: var(--fg);
  --primary: var(--brand);
  --primary-foreground: var(--brand-fg);
  --primary-hover: var(--brand-hover);
  --secondary: var(--bg-sunken);
  --secondary-foreground: var(--fg);
  --muted: var(--bg-sunken);
  --muted-foreground: var(--muted-fg);
  /* shadcn's `accent` is a *surface* hover, not the brand; the module stylesheets use it that way. */
  --accent: var(--bg-sunken);
  --accent-foreground: var(--fg);
  --destructive: var(--danger);
  --destructive-foreground: oklch(99% 0.002 250);
  --input: var(--border-strong);
  --ring: color-mix(in oklab, var(--brand) 55%, var(--bg-surface));

  --chart-1: oklch(55% 0.185 258);
  --chart-2: oklch(62% 0.13 175);
  --chart-3: oklch(72% 0.14 75);
  --chart-4: oklch(58% 0.16 305);
  --chart-5: oklch(60% 0.17 12);

  /* The rail is graphite in both themes: the navigation behaves like the bezel of an instrument, so the eye reads
     hardware on the left and the working surface on the right. That is the one place the shell spends colour. */
  --sidebar: oklch(23.5% 0.012 258);
  --sidebar-foreground: oklch(93% 0.004 258);
  --sidebar-primary: var(--brand);
  --sidebar-primary-foreground: var(--brand-fg);
  --sidebar-accent: oklch(30.5% 0.016 258);
  --sidebar-accent-foreground: oklch(98% 0.002 258);
  --sidebar-muted: oklch(72% 0.012 258);
  --sidebar-border: oklch(31% 0.012 258);
  --sidebar-ring: oklch(62% 0.03 258);
  --topbar: var(--bg-canvas);
  --topbar-foreground: var(--fg);

  /* ---------- type ---------- */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  --text-xs: .8125rem; --text-sm: .875rem; --text-base: .9375rem; --text-md: 1rem;
  --text-lg: 1.125rem; --text-xl: 1.4375rem; --text-2xl: 1.875rem;
  --tracking-tight: -.015em; --tracking-wide: .06em;

  /* ---------- space (4px base) + radius + elevation ---------- */
  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem;
  --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem;
  --radius: .5rem; --radius-sm: .375rem; --radius-xs: .25rem; --radius-lg: .75rem; --radius-pill: 999px;
  --shadow-xs: 0 1px 0 0 oklch(0% 0 0 / .04);
  --shadow-sm: 0 1px 2px 0 oklch(0% 0 0 / .05);
  --shadow: 0 2px 6px -1px oklch(0% 0 0 / .08);
  --shadow-lg: 0 18px 44px -14px oklch(0% 0 0 / .3);

  /* ---------- terminal surface (a log pane stays dark in both themes: it is a screen, not paper) ---------- */
  --term-bg: oklch(19% 0.012 265);
  --term-fg: oklch(93% 0.005 265);
  --term-dim: oklch(72% 0.01 265);
  --term-accent: oklch(82% 0.1 235);
  --term-add: oklch(82% 0.13 155);
  --term-del: oklch(78% 0.12 20);
  --term-mark-bg: oklch(80% 0.14 80);
  --term-mark-fg: oklch(18% 0 0);

  --sidebar-width: 15.5rem; --sidebar-width-icon: 3.25rem; --topbar-height: 3.5rem;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg-canvas: oklch(17.5% 0.008 260);
  --bg-surface: oklch(21.5% 0.01 260);
  --bg-sunken: oklch(24.5% 0.011 260);
  --fg: oklch(96% 0.003 260);
  --muted-fg: oklch(74% 0.012 260);
  --border: oklch(100% 0 0 / .1);
  --border-strong: oklch(100% 0 0 / .18);

  --brand: oklch(70% 0.13 258);
  --brand-hover: oklch(76% 0.12 258);
  --brand-fg: oklch(15% 0.01 260);
  --brand-soft: oklch(30% 0.05 258);

  --success: oklch(74% 0.15 155);
  --warning: oklch(80% 0.14 80);
  --danger: oklch(68% 0.18 22);
  /* The dark-theme danger fill is light, so its label is dark (6.3:1; white was 3.0:1). */
  --destructive-foreground: oklch(15% 0.01 260);
  --info: oklch(72% 0.12 240);

  --tone-success-bg: oklch(28% 0.05 155); --tone-success-fg: oklch(86% 0.11 155);
  --tone-warning-bg: oklch(29% 0.055 75); --tone-warning-fg: oklch(90% 0.11 85);
  --tone-danger-bg: oklch(27% 0.06 20);   --tone-danger-fg: oklch(86% 0.09 20);
  --tone-info-bg: oklch(27% 0.05 250);    --tone-info-fg: oklch(86% 0.08 250);
  --tone-neutral-bg: oklch(26% 0.008 260); --tone-neutral-fg: oklch(80% 0.008 260);

  --chart-1: oklch(70% 0.15 258);
  --chart-2: oklch(74% 0.12 175);
  --chart-3: oklch(82% 0.13 80);
  --chart-4: oklch(72% 0.14 305);
  --chart-5: oklch(72% 0.15 12);

  --shadow-xs: 0 1px 0 0 oklch(0% 0 0 / .3);
  --shadow-sm: 0 1px 2px 0 oklch(0% 0 0 / .35);
  --shadow: 0 2px 8px -1px oklch(0% 0 0 / .45);
  --shadow-lg: 0 20px 48px -16px oklch(0% 0 0 / .7);

  --sidebar: oklch(13.5% 0.008 260);
  --sidebar-foreground: oklch(92% 0.004 260);
  --sidebar-accent: oklch(19.5% 0.012 260);
  --sidebar-accent-foreground: oklch(98% 0.002 260);
  --sidebar-muted: oklch(70% 0.012 260);
  --sidebar-border: oklch(22% 0.01 260);
  --sidebar-ring: oklch(58% 0.03 260);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg-canvas); color: var(--fg); font: 400 var(--text-md)/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

a { color: var(--brand); text-decoration: none; text-underline-offset: .15em; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: var(--tracking-tight); color: var(--fg); }
h1 { font-size: var(--text-xl); line-height: 1.2; }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }
h4 { font-size: var(--text-base); }
p { margin: 0; }

code, kbd, pre, .mono { font-family: var(--font-mono); font-size: var(--text-sm); font-variant-ligatures: none; }
code { background: var(--bg-sunken); color: var(--fg); padding: .1rem .3rem; border-radius: var(--radius-xs);
  border: 1px solid var(--border); word-break: break-word; }
pre { background: var(--bg-sunken); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm);
  border: 1px solid var(--border); overflow: auto; margin: 0; line-height: 1.55; }
pre code { background: none; border: 0; padding: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-4) 0; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--radius-xs); }
::selection { background: color-mix(in oklab, var(--brand) 24%, transparent); }

/* identifiers and figures are the material of this console: mono, never squashed */
time, .num, .tabular { font-variant-numeric: tabular-nums; }

.muted { color: var(--muted-fg); }
.small { font-size: var(--text-sm); } .xs { font-size: var(--text-xs); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: right; } .center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.grid { display: grid; gap: var(--space-5); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
@media (max-width: 1100px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }
.mt-1 { margin-top: var(--space-2); } .mt-2 { margin-top: var(--space-4); } .mt-3 { margin-top: var(--space-6); }
.mb-1 { margin-bottom: var(--space-2); } .mb-2 { margin-bottom: var(--space-4); }
.gap-1 { gap: var(--space-2); } .gap-2 { gap: var(--space-4); }
.w-full { width: 100%; } .flex-1 { flex: 1 1 auto; min-width: 0; }
/* used by tasks/detail and platform/instances; defined here so it never depends on which module CSS loaded */
.h1-sm { font-size: 1.15rem; }
.text-destructive { color: var(--danger); }
.text-primary { color: var(--brand); }
.text-success { color: var(--tone-success-fg); }

/* ---------- utilities the ported templates already ask for ----------
   These names appear in the views but had no rule, so the markup silently did nothing. */
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-normal { font-weight: 400; }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-right { text-align: right; }
.uppercase { text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.items-center { align-items: center; }
.grow { flex: 1 1 auto; min-width: 0; }
.ml-1 { margin-left: var(--space-1); }
.ml-2 { margin-left: var(--space-2); }
.mb-0-5 { margin-bottom: var(--space-1); }
.h2 { font-size: var(--text-lg); font-weight: 600; letter-spacing: var(--tracking-tight); }
/* a dialog may ask for the wide frame without its own class */
dialog.dialog.dialog-lg { width: min(48rem, calc(100vw - 2rem)); }
/* the badge base is neutral; naming the tone explicitly must not change that */
.badge.neutral { background: var(--tone-neutral-bg); color: var(--tone-neutral-fg); }

/* ---------- Command Deck shell ----------
   Desktop: one dark sidebar (every destination, grouped, one click each) beside the workspace. Mobile: the sidebar
   becomes a sheet and a bottom tab bar of links (.tabbar) gives one-tap access to the main areas. */
.app.shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.tabbar { display: none; }

.context-panel { position: sticky; top: 0; z-index: 40; display: flex; height: 100vh; min-width: 0; flex-direction: column; overflow: hidden;
  background: var(--sidebar); color: var(--sidebar-foreground); border-right: 1px solid var(--sidebar-border); }
.context-heading { display: flex; height: var(--topbar-height); flex-shrink: 0; align-items: center; padding: 0 var(--space-4); border-bottom: 1px solid var(--sidebar-border); }
.brand { display: flex; align-items: center; gap: .625rem; min-width: 0; color: var(--sidebar-foreground); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; width: 1.75rem; height: 1.75rem; flex-shrink: 0; place-items: center; border-radius: var(--radius-xs); background: var(--brand); color: var(--brand-fg);
  font-family: var(--font-mono); font-size: .9rem; font-weight: 700; letter-spacing: -.04em; box-shadow: 0 0 0 1px oklch(100% 0 0 / .12) inset; }
.brand-text { overflow: hidden; line-height: 1.25; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
.brand-text small { display: block; color: var(--sidebar-muted); font-size: var(--text-xs); font-weight: 400; letter-spacing: 0; }

.context-nav { flex: 1; overflow-y: auto; padding: var(--space-2); scrollbar-width: thin; scrollbar-color: var(--sidebar-border) transparent; }
.nav-group { margin: var(--space-2) 0 var(--space-3); }
.nav-label { display: flex; align-items: center; gap: .5rem; padding: var(--space-3) var(--space-2) var(--space-1); color: var(--sidebar-muted);
  font-size: var(--text-xs); font-weight: 600; letter-spacing: var(--tracking-wide); text-transform: uppercase; white-space: nowrap; }
.nav-label::after { flex: 1; height: 1px; background: var(--sidebar-border); content: ""; }
.nav-item { position: relative; display: flex; min-height: 2rem; align-items: center; gap: .6rem; padding: .45rem .625rem; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--sidebar-foreground); font: inherit; font-size: var(--text-base); line-height: 1.3; text-align: left; white-space: nowrap;
  cursor: pointer; transition: background-color .12s, color .12s; }
.nav-item span { overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); text-decoration: none; }
.nav-item[aria-current="page"] { background: color-mix(in oklab, var(--brand) 30%, var(--sidebar)); color: oklch(99% 0 0); font-weight: 600; }
.nav-item[aria-current="page"]::before { position: absolute; top: 50%; left: 0; width: 2px; height: 1.15rem; border-radius: 0 2px 2px 0;
  background: color-mix(in oklab, var(--brand) 55%, white); content: ""; transform: translateY(-50%); }
.nav-item .icon { width: 1rem; height: 1rem; flex-shrink: 0; opacity: .8; }
.nav-item[aria-current="page"] .icon { opacity: 1; }

.context-cluster { padding: var(--space-3) var(--space-4) var(--space-4); border-bottom: 1px solid var(--sidebar-border); }
.context-cluster .back { display: inline-flex; align-items: center; gap: .3rem; color: var(--sidebar-muted); font-size: var(--text-sm); }
.context-cluster .back:hover { color: var(--sidebar-foreground); text-decoration: none; }
.context-cluster .back .icon { width: .85rem; height: .85rem; }
.context-cluster .sidebar-cluster-meta { margin-top: var(--space-2); min-width: 0; }
.context-cluster .sidebar-cluster-meta .name { overflow: hidden; color: var(--sidebar-foreground); font-family: var(--font-mono); font-size: var(--text-base); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.context-cluster .sidebar-cluster-meta .xs { margin-top: .2rem; color: var(--sidebar-muted); }
.context-cluster .engine-mark .logo { box-shadow: 0 0 0 1px oklch(100% 0 0 / .18); }
.context-footer { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-2); border-top: 1px solid var(--sidebar-border); }
.context-footer .sidebar-meta { padding: .15rem .625rem .3rem; color: var(--sidebar-muted); font-family: var(--font-mono); font-size: var(--text-xs); }
.context-footer .sidebar-meta .sep { opacity: .5; }
.context-footer .nav-item { color: var(--sidebar-muted); font-size: var(--text-sm); }

.app[data-collapsed="true"] { grid-template-columns: var(--sidebar-width-icon) minmax(0, 1fr); }
.app[data-collapsed="true"] .brand-text, .app[data-collapsed="true"] .nav-label, .app[data-collapsed="true"] .nav-item span,
.app[data-collapsed="true"] .context-cluster, .app[data-collapsed="true"] .sidebar-meta { display: none; }
.app[data-collapsed="true"] .context-heading { justify-content: center; padding: 0; }
.app[data-collapsed="true"] .nav-item { justify-content: center; padding: .55rem 0; }
.app[data-collapsed="true"] .nav-item[aria-current="page"]::before { display: none; }

.workspace { display: flex; min-width: 0; min-height: 100vh; flex-direction: column; }
.command-bar { position: sticky; top: 0; z-index: 30; display: flex; height: var(--topbar-height); align-items: center; gap: var(--space-3); padding: 0 var(--space-6);
  border-bottom: 1px solid var(--border); background: color-mix(in oklab, var(--bg-canvas) 92%, transparent); backdrop-filter: blur(8px); }
.command-bar .spacer { flex: 1; }
.breadcrumb { display: flex; min-width: 0; align-items: center; gap: .4rem; color: var(--muted-fg); font-size: var(--text-base); }
.breadcrumb a { color: inherit; }
.breadcrumb .sep { opacity: .6; }
.breadcrumb .current { overflow: hidden; color: var(--fg); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.command-trigger { display: inline-flex; min-width: 13rem; height: 2rem; align-items: center; gap: var(--space-2); padding: 0 var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-surface); color: var(--muted-fg); font: inherit; font-size: var(--text-sm); cursor: pointer; }
.command-trigger .icon { width: 1rem; height: 1rem; flex: 0 0 auto; }
.command-trigger:hover { border-color: var(--border-strong); color: var(--fg); }
.command-trigger-label { flex: 1; text-align: left; }
.command-trigger kbd + kbd { display: none; }
kbd { padding: .05rem .3rem; border: 1px solid var(--border); border-radius: var(--radius-xs); background: var(--bg-sunken); color: var(--muted-fg); font-family: var(--font-mono); font-size: var(--text-xs); }
.content { flex: 1; width: 100%; min-width: 0; padding: var(--space-6) var(--space-8) var(--space-8); }
.status-strip { position: sticky; bottom: 0; z-index: 10; display: flex; min-height: 2rem; align-items: center; gap: var(--space-2); padding: .25rem var(--space-6);
  border-top: 1px solid var(--border); background: var(--bg-surface); color: var(--muted-fg); font-size: var(--text-sm); }
.status-strip strong { color: var(--fg); font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.status-indicator { width: .5rem; height: .5rem; border-radius: 50%; background: var(--muted-fg); }
.status-strip[data-state="live"] .status-indicator { background: var(--success); }
.status-strip[data-state="reconnecting"] .status-indicator { background: var(--warning); }
.status-strip:not([data-state="live"]) [data-live-counts] { display: none; }
.status-divider { width: 1px; height: .9rem; margin: 0 var(--space-1); background: var(--border); }

/* Command palette */
.palette { width: min(38rem, calc(100vw - 2rem)); max-height: min(34rem, calc(100vh - 2rem)); padding: 0; overflow: hidden; }
.palette-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); font-weight: 600; }
.palette-search { margin: var(--space-3) var(--space-4); }
.palette-search .input { height: 2.75rem; padding-left: 2.5rem; }
.palette-search .icon { left: .8rem; width: 1rem; height: 1rem; }
.palette-results { max-height: min(23rem, 55vh); overflow: auto; padding: 0 var(--space-2) var(--space-2); }
.palette-group { padding: var(--space-3) var(--space-2) var(--space-1); color: var(--muted-fg); font-size: var(--text-sm); font-weight: 600; letter-spacing: var(--tracking-wide); text-transform: uppercase; }
.palette-option { display: block; padding: .55rem var(--space-2); border-radius: var(--radius-sm); color: var(--fg); font-size: var(--text-base); }
.palette-option:hover, .palette-option[aria-selected="true"] { background: var(--brand-soft); color: var(--brand); text-decoration: none; }
.palette-empty { padding: var(--space-4); color: var(--muted-fg); font-size: var(--text-base); text-align: center; }
.palette-hint { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); border-top: 1px solid var(--border); color: var(--muted-fg); font-size: var(--text-sm); }
.overlay { position: fixed; inset: 0; z-index: 45; display: none; background: var(--sidebar); opacity: .48; }
.overlay[data-open="true"] { display: block; }

@media (min-width: 768px) and (max-width: 1280px) { .content { padding: var(--space-5) var(--space-5) var(--space-6); } }
@media (max-width: 767px) {
  .app.shell, .app[data-collapsed="true"] { grid-template-columns: minmax(0, 1fr); padding-bottom: calc(3.5rem + env(safe-area-inset-bottom)); }
  .tabbar { position: fixed; inset: auto 0 0; z-index: 55; display: block; height: calc(3.5rem + env(safe-area-inset-bottom));
    padding: .25rem .25rem env(safe-area-inset-bottom); background: var(--sidebar); border-top: 1px solid var(--sidebar-border); }
  .tabbar-items { display: flex; height: 100%; justify-content: space-around; }
  .tabbar-item { display: grid; flex: 1; max-width: 4.5rem; place-items: center; align-content: center; gap: .15rem; border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--sidebar-muted); font: inherit; cursor: pointer; }
  .tabbar-item:hover { text-decoration: none; color: var(--sidebar-foreground); }
  .tabbar-item.is-active { color: oklch(99% 0 0); }
  .tabbar-item .icon { width: 1.15rem; height: 1.15rem; }
  .tabbar-label { overflow: hidden; max-width: 100%; font-size: var(--text-xs); line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar-items > .tabbar-item:nth-of-type(n + 5):not(.tabbar-more) { display: none; }
  .context-panel { position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(18rem, calc(100vw - 3rem)); height: 100dvh; transform: translateX(-105%);
    transition: transform .2s ease; box-shadow: var(--shadow-lg); overscroll-behavior: contain; }
  .app[data-mobile-open="true"] .context-panel { transform: none; }
  .app[data-collapsed="true"] .brand-text, .app[data-collapsed="true"] .nav-label, .app[data-collapsed="true"] .nav-item span,
  .app[data-collapsed="true"] .context-cluster, .app[data-collapsed="true"] .sidebar-meta { display: revert; }
  #sidebar-toggle { display: none; }
  .command-bar { gap: var(--space-2); padding: 0 var(--space-3); }
  .breadcrumb { display: none; }
  .command-trigger { min-width: 0; padding: 0 .55rem; }
  .command-trigger-label, .command-trigger kbd, .env-chip { display: none; }
  .content { padding: var(--space-4) var(--space-4) var(--space-6); }
  .status-strip { bottom: calc(3.5rem + env(safe-area-inset-bottom)); padding-inline: var(--space-3); }
  .overlay { z-index: 58; }
}
@media (prefers-reduced-motion: reduce) {
  .context-panel { transition: none; }
}
/* Off-screen until a keyboard user tabs to it; then it sits above the shell, top-left. */
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 200; background: var(--brand); color: var(--brand-fg);
  padding: .5rem .85rem; border-radius: 0 0 var(--radius-sm) 0; font-size: var(--text-base); }
.skip-link:focus { left: 0; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; height: 2.125rem;
  padding: 0 .8rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--bg-surface);
  color: var(--fg); font: inherit; font-size: var(--text-base); font-weight: 500; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-xs); transition: background .12s, border-color .12s, color .12s; }
.btn:hover { background: var(--bg-sunken); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.secondary { background: var(--bg-sunken); border-color: transparent; color: var(--fg); box-shadow: none; }
.btn.secondary:hover { background: var(--border); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--bg-sunken); }
.btn.destructive { background: var(--danger); border-color: var(--danger); color: var(--destructive-foreground); }
.btn.destructive:hover { background: color-mix(in oklab, var(--danger) 85%, black); }
/* Darkening the light dark-theme fill under a dark label drops it to 4.2:1; lighten it instead (7.6:1). */
:root[data-theme="dark"] .btn.destructive:hover { background: color-mix(in oklab, var(--danger) 85%, white); }
.btn.destructive.outline { background: transparent; color: var(--danger); box-shadow: none; }
.btn.destructive.outline:hover { background: var(--tone-danger-bg); }
.btn.link { border: 0; background: none; color: var(--brand); padding: 0; height: auto; box-shadow: none; }
.btn.link:hover { background: none; text-decoration: underline; }
.btn.sm { height: 1.9rem; padding: 0 .6rem; font-size: var(--text-sm); }
.btn.xs { height: 1.55rem; padding: 0 .45rem; font-size: var(--text-xs); border-radius: var(--radius-xs); }
.btn.icon { width: 2.125rem; padding: 0; }
.btn.icon.sm { width: 1.9rem; } .btn.icon.xs { width: 1.55rem; }
.btn .icon, .icon { width: 1rem; height: 1rem; flex-shrink: 0; }
.btn .icon { opacity: .9; }
.btn.loading::before { content: ""; width: .8rem; height: .8rem; border: 2px solid currentColor;
  border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-group { display: inline-flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field > label, .label { font-size: var(--text-base); font-weight: 500; }
.field .hint { font-size: var(--text-xs); color: var(--muted-fg); line-height: 1.45; }
.field .error { font-size: var(--text-xs); color: var(--danger); }
.input, .select, .textarea { width: 100%; height: 2.125rem; padding: 0 .65rem; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--bg-surface); color: var(--fg); font: inherit; font-size: var(--text-base); }
.textarea { height: auto; min-height: 5rem; padding: .5rem .65rem; resize: vertical; }
.select { appearance: none; padding-right: 1.85rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .55rem center; cursor: pointer; }
.input::placeholder, .textarea::placeholder { color: var(--muted-fg); opacity: .85; }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in oklab, var(--border-strong) 70%, var(--fg)); }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid color-mix(in oklab, var(--brand) 45%, transparent);
  outline-offset: 0; border-color: var(--brand); }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--danger); }
.input.sm, .select.sm { height: 1.9rem; font-size: var(--text-sm); }
.input-group { display: flex; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: 0; }
.search { position: relative; min-width: 0; }
.search .input { padding-left: 2rem; }
.search .icon { position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); color: var(--muted-fg);
  width: .9rem; height: .9rem; pointer-events: none; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5) var(--space-6); }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: span 1; } }
.check { display: inline-flex; align-items: center; gap: .45rem; font-size: var(--text-base); cursor: pointer; }
.check input { width: .95rem; height: .95rem; accent-color: var(--brand); margin: 0; }
.switch { position: relative; display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; font-size: var(--text-base); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 2.15rem; height: 1.2rem; border-radius: var(--radius-pill); background: var(--border-strong);
  position: relative; transition: background .15s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: .125rem; left: .125rem; width: .95rem; height: .95rem;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(.95rem); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: var(--space-3); }
.radio-card { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: .7rem .8rem; cursor: pointer;
  display: flex; gap: .55rem; align-items: flex-start; background: var(--bg-surface); transition: border-color .12s, box-shadow .12s; }
.radio-card:hover { border-color: color-mix(in oklab, var(--brand) 45%, var(--border-strong)); }
.radio-card input { margin-top: .15rem; accent-color: var(--brand); }
.radio-card:has(input:checked) { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.radio-card .title { font-weight: 600; font-size: var(--text-base); }
.radio-card .desc { font-size: var(--text-xs); color: var(--muted-fg); line-height: 1.45; }
.segment { display: inline-flex; background: var(--bg-sunken); border-radius: var(--radius-sm); padding: .15rem; gap: .15rem;
  border: 1px solid var(--border); }
.segment label, .segment a { padding: .25rem .65rem; border-radius: var(--radius-xs); font-size: var(--text-sm);
  cursor: pointer; color: var(--muted-fg); }
.segment input { display: none; }
.segment label:has(input:checked), .segment a[aria-current="page"] { background: var(--bg-surface); color: var(--fg);
  box-shadow: var(--shadow-xs); text-decoration: none; font-weight: 500; }

/* ---------- cards / kv / stats ---------- */
/* a card is a ledger block: hairline border, no floating shadow, a header separated by a rule */
.card { background: var(--card); color: var(--card-foreground); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: none; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-5);
  padding: var(--space-4) var(--space-5); }
.card-header.bordered { border-bottom: 1px solid var(--border); }
.card-title { font-size: var(--text-md); font-weight: 600; letter-spacing: var(--tracking-tight); }
.card-desc { font-size: var(--text-sm); color: var(--muted-fg); margin-top: .2rem; line-height: 1.5; }
.card-body { padding: var(--space-4) var(--space-5) var(--space-5); }
.card-header + .card-body { padding-top: var(--space-3); }
.card-header.bordered + .card-body, .card-header.bordered + * .card-body { border-top: 0; }
.card-footer { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); display: flex; gap: var(--space-3);
  justify-content: flex-end; flex-wrap: wrap; }
.card.flush .card-body { padding: 0; }
.pad-lg { padding: var(--space-6); }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: var(--space-5) var(--space-8); }
.kv > div { min-width: 0; }
.kv dt { font-size: .6875rem; color: var(--muted-fg); margin-bottom: .25rem; text-transform: uppercase;
  letter-spacing: var(--tracking-wide); font-weight: 600; }
.kv dd { margin: 0; font-size: var(--text-base); overflow-wrap: anywhere; display: flex; align-items: center;
  gap: .4rem; flex-wrap: wrap; line-height: 1.5; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: var(--space-4); }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--space-4); position: relative; }
.stat .label { font-size: .6875rem; color: var(--muted-fg); font-weight: 600; text-transform: uppercase;
  letter-spacing: var(--tracking-wide); }
.stat .value { font-size: var(--text-2xl); font-weight: 600; margin-top: .3rem; letter-spacing: -.025em; line-height: 1.1;
  font-variant-numeric: tabular-nums; }
.stat .sub { font-size: var(--text-xs); color: var(--muted-fg); margin-top: .35rem; line-height: 1.45; }
.stat.clickable { cursor: pointer; transition: border-color .12s; }
.stat.clickable:hover { border-color: var(--brand); }

/* ---------- badges / tags ---------- */
/* status is a tinted pill with a 6px dot; it never becomes a bordered box */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .5rem; border-radius: var(--radius-sm);
  font-size: var(--text-xs); font-weight: 500; background: var(--tone-neutral-bg); color: var(--tone-neutral-fg);
  white-space: nowrap; line-height: 1.5; }
.badge .dot { width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge.success { background: var(--tone-success-bg); color: var(--tone-success-fg); }
.badge.warning { background: var(--tone-warning-bg); color: var(--tone-warning-fg); }
.badge.danger { background: var(--tone-danger-bg); color: var(--tone-danger-fg); }
.badge.info { background: var(--tone-info-bg); color: var(--tone-info-fg); }
.badge.outline { background: transparent; border: 1px solid var(--border-strong); color: var(--fg); }
.badge.pulse .dot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.engine-mark { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; }
.engine-mark .logo { width: 1.15rem; height: 1.15rem; border-radius: var(--radius-xs); display: grid; place-items: center;
  /* The tiles are fixed brand colours in both themes, so the letters are fixed white: --brand-fg turns near-black in
     the dark theme and fell to 2.6:1 on these fills. White clears 4.5:1 on every tile below. */
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 700; color: oklch(100% 0 0); letter-spacing: -.03em; flex-shrink: 0;
  /* unknown engines fall back to a neutral tile: an empty box with white text on nothing was invisible */
  background: oklch(47% 0.014 260); }
.engine-mark.mysql .logo { background: #00618a; } .engine-mark.mariadb .logo { background: #9b3d36; }
.engine-mark.postgresql .logo { background: #33587a; } .engine-mark.redis .logo { background: #a41e14; }
.engine-mark.mongodb .logo { background: #116149; }
/* an engine the catalog does not know still gets a readable tile */
.engine-mark.other .logo, .engine-mark.unknown .logo { background: oklch(47% 0.014 260); }

.tag { display: inline-flex; align-items: center; gap: .3rem; border: 1px solid var(--border); border-radius: var(--radius-xs);
  padding: .15rem .45rem; font-size: var(--text-xs); background: var(--bg-sunken); color: var(--fg); }
.tag b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tag:hover { text-decoration: none; border-color: var(--border-strong); }
.tag-danger { background: var(--tone-danger-bg); color: var(--tone-danger-fg); border-color: transparent; }

/* ---------- tables ---------- */
/* A table wider than its card scrolls here, with a hairline showing the edge is not the end of the content. */
.table-wrap { overflow-x: auto; scrollbar-width: thin;
  background: linear-gradient(to right, var(--bg-surface) 30%, transparent) left / 2rem 100% no-repeat local,
    linear-gradient(to left, var(--bg-surface) 30%, transparent) right / 2rem 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, oklch(0% 0 0 / .08), transparent) left / .7rem 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, oklch(0% 0 0 / .08), transparent) right / .7rem 100% no-repeat scroll; }
table.table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.table th, .table td { text-align: left; padding: .55rem var(--space-3); border-bottom: 1px solid var(--border);
  vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: var(--space-4); }
.table th:last-child, .table td:last-child { padding-right: var(--space-4); }
.table th { font-size: .6875rem; font-weight: 600; color: var(--muted-fg); white-space: nowrap;
  text-transform: uppercase; letter-spacing: var(--tracking-wide); background: var(--bg-surface); position: sticky;
  top: 0; z-index: 1; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable::after { content: " ↕"; opacity: .7; }
.table th[aria-sort="ascending"]::after { content: " ↑"; opacity: 1; color: var(--brand); }
.table th[aria-sort="descending"]::after { content: " ↓"; opacity: 1; color: var(--brand); }
.table tbody tr:hover { background: color-mix(in oklab, var(--bg-sunken) 65%, transparent); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; white-space: nowrap; }
/* A cell wants to stay on one line; a wide table scrolls inside .table-wrap rather than crushing its columns.
   Words never break mid-word: "Normal" and "project-x" must stay readable. Prose cells opt into wrapping. */
.table td { overflow-wrap: break-word; white-space: normal; }
.table td a, .table td code, .table td .mono, .table td .num, .table td .badge, .table td time,
.table td .nowrap, .table td .engine-mark { white-space: nowrap; }
/* a duration keeps its unit attached to its number */
.table td .nowrap, .table td .num { word-break: keep-all; }
.table td .badge, .table td > .xs, .table td > .small { vertical-align: middle; }
.table td .badge + .xs { margin-left: .4rem; }
.table td code:empty { display: none; }
/* a cell that stacks a label over its code (the Mode column) */
.table td .xs.muted { display: inline-block; margin-top: .1rem; }
.card.flush .table th:first-child, .card.flush .table td:first-child { padding-left: var(--space-5); }
.card.flush .table th:last-child, .card.flush .table td:last-child { padding-right: var(--space-5); }
.table td .mono, .table td code { font-size: var(--text-sm); }
.table.compact th, .table.compact td { padding: .35rem .625rem; font-size: var(--text-sm); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-toolbar { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border); flex-wrap: wrap; background: var(--bg-canvas); border-radius: var(--radius) var(--radius) 0 0; }
.table-toolbar .search { flex: 1 1 14rem; max-width: 24rem; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); font-size: var(--text-sm);
  color: var(--muted-fg); flex-wrap: wrap; }
.empty { text-align: center; padding: var(--space-10) var(--space-4); color: var(--muted-fg); }
.empty .icon { width: 2rem; height: 2rem; margin: 0 auto var(--space-3); opacity: .35; }
.empty h3 { color: var(--fg); margin-bottom: .2rem; font-size: var(--text-md); }
.empty p { font-size: var(--text-sm); max-width: 46ch; margin: 0 auto; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: var(--space-4); border-bottom: 1px solid var(--border); margin-bottom: var(--space-4);
  overflow-x: auto; scrollbar-width: thin; }
.tabs a, .tabs button { padding: .55rem .05rem; font-size: var(--text-base); color: var(--muted-fg); border: 0;
  border-bottom: 2px solid transparent; background: none; cursor: pointer; font: inherit; white-space: nowrap;
  margin-bottom: -1px; transition: color .12s, border-color .12s; }
.tabs a[aria-current="page"], .tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--brand);
  font-weight: 500; text-decoration: none; }
.tabs a:hover, .tabs button:hover { color: var(--fg); text-decoration: none; }
[role="tabpanel"][hidden] { display: none; }

/* ---------- dropdown / dialog / drawer / toast ---------- */
.menu { position: relative; display: inline-block; }
.menu-list { position: absolute; right: 0; top: calc(100% + .3rem); min-width: 11.5rem; background: var(--popover);
  color: var(--popover-foreground); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: var(--space-1); z-index: 40; display: none; }
.menu-list.left { right: auto; left: 0; }
.menu[data-open="true"] .menu-list { display: block; animation: menu-in .12s ease-out; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-.2rem); } }
.menu-item { display: flex; align-items: center; gap: .45rem; width: 100%; padding: .4rem .5rem; border-radius: var(--radius-xs);
  font-size: var(--text-base); color: inherit; background: none; border: 0; cursor: pointer; text-align: left; font: inherit; }
.menu-item:hover { background: var(--bg-sunken); text-decoration: none; }
.menu-item.danger { color: var(--danger); }
.menu-item[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.menu-sep { height: 1px; background: var(--border); margin: var(--space-1) 0; }
.menu-label { font-size: .6875rem; color: var(--muted-fg); padding: .3rem .5rem; text-transform: uppercase;
  letter-spacing: var(--tracking-wide); font-weight: 600; }

dialog.dialog { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card);
  color: var(--card-foreground); padding: 0; width: min(32rem, calc(100vw - 2rem)); box-shadow: var(--shadow-lg); }
dialog.dialog.lg { width: min(48rem, calc(100vw - 2rem)); }
dialog.dialog.xl { width: min(64rem, calc(100vw - 2rem)); }
dialog.dialog::backdrop { background: oklch(0% 0 0 / .45); backdrop-filter: blur(2px); }
.dialog-header { padding: var(--space-5) var(--space-5) var(--space-3); }
.dialog-title { font-size: var(--text-lg); font-weight: 600; letter-spacing: var(--tracking-tight); }
.dialog-desc { font-size: var(--text-sm); color: var(--muted-fg); margin-top: .25rem; line-height: 1.5; }
.dialog-body { padding: var(--space-3) var(--space-5) var(--space-5); display: flex; flex-direction: column;
  gap: var(--space-4); max-height: 70vh; overflow: auto; }
.dialog-footer { padding: var(--space-3) var(--space-5) var(--space-5); display: flex; justify-content: flex-end;
  gap: .55rem; flex-wrap: wrap; border-top: 1px solid var(--border); background: var(--bg-canvas);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(40rem, 100vw); background: var(--card);
  border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 45; transform: translateX(100%);
  transition: transform .2s; display: flex; flex-direction: column; }
.drawer[data-open="true"] { transform: none; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow: auto; padding: var(--space-4) var(--space-5); }
.overlay { position: fixed; inset: 0; background: oklch(0% 0 0 / .4); z-index: 44; display: none; }
.overlay[data-open="true"] { display: block; }

.toasts { position: fixed; top: var(--space-4); left: 50%; transform: translateX(-50%); z-index: 100; display: flex;
  flex-direction: column; gap: var(--space-2); width: min(28rem, calc(100vw - 2rem)); }
.toast { background: var(--popover); color: var(--popover-foreground); border: 1px solid var(--border);
  border-left: 3px solid var(--success); border-radius: var(--radius); padding: .6rem .8rem; box-shadow: var(--shadow-lg);
  font-size: var(--text-base); display: flex; gap: .5rem; align-items: flex-start; animation: toast-in .18s ease-out; }
.toast.error { border-left-color: var(--danger); } .toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }
.toast .close { margin-left: auto; background: none; border: 0; color: var(--muted-fg); cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 0 .15rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-.5rem); } }

/* Tone is carried by the full tinted border, the tinted surface and the icon, never a thick one-sided stripe. */
.callout { border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .7rem .9rem; font-size: var(--text-base); display: flex; gap: var(--space-3); align-items: flex-start;
  background: var(--card); line-height: 1.5; }
.callout .icon { flex-shrink: 0; margin-top: .1rem; }
.callout.info { border-color: color-mix(in oklab, var(--info) 35%, var(--border));
  background: var(--tone-info-bg); color: var(--tone-info-fg); }
.callout.warning { border-color: color-mix(in oklab, var(--warning) 35%, var(--border));
  background: var(--tone-warning-bg); color: var(--tone-warning-fg); }
.callout.danger { border-color: color-mix(in oklab, var(--danger) 35%, var(--border));
  background: var(--tone-danger-bg); color: var(--tone-danger-fg); }
.callout.success { border-color: color-mix(in oklab, var(--success) 35%, var(--border)); background: var(--tone-success-bg); color: var(--tone-success-fg); }
.callout b, .callout strong { font-weight: 600; }

/* ---------- progress / skeleton / misc ---------- */
.progress { height: .35rem; background: var(--border); border-radius: var(--radius-pill); overflow: hidden; min-width: 4rem; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: var(--radius-pill);
  transition: width .3s; }
.progress.warning > span { background: var(--warning); } .progress.danger > span { background: var(--danger); }
.usage { display: flex; align-items: center; gap: .5rem; font-size: var(--text-sm); min-width: 8rem; }
.skeleton { background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--border) 37%, var(--bg-sunken) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-xs); height: 1rem; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.avatar { width: 1.85rem; height: 1.85rem; border-radius: var(--radius-xs); background: var(--bg-sunken); color: var(--fg);
  border: 1px solid var(--border); display: grid; place-items: center; font-family: var(--font-mono); font-size: .7rem;
  font-weight: 600; flex-shrink: 0; }
.avatar.sm { width: 1.45rem; height: 1.45rem; font-size: .625rem; }
.secret { font-family: var(--font-mono); letter-spacing: .08em; }
.copy { cursor: copy; }
.copy.copied { outline: 2px solid var(--success); outline-offset: 1px; border-radius: var(--radius-xs); }
.divider-v { width: 1px; align-self: stretch; background: var(--border); }
.kbd { border: 1px solid var(--border); border-bottom-width: 2px; border-radius: var(--radius-xs); padding: 0 .3rem;
  font-size: .6875rem; background: var(--bg-sunken); font-family: var(--font-mono); }

.steps { display: flex; gap: .5rem; align-items: center; font-size: var(--text-sm); color: var(--muted-fg); flex-wrap: wrap; }
.steps .step { display: inline-flex; align-items: center; gap: .4rem; }
.steps .step .n { width: 1.35rem; height: 1.35rem; border-radius: var(--radius-xs); border: 1px solid var(--border-strong);
  display: grid; place-items: center; font-family: var(--font-mono); font-size: .6875rem; }
.steps .step[aria-current="step"] { color: var(--fg); font-weight: 500; }
.steps .step[aria-current="step"] .n { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
.steps .step.done .n { background: var(--tone-success-bg); border-color: transparent; color: var(--tone-success-fg); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 var(--space-4); border-left: 1px solid var(--border-strong); }
.timeline li { position: relative; padding: 0 0 var(--space-4) var(--space-4); font-size: var(--text-base); }
.timeline li::before { content: ""; position: absolute; left: calc(-1rem - 4px); top: .3rem; width: 7px; height: 7px;
  border-radius: 50%; background: var(--border-strong); }
.timeline li.success::before { background: var(--success); }
.timeline li.danger::before { background: var(--danger); }
.timeline li.running::before { background: var(--brand); }

.topology { display: flex; gap: var(--space-4); flex-wrap: wrap; align-items: stretch; }
.node { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: .6rem .75rem;
  min-width: 12rem; background: var(--card); cursor: pointer; transition: border-color .12s; }
.node:hover { border-color: var(--brand); }
.node .role { font-size: .6875rem; text-transform: uppercase; letter-spacing: var(--tracking-wide); color: var(--muted-fg);
  font-weight: 600; }
.node.primary { border-color: color-mix(in oklab, var(--brand) 55%, var(--border-strong)); }
.node .name { font-family: var(--font-mono); font-size: .78rem; margin: .15rem 0; }
.chart { width: 100%; min-height: 220px; }
.chart-title { font-size: var(--text-sm); font-weight: 500; margin-bottom: .2rem; }

/* ---------- signature: health rail ----------
   The one loud element: cluster lifecycle as a segmented meter. Each segment is a phase, its width is its share,
   its colour the phase tone. Used at the top of the cluster list and the dashboard block. */
.health-rail { display: flex; flex-direction: column; gap: var(--space-3); }
.health-rail .rail { display: flex; gap: 2px; height: .5rem; border-radius: var(--radius-pill); overflow: hidden;
  background: var(--border); }
.health-rail .rail a { display: block; height: 100%; background: var(--border-strong); transition: opacity .12s; }
.health-rail .rail a:hover { opacity: .78; }
/* Two phases share a tone (Creating and Updating are both "info"), so the colour keys on the phase itself: states a
   reader must tell apart never land on the same colour. The attribute selector outranks `.rail a` on purpose. */
.health-rail .rail a[data-phase="Running"] { background: var(--success); }
.health-rail .rail a[data-phase="Creating"] { background: var(--info); }
.health-rail .rail a[data-phase="Updating"] { background: var(--chart-4); }
.health-rail .rail a[data-phase="Stopping"] { background: var(--warning); }
.health-rail .rail a[data-phase="Deleting"] { background: color-mix(in oklab, var(--warning) 60%, var(--danger)); }
.health-rail .rail a[data-phase="Stopped"] { background: var(--border-strong); }
.health-rail .rail a[data-phase="Abnormal"], .health-rail .rail a[data-phase="Failed"] { background: var(--danger); }
.health-rail .swatch-sq[data-phase="Running"] { background: var(--success); }
.health-rail .swatch-sq[data-phase="Creating"] { background: var(--info); }
.health-rail .swatch-sq[data-phase="Updating"] { background: var(--chart-4); }
.health-rail .swatch-sq[data-phase="Stopping"] { background: var(--warning); }
.health-rail .swatch-sq[data-phase="Deleting"] { background: color-mix(in oklab, var(--warning) 60%, var(--danger)); }
.health-rail .swatch-sq[data-phase="Stopped"] { background: var(--border-strong); }
.health-rail .swatch-sq[data-phase="Abnormal"], .health-rail .swatch-sq[data-phase="Failed"] { background: var(--danger); }
.health-rail .rail-legend { display: flex; gap: var(--space-4); flex-wrap: wrap; font-size: var(--text-xs); }
.health-rail .rail-legend a { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted-fg); }
.health-rail .rail-legend a:hover { color: var(--fg); text-decoration: none; }
.health-rail .rail-legend b { color: var(--fg); font-variant-numeric: tabular-nums; font-weight: 600; }
.swatch-sq { width: .5rem; height: .5rem; border-radius: 2px; flex-shrink: 0; background: var(--border-strong); }

/* identity chip: the environment / project pair, mono, so it reads as a machine fact */
.env-chip { display: inline-flex; align-items: center; gap: .35rem; font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--muted-fg); border: 1px solid var(--border); border-radius: var(--radius-xs); padding: .05rem .4rem;
  background: var(--bg-surface); }
.env-chip .dot-live { width: .4rem; height: .4rem; border-radius: 50%; background: var(--success); flex-shrink: 0; }

/* ---------- log / terminal ---------- */
.log-view { background: var(--term-bg); color: var(--term-fg); font-family: var(--font-mono);
  font-size: .78rem; line-height: 1.6; padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm);
  overflow: auto; max-height: 70vh; white-space: pre-wrap; word-break: break-all; border: 1px solid var(--border); }
.log-view .ts { color: var(--term-dim); }
.log-view mark { background: var(--term-mark-bg); color: var(--term-mark-fg); border-radius: 2px; }
.log-view.error, .log-view .del { color: var(--term-del); }
.log-view.diff .add { color: var(--term-add); }
.log-view.diff .hunk { color: var(--term-accent); }
.terminal { background: var(--term-bg); border-radius: var(--radius-sm); padding: var(--space-2);
  height: 60vh; border: 1px solid var(--border); }

/* ---------- split-screen sign-in ---------- */
.login-screen { display: grid; min-height: 100vh; grid-template-columns: minmax(0, 1fr) minmax(22rem, .8fr); background: var(--bg-canvas); }
.login-identity { position: relative; display: flex; min-height: 100vh; flex-direction: column; justify-content: space-between; padding: clamp(var(--space-6), 7vw, var(--space-10)); background: var(--sidebar); color: var(--sidebar-foreground); }
.login-brand { display: inline-flex; width: fit-content; align-items: center; gap: var(--space-3); color: var(--sidebar-foreground); font-size: var(--text-lg); font-weight: 600; }
.login-brand:hover { text-decoration: none; }
.login-brand .brand-mark { width: 2.5rem; height: 2.5rem; font-size: 1.2rem; }
.login-intro { max-width: 39rem; padding: var(--space-10) 0; }
.login-intro h1 { max-width: 11ch; margin: var(--space-4) 0; color: var(--sidebar-foreground); font-size: clamp(2.4rem, 5vw, 4.5rem); line-height: 1.05; letter-spacing: -.04em; }
.login-sub { max-width: 40ch; color: var(--sidebar-muted); font-size: var(--text-lg); line-height: 1.6; }
.login-facts { display: flex; gap: clamp(var(--space-5), 6vw, var(--space-10)); margin: 0; }
.login-facts div { display: grid; gap: var(--space-1); }
.login-facts dt { color: var(--sidebar-muted); font-size: var(--text-sm); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.login-facts dd { margin: 0; color: var(--sidebar-foreground); font-family: var(--font-mono); font-size: var(--text-base); }
.login-identity-foot { margin-top: var(--space-6); color: var(--sidebar-muted); font-size: var(--text-sm); }
.login-form-panel { display: grid; min-height: 100vh; place-items: center; padding: var(--space-8); }
.login-form-wrap { width: min(100%, 26rem); }
.login-form-heading { margin-bottom: var(--space-6); }
.login-form-heading h2 { margin-bottom: var(--space-2); font-size: var(--text-2xl); }
.login-form-heading > p:last-child { color: var(--muted-fg); }
.login-form { border-color: var(--border); box-shadow: var(--shadow-sm); }
.login-form .card-body { gap: var(--space-4); padding: var(--space-6); }
.login-foot { margin-top: var(--space-5); color: var(--muted-fg); font-size: var(--text-sm); text-align: center; }
@media (max-width: 760px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-identity { min-height: auto; gap: var(--space-6); padding: var(--space-5) var(--space-5) var(--space-6); }
  .login-intro { padding: var(--space-3) 0 0; }
  .login-intro h1 { max-width: 16ch; margin: var(--space-2) 0; font-size: var(--text-2xl); }
  .login-sub { font-size: var(--text-base); }
  .login-facts { gap: var(--space-6); }
  .login-identity-foot { display: none; }
  .login-form-panel { min-height: auto; padding: var(--space-6) var(--space-5) var(--space-10); }
}

/* ---------- status pages (404 / error inside the frame) ---------- */
.status-page { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-8); align-items: start;
  padding: var(--space-8) 0; max-width: 56rem; }
@media (max-width: 720px) { .status-page { grid-template-columns: 1fr; gap: var(--space-4); padding: var(--space-4) 0; } }
.status-code { font-family: var(--font-mono); font-size: 3.5rem; font-weight: 700; line-height: 1; letter-spacing: -.05em;
  color: var(--muted-fg); font-variant-numeric: tabular-nums; }
.status-code.danger { color: var(--danger); }
.status-body h3 { font-size: var(--text-xl); margin-bottom: .35rem; letter-spacing: -.02em; }
.status-body .desc { color: var(--muted-fg); font-size: var(--text-base); line-height: 1.6; max-width: 60ch;
  overflow-wrap: anywhere; }

/* ---------- utilities the templates already ask for ----------
   These names appear in the ported views but had no rule, so the markup silently did nothing. */
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-normal { font-weight: 400; }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-right { text-align: right; }
.uppercase { text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.grow { flex: 1 1 auto; min-width: 0; }
.items-center { align-items: center; }
.ml-1 { margin-left: var(--space-1); }
.ml-2 { margin-left: var(--space-2); }
.mb-0-5 { margin-bottom: var(--space-1); }
.h2 { font-size: var(--text-lg); font-weight: 600; letter-spacing: var(--tracking-tight); }
/* the badge base is already neutral; this exists so an explicit `neutral` tone reads the same */
.badge.neutral { background: var(--tone-neutral-bg); color: var(--tone-neutral-fg); }
dialog.dialog.dialog-lg { width: min(48rem, calc(100vw - 2rem)); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; }
}
@media print {
  .sidebar, .topbar, .btn, .menu { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .card { break-inside: avoid; }
  body { background: #fff; }
}