:root {
  --bg: #f4f5f7; --panel: #ffffff; --fg: #1f2933; --muted: #616e7c; --faint: #9aa5b1; --line: #e4e7eb; --soft: #f7f8fa;
  --accent: #2f5fa7; --accent-fg: #ffffff; --accent-soft: #e8eef8;
  --ok: #1b7f4b; --ok-bg: #e6f4ec; --warn: #9a5b00; --warn-bg: #fdf3e1; --err: #b42318; --err-bg: #fdecea;
  --test: #6941c6; --test-bg: #f1ecfb; --prod: #b54708; --prod-bg: #fdf0e6;
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101317; --panel: #171b20; --fg: #e4e7eb; --muted: #9aa5b1; --faint: #616e7c; --line: #2a3037; --soft: #1c2127;
    --accent: #7aa7e6; --accent-fg: #0d1520; --accent-soft: #1f2d42;
    --ok: #5fcf8f; --ok-bg: #173325; --warn: #f0b552; --warn-bg: #3a2c12; --err: #f2867c; --err-bg: #3d1c19;
    --test: #b69cf0; --test-bg: #2a2140; --prod: #f2a46b; --prod-bg: #3a2416;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0; font-weight: 600; }
h3 { font-size: 13px; margin: 18px 0 8px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* layout */
.top { display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 54px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand svg { width: 22px; height: 22px; color: var(--accent); }
.top nav { display: flex; gap: 4px; }
.top nav a { padding: 6px 10px; border-radius: 7px; color: var(--muted); font-weight: 500; }
.top nav a.active, .top nav a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.top .who { margin-left: auto; display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 13px; }
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 54px); }
.side { border-right: 1px solid var(--line); padding: 16px 12px; background: var(--panel); }
.side h3 { margin: 4px 8px 8px; }
.side a.item { display: flex; justify-content: space-between; align-items: center; padding: 7px 8px; border-radius: 7px; color: var(--fg); }
.side a.item:hover { background: var(--soft); text-decoration: none; }
.side a.item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side .dots { display: flex; gap: 3px; }
.main { padding: 24px 28px 60px; min-width: 0; max-width: 1240px; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
@media (max-width: 820px) { .shell { grid-template-columns: 1fr; } .side { border-right: 0; border-bottom: 1px solid var(--line); } .main { padding: 16px; } .top { overflow-x: auto; } }

/* pieces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.card.flush { padding: 0; overflow: hidden; }
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--fg); border-color: var(--accent); text-decoration: none; }
.tabs a:hover { text-decoration: none; color: var(--fg); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.test { background: var(--test-bg); color: var(--test); border-color: transparent; }
.badge.production { background: var(--prod-bg); color: var(--prod); border-color: transparent; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.err { background: var(--err-bg); color: var(--err); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--faint); }
.dot.test { background: var(--test); } .dot.production { background: var(--prod); }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--soft); white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }

/* stats */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.envline { display: grid; grid-template-columns: minmax(150px, 1.4fr) repeat(3, minmax(60px, .5fr)) minmax(120px, 1fr); gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.envline:first-of-type { border-top: 0; }
@media (max-width: 700px) { .envline { grid-template-columns: 1fr 1fr; } }

/* forms */
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 500; color: var(--muted); min-width: 0; }
label.f.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--fg); font-size: 13.5px; }
input, select, textarea { font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; min-width: 0; width: 100%; }
input[type=checkbox] { width: auto; }
textarea { font-family: var(--mono); font-size: 12.5px; min-height: 90px; resize: vertical; }
input.mono { font-family: var(--mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form .wide { grid-column: 1 / -1; }
.help { font-size: 12px; color: var(--faint); font-weight: 400; }

button, .btn { font: inherit; font-weight: 550; font-size: 13.5px; border-radius: 7px; padding: 7px 13px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover { background: var(--soft); }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--err); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 5px 8px; }
button.ghost:hover { color: var(--fg); background: var(--soft); }
button:disabled { opacity: .5; cursor: default; }
button.small { padding: 4px 9px; font-size: 12.5px; }

/* steps */
.step { border: 1px solid var(--line); border-radius: 9px; margin-bottom: 10px; background: var(--panel); }
.step > header { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--soft); border-bottom: 1px solid var(--line); border-radius: 9px 9px 0 0; }
.step > header .n { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.step > header select { width: auto; max-width: 300px; font-weight: 600; }
.step .body { padding: 12px; }
.maprow { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin-bottom: 6px; }
.oplist { font-size: 12px; color: var(--muted); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1050px) { .split { grid-template-columns: 1fr; } }
.sticky { position: sticky; top: 70px; }

.trace { font-family: var(--mono); font-size: 12px; background: var(--soft); border-radius: 7px; padding: 10px 12px; max-height: 260px; overflow: auto; margin: 0; white-space: pre-wrap; }
.problems { background: var(--err-bg); color: var(--err); border-radius: 7px; padding: 8px 12px; font-size: 13px; margin-bottom: 10px; }
.notice { background: var(--accent-soft); color: var(--fg); border-radius: 7px; padding: 10px 14px; font-size: 13px; margin-bottom: 12px; }
.secret { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.secret:first-child { border-top: 0; }
.copy { display: flex; gap: 6px; align-items: center; }
.copy code { background: var(--soft); padding: 5px 8px; border-radius: 6px; overflow-x: auto; white-space: nowrap; flex: 1; min-width: 0; display: block; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.login { max-width: 380px; margin: 12vh auto 0; }
.login .card { padding: 26px; }
.login h1 { margin-bottom: 14px; }
.login form { display: grid; gap: 12px; }
.qr { background: #fff; padding: 10px; border-radius: 8px; width: 200px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 13.5px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; z-index: 20; }
#toast.show { opacity: 1; }
#toast.err { background: var(--err); color: #fff; }
.preview { background: var(--soft); border-radius: 9px; padding: 12px; }
.grid > *, .split > *, .form > * { min-width: 0; }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
label.f.inline { white-space: nowrap; }
.row.nowrap { flex-wrap: nowrap; }
@media (max-width: 600px) { .top .who span { display: none; } .brand span { display: none; } }
