:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #16181d;
  --muted: #5f6672;
  --line: #e3e6eb;
  --accent: #2456e6;
  --accent-ink: #ffffff;
  --ok: #138a4a;
  --warn: #b7791f;
  --bad: #c62828;
  --code: #f0f2f5;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --panel: #171b21; --text: #e8eaee; --muted: #9aa3b0; --line: #2a3038;
    --accent: #6a8dff; --accent-ink: #0b0f1a; --ok: #4ccb84; --warn: #e2b04a; --bad: #ff6b6b; --code: #1f242c;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --panel: #171b21; --text: #e8eaee; --muted: #9aa3b0; --line: #2a3038;
  --accent: #6a8dff; --accent-ink: #0b0f1a; --ok: #4ccb84; --warn: #e2b04a; --bad: #ff6b6b; --code: #1f242c;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code, pre { font-family: var(--mono); font-size: .86em; }
code { background: var(--code); padding: .1em .35em; border-radius: 5px; }
pre { background: var(--code); padding: .75rem 1rem; border-radius: var(--radius); overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.wrap { width: min(1180px, 100% - 32px); margin: 0 auto; padding: 1.25rem 0 3rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 0 1rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; text-decoration: none; color: var(--text); }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); display: inline-block; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.nav button { background: transparent; border: 1px solid transparent; color: var(--muted); padding: .4rem .75rem; border-radius: 8px; cursor: pointer; font: inherit; }
.nav button.active { background: var(--panel); border-color: var(--line); color: var(--text); font-weight: 600; }
.nav button .pill { margin-left: .4rem; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid.cols-4, .grid.cols-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } }
.stat .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.7rem; font-weight: 700; margin-top: .15rem; }
.stat .sub { color: var(--muted); font-size: .85rem; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.table-wrap { overflow-x: auto; }

.pill { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.pill.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: .45rem .8rem; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; }
button:hover, .btn:hover { border-color: var(--accent); }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--bad); }
button.sm { padding: .25rem .55rem; font-size: .82rem; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .45rem .6rem; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
.field { margin-bottom: .75rem; }
.field.inline { display: flex; align-items: center; gap: .5rem; }
.field.inline input[type=checkbox] { width: auto; }
.toggle { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; }
.toggle input { width: auto; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; padding: 1rem; z-index: 10; }
.modal-bg.open { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: min(640px, 100%); max-height: 92vh; overflow: auto; padding: 1.25rem; }
.keybox { font-family: var(--mono); background: var(--code); border-radius: 8px; padding: .6rem .75rem; word-break: break-all; display: flex; gap: .5rem; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.keybox span { flex: 1; }
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .5rem .9rem; border-radius: 8px; font-size: .9rem; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; }
.toast.show { opacity: 1; }

.bars { display: flex; align-items: flex-end; gap: 3px; height: 90px; margin-top: .5rem; }
.bars div { flex: 1; background: var(--accent); opacity: .85; border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars div:hover { opacity: 1; }
.bars div::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); font-size: .7rem; padding: .1rem .35rem; border-radius: 4px; white-space: nowrap; opacity: 0; pointer-events: none; }
.bars div:hover::after { opacity: 1; }

.login { width: min(440px, 100%); margin: 10vh auto; }
.empty { color: var(--muted); padding: 1.5rem; text-align: center; }
details.args summary { cursor: pointer; color: var(--accent); font-size: .85rem; }
details.args pre { margin-top: .4rem; max-height: 260px; }

/* landing */
.hero { padding: 2.5rem 0 1.5rem; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
.hero p.lead { font-size: 1.1rem; color: var(--muted); max-width: 46rem; }
.steps { counter-reset: s; }
.steps li { margin-bottom: .6rem; }
ul.tight { margin: 0; padding-left: 1.2rem; }
ul.tight li { margin-bottom: .25rem; }
.cta { margin-top: 1rem; }
footer { color: var(--muted); font-size: .85rem; margin-top: 2rem; }
