:root {
  --bg: #f6f7fb; --card: #ffffff; --ink: #1b1f2a; --muted: #667085; --line: #e4e7ee;
  --brand: #4338ca; --brand-ink: #ffffff; --brand-soft: #eef0ff;
  --ok: #15803d; --ok-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7;
  --bad: #b91c1c; --bad-bg: #fee2e2; --info: #1d4ed8; --info-bg: #dbeafe;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --card: #181c25; --ink: #eceff5; --muted: #98a2b3; --line: #2a3040;
    --brand: #8b93ff; --brand-ink: #0f1218; --brand-soft: #22264a;
    --ok: #4ade80; --ok-bg: #12301f; --warn: #fbbf24; --warn-bg: #3a2a08;
    --bad: #f87171; --bad-bg: #3b1515; --info: #7cb0ff; --info-bg: #14264a;
    --shadow: none;
  }
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: 76px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.1rem; } h3 { font-size: 1rem; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.grow { flex: 1; min-width: 0; }

.topbar { position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
.topbar .logo { font-weight: 800; color: var(--brand); letter-spacing: -.01em; }
.topbar .sub { font-size: .8rem; color: var(--muted); }
.bell { position: relative; background: none; border: 0; font-size: 1.35rem; padding: 6px 8px; cursor: pointer; border-radius: 10px; }
.bell .dot { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: .7rem; font-weight: 700; display: grid; place-items: center; }

main { max-width: 760px; margin: 0 auto; padding: 16px; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); padding: 8px 2px 9px; font-size: .72rem; position: relative; }
.tabs a .ic { display: block; font-size: 1.3rem; line-height: 1.2; }
.tabs a.on { color: var(--brand); font-weight: 700; }
.tabs a .badge { position: absolute; top: 3px; left: 54%; min-width: 17px; height: 17px; border-radius: 9px; background: var(--warn); color: #fff;
  font-size: .68rem; display: grid; place-items: center; padding: 0 4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card.click { cursor: pointer; } .card.click:active { background: var(--brand-soft); }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .row.top { align-items: flex-start; }
.stack > * + * { margin-top: 10px; }
.sec { margin: 20px 0 10px; display: flex; align-items: center; gap: 8px; } .sec h2 { flex: 1; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.kpi b { display: block; font-size: 1.5rem; line-height: 1.1; } .kpi span { font-size: .8rem; color: var(--muted); }

.pill { display: inline-block; font-size: .75rem; font-weight: 600; border-radius: 99px; padding: 2px 10px; white-space: nowrap; }
.pill.todo { background: var(--info-bg); color: var(--info); }
.pill.submitted { background: var(--warn-bg); color: var(--warn); }
.pill.reviewed { background: var(--ok-bg); color: var(--ok); }
.pill.redo { background: var(--bad-bg); color: var(--bad); }
.pill.gray { background: var(--line); color: var(--muted); }
.pill.late { background: var(--bad-bg); color: var(--bad); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--brand); color: var(--brand-ink);
  border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 700; cursor: pointer; text-decoration: none; min-height: 44px; }
.btn.block { display: flex; width: 100%; }
.btn.sm { padding: 6px 12px; min-height: 36px; font-size: .9rem; }
.btn.gray { background: var(--line); color: var(--ink); } .btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn.danger { background: var(--bad-bg); color: var(--bad); } .btn.rec { background: #dc2626; color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

label.f { display: block; font-size: .85rem; font-weight: 600; margin: 12px 0 4px; }
input[type=text], input[type=tel], input[type=password], input[type=number], input[type=datetime-local], input[type=url], select, textarea {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 44px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.err { color: var(--bad); font-size: .9rem; margin-top: 8px; min-height: 1.2em; }
.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg { overflow-x: auto; }
.seg button { white-space: nowrap; padding-left: 10px !important; padding-right: 10px !important; flex: 1; border: 0; background: transparent; padding: 8px 6px; border-radius: 10px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--brand); box-shadow: var(--shadow); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; } .chip { font-size: .78rem; background: var(--brand-soft); color: var(--brand); padding: 2px 10px; border-radius: 99px; }

.auth { max-width: 420px; margin: 0 auto; padding: 28px 16px; }
.auth .brand { text-align: center; margin-bottom: 18px; } .auth .brand .big { font-size: 2rem; font-weight: 800; color: var(--brand); }

video { width: 100%; max-height: 70vh; background: #000; border-radius: 12px; display: block; }
.vwrap { position: relative; } .rec-badge { position: absolute; top: 10px; left: 10px; background: #dc2626; color: #fff; font-weight: 700;
  border-radius: 99px; padding: 3px 12px; font-size: .85rem; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .45; } }
.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; } .bar > i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }

.score { display: flex; gap: 6px; } .score button { flex: 1; min-height: 42px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; font-weight: 700; cursor: pointer; }
.score button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.crit { padding: 10px 0; border-bottom: 1px solid var(--line); } .crit:last-child { border-bottom: 0; }
.meter { display: flex; align-items: center; gap: 8px; } .meter .track { flex: 1; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.meter .track i { display: block; height: 100%; background: var(--brand); } .meter b { min-width: 2.4em; text-align: right; }
.up { color: var(--ok); font-weight: 700; } .down { color: var(--bad); font-weight: 700; }

.thread .msg { padding: 8px 12px; border-radius: 12px; background: var(--line); margin-bottom: 8px; max-width: 92%; }
.thread .msg.staff { background: var(--brand-soft); } .thread .msg .who { font-size: .78rem; color: var(--muted); }
.ts { background: var(--info-bg); color: var(--info); border: 0; border-radius: 99px; padding: 1px 9px; font-weight: 700; font-size: .78rem; cursor: pointer; }

table.t { width: 100%; border-collapse: collapse; font-size: .9rem; } table.t th, table.t td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.t th { font-size: .75rem; color: var(--muted); font-weight: 600; } table.t tr.click { cursor: pointer; }
.scroll-x { overflow-x: auto; }

.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 18px 16px 24px; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #1b1f2a; color: #fff; padding: 10px 18px; border-radius: 12px; z-index: 60; max-width: 90vw; }
.toast.bad { background: #b91c1c; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.attn { border-left: 4px solid var(--warn); }
.wait-old { color: var(--bad); font-weight: 700; } .wait-mid { color: var(--warn); font-weight: 700; }
.code { font: 700 1.5rem ui-monospace, Consolas, monospace; letter-spacing: .15em; color: var(--brand); }
svg.chart text { fill: var(--muted); font-size: 10px; } svg.chart .grid { stroke: var(--line); } svg.chart .ln { stroke: var(--brand); fill: none; stroke-width: 2.5; }
svg.chart .pt { fill: var(--brand); } svg.chart .self { stroke: var(--warn); fill: none; stroke-width: 2; stroke-dasharray: 4 3; }
@media (min-width: 900px) { body { padding-bottom: 0; padding-left: 92px; } .tabs { top: 0; bottom: 0; right: auto; width: 92px; flex-direction: column; border-top: 0; border-right: 1px solid var(--line); padding-top: 64px; }
  .tabs a { flex: none; padding: 14px 4px; } .sheet-bg { align-items: center; } .sheet { border-radius: 20px; } }
