:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e3e8f2;
  --text: #1c2537;
  --muted: #6b7893;
  --accent: #3b6dd8;
  --accent-soft: #eaf1ff;
  --green: #1d9e75;
  --green-soft: #e4f5ee;
  --red: #c0392b;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; }
h1, h2, h3 { margin: 0; font-weight: 500; }
h3 { font-size: 15px; margin-bottom: 14px; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 8px; }
.muted { color: var(--muted); font-size: 13px; }
[hidden] { display: none !important; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px; }
.login-mark { display: inline-block; font-size: 12px; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 3px 10px; margin-bottom: 16px; }
.login-card h1 { font-size: 22px; }
.login-card p { margin: 4px 0 22px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.login-card input { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; color: var(--text); background: #fff; }
.login-card input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
button { cursor: pointer; font-family: inherit; }
.login-card button[type="submit"] { width: 100%; padding: 11px; margin-top: 6px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-size: 15px; }
.login-card button[type="submit"]:disabled { opacity: .6; cursor: wait; }
.error-text { color: var(--red); font-size: 13px; min-height: 20px; margin: 10px 0 0; }

.topbar { display: flex; align-items: center; gap: 20px; padding: 0 24px; height: 62px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { font-size: 16px; font-weight: 500; }
.brand small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 8px; }
.online-badge { background: var(--green-soft); color: #0f6e56; border-radius: 20px; padding: 5px 14px; font-size: 13px; }
.online-badge strong { font-size: 17px; margin: 0 4px; }
.stream-state { font-size: 11px; opacity: .75; margin-left: 6px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
select, .btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 7px 12px; font-size: 13px; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.ghost { color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { color: #fff; opacity: .9; }
.btn:disabled { opacity: .55; cursor: wait; }

main { padding: 22px 24px 40px; max-width: 1500px; margin: 0 auto; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.metric .label { font-size: 12px; color: var(--muted); }
.metric .value { font-size: 26px; font-weight: 500; margin-top: 4px; line-height: 1.2; }
.metric .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.metric.live .value { color: var(--green); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; min-width: 0; }
.card.wide { grid-column: span 2; }
@media (max-width: 900px) { .card.wide { grid-column: span 1; } }
.chart-box { position: relative; height: 220px; }
.chart-box canvas { width: 100% !important; height: 100% !important; }

.table-scroll { overflow-x: auto; max-height: 320px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--surface); }
tbody tr:hover { background: #f8faff; }
.empty { color: var(--muted); text-align: center; padding: 26px 0; font-size: 13px; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 8px 14px; font-size: 14px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; font-size: 13px; color: var(--muted); }

#configCard { margin-top: 14px; }
#configEditor { width: 100%; min-height: 220px; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; border: 1px solid var(--border); border-radius: 8px; padding: 14px; resize: vertical; color: var(--text); background: #fbfcff; }
.config-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; gap: 12px; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 28px 0 8px; }

.toast { position: fixed; right: 24px; bottom: 24px; background: #1c2537; color: #fff; padding: 11px 18px; border-radius: 8px; font-size: 13px; z-index: 20; }
.toast.error { background: var(--red); }
.offline { position: fixed; top: 0; left: 0; right: 0; background: #fff3cd; color: #7a5b00; text-align: center; padding: 6px; font-size: 13px; z-index: 30; }
