:root {
  --bg: #0b0c10; --panel: #13151b; --panel2: #1a1d25; --line: #262a35; --fg: #eceef4; --muted: #9097a8;
  --accent: #6d5efc; --accent2: #8b7fff; --ok: #22c55e; --okbg: #12301f; --warn: #f5b942; --bad: #f05252;
  --badbg: #3a1717; --radius: 14px; --shadow: 0 10px 30px rgba(0,0,0,.35);
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f5f6fa; --panel: #ffffff; --panel2: #f0f1f6; --line: #e2e4ec; --fg: #151821; --muted: #646b7d;
          --okbg: #e3f7ea; --badbg: #fde8e8; --shadow: 0 8px 24px rgba(20,24,40,.08); }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 14px/1.45 Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
       -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
.hide { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }
.err { color: var(--bad); min-height: 1em; margin: 0; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font-size: 11px; }

/* brand */
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; letter-spacing: -.01em; }
.brand b { color: var(--accent2); font-weight: 700; }
.brand.big { font-size: 22px; justify-content: center; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #b15cff);
        position: relative; flex: none; box-shadow: 0 4px 14px rgba(109,94,252,.45); }
.logo::after { content: ""; position: absolute; left: 11px; top: 8px; border-left: 9px solid #fff;
               border-top: 6px solid transparent; border-bottom: 6px solid transparent; }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--panel2); border-radius: 10px; padding: 8px 14px; font-weight: 600;
       transition: transform .08s, background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #05210f; }
.btn.bad { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; padding: 11px; }
.icon { background: none; border: 0; font-size: 18px; padding: 6px 8px; border-radius: 8px; }
.icon:hover { background: var(--panel2); }
.link { background: none; border: 0; color: var(--muted); padding: 0; }
.link:hover { color: var(--fg); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 20px;
         background: radial-gradient(800px 400px at 50% -10%, rgba(109,94,252,.25), transparent); }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
              padding: 32px 28px; display: grid; gap: 14px; text-align: center; box-shadow: var(--shadow); }
.login-card input { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2);
                    color: var(--fg); font: inherit; }

/* layout */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100%; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column;
        gap: 6px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.side .brand { padding: 0 8px 16px; }
.nav { display: grid; gap: 2px; }
.nav button { display: flex; align-items: center; gap: 10px; background: none; border: 0; text-align: left;
              padding: 9px 10px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.nav button i { font-style: normal; width: 18px; text-align: center; }
.nav button:hover { background: var(--panel2); color: var(--fg); }
.nav button.on { background: rgba(109,94,252,.14); color: var(--fg); }
.count { margin-left: auto; font-size: 11px; background: var(--panel2); border-radius: 99px; padding: 1px 8px; color: var(--muted); }
.nav button.on .count { background: var(--accent); color: #fff; }
.side-h { margin: 18px 10px 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.chan-list { display: grid; gap: 2px; }
.chan { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 9px; background: none; border: 0;
        text-align: left; color: var(--fg); }
.chan:hover { background: var(--panel2); }
.chan.on { background: var(--panel2); outline: 1px solid var(--line); }
.chan .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chan .off { font-size: 10px; color: var(--muted); }
.side-foot { margin-top: auto; padding: 14px 10px 0; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 10px; padding: 18px 26px; border-bottom: 1px solid var(--line);
       position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); z-index: 5; }
.top h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.view { padding: 22px 26px 60px; }
.only-mobile { display: none; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
        display: flex; flex-direction: column; box-shadow: var(--shadow); transition: opacity .25s, transform .25s; }
.card.leaving { opacity: 0; transform: scale(.96); }
.player { position: relative; aspect-ratio: 9 / 16; background: #000; max-height: 480px; }
.player video, .player img { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.player .nomedia { position: absolute; inset: 0; display: grid; place-items: center; color: #889; font-size: 13px; padding: 20px; text-align: center; }
.badge { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: rgba(0,0,0,.6); color: #fff;
        backdrop-filter: blur(6px); }
.chip.warn { background: rgba(245,185,66,.9); color: #241800; }
.chip.ok { background: var(--okbg); color: var(--ok); }
.chip.bad { background: var(--badbg); color: var(--bad); }
.chip.busy { background: rgba(109,94,252,.85); }
.body { padding: 14px 14px 10px; display: grid; gap: 6px; flex: 1; }
.body h3 { margin: 0; font-size: 15px; line-height: 1.3; }
.meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
details { font-size: 12px; color: var(--muted); }
details summary { cursor: pointer; }
details ul { margin: 6px 0 0; padding-left: 18px; }
.note { font-size: 12px; background: var(--panel2); border-radius: 8px; padding: 7px 9px; color: var(--muted); }
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; padding: 0 14px 14px; }
.actions .btn { padding: 9px 6px; }
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty b { display: block; font-size: 17px; color: var(--fg); margin-bottom: 6px; }

/* list (scheduled / rejected) */
.list { display: grid; gap: 10px; }
.item { display: grid; grid-template-columns: 72px 1fr auto; gap: 14px; align-items: center; background: var(--panel);
        border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.item img { width: 72px; aspect-ratio: 9/16; object-fit: cover; border-radius: 8px; background: #000; }
.item h4 { margin: 0 0 3px; font-size: 14px; }

/* stats */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi .v { font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.kpi .l { color: var(--muted); font-size: 12px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: var(--panel2); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.section-h { margin: 26px 0 10px; font-size: 15px; }
.callout { background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; padding: 14px 16px; color: var(--muted); }

/* focus mode */
.focus { position: fixed; inset: 0; background: rgba(5,6,10,.92); z-index: 30; display: grid; place-items: center; padding: 16px; }
.focus-in { position: relative; width: min(980px, 100%); max-height: 100%; overflow: auto; }
.focus .close { position: absolute; right: 0; top: -6px; color: #fff; }
.fwrap { display: grid; grid-template-columns: minmax(240px, 360px) 1fr; gap: 26px; align-items: start; color: #eef; }
.fwrap .player { border-radius: 16px; overflow: hidden; max-height: 78vh; }
.fwrap h2 { margin: 0 0 8px; font-size: 22px; }
.fwrap .actions { padding: 14px 0 0; }
.keys { text-align: center; margin-top: 14px; }

/* modal + toasts */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal-card { width: min(460px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: grid; gap: 10px; }
.modal-card h3 { margin: 0; }
.modal-card textarea { width: 100%; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--fg);
                       font: inherit; padding: 10px; resize: vertical; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 14px;
         border-radius: 10px; box-shadow: var(--shadow); max-width: 340px; animation: in .2s ease-out; }
.toast.bad { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }
@keyframes in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: var(--shadow); }
  .only-mobile { display: inline-block; }
  .top { padding: 12px 14px; }
  .view { padding: 14px 12px 60px; }
  .grid { grid-template-columns: 1fr; }
  .player { max-height: 70vh; }
  .fwrap { grid-template-columns: 1fr; }
  .toasts { left: 12px; right: 12px; }
  #focusBtn { display: none; }
}

/* fixes: empty counters, focus overlay is always dark */
.count:empty { display: none; }
.focus .btn:not(.ok):not(.bad) { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.22); }
.focus .meta, .focus details, .focus .muted { color: #a9afc0; }
.focus .note { background: rgba(255,255,255,.07); color: #c8cbd6; }
