:root {
  --background: oklch(98.4% 0.004 255);
  --foreground: oklch(21% 0.02 260);
  --card: oklch(100% 0 0);
  --card-foreground: var(--foreground);
  --muted: oklch(96.2% 0.006 255);
  --muted-foreground: oklch(52% 0.02 258);
  --border: oklch(91.5% 0.008 255);
  --input: oklch(89% 0.01 255);
  --primary: oklch(50% 0.17 258);
  --primary-foreground: oklch(98.5% 0.005 255);
  --secondary: oklch(95.5% 0.008 255);
  --secondary-foreground: var(--foreground);
  --accent: oklch(94.5% 0.014 258);
  --destructive: oklch(55% 0.21 27);
  --destructive-foreground: oklch(98.5% 0 0);
  --success: oklch(56% 0.14 152);
  --warning: oklch(68% 0.15 72);
  --info: oklch(58% 0.12 230);
  --ring: oklch(60% 0.15 258);
  --sidebar: oklch(96.8% 0.007 255);
  --sidebar-primary: var(--primary);
  --sidebar-accent: oklch(93.5% 0.012 258);
  --popover: var(--card);
  --radius: 8px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: oklch(17% 0.012 262); --foreground: oklch(94% 0.008 255);
    --card: oklch(20.5% 0.013 262); --muted: oklch(24% 0.014 262); --muted-foreground: oklch(70% 0.02 258);
    --border: oklch(29% 0.015 262); --input: oklch(33% 0.016 262);
    --primary: oklch(66% 0.15 258); --primary-foreground: oklch(16% 0.02 262);
    --secondary: oklch(25% 0.014 262); --accent: oklch(28% 0.03 258);
    --destructive: oklch(64% 0.19 25); --success: oklch(70% 0.14 152); --warning: oklch(78% 0.14 75); --info: oklch(72% 0.11 230);
    --sidebar: oklch(19% 0.013 262); --sidebar-accent: oklch(26% 0.025 258);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --background: oklch(17% 0.012 262); --foreground: oklch(94% 0.008 255);
  --card: oklch(20.5% 0.013 262); --muted: oklch(24% 0.014 262); --muted-foreground: oklch(70% 0.02 258);
  --border: oklch(29% 0.015 262); --input: oklch(33% 0.016 262);
  --primary: oklch(66% 0.15 258); --primary-foreground: oklch(16% 0.02 262);
  --secondary: oklch(25% 0.014 262); --accent: oklch(28% 0.03 258);
  --destructive: oklch(64% 0.19 25); --success: oklch(70% 0.14 152); --warning: oklch(78% 0.14 75); --info: oklch(72% 0.11 230);
  --sidebar: oklch(19% 0.013 262); --sidebar-accent: oklch(26% 0.025 258);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--background); color: var(--foreground); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted-foreground); }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.rail { background: var(--sidebar); border-right: 1px solid var(--border); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; padding: 4px 10px 14px; letter-spacing: -0.01em; }
.brand svg { color: var(--primary); }
.rail a.nav { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; text-decoration: none; color: var(--muted-foreground); font-weight: 500; }
.rail a.nav:hover { background: var(--sidebar-accent); color: var(--foreground); }
.rail a.nav.active { background: var(--sidebar-primary); color: var(--primary-foreground); }
.rail .band { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-foreground); padding: 14px 10px 4px; }
.rail .foot { margin-top: auto; font-size: 12px; color: var(--muted-foreground); padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; }
main { padding: 24px 28px 48px; min-width: 0; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head h1 { font-size: 20px; margin: 0; letter-spacing: -0.015em; font-weight: 650; }
.crumbs { font-size: 13px; color: var(--muted-foreground); margin-bottom: 6px; }
.crumbs a { text-decoration: none; } .crumbs a:hover { text-decoration: underline; }
.cluster { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.reason { font-size: 12.5px; color: var(--muted-foreground); margin-top: 6px; text-align: right; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--card); color: var(--foreground); font: 500 13px/1 var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--accent); }
.btn:focus-visible, .iconbtn:focus-visible, a.nav:focus-visible, .tab:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-foreground); border-color: transparent; }
.btn.primary:hover:not(:disabled) { background: color-mix(in oklch, var(--primary) 88%, black); }
.btn.danger { background: var(--destructive); color: var(--destructive-foreground); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 6px; border: 0; background: transparent; color: var(--muted-foreground); cursor: pointer; }
.iconbtn:hover:not(:disabled) { background: var(--accent); color: var(--foreground); }
.iconbtn:disabled { opacity: .35; cursor: not-allowed; }

/* cards + stats */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.card > .card-h { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { padding: 14px 16px; min-height: 92px; display: flex; flex-direction: column; }
.stat .label { font-size: 12.5px; color: var(--muted-foreground); }
.stat .figure { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .foot { font-size: 12px; color: var(--muted-foreground); margin-top: auto; min-height: 18px; }
.bar { height: 6px; border-radius: 3px; background: var(--muted); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--primary); }
.bar.warn > i { background: var(--warning); } .bar.crit > i { background: var(--destructive); }

/* tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 550; color: var(--muted-foreground); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--card); }
td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in oklch, var(--accent) 45%, transparent); }
tr.sel td { background: color-mix(in oklch, var(--primary) 8%, transparent); }
td.actions { text-align: right; white-space: nowrap; width: 1%; }
td a.rowlink { font-weight: 550; text-decoration: none; } td a.rowlink:hover { text-decoration: underline; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted-foreground); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted-foreground); }
input[type=checkbox].cb { appearance: none; width: 16px; height: 16px; border: 1px solid var(--input); border-radius: 4px; background: var(--card); display: inline-grid; place-content: center; cursor: pointer; margin: 0; }
input[type=checkbox].cb:checked { background: var(--primary); border-color: var(--primary); }
input[type=checkbox].cb:checked::after { content: ""; width: 8px; height: 4px; border: 2px solid var(--primary-foreground); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
input[type=checkbox].cb:disabled { opacity: .4; cursor: not-allowed; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 550; white-space: nowrap; background: var(--muted); color: var(--muted-foreground); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
/* Status colours carry meaning; they stay as fixed semantic tokens. */
.badge.success { background: color-mix(in oklch, var(--success) 15%, transparent); color: var(--success); }
.badge.warning { background: color-mix(in oklch, var(--warning) 18%, transparent); color: color-mix(in oklch, var(--warning) 80%, var(--foreground)); }
.badge.danger { background: color-mix(in oklch, var(--destructive) 14%, transparent); color: var(--destructive); }
.badge.info { background: color-mix(in oklch, var(--info) 15%, transparent); color: var(--info); }
.badge.primary { background: color-mix(in oklch, var(--primary) 14%, transparent); color: var(--primary); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 8px 12px; font-weight: 550; color: var(--muted-foreground); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; background: none; border-top: 0; border-left: 0; border-right: 0; cursor: pointer; font-size: 14px; }
.tab:hover { color: var(--foreground); }
.tab.active { color: var(--foreground); border-bottom-color: var(--primary); }

/* menu, dialog, hint, toast */
.menuwrap { position: relative; display: inline-block; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); min-width: 180px; background: var(--popover); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px -6px rgb(0 0 0 / .18); padding: 4px; z-index: 30; }
.menu button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 7px 10px; border: 0; background: none; color: var(--foreground); font: 13px var(--font); border-radius: 5px; cursor: pointer; text-align: left; }
.menu button:hover:not(:disabled) { background: var(--accent); }
.menu button:disabled { opacity: .45; cursor: not-allowed; }
.menu button.danger { color: var(--destructive); }
.menu .sep { height: 1px; background: var(--border); margin: 4px 0; }
.overlay { position: fixed; inset: 0; background: rgb(0 0 0 / .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.dialog { background: var(--card); border: 1px solid var(--border); border-radius: 10px; width: min(480px, 100%); padding: 20px; box-shadow: 0 20px 50px -10px rgb(0 0 0 / .35); }
.dialog h2 { margin: 0 0 8px; font-size: 16px; }
.dialog p { margin: 0 0 12px; color: var(--muted-foreground); }
.dialog .cluster { justify-content: flex-end; margin-top: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 550; }
.input { height: 34px; border: 1px solid var(--input); border-radius: 6px; padding: 0 10px; background: var(--card); color: var(--foreground); font: 13px var(--font); }
.input:focus { outline: 2px solid var(--ring); outline-offset: 0; border-color: transparent; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 8px; }
.hintwrap { position: relative; display: inline-flex; }
.hintwrap .hint { position: absolute; bottom: calc(100% + 6px); right: 0; background: var(--foreground); color: var(--background); font-size: 12px; padding: 5px 8px; border-radius: 5px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 40; }
.hintwrap:hover .hint, .hintwrap:focus-within .hint { opacity: 1; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--success); border-radius: 8px; padding: 10px 14px; min-width: 260px; max-width: 420px; box-shadow: 0 8px 24px -8px rgb(0 0 0 / .25); font-size: 13px; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.toast.error { border-left-color: var(--destructive); }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid color-mix(in oklch, var(--warning) 45%, transparent); background: color-mix(in oklch, var(--warning) 10%, var(--card)); font-size: 13px; }
.banner.danger { border-color: color-mix(in oklch, var(--destructive) 45%, transparent); background: color-mix(in oklch, var(--destructive) 8%, var(--card)); }

/* build panel */
.steps { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 4px 0 12px; }
.step { font-size: 12px; color: var(--muted-foreground); }
.step > i { display: block; height: 4px; border-radius: 2px; background: var(--muted); margin-bottom: 6px; }
.step.done > i { background: var(--success); } .step.now > i { background: var(--primary); animation: pulse 1.4s ease-in-out infinite; }
.step.now { color: var(--foreground); font-weight: 600; } .step.failed > i { background: var(--destructive); }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .step.now > i { animation: none; } }
.log { background: oklch(18% 0.012 262); color: oklch(90% 0.01 255); font: 12px/1.55 var(--mono); padding: 12px 14px; border-radius: 0 0 8px 8px; height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 0; }
.log .ph { color: oklch(78% 0.12 258); font-weight: 600; }
.log .err { color: oklch(72% 0.17 25); }
.log .ok { color: oklch(78% 0.14 152); }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; padding: 16px; font-size: 13px; }
.kv dt { color: var(--muted-foreground); } .kv dd { margin: 0; word-break: break-all; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.timeline { list-style: none; margin: 0; padding: 4px 16px; }
.timeline li { display: grid; grid-template-columns: 150px 120px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }

/* palette */
.palette { width: min(560px, 100%); padding: 0; overflow: hidden; align-self: start; margin-top: 12vh; }
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--border); padding: 14px 16px; font: 15px var(--font); background: transparent; color: var(--foreground); outline: none; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 340px; overflow: auto; }
.palette li { padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; font-size: 13.5px; }
.palette li.on { background: var(--accent); }
kbd { font: 11px var(--mono); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; color: var(--muted-foreground); background: var(--muted); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px 12px; }
  .rail .band, .rail .foot { display: none; }
  .brand { padding: 4px 8px; }
  main { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .steps { grid-template-columns: repeat(4, 1fr); }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
}
