:root {
  --bg: #11141d; --panel: #1a1f2c; --panel2: #222839; --line: #2e3549; --text: #e8eaf2;
  --muted: #9aa3b8; --accent: #f5c84c; --accent-ink: #1b1600; --good: #4ccf8a; --bad: #ff6b6b;
  --warn: #ffb547; --info: #6aa8ff; --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--info); text-decoration: none; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h2 { font-size: 18px; } h3 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.muted { color: var(--muted); } .small { font-size: 13px; } .error { color: var(--bad); } .good { color: var(--good); }
.warn { color: var(--warn); } .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.right { text-align: right; } .nowrap { white-space: nowrap; }

/* top bar */
.top { position: sticky; top: 0; z-index: 10; display: flex; gap: 16px; align-items: center;
  padding: 10px 16px; background: #0c0f16; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 20px; color: var(--accent); }
#nav { display: flex; gap: 4px; flex-wrap: wrap; }
#nav a { color: var(--muted); padding: 6px 12px; border-radius: 8px; }
#nav a.on { background: var(--panel2); color: var(--text); }
#status { margin-left: auto; } .logout { margin: 0; }
main { padding: 16px; max-width: 1500px; margin: 0 auto; }

/* panels & grids */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.g2.wide { grid-template-columns: repeat(auto-fit, minmax(520px, 1fr)); }
@media (max-width: 600px) { .g2.wide, .g2 { grid-template-columns: 1fr; } #status { display: none; } }
.g3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.live { grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); }
@media (max-width: 900px) { .live { grid-template-columns: 1fr; } main { padding: 10px; } }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }
.stack > * + * { margin-top: 8px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.kpi { background: var(--panel2); border-radius: 10px; padding: 10px 12px; }
.kpi .v { font-size: 22px; font-weight: 700; } .kpi .l { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.kpi.accent .v { color: var(--accent); }

/* forms */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: #0d1018; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--info); outline-offset: -1px; }
textarea { width: 100%; min-height: 260px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
button.good { background: var(--good); color: #04210f; border-color: var(--good); font-weight: 700; }
button.bad { background: transparent; color: var(--bad); border-color: var(--bad); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.big { font-size: 20px; padding: 14px 22px; }
button:disabled { opacity: .5; cursor: default; }
input.big { font-size: 22px; padding: 12px; width: 140px; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel2); }
.scroll { overflow-x: auto; }
.thumb { width: 36px; height: 50px; object-fit: cover; border-radius: 4px; background: var(--panel2); display: block; }

/* stage card */
.stage { display: grid; grid-template-columns: 220px 1fr; gap: 18px; }
@media (max-width: 600px) { .stage { grid-template-columns: 1fr; } }
.stage img, .card-img { width: 100%; border-radius: 12px; background: var(--panel2); aspect-ratio: 63/88; object-fit: contain; }
.noimg { display: grid; place-items: center; color: var(--muted); aspect-ratio: 63/88; border: 1px dashed var(--line); border-radius: 12px; }
.title { font-size: 26px; font-weight: 800; } .sub { color: var(--muted); }
.money { font-size: 28px; font-weight: 800; color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.chip.accent { border-color: var(--accent); color: var(--accent); }
.chip.good { border-color: var(--good); color: var(--good); } .chip.warn { border-color: var(--warn); color: var(--warn); }
.fact { font-style: italic; color: #cfd5e6; }
.copy { cursor: copy; border-bottom: 1px dotted var(--muted); }
.banner { padding: 12px 14px; border-radius: 10px; font-weight: 700; font-size: 18px; }
.banner.hit { background: rgba(245, 200, 76, .15); border: 1px solid var(--accent); color: var(--accent); }
.banner.miss { background: var(--panel2); }

/* alerts */
.alert { border-left: 4px solid var(--info); background: var(--panel2); padding: 8px 10px; border-radius: 6px; font-size: 14px; }
.alert.warn { border-color: var(--warn); } .alert.action { border-color: var(--accent); }

/* odds */
.odds td.one { font-weight: 700; color: var(--accent); }
.tap { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.tap button { padding: 16px 10px; font-size: 16px; text-align: left; }
.tap button .n { display: block; font-size: 12px; color: var(--muted); }

/* modal & toast */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: grid; place-items: center; z-index: 50; padding: 12px; }
.modal-box { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; width: min(900px, 100%); max-height: 92vh; overflow: auto; }
.modal .close { position: absolute; top: 8px; right: 8px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 60; max-width: 90vw; }
.toast.err { border-color: var(--bad); color: var(--bad); }
pre { white-space: pre-wrap; background: #0d1018; padding: 10px; border-radius: 8px; font-size: 13px; }
.md table { margin: 8px 0 14px; } .md h1 { font-size: 22px; } .md h2 { margin-top: 16px; }

/* scanner */
.scanner { position: relative; max-width: 520px; margin: 0 auto; }
.scanner video, .scanner canvas { width: 100%; border-radius: 14px; background: #000; display: block; }
.frame { position: absolute; left: 50%; top: 50%; height: 80%; aspect-ratio: 63/88; transform: translate(-50%, -50%);
  border: 3px solid var(--accent); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); pointer-events: none; }
.scanner + .row { justify-content: center; margin-top: 12px; }

/* login */
body.login { display: grid; place-items: center; min-height: 100vh; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: min(360px, 92vw); display: grid; gap: 14px; }
.login-card h1 { color: var(--accent); font-size: 32px; margin: 0; }
