/*
 * paas dashboard: one design system, defined here as custom properties.
 *
 * Layout: one centred column (max 1180px) under a sticky top bar. Screens
 * are stacks of plain sections; borders and fills mark only the objects a
 * person acts on (an approval, a service, a node).
 *
 * Every colour is a token. Light values live on :root; dark values are
 * redefined for prefers-color-scheme and for an explicit data-theme, so the
 * theme switch wins both ways. System fonts only: the dashboard must work
 * on an air-gapped control plane.
 */
:root {
  color-scheme: light;
  /* surfaces: a faintly green-grey paper with white objects on it */
  --bg: #f4f5f3;
  --surface: #ffffff;
  --surface-2: #eceeeb;
  --surface-3: #e1e4e0;
  --line: #d9ddd8;
  --line-strong: #bfc5bf;
  /* ink */
  --ink: #161a19;
  --ink-2: #434b48;
  --ink-3: #5f6864;
  /* one interactive accent: a deep harbour blue */
  --accent: #1d5c86;
  --accent-hover: #164a6d;
  --accent-ink: #ffffff;
  --accent-soft: #e2ecf3;
  --focus: #2a7cc0;
  /* state colours, separate from the accent, always paired with a label */
  --good: #1b7537;
  --good-soft: #e1f1e5;
  --warn: #8a5300;
  --warn-soft: #fbefd8;
  --bad: #b02a2a;
  --bad-soft: #f8e3e1;
  --neutral-soft: #e8eae7;
  /* diff */
  --add: #1b7537;
  --add-soft: #e5f3e8;
  --del: #a83232;
  --del-soft: #f9e8e6;
  /* charts (validated categorical order; see charts.js) */
  --chart-surface: #ffffff;
  --chart-grid: #e6e8e4;
  --chart-axis: #c4c9c3;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-other: #a3a8a2;
  --forecast: #9fb9d6;
  --meter-track: #dfe8f2;
  --shadow: 0 1px 2px rgba(20, 26, 24, 0.06), 0 2px 8px rgba(20, 26, 24, 0.04);
  --shadow-pop: 0 8px 30px rgba(20, 26, 24, 0.16);

  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.875rem;
  --fs-lg: 1rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.625rem;
  --fs-hero: 2.25rem;
  --r-sm: 4px;
  --r-md: 6px;
  --gap: 16px;
  --topbar-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101413;
    --surface: #171c1b;
    --surface-2: #1e2422;
    --surface-3: #272e2c;
    --line: #2b3331;
    --line-strong: #3d4643;
    --ink: #e8ecea;
    --ink-2: #b4bdb9;
    --ink-3: #8f9995;
    --accent: #6fb3e3;
    --accent-hover: #93c6ea;
    --accent-ink: #0b1a24;
    --accent-soft: #1a2e3b;
    --focus: #7fc0ee;
    --good: #5cc77d;
    --good-soft: #17301f;
    --warn: #e2a648;
    --warn-soft: #36290f;
    --bad: #f08080;
    --bad-soft: #3a1c1c;
    --neutral-soft: #242b29;
    --add: #6fd08c;
    --add-soft: #16301f;
    --del: #f39494;
    --del-soft: #3a1d1d;
    --chart-surface: #171c1b;
    --chart-grid: #262d2b;
    --chart-axis: #3a4340;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-other: #5f6866;
    --forecast: #34506b;
    --meter-track: #1f3242;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-pop: 0 8px 30px rgba(0, 0, 0, 0.55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101413;
  --surface: #171c1b;
  --surface-2: #1e2422;
  --surface-3: #272e2c;
  --line: #2b3331;
  --line-strong: #3d4643;
  --ink: #e8ecea;
  --ink-2: #b4bdb9;
  --ink-3: #8f9995;
  --accent: #6fb3e3;
  --accent-hover: #93c6ea;
  --accent-ink: #0b1a24;
  --accent-soft: #1a2e3b;
  --focus: #7fc0ee;
  --good: #5cc77d;
  --good-soft: #17301f;
  --warn: #e2a648;
  --warn-soft: #36290f;
  --bad: #f08080;
  --bad-soft: #3a1c1c;
  --neutral-soft: #242b29;
  --add: #6fd08c;
  --add-soft: #16301f;
  --del: #f39494;
  --del-soft: #3a1d1d;
  --chart-surface: #171c1b;
  --chart-grid: #262d2b;
  --chart-axis: #3a4340;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-other: #5f6866;
  --forecast: #34506b;
  --meter-track: #1f3242;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-pop: 0 8px 30px rgba(0, 0, 0, 0.55);
}

/* ---- base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--fs-md)/1.5 var(--font-ui);
  min-height: 100vh;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
code, pre, kbd, .mono { font-family: var(--font-mono); font-size: 0.92em; }
h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }
h1 { font-size: var(--fs-xl); font-weight: 650; }
h2 { font-size: var(--fs-lg); font-weight: 650; }
h3 { font-size: var(--fs-md); font-weight: 650; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
::selection { background: var(--accent-soft); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.nowrap { white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: 8px; top: -40px; z-index: 50; background: var(--surface); padding: 8px 12px; border-radius: var(--r-sm); }
.skip-link:focus { top: 8px; }

/* ---- top bar --------------------------------------------------------------- */
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  z-index: 10; background: var(--surface);
}
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; min-height: var(--topbar-h);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 8px; color: var(--ink); text-decoration: none; }
.brand-mark { font-family: var(--font-mono); font-weight: 700; font-size: 1.05rem; letter-spacing: -0.02em; }
.brand-mark span { color: var(--accent); }
.brand-org { color: var(--ink-3); font-size: var(--fs-sm); }
.nav { display: flex; gap: 2px; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav a {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: var(--r-sm);
  color: var(--ink-2); text-decoration: none; font-weight: 550; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-grid; place-items: center;
  background: var(--warn-soft); color: var(--warn); font-size: var(--fs-xs); font-weight: 700;
}
.user { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.user-name { font-size: var(--fs-sm); color: var(--ink-2); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 720px) {
  .topbar-inner { gap: 8px 12px; padding-block: 8px; }
  .nav { order: 3; flex-basis: 100%; }
  .user-name { display: none; }
}

/* ---- page ------------------------------------------------------------------ */
.page {
  max-width: 1180px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 24px 64px;
  display: flex; flex-direction: column; gap: 28px;
}
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.page-head > div { min-width: 0; }
.page-sub { color: var(--ink-3); margin-top: 4px; }
.section { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head h2 { display: flex; align-items: baseline; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.stack-tight { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.spacer { flex: 1 1 auto; }
.refreshing { opacity: 0.55; transition: opacity 0.15s; }
@media (prefers-reduced-motion: reduce) { .refreshing { transition: none; } }

/* ---- controls -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 6px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 550 var(--fs-md)/1.2 var(--font-ui); cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.btn-danger:hover { background: var(--bad-soft); color: var(--bad); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 28px; padding: 3px 10px; font-size: var(--fs-sm); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn .spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn .spin { animation: none; } }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: var(--fs-xs); color: var(--ink-3); font-weight: 400; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  font: 400 var(--fs-md)/1.4 var(--font-ui); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 7px 10px; min-height: 34px;
  max-width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
select { padding-right: 28px; }
textarea { resize: vertical; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { min-width: 180px; flex: 0 1 240px; }
.filters .field.auto { flex: 0 0 auto; min-width: 0; }
dialog { overflow: auto; }
.actions-list li { overflow-wrap: anywhere; }
@media (max-width: 520px) { .filters .field { flex: 1 1 100%; } }

/* ---- pills (state: always a word, never colour alone) ---------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px 1px 7px; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 650; line-height: 18px; white-space: nowrap;
  background: var(--neutral-soft); color: var(--ink-2);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.warn::before { border-radius: 1px; transform: rotate(45deg); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.bad::before { border-radius: 1px; }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.pill.plain::before { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 0 6px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
  font: 500 var(--fs-xs)/20px var(--font-mono); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.kind { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-3); }

/* ---- cards ----------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); min-width: 0; display: flex; flex-direction: column; }
.card-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; flex: 1 1 auto; }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.well { background: var(--surface-2); border-radius: var(--r-md); padding: 12px 14px; min-width: 0; }

/* ---- key/value ------------------------------------------------------------- */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 0; font-size: var(--fs-sm); }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---- feedback -------------------------------------------------------------- */
.error-box {
  border: 1px solid color-mix(in srgb, var(--bad) 35%, var(--line)); background: var(--bad-soft);
  border-radius: var(--r-md); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.error-box .code { font: 650 var(--fs-sm) var(--font-mono); color: var(--bad); }
.error-box .detail { color: var(--ink); overflow-wrap: anywhere; }
.error-box .suggestion { color: var(--ink-2); }
.error-box .suggestion::before { content: "Next: "; font-weight: 650; color: var(--ink); }
.error-box details summary { cursor: pointer; color: var(--ink-3); font-size: var(--fs-sm); }
.notice { border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--r-md); padding: 10px 14px; color: var(--ink-2); }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, var(--line)); color: var(--ink); }
.empty {
  border: 1px dashed var(--line-strong); border-radius: var(--r-md); padding: 28px 20px;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start; color: var(--ink-2); background: var(--surface);
}
.empty h3 { color: var(--ink); }
.empty code, .cmd {
  display: inline-block; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 2px 8px; color: var(--ink); max-width: 100%; overflow-wrap: anywhere;
}
.loading { color: var(--ink-3); padding: 20px 0; min-height: 120px; display: flex; align-items: flex-start; gap: 8px; }
.loading::before {
  content: ""; width: 14px; height: 14px; margin-top: 3px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin 0.9s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .loading::before { animation: none; } }

.toasts {
  position: fixed; z-index: 40; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px));
  right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px));
}
.toast {
  background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--r-md); box-shadow: var(--shadow-pop);
  font-size: var(--fs-sm);
}
.toast.bad { background: var(--bad); color: #fff; }

/* ---- tables ---------------------------------------------------------------- */
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--ink-3); background: var(--surface-2); white-space: nowrap; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: 0; }
td.money, th.money { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- activity timeline ----------------------------------------------------- */
.approvals { display: flex; flex-direction: column; gap: 12px; }
.approval { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.approval-head { display: flex; gap: 8px 12px; align-items: baseline; flex-wrap: wrap; }
.approval-title { font-weight: 650; overflow-wrap: anywhere; }
.approval textarea { width: 100%; min-height: 34px; }
.card-foot .reason { flex: 1 1 260px; min-width: 0; }
.day { display: flex; flex-direction: column; }
.day-label {
  font-size: var(--fs-xs); font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3);
  padding: 0 0 6px;
}
.events { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.event { display: grid; grid-template-columns: 68px minmax(0, 1fr) auto; gap: 4px 14px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.event:last-child { border-bottom: 0; }
.event-time { color: var(--ink-3); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; padding-top: 1px; white-space: nowrap; }
.event-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.event-line { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; overflow-wrap: anywhere; }
.event-who { font-weight: 650; }
.event-who .kind-tag { font-weight: 500; color: var(--ink-3); margin-right: 4px; }
.event-op { font: 600 var(--fs-sm) var(--font-mono); color: var(--ink); }
.event-target { font: 400 var(--fs-sm) var(--font-mono); color: var(--ink-2); }
.event-task { color: var(--ink-2); font-size: var(--fs-sm); }
.event-task q { quotes: "\201C" "\201D"; font-style: italic; }
.event-detail { color: var(--ink-3); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.event-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.delta { font-size: var(--fs-sm); font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink-2); }
.delta.up { color: var(--warn); }
.delta.down { color: var(--good); }
.event details { margin-top: 2px; }
.approval details > summary { cursor: pointer; color: var(--accent); font-size: var(--fs-sm); margin-bottom: 6px; }
.event summary, .disclose { cursor: pointer; color: var(--accent); font-size: var(--fs-sm); width: fit-content; }
@media (max-width: 600px) {
  .event { grid-template-columns: minmax(0, 1fr) auto; }
  .event-time { grid-column: 1 / -1; }
}

/* ---- plan diff ------------------------------------------------------------- */
.diff { display: flex; flex-direction: column; gap: 10px; font-size: var(--fs-sm); min-width: 0; }
.diff-summary { font-weight: 600; }
.diff-block { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); overflow: hidden; }
.diff-title { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; padding: 6px 10px; background: var(--surface-2); font-family: var(--font-mono); }
.diff-op { font-weight: 700; width: 1.2em; text-align: center; }
.diff-op.create { color: var(--add); }
.diff-op.delete { color: var(--del); }
.diff-op.update { color: var(--warn); }
.diff-rows { display: grid; grid-template-columns: minmax(100px, max-content) minmax(0, 1fr); font-family: var(--font-mono); font-size: var(--fs-xs); }
.diff-rows > div { padding: 4px 10px; border-top: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
.diff-path { color: var(--ink-3); }
.diff-vals { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.diff-old { background: var(--del-soft); color: var(--del); text-decoration: line-through; text-decoration-thickness: 1px; padding: 0 3px; border-radius: 2px; }
.diff-new { background: var(--add-soft); color: var(--add); padding: 0 3px; border-radius: 2px; }
.diff-arrow { color: var(--ink-3); }
.actions-list { margin: 0; padding-left: 18px; color: var(--ink-2); }
pre.json, pre.code {
  margin: 0; padding: 10px 12px; background: var(--surface-2); border-radius: var(--r-sm); overflow: auto;
  font-size: var(--fs-xs); line-height: 1.5; max-height: 360px; color: var(--ink);
}

/* ---- projects -------------------------------------------------------------- */
.project-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.project-link { color: inherit; text-decoration: none; display: block; }
.project-link:hover .card { border-color: var(--line-strong); }
.project-link h3 { font-family: var(--font-mono); font-size: var(--fs-lg); }
.facts { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--fs-sm); color: var(--ink-2); }
.facts b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.title-row h1 { font-family: var(--font-mono); font-size: var(--fs-2xl); letter-spacing: -0.01em; overflow-wrap: anywhere; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.tab {
  border: 0; background: transparent; padding: 9px 14px; font: 600 var(--fs-md) var(--font-ui); color: var(--ink-3);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: baseline;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab .from { font-weight: 400; font-size: var(--fs-xs); color: var(--ink-3); }

.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 12px; }
.svc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.svc-name { font: 650 var(--fs-lg) var(--font-mono); overflow-wrap: anywhere; }
.svc-url { font-size: var(--fs-sm); overflow-wrap: anywhere; }
.domains { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.domain-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.domain-hint { margin: 2px 0 0; overflow-wrap: anywhere; }
.replicas { display: flex; flex-wrap: wrap; gap: 4px; }
.svc-card .logs { max-height: 240px; }
.svc-cost { font-variant-numeric: tabular-nums; }
.vars { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; align-items: start; }
.secret-value { font-family: var(--font-mono); background: var(--surface-2); padding: 2px 6px; border-radius: var(--r-sm); overflow-wrap: anywhere; user-select: all; }

/* ---- editor ---------------------------------------------------------------- */
.editor { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .editor { grid-template-columns: minmax(0, 1fr); } }
.editor textarea {
  width: 100%; min-height: 460px; font: 400 var(--fs-sm)/1.55 var(--font-mono); tab-size: 2;
  white-space: pre; overflow: auto; background: var(--surface);
}
.estimate { display: flex; gap: 20px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.estimate div { display: flex; flex-direction: column; }
.estimate span { color: var(--ink-3); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; }
.estimate b { font-size: var(--fs-lg); }

/* ---- stats and meters ------------------------------------------------------ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { font-size: var(--fs-sm); color: var(--ink-3); }
.stat-value { font-size: var(--fs-2xl); font-weight: 650; letter-spacing: -0.01em; }
.stat-value.hero { font-size: var(--fs-hero); }
.stat-sub { font-size: var(--fs-sm); color: var(--ink-2); }
.meter { height: 8px; border-radius: 4px; background: var(--meter-track); overflow: hidden; position: relative; min-width: 80px; }
.meter > i { position: absolute; inset: 0 auto 0 0; background: var(--series-1); border-radius: 4px; }
.meter.warn > i { background: var(--warn); }
.meter.bad > i { background: var(--bad); }
.meter > b { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink-3); }
.util { display: grid; grid-template-columns: 36px minmax(60px, 1fr) auto; gap: 4px 8px; align-items: center; font-size: var(--fs-xs); }
.util .label { color: var(--ink-3); }

/* ---- charts ---------------------------------------------------------------- */
.chart-card { background: var(--chart-surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; position: relative; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--ink-3); font: 400 11px var(--font-ui); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis { stroke: var(--chart-axis); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .col-hover, .chart .col-hover { pointer-events: none; }
.chart .mark-active { filter: brightness(1.08); }
.chart .forecast { fill: none; stroke: var(--forecast); stroke-width: 1.5; }
.chart .forecast-fill { fill: var(--forecast); opacity: 0.25; }
.chart .cursor { stroke: var(--ink-3); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--fs-sm); color: var(--ink-2); margin: 0; padding: 0; list-style: none; }
.legend li { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.swatch.s1 { background: var(--series-1); } .swatch.s2 { background: var(--series-2); }
.swatch.s3 { background: var(--series-3); } .swatch.s4 { background: var(--series-4); }
.swatch.s5 { background: var(--series-5); } .swatch.s6 { background: var(--series-6); }
.swatch.so { background: var(--series-other); }
.swatch.fc { background: transparent; border: 1.5px dashed var(--forecast); }
.fill-s1 { fill: var(--series-1); } .fill-s2 { fill: var(--series-2); } .fill-s3 { fill: var(--series-3); }
.fill-s4 { fill: var(--series-4); } .fill-s5 { fill: var(--series-5); } .fill-s6 { fill: var(--series-6); }
.fill-so { fill: var(--series-other); }
.tooltip {
  position: absolute; z-index: 5; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); box-shadow: var(--shadow-pop);
  padding: 8px 10px; font-size: var(--fs-xs); min-width: 160px; max-width: 260px;
}
.tooltip .tt-title { font-weight: 650; margin-bottom: 4px; }
.tooltip .tt-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.tooltip .tt-row b { font-variant-numeric: tabular-nums; }
.tooltip .tt-key { width: 10px; height: 2px; }
.bars { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; font-size: var(--fs-sm); }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.bar-row .val { font-variant-numeric: tabular-nums; color: var(--ink); }
.bar-track { grid-column: 1 / -1; height: 6px; position: relative; }
.bar-track > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--series-1); border-radius: 0 3px 3px 0; min-width: 2px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; align-items: start; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 16px; align-items: start; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; white-space: nowrap; min-height: 32px; font: 550 var(--fs-sm) var(--font-ui); color: var(--ink-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); }

/* ---- fleet ----------------------------------------------------------------- */
.nodes { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 12px; }
.node-name { font: 650 var(--fs-lg) var(--font-mono); overflow-wrap: anywhere; }
.labels { display: flex; flex-wrap: wrap; gap: 4px; }
.subsys { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: var(--fs-xs); color: var(--ink-3); }
.subsys .ok { color: var(--good); }
.subsys .skip { color: var(--ink-3); }
.subsys .fail { color: var(--bad); }
.join-cmd { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.join-cmd pre { flex: 1 1 320px; min-width: 0; white-space: pre-wrap; word-break: break-all; }

/* ---- dialogs ---------------------------------------------------------------- */
dialog {
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 0; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-pop); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
}
dialog.wide { width: min(1120px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 14, 13, 0.45); }
.dialog-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* ---- login ------------------------------------------------------------------ */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
.login { width: min(440px, 100%); }
.login .card-body { padding: 28px; gap: 16px; }
.login h1 { font-size: var(--fs-xl); }
.login input { width: 100%; font-family: var(--font-mono); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: var(--fs-sm); }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
