:root {
  --bg: #f5f6f8; --panel: #ffffff; --ink: #14171f; --muted: #667085; --line: #e3e6ec;
  --brand: #3b4cca; --brand-ink: #ffffff; --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
  --ok-bg: #e7f6ec; --warn-bg: #fdf1dc; --bad-bg: #fde8e8; --code: #f0f2f6;
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218; --panel: #171b24; --ink: #e8eaf0; --muted: #98a2b3; --line: #262c39;
    --brand: #7c8cff; --brand-ink: #0b0e16; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171;
    --ok-bg: #12301f; --warn-bg: #3a2c0f; --bad-bg: #3a1616; --code: #1d222d;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.mono, code, pre { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--code); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--code); padding: 12px 14px; border-radius: 8px; overflow-x: auto; margin: 8px 0 14px; line-height: 1.5; }

/* layout */
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
.brand { font-weight: 700; font-size: 15px; padding: 4px 10px 14px; }
.side a.nav { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.side a.nav:hover { background: var(--code); }
.side a.nav.on { background: var(--brand); color: var(--brand-ink); }
.side .spacer { flex: 1; }
.main { padding: 24px 28px 60px; max-width: 1280px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 8px; }
  .brand { width: 100%; padding-bottom: 4px; }
  .main { padding: 16px 14px 50px; }
}

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .n { font-size: 24px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field .hint { font-size: 12px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
input[type=checkbox] { width: auto; }
.check { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 7px 13px; border-radius: 8px; cursor: pointer; font-weight: 600; }
button:hover { background: var(--code); }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button.small { padding: 3px 9px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--code); color: var(--muted); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.badge { background: var(--bad); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 11px; }
.note { border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; background: var(--warn-bg); color: var(--warn); }
.note.ok { background: var(--ok-bg); color: var(--ok); }
.note.bad { background: var(--bad-bg); color: var(--bad); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* modal + toast */
.overlay { position: fixed; inset: 0; background: rgba(8, 10, 16, .55); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; overflow-y: auto; z-index: 20; }
.modal { background: var(--panel); border-radius: 12px; border: 1px solid var(--line); padding: 20px; width: 100%; max-width: 640px; }
.modal.wide { max-width: 900px; }
.modal h2 { font-size: 17px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 30; max-width: 360px; }
.toast.bad { background: var(--bad); color: #fff; }

/* login */
.login { max-width: 340px; margin: 14vh auto 0; padding: 0 16px; }

/* docs page */
.doc { max-width: 860px; margin: 0 auto; padding: 32px 18px 80px; }
.doc h2 { margin-top: 34px; font-size: 18px; padding-top: 12px; border-top: 1px solid var(--line); }
.doc .ep { display: flex; gap: 10px; align-items: baseline; margin: 22px 0 6px; }
.doc .m { font-family: var(--mono); font-weight: 700; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--code); }
.doc .m.get { color: var(--ok); } .doc .m.post { color: var(--brand); } .doc .m.put { color: var(--warn); }

.grow { flex: 1; }
