:root {
  --bg: #0b1020;
  --bg2: #121a33;
  --card: #18213f;
  --line: #2a3560;
  --text: #eef1fb;
  --muted: #9aa5c9;
  --gold: #f2c14e;
  --gold-ink: #241a00;
  --ok: #2fbf71;
  --warn: #f2994a;
  --bad: #eb5757;
  --info: #56a3f5;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; font-size: 16px; line-height: 1.4; }
a { color: var(--gold); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--bg2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.topbar .brand { font-weight: 800; color: var(--gold); white-space: nowrap; }
.topbar .station { font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: .9rem; }
@media (max-width: 600px) { .topbar .who { display: none; } .topbar .station { font-size: .9rem; } }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); display: inline-block; }
.live-dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(47,191,113,.25); }

.wrap { padding: 16px; max-width: 1400px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid2 > *, .grid3 > * { min-width: 0; }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--bg2); color: var(--text);
  padding: 12px 16px; border-radius: 10px; font-size: 1rem; font-weight: 600; cursor: pointer;
  min-height: 48px; touch-action: manipulation;
}
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.btn.ok { background: var(--ok); color: #04210f; border-color: var(--ok); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.btn.lg { min-height: 64px; font-size: 1.2rem; }
.btn.block { width: 100%; }
.btn.sel { outline: 3px solid var(--gold); outline-offset: 1px; }

label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; font-size: 1rem; min-height: 48px;
}
input:focus, select:focus { outline: 2px solid var(--gold); border-color: transparent; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; vertical-align: middle; }
.check { display: flex; gap: 10px; align-items: center; color: var(--text); font-size: 1rem; }

/* scan zone */
.scan {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 16px; text-align: center;
  background: repeating-linear-gradient(135deg, transparent 0 12px, rgba(255,255,255,.015) 12px 24px);
}
.scan .hint { font-size: 1.1rem; font-weight: 600; }
.scan .icon { font-size: 2.2rem; }
.scan .manual { display: flex; gap: 8px; margin-top: 12px; }
.scan .manual input { flex: 1; }
.scan.flash { border-color: var(--gold); }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.pill.queued { background: rgba(154,165,201,.18); color: var(--muted); }
.pill.preparing { background: rgba(242,153,74,.2); color: var(--warn); }
.pill.ready { background: rgba(47,191,113,.2); color: var(--ok); }
.pill.delivered { background: rgba(86,163,245,.15); color: var(--info); }
.pill.free { background: rgba(242,193,78,.2); color: var(--gold); }
.pill.bad { background: rgba(235,87,87,.2); color: var(--bad); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tr.click { cursor: pointer; }
tr.click:hover td { background: rgba(255,255,255,.03); }
.table-scroll { overflow-x: auto; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: .85rem; }
.kpi .value { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 4px; }
.kpi .sub { color: var(--muted); font-size: .8rem; margin-top: 2px; }

.guest-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.code-badge { font-size: 1.4rem; font-weight: 800; background: var(--gold); color: var(--gold-ink); padding: 6px 14px; border-radius: 10px; letter-spacing: .03em; }
.balance { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* toast */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: calc(100vw - 32px); }
.toast { background: var(--bg2); border: 1px solid var(--line); border-left: 5px solid var(--info); padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.4); font-weight: 600; }
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }

dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.6); }

.empty { color: var(--muted); text-align: center; padding: 24px; }
