:root {
  --bg: #f6f7f9; --card: #ffffff; --text: #14171c; --muted: #667085; --line: #e4e7ec;
  --accent: #2563eb; --accent-text: #ffffff; --good: #15803d; --bad: #c62828;
  --warn-bg: #fff4e5; --warn-text: #8a4b00; --danger-bg: #fdecec;
  --radius: 14px; --pad: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --card: #171a21; --text: #e8eaed; --muted: #9aa3b2; --line: #272c36;
    --accent: #4f8cff; --accent-text: #ffffff; --good: #3ecf6e; --bad: #ff6b6b;
    --warn-bg: #3a2a10; --warn-text: #ffcf87; --danger-bg: #3a1618;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; }
h1 { margin: 0; font-size: 26px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  margin: 24px 4px 8px; }

/* layout */
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between;
  align-items: center; padding: calc(10px + env(safe-area-inset-top)) var(--pad) 10px;
  background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 18px; display: flex; gap: 8px; align-items: center; }
main { max-width: 760px; margin: 0 auto; padding: var(--pad) var(--pad)
  calc(90px + env(safe-area-inset-bottom)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--pad); }
.row { display: flex; gap: 8px; margin-top: 12px; }
.row > * { flex: 1; }

/* buttons */
.btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 12px 14px; font-size: 16px; font-weight: 600; min-height: 46px;
  cursor: pointer; text-align: center; text-decoration: none; display: inline-block; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { background: var(--danger-bg); border-color: var(--bad); color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.block { display: block; width: 100%; margin-top: 12px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--pad); }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-card input { margin-top: 18px; }

/* forms */
input, select, textarea { width: 100%; font: inherit; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; }
textarea { font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
.form label { display: block; margin-bottom: 16px; font-weight: 600; font-size: 14px; }
.form label > input, .form label > select, .form label > textarea { margin-top: 6px; font-weight: 400; }
.form small { display: block; font-weight: 400; margin-top: 6px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 16px; padding: 10px 12px; }
legend { font-weight: 600; font-size: 14px; padding: 0 4px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400;
  margin: 8px 0; font-size: 15px; }
label.check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; }
label.check small { margin-top: 2px; }

/* status */
.status-line { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 25%, transparent); }
.dot.wait { background: #e0a100; }
.dot.off { background: var(--muted); }
.dot.bad { background: var(--bad); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 14px 0 4px; }
.facts div { min-width: 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { font-size: 11px; font-weight: 700; letter-spacing: .05em; padding: 3px 8px;
  border-radius: 999px; background: var(--line); color: var(--muted); }
.badge.live { background: var(--bad); color: #fff; }
.badge.long { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.badge.short { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }

.banner { border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-weight: 600;
  background: var(--warn-bg); color: var(--warn-text); }
.banner.danger { background: var(--danger-bg); color: var(--bad); }

/* kpis */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
@media (min-width: 620px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.kpi span { font-size: 12px; color: var(--muted); }
.kpi b { font-size: 22px; font-variant-numeric: tabular-nums; }
.pos { color: var(--good); } .neg { color: var(--bad); }

/* lists */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.item-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.item-top b { font-size: 16px; }
.item-sub { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 13px;
  color: var(--muted); font-variant-numeric: tabular-nums; }
.item-sub span b { color: var(--text); font-weight: 600; }
.amt { font-weight: 700; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
.r { text-align: right; }
tr:last-child td { border-bottom: 0; }

.logs { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  font: 12px/1.5 ui-monospace, Menlo, monospace; white-space: pre-wrap; word-break: break-word;
  max-height: 70vh; overflow: auto; margin-top: 12px; }
.logs .w { color: var(--warn-text); } .logs .e { color: var(--bad); font-weight: 600; }

/* tab bar */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; z-index: 5;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; background: none; border: 0; color: var(--muted); font: inherit;
  font-size: 14px; font-weight: 600; padding: 14px 0; min-height: 52px; cursor: pointer; }
.tabbar button.active { color: var(--accent); }

.flash { margin: 12px var(--pad) 0; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); z-index: 10;
  bottom: calc(70px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); }
