:root {
  --bg: #f4f2ec;
  --surface: #fffefb;
  --surface-2: #f8f6f0;
  --ink: #1b2430;
  --muted: #667085;
  --line: #e2ddd0;
  --line-strong: #cfc8b6;
  --accent: #0b5d51;
  --accent-ink: #ffffff;
  --accent-soft: #e2f0ec;
  --ok: #0b6b4f;
  --ok-bg: #dff3e8;
  --warn: #8a5a00;
  --warn-bg: #fbecc8;
  --err: #a12a1f;
  --err-bg: #fbe2dd;
  --off: #55606e;
  --off-bg: #e9e6dd;
  --side: #17202b;
  --side-ink: #d8dee6;
  --side-muted: #8c98a8;
  --radius: 8px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161d;
    --surface: #18202a;
    --surface-2: #1d2631;
    --ink: #e6eaf0;
    --muted: #96a2b3;
    --line: #2a3542;
    --line-strong: #3a4757;
    --accent: #4fc3a8;
    --accent-ink: #06231d;
    --accent-soft: #17352f;
    --ok: #6fdcae;
    --ok-bg: #143427;
    --warn: #f2c66a;
    --warn-bg: #3a2d0f;
    --err: #ff9c8f;
    --err-bg: #43201c;
    --off: #a9b4c2;
    --off-bg: #263140;
    --side: #0c1117;
    --side-ink: #d8dee6;
    --side-muted: #7f8b9b;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.2; margin: 0 0 4px; font-weight: 650; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-size: 15px; margin: 0; font-weight: 650; }
p { margin: 0 0 10px; }
code, .mono { font-family: var(--mono); font-size: 0.93em; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 650; }
.upper { text-transform: uppercase; }
.right { text-align: right; white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- sidebar ---------- */
.side {
  background: var(--side);
  color: var(--side-ink);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 650; font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand small { display: block; font-weight: 400; font-size: 11.5px; color: var(--side-muted); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 7px; display: grid; place-items: center;
  background: #4fc3a8; color: #06231d; font-weight: 800; font-size: 17px;
}
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: var(--side-ink); padding: 8px 10px; border-radius: 6px; }
.side nav a:hover { background: rgba(255, 255, 255, 0.07); text-decoration: none; }
.side nav a.on { background: rgba(79, 195, 168, 0.16); color: #7fe0c9; font-weight: 600; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.side-foot .muted { color: var(--side-muted); }
.env { align-self: flex-start; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 3px 8px; border-radius: 4px; }
.env-sandbox { background: #f2c66a; color: #3a2d0f; }
.env-live { background: #ff9c8f; color: #43201c; }

/* ---------- layout ---------- */
main { padding: 26px 32px 60px; min-width: 0; max-width: 1400px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head p { margin: 0; }
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 4px !important; }
.lede { max-width: 80ch; color: var(--muted); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.card > p, .card > ol, .card > form, .card > .actions, .card > h2 { margin-left: 16px; margin-right: 16px; }
.card > h2 { margin-top: 14px; margin-bottom: 8px; }
.card > form { margin-bottom: 14px; }
.card.padded { padding: 16px; }
.card.padded > * { margin-left: 0; margin-right: 0; }
.card.padded > h2 { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); margin-bottom: 12px; flex-wrap: wrap; }
.card-head + .scroll, .card-head + table { margin-top: -12px; }
.pad { padding: 0 16px; }
.hint { color: var(--muted); font-size: 12.5px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.empty p { margin-bottom: 12px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 26px; line-height: 1.1; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12.5px; }

/* ---------- tables ---------- */
.scroll { overflow-x: auto; }
.scroll.tall { max-height: 560px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data th, table.data td { padding: 6px 12px; font-size: 13px; white-space: nowrap; }
table.data th { position: sticky; top: 0; text-transform: none; letter-spacing: 0; font-family: var(--mono); font-size: 12px; }
table.data tfoot td { position: sticky; bottom: 0; background: var(--surface-2); font-weight: 650; border-top: 2px solid var(--line-strong); border-bottom: 0; }
table.kv th { width: 260px; text-transform: none; letter-spacing: 0; font-size: 13px; background: none; }
.clip { display: inline-block; max-width: 38ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.w-bar { min-width: 120px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 3px 10px; font-size: 12.5px; }
.btn.danger { color: var(--err); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
input, select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 7px 10px; min-width: 0; max-width: 100%;
}
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; }
label input, label select { font-weight: 400; font-size: 14px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-row label { min-width: 170px; }
.form-row .grow { flex: 1; }
.filters { padding: 14px 16px; margin: 0 !important; border-bottom: 1px solid var(--line); }
.filters + .muted { margin-top: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.stack label { width: 100%; max-width: 420px; }
.inline { display: inline; }
.inline-form select { padding: 4px 8px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card > .actions { margin-bottom: 14px; }
.steps { padding-left: 34px; margin-top: 4px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 12px; }
.steps li { padding-left: 4px; }
.steps form { display: inline-flex; gap: 8px; margin-right: 8px; }
.otp input { width: 120px; font-family: var(--mono); letter-spacing: 0.15em; }
.params { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 14px; }
.params .actions { grid-column: 1 / -1; }
.params small { font-weight: 400; }
.req { color: var(--err); font-weight: 600; }
.table-filter { padding: 3px 8px; font-size: 12.5px; width: 150px; }
ol.plain { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }

/* ---------- small parts ---------- */
.badge { display: inline-block; font-size: 11.5px; font-weight: 650; padding: 2px 8px; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.off { background: var(--off-bg); color: var(--off); }
h1 .badge { font-size: 12px; margin-left: 6px; }
.verb { font-weight: 700; font-size: 11px; padding: 1px 5px; border-radius: 4px; }
.verb-get { background: var(--ok-bg); color: var(--ok); }
.verb-post, .verb-put { background: var(--off-bg); color: var(--off); }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid transparent; }
.flash-ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash-err { background: var(--err-bg); color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, transparent); }
.flash a { color: inherit; text-decoration: underline; }
.bar { height: 8px; background: var(--off-bg); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.4s; }
.progress-line { margin: 10px 0 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-family: var(--mono); font-size: 12.5px; }
.chip i { font-style: normal; color: var(--muted); }
.group { border-top: 1px solid var(--line); }
.group > summary { cursor: pointer; padding: 10px 16px; display: flex; gap: 10px; align-items: baseline; list-style-position: inside; }
.group > summary:hover { background: var(--surface-2); }
.group[open] > summary { border-bottom: 1px solid var(--line); }
.raw > summary { cursor: pointer; padding: 12px 16px; font-weight: 650; }
.raw pre { margin: 0; padding: 14px 16px; overflow: auto; max-height: 520px; font: 12.5px/1.5 var(--mono); border-top: 1px solid var(--line); background: var(--surface-2); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-top: 1px solid var(--line); }

@media (max-width: 860px) {
  body { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 16px; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side nav a { padding: 5px 8px; }
  .side-foot { margin: 0; flex-direction: row; align-items: center; }
  .side-foot .muted { display: none; }
  main { padding: 18px 16px 48px; }
  th, td { padding: 8px 12px; }
}
@media (prefers-reduced-motion: reduce) { .bar i { transition: none; } }

/* ---------- sign in ---------- */
body.login-page { display: grid; grid-template-columns: 1fr; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 28px 28px 22px; }
.login h1 { margin: 18px 0 14px; }
.login .stack label { max-width: none; }
.login .stack .btn { width: 100%; margin-top: 4px; }
.login .hint { margin: 16px 0 0; }
.login-brand { color: var(--ink); }
.login-brand small { color: var(--muted); }
.who { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--side-ink); }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: #7fe0c9; cursor: pointer; white-space: nowrap; }
.linkish:hover { text-decoration: underline; }
