:root {
  --bg: #f6f7f9; --card: #ffffff; --text: #1b1f24; --muted: #667085; --line: #e4e7ec;
  --accent: #2f6fde; --ok: #1f8a4c; --ok-bg: #e6f4ec; --warn: #a15c00; --warn-bg: #fdf1dc;
  --err: #c4320a; --err-bg: #fdecea; --chip: #eef0f3; --code: #f1f3f6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --card: #1a1e24; --text: #e6e8eb; --muted: #98a2b3; --line: #2b313a;
    --accent: #6ea0ff; --ok: #5fd08f; --ok-bg: #16301f; --warn: #f0b45a; --warn-bg: #352812;
    --err: #ff8a72; --err-bg: #3a1a14; --chip: #262c34; --code: #20252c;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
code { background: var(--code); padding: 1px 5px; border-radius: 4px; }
small, .muted { color: var(--muted); }
h2 { font-size: 15px; margin: 0 0 10px; }
h2 + h2, table + h2, p + h2 { margin-top: 18px; }
h3 { font-size: 13px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.top { display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2; }
.brand { font-weight: 700; font-size: 16px; }
.mode { font-weight: 600; font-size: 11px; margin-left: 4px; padding: 2px 6px; border-radius: 4px;
  background: var(--accent); color: #fff; text-transform: uppercase; letter-spacing: .05em; vertical-align: 2px; }
.mode-ro { background: var(--muted); }
nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
nav a { padding: 6px 10px; border-radius: 6px; color: var(--text); }
nav a:hover { background: var(--chip); text-decoration: none; }
nav a.on { background: var(--chip); font-weight: 600; }
nav a.ext { color: var(--muted); }

main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; margin-bottom: 16px; }
@media (max-width: 520px) { .grid { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px;
  margin-bottom: 16px; overflow-x: auto; }
.grid > .card { margin-bottom: 0; }
.card.narrow { max-width: 640px; }
.card.login { max-width: 380px; margin: 60px auto; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.dim td { opacity: .5; }
td.wide { min-width: 220px; }
td.actions { white-space: nowrap; text-align: right; }

dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 12px; }
dt { color: var(--muted); }
dd { margin: 0; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--chip); color: var(--muted); }
.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); }

.meter-row { display: grid; grid-template-columns: 70px 1fr max-content; gap: 10px; align-items: center; margin: 6px 0; }
.meter-row.tight { grid-template-columns: 1fr max-content; margin: 0; }
progress.meter { width: 100%; height: 8px; border: 0; border-radius: 4px; overflow: hidden;
  appearance: none; background: var(--chip); }
progress.meter::-webkit-progress-bar { background: var(--chip); }
progress.meter::-webkit-progress-value { background: var(--accent); }
progress.meter::-moz-progress-bar { background: var(--accent); }
progress.meter.warn::-webkit-progress-value { background: var(--warn); }
progress.meter.warn::-moz-progress-bar { background: var(--warn); }

button { font: inherit; font-weight: 600; padding: 7px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff; }
button:hover { filter: brightness(1.08); }
button.small { padding: 2px 10px; font-size: 12px; background: transparent; color: var(--accent); }
button.danger { border-color: var(--err); background: transparent; color: var(--err); }
button.link { border: 0; background: none; color: var(--muted); padding: 6px 10px; font-weight: 400; }
input, textarea, select { font: inherit; color: var(--text); background: var(--bg); width: 100%;
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; }
textarea { font-family: ui-monospace, monospace; font-size: 12px; }
label { display: block; font-weight: 600; font-size: 13px; }
label input, label textarea { margin-top: 4px; font-weight: 400; }
form.stack { display: grid; gap: 10px; max-width: 560px; }
form.row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
form.row input, form.row select { flex: 1 1 140px; width: auto; }
form.inline { display: inline; }
details summary { cursor: pointer; color: var(--accent); font-size: 12px; margin-top: 4px; }
details form { margin-top: 8px; }
.key { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid transparent; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }
.secret { margin-top: 8px; color: var(--text); }
.secret code { font-size: 15px; padding: 3px 8px; user-select: all; }
.secret small { display: block; margin-top: 4px; }

pre.log { background: var(--code); padding: 12px; border-radius: 8px; max-height: 420px; overflow: auto;
  white-space: pre-wrap; word-break: break-word; margin: 0; }
.qr svg { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: 8px; }

.busy { position: fixed; bottom: 16px; right: 16px; background: var(--text); color: var(--bg);
  padding: 6px 12px; border-radius: 6px; font-size: 12px; opacity: 0; transition: opacity .15s; pointer-events: none; }
.busy.htmx-request { opacity: .9; }
