/* ============================================================
 * Shadow Live Services — control panel
 *
 * Aesthetic direction: "Console" — technical / vigilant / calm.
 * Ground-up layout: no sidebar, no card grids. A command header with
 * horizontal nav, a persistent telemetry strip, flat panels divided by
 * hairline rules, ledger lists, data tables, scoreboard tiles and a
 * status banner. Built for operators reading state at a glance.
 *
 * - Type: Space Grotesk (display + UI), IBM Plex Mono (data: numerals,
 *   codes, timestamps, micro-labels, nav). Google Fonts.
 * - Color: near-black blue console #04060a. Layering via surface steps
 *   and 1px hairlines — shadows only on overlays. Brand: ice cyan
 *   #6fe4fb, used sparingly. Status semantics are sacred: green = ok,
 *   amber = degraded, red = down, blue = maintenance/info.
 * - Density: tight. 4px scale.
 * - Radius: sharp. 2px. No pills.
 * - Components: outlined/flat by default; filled ice primary only.
 * - Icons: inline SVG, 1.7px stroke (see icon() in app.js).
 * - Motion: quiet. 140ms ease; slow pulse on live dots; scanning
 *   progress bar. prefers-reduced-motion honored.
 * ============================================================ */

:root {
  color-scheme: dark;
  --bg: #04060a;
  --bg-2: #090c12;
  --surface: #0d1118;
  --surface-2: #121722;
  --surface-3: #1a2130;
  --line: #232c3c;
  --line-soft: #181f2b;
  --text: #e8edf4;
  --text-2: #9aa7b9;
  --text-3: #5d6c80;
  --brand: #6fe4fb;
  --brand-dim: #38bdd8;
  --brand-ink: #04181d;
  --green: #3fde8c;
  --amber: #ffc857;
  --red: #ff6b6b;
  --blue: #6ca8ff;
  --grey: #74839a;
  --radius: 2px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
  --sans: "Space Grotesk", ui-sans-serif, system-ui, "Segoe UI", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-family: var(--sans);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(111, 228, 251, 0.25); }

* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; font-weight: 600; letter-spacing: 0.01em; }
h2 { font-size: 14px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; }
a { color: var(--brand); text-decoration-color: rgba(111, 228, 251, 0.4); }
code { font-family: var(--mono); }

button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

.icon { display: inline-flex; flex: none; }
.icon svg { display: block; }

/* shared micro-label look */
.fieldset > .fs-title, .kpi .label, .metric-mini .mm-label,
th, .readout-section h4, .health-pill, .tm-label, .sb-eyebrow,
.login-eyebrow, .page-sub, .gt-h, .tile-state {
  font-family: var(--mono);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 32px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-2);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, opacity 140ms ease;
}
.btn:hover { background: var(--surface-2); border-color: #2e3a4d; color: var(--text); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
  font-weight: 600;
}
.btn.primary:hover { background: #8eeafd; border-color: #8eeafd; color: var(--brand-ink); }
.btn.danger { color: var(--red); border-color: rgba(255, 107, 107, 0.35); background: transparent; }
.btn.danger:hover { background: rgba(255, 107, 107, 0.1); border-color: rgba(255, 107, 107, 0.55); color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 26px; padding: 2px 9px; font-size: 12px; }
.btn.block { width: 100%; }
.btn.icon-only { width: 32px; padding: 0; }
.btn.sm.icon-only { width: 26px; }
.btn:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible,
.ch-tab:focus-visible, [role="button"]:focus-visible {
  outline: 1.5px solid var(--brand);
  outline-offset: 1px;
}

/* ---------- form fields ---------- */
.field { display: grid; gap: 5px; }
.field > label, .field-label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--text-3); }
input[type="text"], input[type="password"], input[type="search"],
input:not([type]), select, textarea {
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  font-size: 13px;
  transition: border-color 140ms ease;
}
input:hover, select:hover, textarea:hover { border-color: #2e3a4d; }
textarea { min-height: 90px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
input::placeholder { color: var(--text-3); }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235d6c80' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-grid .span-2 { grid-column: 1 / -1; }
.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  cursor: pointer;
  transition: border-color 140ms ease;
}
.check:hover { border-color: #2e3a4d; }
.check input { width: 15px; height: 15px; margin: 2px 0 0; flex: none; accent-color: var(--brand); }
.check .check-text { display: grid; gap: 2px; font-size: 13px; }
.check .check-text small { color: var(--text-3); font-size: 11.5px; }
.check-group { display: grid; gap: 7px; }

/* ============================================================
 * SHELL — command header + telemetry strip + content column
 * ============================================================ */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.console-head {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: stretch; gap: 12px;
  padding: 0 16px;
  min-height: 52px;
  background: rgba(4, 6, 10, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.ch-brand { display: flex; align-items: center; gap: 10px; padding-right: 4px; }
.brand-mark {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius);
  background: rgba(111, 228, 251, 0.07);
  border: 1px solid rgba(111, 228, 251, 0.35);
  color: var(--brand);
  box-shadow: 0 0 14px rgba(111, 228, 251, 0.12);
}
.brand-mark svg { display: block; }
.brand-word { display: grid; line-height: 1.15; }
.brand-word b { font-size: 13px; font-weight: 600; white-space: nowrap; }
.brand-word span {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.ch-nav {
  display: flex; align-items: stretch;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}
.ch-nav::-webkit-scrollbar { display: none; }
.ch-sep { width: 1px; background: var(--line-soft); margin: 16px 5px; flex: none; }
.ch-tab {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: color 140ms ease;
}
.ch-tab:hover { color: var(--text-2); }
.ch-tab.active { color: var(--brand); }
.ch-tab.active::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px; bottom: -1px;
  height: 2px;
  background: var(--brand);
  box-shadow: 0 0 8px rgba(111, 228, 251, 0.6);
}
.ch-tab .count {
  font-size: 10px;
  padding: 0 5px;
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--text-2);
}
.ch-tab .count.alert { background: rgba(255, 107, 107, 0.16); color: var(--red); }

.ch-tools { display: flex; align-items: center; gap: 10px; }
.ch-tools .clock {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.health-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 10px;
  background: var(--surface);
  color: var(--text-2);
  white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grey); flex: none; }
.dot.green { background: var(--green); box-shadow: 0 0 7px rgba(63, 222, 140, 0.7); }
.dot.amber { background: var(--amber); box-shadow: 0 0 7px rgba(255, 200, 87, 0.7); }
.dot.red { background: var(--red); box-shadow: 0 0 7px rgba(255, 107, 107, 0.7); animation: blink 1.4s ease-in-out infinite; }
.dot.blue { background: var(--blue); box-shadow: 0 0 7px rgba(108, 168, 255, 0.6); }
@keyframes blink { 50% { opacity: 0.45; } }

/* telemetry strip */
.telemetry {
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line-soft);
  padding: 0 20px;
}
.tm-item {
  display: grid;
  gap: 1px;
  align-content: center;
  padding: 8px 22px 8px 0;
  margin-right: 22px;
  border-right: 1px solid var(--line-soft);
  white-space: nowrap;
}
.tm-item:last-child { border-right: 0; }
.tm-label { font-size: 9px; color: var(--text-3); }
.tm-value { font-family: var(--mono); font-size: 15px; font-weight: 600; line-height: 1.2; }
.tm-value.green { color: var(--green); }
.tm-value.amber { color: var(--amber); }
.tm-value.red { color: var(--red); }
.tm-value.blue { color: var(--blue); }

/* content column */
.content {
  width: min(100%, 1280px);
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: grid;
  gap: 22px;
  align-content: start;
  flex: 1;
}
.page { display: grid; gap: 26px; }
.page-head { display: grid; gap: 3px; }
.page-head h1 { font-size: 21px; }
.page-sub { font-size: 10px; color: var(--text-3); }

/* ============================================================
 * PANELS — flat sections with eyebrow rules (replaces cards)
 * ============================================================ */
.panel { display: grid; gap: 13px; }
.panel-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.panel-head .titles { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1 1 180px; flex-wrap: wrap; }
.panel-head .titles h2 {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text);
}
.panel-head .titles h2::before { content: "// "; color: var(--brand-dim); }
.panel-head .titles p { font-size: 11px; color: var(--text-3); font-family: var(--mono); }
.panel-head .actions { margin-left: auto; display: flex; gap: 7px; flex-wrap: wrap; }

/* cards remain for modal/detail internals */
.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px;
}
.card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head .titles { display: grid; gap: 3px; min-width: 0; flex: 1 1 180px; }
.card-head .titles h2 {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-2);
}
.card-head .titles p { font-size: 12px; color: var(--text-3); }
.card-head .actions { margin-left: auto; display: flex; gap: 7px; flex-wrap: wrap; }

.section-grid { display: grid; gap: 22px; }
.cols-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 26px; align-items: start; }

/* ============================================================
 * SYSTEM STATUS BANNER
 * ============================================================ */
.sysbanner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-top: 2px solid var(--grey);
  border-radius: var(--radius);
  overflow: hidden;
}
.sysbanner::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(480px 130px at 0% 0%, rgba(116, 131, 154, 0.1), transparent 70%);
}
.sysbanner.green { border-top-color: var(--green); }
.sysbanner.green::before { background: radial-gradient(480px 130px at 0% 0%, rgba(63, 222, 140, 0.1), transparent 70%); }
.sysbanner.amber { border-top-color: var(--amber); }
.sysbanner.amber::before { background: radial-gradient(480px 130px at 0% 0%, rgba(255, 200, 87, 0.1), transparent 70%); }
.sysbanner.red { border-top-color: var(--red); }
.sysbanner.red::before { background: radial-gradient(480px 130px at 0% 0%, rgba(255, 107, 107, 0.12), transparent 70%); }
.sb-main { display: grid; gap: 5px; position: relative; }
.sb-eyebrow { font-size: 9.5px; color: var(--text-3); }
.sb-headline {
  font-family: var(--mono);
  font-size: clamp(20px, 3.2vw, 30px);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.1;
}
.sysbanner.green .sb-headline { color: var(--green); text-shadow: 0 0 22px rgba(63, 222, 140, 0.35); }
.sysbanner.amber .sb-headline { color: var(--amber); text-shadow: 0 0 22px rgba(255, 200, 87, 0.35); }
.sysbanner.red .sb-headline { color: var(--red); text-shadow: 0 0 22px rgba(255, 107, 107, 0.4); }
.sb-sub { font-size: 12.5px; color: var(--text-2); }
.sb-actions { display: flex; gap: 8px; flex-wrap: wrap; position: relative; }

/* ============================================================
 * FLEET BOARD — scoreboard tiles
 * ============================================================ */
.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.tile {
  display: grid;
  border: 1px solid var(--line-soft);
  border-top: 2px solid var(--grey);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.tile.click { width: 100%; color: inherit; text-align: left; cursor: pointer; padding: 0; transition: background 140ms ease, border-color 140ms ease; }
.tile.click:hover { background: var(--surface-2); border-color: #2e3a4d; }
.tile.green { border-top-color: var(--green); }
.tile.amber { border-top-color: var(--amber); }
.tile.red { border-top-color: var(--red); }
.tile.blue { border-top-color: var(--blue); }
.tile-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
}
.tile-head b { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.tile-state { font-size: 9.5px; color: var(--text-3); white-space: nowrap; }
.tile.green .tile-state { color: var(--green); }
.tile.amber .tile-state { color: var(--amber); }
.tile.red .tile-state { color: var(--red); }
.tile.blue .tile-state { color: var(--blue); }
.tile-body { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 11px; }
.tile-foot {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 7px 11px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
}
.tile-foot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.metric-mini { display: grid; gap: 4px; }
.metric-mini .mm-label { font-size: 9px; color: var(--text-3); }
.metric-mini .mm-value { font-family: var(--mono); font-size: 12.5px; font-weight: 500; }
.bar { height: 3px; background: var(--bg); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand-dim); transition: width 300ms ease; }
.bar.warn > span { background: var(--amber); }
.bar.crit > span { background: var(--red); }
.bar.none { background: repeating-linear-gradient(90deg, var(--bg) 0 5px, var(--surface-3) 5px 10px); }

/* ============================================================
 * OPS COLUMNS + LEDGER ROWS
 * ============================================================ */
.ops-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.95fr) minmax(260px, 0.8fr);
  gap: 26px;
  align-items: start;
}
.ops-list {
  display: grid;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-2);
  overflow: hidden;
}
.ops-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--text);
  text-align: left;
}
.ops-row:last-child { border-bottom: 0; }
.ops-row.click { cursor: pointer; transition: background 140ms ease; }
.ops-row.click:hover { background: var(--surface-2); }
.ops-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--grey); flex: none; }
.ops-dot.green { background: var(--green); box-shadow: 0 0 6px rgba(63, 222, 140, 0.6); }
.ops-dot.amber { background: var(--amber); box-shadow: 0 0 6px rgba(255, 200, 87, 0.6); }
.ops-dot.red { background: var(--red); box-shadow: 0 0 6px rgba(255, 107, 107, 0.6); }
.ops-dot.blue { background: var(--blue); box-shadow: 0 0 6px rgba(108, 168, 255, 0.55); }
.ops-main { display: grid; gap: 1px; min-width: 0; }
.ops-main b { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ops-main small, .ops-meta { color: var(--text-3); font-size: 11px; }
.ops-meta { font-family: var(--mono); font-size: 10.5px; white-space: nowrap; }

/* generic ledger list (incidents, channels, permissions, activity) */
.list {
  display: grid;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-2);
  overflow: hidden;
}
.list > * { border-bottom: 1px solid var(--line-soft); }
.list > *:last-child { border-bottom: 0; }
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 13px;
  background: transparent;
  transition: background 140ms ease;
}
.row:hover { background: var(--surface-2); }
.row .row-main { display: grid; gap: 5px; min-width: 0; flex: 1; }
.row .row-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row .row-title b { font-size: 13.5px; font-weight: 600; }
.row .row-meta { font-size: 11.5px; color: var(--text-3); display: flex; gap: 4px 13px; flex-wrap: wrap; }
.row .row-meta code { color: var(--brand-dim); font-size: 11px; }
.row .row-actions { display: flex; gap: 6px; flex: none; }
.row.compact { padding: 9px 11px; }

/* skeleton rows inside ledgers */
.list .skeleton { border-bottom: 1px solid var(--line-soft); }

/* ============================================================
 * DATA TABLES (instances / servers)
 * ============================================================ */
.gtable {
  display: grid;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-2);
  overflow-x: auto;
}
.gt-row {
  display: grid;
  grid-template-columns: var(--cols);
  gap: 12px;
  align-items: center;
  padding: 9px 13px;
  border-bottom: 1px solid var(--line-soft);
  min-width: max-content;
  width: 100%;
}
.gt-row:last-child { border-bottom: 0; }
.gt-row:not(.gt-head):hover { background: var(--surface-2); }
.gt-head { background: var(--bg); padding-top: 7px; padding-bottom: 7px; }
.gt-h { font-size: 9.5px; color: var(--text-3); }
.gt-cell { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 12.5px; }
.gt-cell.mono { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); }
.gt-cell code { color: var(--brand-dim); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gt-cell b { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gt-cell .sub { color: var(--text-3); font-size: 11px; }
.gt-name { gap: 9px; }
.gt-name .name-wrap { display: grid; gap: 1px; min-width: 0; }
.gt-actions { justify-content: flex-end; gap: 6px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: var(--surface-3);
  border: 1px solid transparent;
  color: var(--text-2);
  white-space: nowrap;
}
.badge.green { background: rgba(63, 222, 140, 0.1); border-color: rgba(63, 222, 140, 0.25); color: var(--green); }
.badge.amber { background: rgba(255, 200, 87, 0.1); border-color: rgba(255, 200, 87, 0.25); color: var(--amber); }
.badge.red { background: rgba(255, 107, 107, 0.1); border-color: rgba(255, 107, 107, 0.25); color: var(--red); }
.badge.blue { background: rgba(108, 168, 255, 0.1); border-color: rgba(108, 168, 255, 0.25); color: var(--blue); }
.badge.grey { background: var(--surface-3); border-color: var(--line); color: var(--text-2); }

/* ---------- KPI (access page) ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.kpi {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 13px 15px;
  display: grid; gap: 5px;
  overflow: hidden;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--line); }
.kpi.green::before { background: var(--green); }
.kpi.amber::before { background: var(--amber); }
.kpi.red::before { background: var(--red); }
.kpi .label { font-size: 9.5px; color: var(--text-3); display: flex; align-items: center; gap: 7px; }
.kpi .value { font-family: var(--mono); font-size: 24px; font-weight: 600; line-height: 1.05; }
.kpi .sub { font-size: 11.5px; color: var(--text-3); }
.kpi.green .value { color: var(--green); }
.kpi.amber .value { color: var(--amber); }
.kpi.red .value { color: var(--red); }

/* ---------- detail workspaces (modals) ---------- */
.detail-hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 14px 14px 17px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}
.detail-hero::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--grey); }
.detail-hero.green::before { background: var(--green); box-shadow: 0 0 12px rgba(63, 222, 140, 0.55); }
.detail-hero.amber::before { background: var(--amber); box-shadow: 0 0 12px rgba(255, 200, 87, 0.55); }
.detail-hero.red::before { background: var(--red); box-shadow: 0 0 12px rgba(255, 107, 107, 0.55); }
.detail-hero.blue::before { background: var(--blue); box-shadow: 0 0 12px rgba(108, 168, 255, 0.5); }
.detail-hero h2 { font-size: 16px; margin-bottom: 5px; }
.detail-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.detail-grid .card { padding: 13px; }
.detail-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 7px; }
.inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }

/* ---------- real tables (audit, readouts) ---------- */
.table-wrap { border: 1px solid var(--line-soft); border-radius: var(--radius); overflow-x: auto; background: var(--bg-2); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); }
th { font-size: 10px; color: var(--text-3); background: var(--bg); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td code { color: var(--brand-dim); font-size: 11.5px; }

/* ---------- toolbar / filters ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 170px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button {
  border: 0; background: transparent; color: var(--text-3);
  padding: 5px 12px; font-weight: 500; font-size: 12px; cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}
.seg button + button { border-left: 1px solid var(--line-soft); }
.seg button:hover { color: var(--text-2); }
.seg button.active { background: var(--surface-3); color: var(--text); }

/* ---------- empty / loading ---------- */
.empty {
  display: grid; gap: 9px; justify-items: center; text-align: center;
  padding: 32px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13px;
}
.empty .ico {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-3);
  font-size: 15px;
  background: var(--bg-2);
}
.empty.good { border-color: rgba(63, 222, 140, 0.3); background: rgba(63, 222, 140, 0.04); }
.empty.good .ico { border-color: rgba(63, 222, 140, 0.35); color: var(--green); background: rgba(63, 222, 140, 0.07); }
.skeleton { border-radius: var(--radius); background: var(--surface-2); position: relative; overflow: hidden; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.04), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.skeleton.row-sk { height: 52px; }
.skeleton.kpi-sk { height: 92px; }
.skeleton.card-sk { height: 120px; }

/* ---------- checklist ---------- */
.checklist {
  display: grid;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-2);
  overflow: hidden;
}
.check-step {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.check-step:last-child { border-bottom: 0; }
.check-step .mark {
  width: 22px; height: 22px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px; font-weight: 600;
  background: var(--bg); color: var(--text-3);
  border: 1px solid var(--line);
}
.check-step.done .mark { background: rgba(63, 222, 140, 0.1); color: var(--green); border-color: rgba(63, 222, 140, 0.3); }
.check-step .cs-text { display: grid; gap: 1px; flex: 1; }
.check-step .cs-text b { font-size: 13px; font-weight: 600; }
.check-step .cs-text span { font-size: 11.5px; color: var(--text-3); }
.check-step.done .cs-text b { color: var(--text-2); }

/* ---------- key/value ---------- */
.kv { display: grid; gap: 0; }
.kv .kv-row {
  display: grid; grid-template-columns: minmax(150px, 240px) 1fr; gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}
.kv .kv-row:last-child { border-bottom: 0; }
.kv .kv-row .k { font-size: 12px; color: var(--text-3); }
.kv .kv-row .v { font-size: 12.5px; overflow-wrap: anywhere; }
.kv .kv-row .v code { color: var(--brand-dim); font-size: 11.5px; overflow-wrap: anywhere; }

/* ============================================================
 * LOGIN — split console gate
 * ============================================================ */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}
.login-side {
  display: flex;
  flex-direction: column;
  gap: 34px;
  padding: 42px 48px;
  background:
    radial-gradient(640px 420px at 18% 0%, rgba(111, 228, 251, 0.08), transparent 70%),
    radial-gradient(rgba(154, 167, 185, 0.07) 1px, transparent 1px),
    var(--bg-2);
  background-size: auto, 26px 26px, auto;
  border-right: 1px solid var(--line);
}
.login-side .brand { display: flex; align-items: center; gap: 11px; }
.login-side .brand-mark { width: 36px; height: 36px; }
.login-hero { display: grid; gap: 14px; margin-top: auto; }
.login-hero h2 { font-size: clamp(26px, 3.4vw, 38px); font-weight: 600; line-height: 1.12; letter-spacing: -0.01em; }
.login-hero p { color: var(--text-2); font-size: 13.5px; line-height: 1.6; max-width: 46ch; }
.login-points {
  margin: 0; padding: 0;
  list-style: none;
  display: grid; gap: 9px;
}
.login-points li {
  position: relative;
  padding-left: 18px;
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.03em;
}
.login-points li::before {
  content: ">";
  position: absolute; left: 0;
  color: var(--brand-dim);
}
.login-foot {
  margin-top: auto;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  color: var(--text-3);
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
}
.login-main { display: grid; place-items: center; padding: 32px 24px; }
.login-panel { width: min(100%, 340px); display: grid; gap: 14px; }
.login-eyebrow { font-size: 9.5px; color: var(--brand-dim); }
.login-panel h1 { font-size: 22px; }
.login-panel p.sub { color: var(--text-3); font-size: 12.5px; line-height: 1.5; }
.login-error { color: var(--red); font-size: 12px; min-height: 17px; font-family: var(--mono); }
.login-panel .muted { font-size: 11.5px; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(2, 3, 6, 0.8);
  backdrop-filter: blur(3px);
}
.modal {
  width: min(100%, 620px);
  max-height: 90vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.modal.wide { width: min(100%, 840px); }
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.modal-head h2 {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text);
}
.modal-head h2::before { content: "// "; color: var(--brand-dim); }
.modal-body { padding: 18px; overflow-y: auto; display: grid; gap: 15px; }
.modal-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 13px 18px;
  border-top: 1px solid var(--line-soft);
}
.modal-foot .left { margin-right: auto; }

.fieldset { display: grid; gap: 11px; }
.fieldset > .fs-title {
  font-size: 10px;
  color: var(--text-3);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
}
.callout {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12.5px; color: var(--text-2);
  line-height: 1.5;
}
.callout.info { border-color: rgba(108, 168, 255, 0.3); background: rgba(108, 168, 255, 0.06); }
.callout.info .ico { color: var(--blue); }
.callout.warn { border-color: rgba(255, 200, 87, 0.3); background: rgba(255, 200, 87, 0.06); }
.callout.warn .ico { color: var(--amber); }
.callout .ico { flex: none; display: inline-flex; margin-top: 1px; }
.output {
  margin: 0; max-height: 320px; overflow: auto;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 11.5px; color: var(--text-2);
  word-break: break-word;
}
.output.workspace-output {
  min-height: 260px;
  max-height: 52vh;
  resize: vertical;
  font-size: 12px;
  line-height: 1.5;
}
.compact-audit {
  display: grid;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.compact-audit-head { display: flex; align-items: center; gap: 10px; }
.compact-audit-head h3 { flex: 1; }
.compact-audit-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 7px; }
.audit-chip {
  display: grid; gap: 2px;
  padding: 7px 9px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-2);
}
.audit-chip b { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-chip span, .compact-empty { font-size: 11.5px; color: var(--text-3); }
.readout { display: grid; gap: 13px; }
.readout-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}
.readout-head h3 { font-size: 14px; margin-bottom: 4px; }
.readout-sections { display: grid; gap: 12px; }
.readout-section { display: grid; gap: 7px; }
.readout-section h4 { margin: 0; font-size: 10px; color: var(--text-3); }
.readout-kv .kv-row { grid-template-columns: minmax(140px, 220px) 1fr; padding: 6px 0; }
.readout-table { max-height: 340px; }
.readout-value, .readout-empty {
  padding: 11px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.raw-details { border-top: 1px solid var(--line-soft); padding-top: 8px; }
.raw-details summary {
  cursor: pointer;
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.raw-details summary:hover { color: var(--text-2); }
.raw-details pre {
  margin: 9px 0 0;
  max-height: 280px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: pre-wrap;
}
.config-node-list { display: grid; gap: 7px; max-height: 420px; overflow: auto; }
.config-node {
  display: grid; gap: 3px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}
.config-node:hover { background: var(--surface-3); border-color: #2e3a4d; }
.config-node .config-title { font-weight: 600; font-size: 13px; }
.config-node code { color: var(--brand-dim); font-size: 11.5px; overflow-wrap: anywhere; }
.config-node small { color: var(--text-3); font-size: 11.5px; }
.token-box {
  display: flex; gap: 8px; align-items: center;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--mono); font-size: 12px;
  word-break: break-all;
}
.token-box span { flex: 1; color: var(--brand); }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 80;
  display: grid; gap: 8px;
  width: min(360px, calc(100vw - 32px));
}
.toast {
  position: relative;
  display: flex; gap: 10px;
  padding: 11px 13px 11px 16px;
  border-radius: var(--radius);
  background: var(--surface-3);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  overflow: hidden;
  animation: toast-in 160ms ease;
}
.toast::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--grey); }
.toast.ok::before { background: var(--green); }
.toast.err::before { background: var(--red); }
.toast.warn::before { background: var(--amber); }
.toast.info::before { background: var(--blue); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- top progress ---------- */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 90; background: transparent; }
.progress.active {
  background: linear-gradient(90deg, transparent 20%, var(--brand) 50%, transparent 80%) 0 0 / 50% 100% no-repeat;
  animation: progress 1.1s linear infinite;
}
@keyframes progress { from { background-position: -60% 0; } to { background-position: 160% 0; } }

/* ---------- menu ---------- */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30;
  min-width: 170px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px;
  display: grid; gap: 1px;
}
.menu button {
  display: block; width: 100%; text-align: left;
  padding: 6px 9px;
  border: 0; border-radius: var(--radius);
  background: transparent; color: var(--text-2);
  font-size: 12.5px; cursor: pointer;
}
.menu button:hover { background: var(--surface-3); color: var(--text); }
.menu button.danger { color: var(--red); }
.menu .sep { height: 1px; background: var(--line-soft); margin: 3px 0; }

.muted { color: var(--text-3); font-size: 12.5px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text-2);
}

/* header compression before the mobile breakpoint */
@media (max-width: 1320px) {
  .ch-tools .clock { display: none; }
}
@media (max-width: 1180px) {
  .health-pill .hp-text { display: none; }
  .health-pill { padding: 4px 7px; }
  .console-head .brand-word span { display: none; }
}

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

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .cols-2 { grid-template-columns: 1fr; }
  .ops-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .console-head { flex-wrap: wrap; padding: 8px 14px; gap: 8px 14px; }
  .ch-brand { order: 1; }
  .ch-tools { order: 2; margin-left: auto; }
  .ch-nav { order: 3; flex-basis: 100%; border-top: 1px solid var(--line-soft); }
  .ch-tab { padding: 10px 10px; }
  .ch-tab.active::after { bottom: 0; }
  .ch-sep { display: none; }
  .ch-tools .clock { display: none; }
  .telemetry { padding: 0 14px; }
  .content { padding: 18px 14px 40px; }
  .field-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-hero { align-items: flex-start; flex-direction: column; }
  .detail-badges { justify-content: flex-start; }
  .row { flex-wrap: wrap; }
  .row .row-actions { width: 100%; }
  .login { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .login-main { min-height: 100vh; align-content: center; }
}
@media (max-width: 560px) {
  .kpi-row { grid-template-columns: 1fr; }
  .detail-metrics { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
  .kv .kv-row { grid-template-columns: 1fr; gap: 3px; }
  .panel-head .actions, .card-head .actions { width: 100%; }
  .health-pill { display: none; }
  .sysbanner { flex-direction: column; align-items: flex-start; }
}
