:root {
  color-scheme: light dark;
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #eef0f3; --text: #1b1f27; --muted: #5d6673; --line: #dfe2e7;
  --brand: #1d4e89; --brand-text: #ffffff;
  --ok: #17693a; --ok-bg: #e2f4e9; --bad: #a92525; --bad-bg: #fbe6e6; --warn: #8a5b00; --warn-bg: #fdf1d7; --off: #5d6673; --off-bg: #e9ebee;
  --shadow: 0 1px 2px rgba(20, 25, 35, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151a; --surface: #1b1f26; --surface-2: #252a33; --text: #eceef2; --muted: #a0a8b4; --line: #313742;
    --brand: #6ea8e8; --brand-text: #0d1420;
    --ok: #63d394; --ok-bg: #16352a; --bad: #ff8f8f; --bad-bg: #421f22; --warn: #f0c261; --warn-bg: #3d3019; --off: #a0a8b4; --off-bg: #2b303a;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-in { max-width: 1120px; margin: auto; padding: 0 20px; display: flex; align-items: center; gap: 20px; min-height: 56px; flex-wrap: wrap; }
.logo { font-weight: 700; font-size: 16px; }
.logo span { color: var(--brand); }
nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.nav-btn { background: none; border: 0; padding: 8px 12px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.badge-count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: var(--surface); font-size: 12px; font-weight: 700; text-align: center; margin-left: 4px; }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }

main { max-width: 1120px; margin: auto; padding: 24px 20px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 10px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 24px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.alert b { color: var(--bad); }

.group { margin-bottom: 22px; }
.group-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.group-head small { color: var(--muted); }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); }
.row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; flex-wrap: wrap; }
.row:first-child { border-top: 0; }
button.row:hover { background: var(--surface-2); }
.row-main { flex: 1 1 220px; min-width: 0; }
.row-main strong { display: block; overflow-wrap: anywhere; }
.row-main small { color: var(--muted); overflow-wrap: anywhere; }
.row-side { color: var(--muted); font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--off); }
.dot.on { background: var(--ok); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.off { color: var(--off); background: var(--off-bg); }

.btn { border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 6px; font-weight: 600; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-text); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.btn.danger:hover { filter: brightness(1.1); }
.btn.small { padding: 4px 10px; font-size: 13px; font-weight: 500; }
.btn:disabled { opacity: .55; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.panel h3 { margin-bottom: 10px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 20px; margin: 0; }
.facts dt { color: var(--muted); font-size: 12.5px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.back { background: none; border: 0; color: var(--brand); padding: 0; margin-bottom: 12px; font-weight: 600; }
.notice { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }

table { width: 100%; border-collapse: collapse; }
.table-wrap { overflow-x: auto; }
th, td { text-align: left; padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 12.5px; font-weight: 600; border-top: 0; white-space: nowrap; }
td { overflow-wrap: anywhere; }

label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 12px; }
label input, label select, label textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-weight: 400; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; margin: 0 0 12px; }
.error { color: var(--bad); font-size: 14px; min-height: 20px; margin: 0 0 10px; }
.mono { font-family: Consolas, "Courier New", monospace; }
.secret { font: 600 18px Consolas, "Courier New", monospace; background: var(--surface-2); padding: 12px; border-radius: 6px; text-align: center; overflow-wrap: anywhere; letter-spacing: .05em; user-select: all; margin-bottom: 14px; }
.big-code { font-size: 28px; }

.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-box { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 26px; box-shadow: var(--shadow); }
.auth-box h1 { margin-bottom: 4px; }
.auth-box .sub { color: var(--muted); margin: 0 0 18px; }
.auth-box .btn { width: 100%; }
.auth-box ol { padding-left: 20px; margin: 0 0 14px; }

.modal-back { position: fixed; inset: 0; background: rgba(10, 14, 20, .5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modal { background: var(--surface); border-radius: 10px; padding: 22px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal h2 { margin-bottom: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 30; display: none; max-width: 90vw; }
#toast.show { display: block; }

@media (max-width: 640px) {
  main { padding: 16px 16px 50px; }
  .topbar-in { padding: 8px 16px; gap: 8px; }
  nav { order: 3; flex-basis: 100%; }
  .who span { display: none; }
  .who { margin-left: auto; }
}
