:root {
  --bg: #0d1117; --panel: #161b22; --panel-2: #1c232d; --line: #2a3340;
  --text: #e6edf3; --muted: #8b98a8; --accent: #3b82f6; --accent-2: #2563eb;
  --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: #7db3ff; }
h1, h2 { margin: 0; font-weight: 650; letter-spacing: .01em; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.05rem; }
.muted { color: var(--muted); font-weight: 400; }
.fine { color: var(--muted); font-size: .82rem; text-align: center; margin: 1.1rem 0 0; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; align-items: center; } .gap { gap: .6rem; } .wrap { flex-wrap: wrap; } .spacer { flex: 1; }

:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }

/* ---------- buttons & inputs ---------- */
.btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; cursor: pointer;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .95rem;
  font: inherit; font-weight: 550; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover { background: #232c38; border-color: #3a4656; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: #7f1d1d; border-color: #b91c1c; color: #fff; }
.btn.danger:hover { background: #991b1b; }
.btn.small { padding: .3rem .65rem; font-size: .85rem; border-radius: 7px; }
.btn.icon { padding: .3rem .45rem; } .btn.icon svg { width: 18px; height: 18px; display: block; }
.btn.wide { width: 100%; margin-top: 1.1rem; padding: .7rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label { display: block; margin: .9rem 0 .3rem; font-size: .85rem; font-weight: 600; }
input, select { width: 100%; background: #0b0f14; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; font: inherit; }
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,.25); }
input.filter { width: 12rem; padding: .35rem .6rem; font-size: .85rem; }
.alert { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.45); color: #fecaca; padding: .6rem .8rem; border-radius: 8px; margin: .8rem 0 0; font-size: .9rem; }

/* ---------- auth pages ---------- */
.auth-page { display: grid; place-items: center; min-height: 100%; padding: 1.2rem; background:
  radial-gradient(1200px 500px at 50% -10%, rgba(59,130,246,.18), transparent), var(--bg); }
.auth-card { width: min(100%, 380px); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.8rem 1.6rem 1.5rem; box-shadow: 0 20px 50px rgba(0,0,0,.45); }
.brand { display: flex; align-items: center; gap: .6rem; }
.brand-icon { width: 28px; height: 28px; color: var(--accent); }
.auth-card .muted { margin: .3rem 0 .4rem; }

/* ---------- viewer ---------- */
.viewer-page { overflow: hidden; background: #000; }
.stage { position: fixed; inset: 0; background: #000; }
.feed { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; pointer-events: none; }
.feed::-webkit-media-controls, .feed::-webkit-media-controls-enclosure, .feed::-webkit-media-controls-panel,
.feed::-webkit-media-controls-start-playback-button { display: none !important; -webkit-appearance: none; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; transition: opacity .35s; }
.overlay.idle { opacity: 0; cursor: none; } .overlay.idle * { cursor: none; }
.overlay.idle { pointer-events: none; }
.topbar { display: flex; align-items: center; gap: .55rem; padding: .8rem 1rem calc(.8rem + 1.6rem);
  background: linear-gradient(to bottom, rgba(0,0,0,.7), rgba(0,0,0,0)); }
.topbar .btn { background: rgba(20,24,30,.65); backdrop-filter: blur(6px); }
.topbar .btn:hover { background: rgba(40,48,60,.85); }
.who { color: #cbd5e1; font-size: .85rem; max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: .5rem; padding: .3rem .7rem; border-radius: 999px; font-size: .8rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; background: rgba(20,24,30,.65); backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.1); }
.badge .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); }
.badge[data-state="live"] .dot { background: var(--bad); box-shadow: 0 0 0 0 rgba(239,68,68,.6); animation: pulse 1.8s infinite; }
.badge[data-state="error"] .dot { background: #64748b; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(239,68,68,0); } 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); } }
.center-message { margin: auto; max-width: min(90%, 28rem); text-align: center; padding: 1rem 1.3rem; font-weight: 600; color: #e2e8f0;
  background: rgba(10,14,20,.7); border-radius: 12px; backdrop-filter: blur(6px); }
.center-message:empty { display: none; }
.stage.live .center-message { display: none; }
.stage.live .overlay .center-message { display: none; }

/* ---------- admin ---------- */
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .9rem 1.4rem; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.admin-main { max-width: 1250px; margin: 0 auto; padding: 1.2rem 1.4rem 4rem; }
.admin-main section { margin-top: 1.8rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .7rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; }
.card-label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.card-value { font-size: 1.6rem; font-weight: 700; margin-top: .15rem; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; background: var(--panel-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.025); }
td.empty { text-align: center; color: var(--muted); padding: 1.4rem; }
td.actions, th.actions { text-align: right; }
td.actions .btn { margin-left: .3rem; }
.pill { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 650; border: 1px solid var(--line); }
.pill.ok { color: #86efac; border-color: rgba(34,197,94,.5); background: rgba(34,197,94,.1); }
.pill.bad { color: #fca5a5; border-color: rgba(239,68,68,.5); background: rgba(239,68,68,.1); }
.pill.warn { color: #fcd34d; border-color: rgba(245,158,11,.5); background: rgba(245,158,11,.1); }
.pill.info { color: #93c5fd; border-color: rgba(59,130,246,.5); background: rgba(59,130,246,.1); }
.tabs { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tab { appearance: none; border: 0; background: transparent; color: var(--muted); padding: .38rem .8rem; font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.tab.active { background: var(--accent); color: #fff; }
.toast { position: fixed; right: 1rem; bottom: 1rem; background: #0f2a1a; border: 1px solid #166534; color: #bbf7d0; padding: .65rem .9rem; border-radius: 8px; z-index: 20; max-width: 22rem; }
.toast.error { background: #2a1010; border-color: #7f1d1d; color: #fecaca; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(92vw, 420px); }
dialog::backdrop { background: rgba(0,0,0,.65); }
.dlg-body { padding: 1.3rem 1.4rem 1.2rem; }
.dlg-body h2 { margin-bottom: .4rem; }
.dlg-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.2rem; }
.secret { display: flex; align-items: center; gap: .6rem; background: #0b0f14; border: 1px dashed var(--line); border-radius: 8px; padding: .7rem .8rem; }
.secret code { flex: 1; font-size: 1.1rem; letter-spacing: .06em; user-select: all; word-break: break-all; }

@media (max-width: 640px) {
  .topbar { padding: .6rem .6rem 2rem; gap: .35rem; flex-wrap: wrap; }
  .who { display: none; }
  .admin-main { padding: 1rem .8rem 3rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
