:root {
  --bg: #f4f5f7; --card: #ffffff; --fg: #15171c; --muted: #6b7280; --line: #e3e5ea;
  --accent: #2563eb; --red: #dc2626; --red-bg: #fde8e8; --green: #16a34a; --green-bg: #e3f6e9;
  --yellow: #d97706; --yellow-bg: #fdf1dc; --blue: #2563eb; --blue-bg: #e2ebfd;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 10px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216; --card: #1a1d23; --fg: #e8eaee; --muted: #949aa6; --line: #2a2e36;
    --accent: #5b8cff; --red: #f05252; --red-bg: #3a1618; --green: #34c06a; --green-bg: #13301e;
    --yellow: #f0a430; --yellow-bg: #362710; --blue: #5b8cff; --blue-bg: #18233d;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 4px 8px; }
code { background: var(--line); padding: 1px 5px; border-radius: 5px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px var(--line); }
.tabs { position: sticky; top: 53px; z-index: 4; display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px;
  background: var(--bg); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; border: 0; background: transparent; color: var(--muted); padding: 8px 12px;
  border-radius: 999px; font: inherit; font-weight: 550; cursor: pointer; }
.tabs button.active { background: var(--card); color: var(--fg); box-shadow: var(--shadow); }
main { max-width: 720px; margin: 0 auto; padding: 4px 16px 40px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  margin: 12px 0; box-shadow: var(--shadow); }
label { display: block; margin: 10px 0; font-weight: 550; }
input, select, textarea { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit;
  color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=range] { padding: 0; border: 0; background: transparent; accent-color: var(--accent); height: 32px; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.switch input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--accent); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px;
  font: inherit; font-weight: 600; color: var(--fg); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ok { background: var(--green); border-color: var(--green); color: #fff; }
.btn.ghost { background: transparent; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; } .wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; } .mt { margin-top: 14px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: 13px; } .err { color: var(--red); min-height: 1em; }

.hero { margin: 12px 0; padding: 26px 20px; border-radius: var(--radius); text-align: center;
  background: var(--card); border: 1px solid var(--line); transition: background .3s; }
.hero-state { font-size: 30px; font-weight: 750; letter-spacing: -.01em; }
.hero-region { margin-top: 4px; font-weight: 550; }
.hero-since { margin-top: 2px; color: var(--muted); font-size: 14px; }
.hero.alert { background: var(--red-bg); border-color: var(--red); } .hero.alert .hero-state { color: var(--red); }
.hero.alert.yellow { background: var(--yellow-bg); border-color: var(--yellow); } .hero.alert.yellow .hero-state { color: var(--yellow); }
.hero.ok { background: var(--green-bg); border-color: var(--green); } .hero.ok .hero-state { color: var(--green); }
.hero.warn { background: var(--yellow-bg); border-color: var(--yellow); } .hero.warn .hero-state { color: var(--yellow); }
.hero.setup { background: var(--blue-bg); border-color: var(--blue); } .hero.setup .hero-state { color: var(--blue); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 .card { margin: 0; }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-weight: 650; font-size: 17px; margin-top: 2px; display: flex; align-items: center; gap: 8px; }
.stat .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; word-break: break-word; }
.led { width: 16px; height: 16px; border-radius: 50%; background: #555; flex: none; }
.led.red, .dot.red { background: var(--red); box-shadow: 0 0 10px var(--red); }
.led.green, .dot.green { background: var(--green); box-shadow: 0 0 10px var(--green); }
.led.yellow, .dot.yellow { background: var(--yellow); box-shadow: 0 0 10px var(--yellow); }
.led.blue, .dot.blue { background: var(--blue); box-shadow: 0 0 10px var(--blue); }

#playingBar { margin: 12px 0; padding: 10px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: p 1s infinite alternate; flex: none; }
@keyframes p { to { opacity: .2; } }

.events, .list { list-style: none; margin: 0; padding: 0; }
.events li { display: flex; gap: 12px; padding: 10px 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; margin-bottom: 6px; }
.events time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.events .alert_start b { color: var(--red); } .events .alert_end b { color: var(--green); }
.events .offline b { color: var(--yellow); }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.push-sec { border: 1px solid var(--line); border-radius: 10px; padding: 0 12px 10px; margin: 10px 0; }
.push-sec summary { margin: 0 -12px; padding: 10px 12px; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0 6px; }
.boxes li input[type=checkbox] { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--accent); }
details summary { cursor: pointer; margin: 10px 0 4px; }
.banner { margin: 12px 0; padding: 12px 14px; border-radius: 12px; background: var(--yellow-bg); color: var(--fg);
  border: 1px solid var(--yellow); font-weight: 550; cursor: pointer; }
.matrix { width: 100%; border-collapse: collapse; margin-top: 6px; }
.matrix th { font-size: 12.5px; color: var(--muted); font-weight: 600; text-align: center; padding: 6px 4px; }
.matrix th:first-child { text-align: left; }
.matrix td { padding: 8px 4px; border-top: 1px solid var(--line); }
.matrix td:not(:first-child) { text-align: center; width: 92px; }
.matrix input { width: 20px; height: 20px; margin: 0 auto; accent-color: var(--accent); }
.time-inline { width: auto; margin: 0; }
.boxes li { flex-wrap: wrap; }
.boxes .meta { width: 100%; padding-left: 26px; color: var(--muted); font-size: 12.5px; }
.badge { font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 999px; }
.badge.ok { background: var(--green-bg); color: var(--green); }
.badge.warn { background: var(--yellow-bg); color: var(--yellow); }
.badge.err { background: var(--red-bg); color: var(--red); }
.bars { font-family: ui-monospace, monospace; color: var(--accent); width: 36px; flex: none; }

.result, .logs { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.logs { max-height: 50vh; overflow: auto; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }
.login-card .btn { width: 100%; margin-top: 6px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); opacity: 0;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 10px; background: var(--fg); color: var(--bg);
  font-weight: 550; transition: .2s; pointer-events: none; z-index: 10; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.bad { background: var(--red); color: #fff; }

@media (max-width: 380px) { .grid2 { grid-template-columns: 1fr; } }
