:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1d2330; --muted: #6b7280; --border: #e3e6eb;
  --accent: #2563eb; --accent-text: #fff; --danger: #dc2626; --ok: #16a34a; --soft: #eef2ff;
  --warn: #b45309; --code: #f3f4f6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1b1f27; --text: #e6e8ec; --muted: #9aa3b2; --border: #2c323d;
    --accent: #4f8cff; --accent-text: #fff; --danger: #f87171; --ok: #4ade80; --soft: #1f2a44;
    --warn: #fbbf24; --code: #151920;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
header { padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--panel);
         display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
header h1 { font-size: 16px; margin: 0; }
header nav { display: flex; gap: 4px; }
header nav a { color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 6px; font-size: 13px; }
header nav a.active { background: var(--soft); color: var(--accent); font-weight: 600; }
header .right { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
main { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
h2 { font-size: 15px; margin: 0 0 4px; }
p.hint { color: var(--muted); margin: 0 0 12px; font-size: 13px; }
label { display: block; font-weight: 600; margin: 0 0 4px; font-size: 13px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); font: inherit; }
textarea { display: block; resize: vertical; min-height: 38px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
button.btn { padding: 7px 14px; border-radius: 6px; border: 1px solid var(--border); cursor: pointer;
             background: var(--panel); color: var(--text); font: inherit; white-space: nowrap; }
button.btn:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.sm { padding: 3px 10px; font-size: 12px; }
button.danger { color: var(--danger); }
button.danger.armed { background: var(--danger); border-color: var(--danger); color: #fff; }
.status { color: var(--muted); font-size: 13px; min-height: 20px; margin-top: 8px; }
.status.ok { color: var(--ok); } .status.err { color: var(--danger); }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 1px 9px; border-radius: 999px;
         border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); } .badge.err { color: var(--danger); } .badge.warn { color: var(--warn); }
.badge.plain::before { display: none; }
code, .mono { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--bg); }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 18px; font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
.stat .v.small { font-size: 13px; font-weight: 500; }
.switch { position: relative; display: inline-block; width: 34px; height: 20px; margin: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 999px; cursor: pointer; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px;
                       background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(14px); }
dialog { border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text);
         padding: 20px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h3 { margin: 0 0 12px; font-size: 15px; }
dialog .field { margin-bottom: 12px; }
dialog .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
pre { background: var(--code); border: 1px solid var(--border); border-radius: 6px; padding: 10px; margin: 0;
      overflow: auto; max-height: 360px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 640px) { header { padding: 12px 16px; } }
