:root {
  --bg: #0b0b0b; --panel: #171717; --panel2: #222; --line: #333;
  --text: #f4efe2; --muted: #a39d8e;
  --gold: #e3b341; --gold-ink: #1a1305; --pink: #ff2d8a;
  --good: #1fa463; --bad: #d93838; --warn: #e39b1b;
  --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--gold); }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: .9rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.4rem 0 .6rem; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.error { color: #ff7b7b; }
main { padding: 16px; max-width: 1280px; margin: 0 auto; }
body.center main { min-height: 100vh; display: grid; place-items: center; }

/* topo */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--gold); font-weight: 800; text-decoration: none; font-size: 1.1rem; }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.top nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.top nav a { color: var(--text); text-decoration: none; }
.top nav form { margin: 0; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }

/* botões e cartões */
.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: .6rem 1rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:disabled { opacity: .5; cursor: wait; }
.btn.primary { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.btn.big { padding: .9rem; font-size: 1.1rem; width: 100%; }
.btn.huge { width: 100%; padding: 1.3rem; font-size: 1.4rem; margin-top: 1.4rem; border-radius: var(--r); }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn.round { width: 64px; height: 64px; border-radius: 50%; font-size: 2rem; padding: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.card.narrow { max-width: 520px; margin: 40px auto; }
.row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
input, select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: .7rem; font: inherit; width: 100%; }
label { display: grid; gap: 6px; margin-bottom: 14px; color: var(--muted); }

.login { width: min(380px, 100%); }
.login-logo { width: 140px; display: block; margin: 0 auto 16px; border-radius: 18px; }

/* venda */
.sale { display: grid; grid-template-columns: 1fr 340px; gap: 20px; }
@media (max-width: 900px) { .sale { grid-template-columns: 1fr; } }
.event-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.counter { text-align: right; }
.counter strong { font-size: 2.4rem; color: var(--gold); }
.counter span { font-size: 1.3rem; color: var(--muted); }
.counter small { display: block; color: var(--muted); }
.cap-bar { height: 8px; background: var(--panel2); border-radius: 99px; overflow: hidden; margin: 10px 0; }
.cap-bar > div { height: 100%; width: 0; background: var(--good); transition: width .3s; }
.cap-bar > div.warn { background: var(--warn); }
.cap-bar > div.full { background: var(--bad); }
.types { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.type { background: var(--panel); border: 2px solid var(--line); border-radius: var(--r); color: var(--text); padding: 18px; text-align: left; cursor: pointer; display: grid; gap: 4px; font: inherit; }
.type span { font-weight: 700; font-size: 1.1rem; }
.type strong { font-size: 1.5rem; color: var(--gold); }
.type em { font-style: normal; color: var(--muted); font-size: .9rem; }
.type.selected { border-color: var(--gold); background: #2a2208; }
.qty { display: flex; align-items: center; gap: 22px; }
.qty output { font-size: 2.4rem; font-weight: 800; min-width: 2ch; text-align: center; }
.pay { display: flex; gap: 10px; flex-wrap: wrap; }
.pay-btn { background: var(--panel); border: 2px solid var(--line); color: var(--text); border-radius: 12px; padding: 14px 18px; font: inherit; font-weight: 600; cursor: pointer; }
.pay-btn.locked { color: var(--muted); }
.pay-btn.selected { border-color: var(--gold); color: var(--text); background: #2a2208; }
.cash-calc { display: flex; gap: 20px; align-items: center; margin-top: 14px; }
.cash-calc label { margin: 0; flex: 0 0 200px; }
.cash-calc strong { font-size: 1.4rem; color: var(--gold); }
.msg { margin-top: 14px; padding: 12px 14px; border-radius: 10px; min-height: 1em; }
.msg:empty { display: none; }
.msg.ok { background: #0f3221; color: #9ff0c4; }
.msg.warn { background: #3a2a07; color: #ffd98a; }
.msg.error { background: #3a1010; color: #ffb3b3; }
.recent { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.recent li { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.recent li.cancelled { opacity: .5; text-decoration: line-through; }
.recent li span:first-of-type { flex: 1; }
dialog { background: transparent; border: 0; padding: 0; }
dialog::backdrop { background: rgba(0,0,0,.7); }
dialog .card { width: min(360px, 90vw); }
#pin { font-size: 1.8rem; text-align: center; letter-spacing: .4em; }

/* scanner (bar/porta) */
body.scanner main { padding: 0; max-width: 640px; }
.scan-top { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 2; }
.net { padding: 4px 10px; border-radius: 99px; font-size: .8rem; font-weight: 700; background: var(--panel2); cursor: default; }
.net.on { background: var(--good); color: #fff; }
.net.off { background: var(--bad); color: #fff; }
.net.warn { background: var(--warn); color: #000; cursor: pointer; }
.evname { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending { background: var(--warn); color: #000; border-radius: 99px; padding: 4px 10px; font-size: .8rem; font-weight: 700; }
.reader { width: 100%; min-height: 300px; background: #000; }
.reader video { object-fit: cover; }
.camerr { padding: 12px 16px; color: #ffd98a; background: #3a2a07; margin: 0; }
.manual { display: flex; gap: 8px; padding: 12px 14px; }
.scan-foot { display: flex; justify-content: space-between; padding: 6px 14px 20px; font-size: .85rem; gap: 10px; }
.scan-foot form { margin: 0; }
.result { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; color: #fff; }
.result.good { background: var(--good); }
.result.bad { background: var(--bad); }
.result.warn { background: var(--warn); color: #000; }
.result-icon { font-size: 7rem; line-height: 1; font-weight: 900; }
.result-title { font-size: 2.4rem; font-weight: 900; margin-top: 12px; }
.result-sub { font-size: 1.2rem; margin-top: 12px; opacity: .95; }
.result-off { margin-top: 24px; background: rgba(0,0,0,.3); padding: 6px 12px; border-radius: 99px; font-size: .85rem; font-weight: 700; }

/* painel */
.dash-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.dash-head select { width: auto; min-width: 280px; }
.chip { padding: 6px 12px; border-radius: 99px; background: var(--panel2); font-size: .85rem; }
.chip.good { background: #0f3221; color: #9ff0c4; }
.chip.bad { background: #3a1010; color: #ffb3b3; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 6px; }
.tile small { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; }
.tile strong { font-size: 2.2rem; color: var(--gold); }
.tile strong span { font-size: 1.1rem; color: var(--muted); }
.tile em { font-style: normal; color: var(--muted); font-size: .85rem; }
.tile.alert { border-color: var(--bad); }
.tile.alert strong { color: #ff7b7b; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }
table { width: 100%; border-collapse: collapse; }
td { padding: 6px 0; border-bottom: 1px solid var(--line); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 50px 1fr 40px; gap: 8px; align-items: center; font-size: .9rem; }
.bar-row div { background: var(--panel2); height: 14px; border-radius: 4px; overflow: hidden; }
.bar-row i { display: block; height: 100%; background: var(--gold); }
.bar-row b { text-align: right; }

/* bilheteira: estado da ligação */
.net { margin: 4px 0 0; padding: 8px 12px; border-radius: 10px; font-size: .9rem; background: var(--panel2); }
.net.good { color: #9ff0c4; }
.net.warn { background: #3a2a07; color: #ffd98a; }
.net.bad { background: #3a1010; color: #ffb3b3; }

/* bilhete impresso (desenhado em venda.js, impresso pelo Chrome) */
#print-area { display: none; }
@media print {
  @page { margin: 0; }
  html, body { background: #fff !important; color: #000 !important; margin: 0; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  .ticket { width: var(--ticket-width, 72mm); margin: 0 auto; padding: 2mm 0 6mm; text-align: center;
            font-family: Arial, Helvetica, sans-serif; color: #000; break-after: page; page-break-after: always; }
  .ticket:last-child { break-after: auto; page-break-after: auto; }
  .t-logo { width: 62%; display: block; margin: 0 auto 3mm; }
  .t-event { font-weight: 700; font-size: 5.5mm; line-height: 1.15; }
  .t-date { font-size: 4.2mm; margin-bottom: 2mm; }
  .t-num { font-weight: 800; font-size: 13mm; line-height: 1.1; margin-bottom: 2mm; }
  .t-qr svg { width: 78%; height: auto; display: block; margin: 0 auto 2mm; }
  .t-drink { border: .8mm solid #000; border-radius: 3mm; padding: 2mm 1mm; margin: 0 0 3mm; font-weight: 700;
             font-size: 5mm; line-height: 1.35; }
  .t-small { font-size: 3.4mm; margin-top: 1mm; }
}

.choose { display: grid; gap: 14px; }
.choose .btn { text-align: center; }
