:root {
  --ink: #10131a;
  --ink-2: #3b4453;
  --muted: #6b7686;
  --paper: #ffffff;
  --paper-2: #f4f6f9;
  --paper-3: #eaeef4;
  --line: #dde3ec;
  --accent: #1f5eff;
  --accent-2: #e8efff;
  --ok: #12805c;
  --ok-2: #e5f6ef;
  --warn: #a35c00;
  --warn-2: #fff4e5;
  --bad: #b3241f;
  --bad-2: #fdeceb;
  --radius: 12px;
  --radius-s: 8px;
  --shadow: 0 1px 2px rgba(16, 19, 26, .05), 0 8px 24px rgba(16, 19, 26, .06);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eef2f7;
    --ink-2: #c3ccd8;
    --muted: #8d99a8;
    --paper: #0e1116;
    --paper-2: #151a21;
    --paper-3: #1c222b;
    --line: #262d37;
    --accent: #7ea6ff;
    --accent-2: #17233a;
    --ok: #4ad2a2;
    --ok-2: #10281f;
    --warn: #f0b45e;
    --warn-2: #2a1f0c;
    --bad: #ff8b84;
    --bad-2: #2c1210;
    color-scheme: dark;
  }
}

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper-2);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

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

h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.35rem; font-weight: 650; }
h2 { font-size: 1.06rem; font-weight: 620; }
h3 { font-size: .95rem; font-weight: 600; }
p { margin: 0; }

code, pre, .mono { font-family: var(--mono); font-size: .86em; }

/* ---------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static !important; height: auto !important; }
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 10px; }
.brand__mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #7c4dff);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px;
  flex: 0 0 auto;
}
.brand__name { font-weight: 650; font-size: .95rem; letter-spacing: -.01em; }
.brand__meta { font-size: .72rem; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__group { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 12px 8px 4px; }
.nav__item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--radius-s);
  color: var(--ink-2); font-size: .9rem; cursor: pointer; border: 0; background: none;
  text-align: left; width: 100%; font-family: inherit;
}
.nav__item:hover { background: var(--paper-2); color: var(--ink); text-decoration: none; }
.nav__item[aria-current="page"] { background: var(--accent-2); color: var(--accent); font-weight: 600; }
.nav__item .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .5; flex: 0 0 auto; }

.sidebar__footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar__title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.topbar__sub { font-size: .78rem; color: var(--muted); }
.topbar__spacer { flex: 1; }

.content { padding: 20px; display: flex; flex-direction: column; gap: 16px; max-width: 1400px; width: 100%; }

/* ---------------------------------------------------------------- controls */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: .82rem; color: var(--ink-2); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 8px 10px; width: 100%; min-height: 36px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-2); }
textarea { min-height: 84px; resize: vertical; font-size: .9rem; }
select { cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-s); border: 1px solid transparent;
  background: var(--accent); color: #fff; font: inherit; font-weight: 560; font-size: .88rem;
  cursor: pointer; white-space: nowrap; transition: filter .15s ease, transform .15s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn--ghost { background: var(--paper); color: var(--ink-2); border-color: var(--line); }
.btn--ghost:hover { background: var(--paper-2); filter: none; }
.btn--danger { background: var(--bad); }
.btn--sm { padding: 5px 10px; font-size: .8rem; min-height: 30px; }
.btn--block { width: 100%; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 180px; }
.row--tight > * { flex: 0 1 auto; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; background: var(--paper-3);
  font-size: .76rem; color: var(--ink-2); white-space: nowrap;
}
.chip--ok { background: var(--ok-2); color: var(--ok); }
.chip--warn { background: var(--warn-2); color: var(--warn); }
.chip--bad { background: var(--bad-2); color: var(--bad); }
.chip--accent { background: var(--accent-2); color: var(--accent); }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.card--flush { padding: 0; overflow: hidden; }
.card__head { display: flex; align-items: flex-start; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.card__title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.card__hint { font-size: .8rem; color: var(--muted); }
.card__body { display: flex; flex-direction: column; gap: 10px; }

.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }

.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat__label { font-size: .76rem; color: var(--muted); }
.stat__value { font-size: 1.5rem; font-weight: 640; letter-spacing: -.02em; margin-top: 2px; }
.stat__hint { font-size: .74rem; color: var(--muted); margin-top: 3px; }

/* ---------------------------------------------------------------- table */
table.tbl { width: 100%; border-collapse: collapse; font-size: .86rem; }
.tbl th, .tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-weight: 600; color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; background: var(--paper-2); position: sticky; top: 0; z-index: 1; }
.tbl tr:hover td { background: var(--paper-2); }
.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-scroll { overflow: auto; max-height: 460px; border-radius: var(--radius-s); }

/* ---------------------------------------------------------------- misc */
.empty {
  padding: 28px 18px; text-align: center; color: var(--muted); font-size: .88rem;
  border: 1px dashed var(--line); border-radius: var(--radius); background: var(--paper);
}
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; font-size: .95rem; }

.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; border-radius: var(--radius-s); font-size: .86rem;
  border: 1px solid var(--line); background: var(--paper-3);
}
.banner--warn { background: var(--warn-2); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }
.banner--bad { background: var(--bad-2); border-color: color-mix(in srgb, var(--bad) 30%, transparent); color: var(--bad); }
.banner--ok { background: var(--ok-2); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--ok); }
.banner--info { background: var(--accent-2); border-color: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--accent); }

.pill-data { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--paper-3); color: var(--muted); }
.pill-data--live { background: var(--ok-2); color: var(--ok); }
.pill-data--degraded { background: var(--warn-2); color: var(--warn); }
.pill-data--empty, .pill-data--synthetic { background: var(--bad-2); color: var(--bad); }

.steps { display: flex; flex-direction: column; gap: 0; }
.step { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: start; }
.step:last-child { border-bottom: 0; }
.step__num { width: 22px; height: 22px; border-radius: 50%; background: var(--paper-3); display: grid; place-items: center; font-size: .72rem; font-weight: 600; color: var(--ink-2); }
.step--ok .step__num { background: var(--ok-2); color: var(--ok); }
.step--run .step__num { background: var(--accent-2); color: var(--accent); }
.step--fail .step__num { background: var(--bad-2); color: var(--bad); }
.step--wait .step__num { background: var(--warn-2); color: var(--warn); }
.step__title { font-size: .88rem; font-weight: 550; }
.step__meta { font-size: .76rem; color: var(--muted); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.tab {
  padding: 8px 12px; border: 0; background: none; font: inherit; font-size: .86rem;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab:hover { color: var(--ink); }

.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: .84rem; color: var(--ink-2); cursor: pointer; }
.toggle input { width: auto; min-height: 0; accent-color: var(--accent); }

.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 6px 14px; font-size: .85rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

details.disclose { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; background: var(--paper); }
details.disclose > summary { cursor: pointer; font-size: .86rem; font-weight: 550; }
details.disclose[open] > summary { margin-bottom: 10px; }

pre.code {
  margin: 0; padding: 12px; background: var(--paper-3); border-radius: var(--radius-s);
  overflow: auto; max-height: 380px; font-size: .78rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}

.toast-host { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: 380px; }
.toast {
  padding: 11px 14px; border-radius: var(--radius-s); background: var(--ink); color: var(--paper);
  font-size: .85rem; box-shadow: var(--shadow); animation: toast-in .18s ease-out;
}
.toast--bad { background: var(--bad); color: #fff; }
.toast--ok { background: var(--ok); color: #fff; }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent); animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.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;
}

.hint-list { margin: 0; padding-left: 18px; font-size: .84rem; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; }

.progress { height: 6px; border-radius: 999px; background: var(--paper-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); transition: width .3s ease; }