:root {
  --bg: #0a0c10;
  --bg2: #10141b;
  --card: #151a23;
  --card2: #1b212c;
  --line: #262e3b;
  --text: #eef1f6;
  --muted: #8b95a7;
  --gold: #f4b81c;
  --gold2: #ffd766;
  --green: #22c55e;
  --red: #ef4444;
  --blue: #60a5fa;
  --radius: 16px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --num: "Space Grotesk", "Inter", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.45; min-height: 100vh;
}
a { color: var(--gold2); }
input, select, textarea, button { font: inherit; font-size: 16px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-family: var(--num); letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }

/* botões e campos */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--card2); color: var(--text);
  padding: 11px 16px; border-radius: 12px; cursor: pointer; text-decoration: none;
  font-weight: 600; transition: transform .08s, background .15s; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.gold { background: linear-gradient(180deg, var(--gold2), var(--gold)); color: #1a1300; border-color: transparent; }
.btn.green { background: var(--green); color: #04220f; border-color: transparent; }
.btn.red { background: transparent; color: var(--red); border-color: #5a2323; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 5px; }
.input, select.input, textarea.input {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  border-radius: 11px; padding: 11px 12px; outline: none;
}
.input:focus { border-color: var(--gold); }
textarea.input { min-height: 110px; resize: vertical; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h2, .card h3 { margin: 0 0 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.stat b { display: block; font-size: 22px; font-family: var(--num); margin-top: 4px; }
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--card2); border: 1px solid var(--line); }
.pill.disponivel, .pill.aberta, .pill.pago { color: var(--green); border-color: #1f4d30; }
.pill.reservado, .pill.pendente, .pill.rascunho { color: var(--gold2); border-color: #5a4613; }
.pill.vendido, .pill.apurada { color: var(--blue); border-color: #1e3a5f; }
.pill.encerrada, .pill.expirado, .pill.falhou, .pill.cancelado { color: var(--muted); }
.pill.pago_incompleto, .pill.pago_fora_prazo { color: var(--red); border-color: #5a2323; }

.alert { padding: 12px 14px; border-radius: 12px; margin: 12px 0; border: 1px solid var(--line); background: var(--card2); }
.alert.ok { border-color: #1f4d30; color: #b9f5cc; }
.alert.err { border-color: #5a2323; color: #ffc9c9; }
.alert.warn { border-color: #5a4613; color: #ffe6a3; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ----------------------------------------------------------- público */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.01em; text-decoration: none; color: var(--text); }
.brand i { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--gold2), #c98a00); display: grid; place-items: center; color: #1a1300; font-style: normal; font-family: var(--num); font-size: 15px; }

.hero {
  position: relative; overflow: hidden; border-radius: 22px; padding: 26px 20px; margin-top: 6px;
  background: radial-gradient(120% 140% at 100% 0%, rgba(244,184,28,.22), transparent 55%), linear-gradient(180deg, #161b25, #11151c);
  border: 1px solid #2c3442;
}
.hero .kicker { color: var(--gold2); font-weight: 700; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; }
.hero .prize { font-family: var(--num); font-weight: 700; font-size: clamp(40px, 11vw, 72px); line-height: 1; margin: 10px 0 6px; color: var(--gold2); text-shadow: 0 0 40px rgba(244,184,28,.25); }
.hero .acc { display: inline-block; background: rgba(239,68,68,.12); color: #ffb4b4; border: 1px solid #5a2323; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; margin-bottom: 10px; }
.count { display: flex; gap: 8px; margin: 16px 0 4px; }
.count div { flex: 1; max-width: 84px; background: rgba(0,0,0,.35); border: 1px solid #2c3442; border-radius: 12px; padding: 8px 6px; text-align: center; }
.count b { display: block; font-family: var(--num); font-size: 22px; }
.count span { font-size: 11px; color: var(--muted); text-transform: uppercase; }

.section-title { display: flex; align-items: end; justify-content: space-between; margin: 26px 0 12px; gap: 10px; flex-wrap: wrap; }
.section-title h2 { margin: 0; font-size: 20px; }

.quick { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stepper { display: flex; align-items: center; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; }
.stepper button { background: none; border: 0; color: var(--text); width: 42px; height: 44px; font-size: 20px; cursor: pointer; }
.stepper input { width: 52px; text-align: center; background: none; border: 0; color: var(--text); font-family: var(--num); font-size: 18px; }

/* grade de bilhetes: cada cartão imita um bilhete destacável */
.numgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
@media (max-width: 420px) { .numgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.tk {
  --notch: var(--bg);
  position: relative; display: flex; flex-direction: column; gap: 10px; text-align: left; cursor: pointer;
  padding: 12px 12px 13px; border-radius: 14px; color: var(--text);
  background:
    radial-gradient(circle at 0 38px, var(--notch) 7px, transparent 7.5px),
    radial-gradient(circle at 100% 38px, var(--notch) 7px, transparent 7.5px),
    linear-gradient(160deg, #1a202b 0%, #131820 100%);
  border: 1px solid var(--line);
  transition: border-color .15s, transform .12s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
.tk:hover { border-color: #3a4558; transform: translateY(-1px); }
.tk:active { transform: scale(.98); }
.tk-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
  padding-bottom: 9px; border-bottom: 1px dashed #2e3747;
}
.tk-check {
  width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid #3a4456; display: grid; place-items: center;
  font-style: normal; font-size: 11px; color: transparent; transition: all .15s;
}
.tk-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tk-nums.one { grid-template-columns: 1fr; }
.tk-nums b {
  font-family: var(--num); font-size: 17px; font-weight: 700; letter-spacing: .06em; text-align: center;
  padding: 6px 0; border-radius: 8px; background: rgba(255,255,255,.035); border: 1px solid rgba(255,255,255,.05);
  font-variant-numeric: tabular-nums;
}
.tk-nums.one b { font-size: 24px; padding: 10px 0; }
.tk-nums b.hit { color: var(--gold2); border-color: rgba(244,184,28,.45); background: rgba(244,184,28,.08); }
.tk.on {
  border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 8px 28px -10px rgba(244,184,28,.45);
  background:
    radial-gradient(circle at 0 38px, var(--notch) 7px, transparent 7.5px),
    radial-gradient(circle at 100% 38px, var(--notch) 7px, transparent 7.5px),
    linear-gradient(160deg, #2a2412 0%, #17150f 100%);
}
.tk.on .tk-head { color: var(--gold2); border-bottom-color: rgba(244,184,28,.35); }
.tk.on .tk-check { background: var(--gold); border-color: var(--gold); color: #1a1300; }
.tk.on .tk-nums b { color: var(--gold2); background: rgba(244,184,28,.07); border-color: rgba(244,184,28,.2); }
.grid-meta { display: flex; justify-content: space-between; align-items: center; margin: -4px 0 12px; font-size: 13px; color: var(--muted); }
.pager { display: flex; justify-content: center; gap: 8px; margin: 14px 0; align-items: center; }

.cartbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(10,12,16,.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
.cartbar .wrap { display: flex; align-items: center; gap: 12px; padding: 0; }
.cartbar .sel { flex: 1; min-width: 0; }
.cartbar .sel b { font-family: var(--num); font-size: 17px; white-space: nowrap; }
.cartbar .sel div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; color: var(--muted); }

.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.65); display: flex; align-items: flex-end; justify-content: center; }
.modal .sheet {
  background: var(--card); border: 1px solid var(--line); width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
}
@media (min-width: 700px) { .modal { align-items: center; } .modal .sheet { border-radius: 22px; } }
.sheet h3 { margin: 0 0 6px; }
.close-x { float: right; background: none; border: 0; color: var(--muted); font-size: 26px; cursor: pointer; line-height: 1; }
.qrbox { background: #fff; border-radius: 16px; padding: 12px; width: 240px; margin: 14px auto; }
.qrbox img, .qrbox canvas { width: 100%; height: auto; display: block; }
.copy { display: flex; gap: 8px; }
.copy input { flex: 1; min-width: 0; font-size: 16px; }

.ticket {
  display: flex; gap: 14px; align-items: center; background: linear-gradient(135deg, #1d2430, #141922); border: 1px dashed #3a4456;
  border-radius: 14px; padding: 12px; margin: 10px 0;
}
.ticket .tq { background: #fff; border-radius: 8px; padding: 6px; width: 92px; flex: none; }
.ticket .tq canvas, .ticket .tq img { width: 100%; height: auto; display: block; }
.ticket .tn { font-family: var(--num); font-size: 26px; font-weight: 700; color: var(--gold2); }

.results { display: grid; gap: 10px; }
.result { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.result .rn { font-family: var(--num); font-size: 24px; font-weight: 700; color: var(--gold2); min-width: 80px; }

footer.site { margin: 40px 0 120px; color: var(--muted); font-size: 13px; text-align: center; }

/* ----------------------------------------------------------- painel */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--bg2); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { margin: 4px 6px 18px; }
.side nav a { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; padding: 10px 12px; border-radius: 10px; margin-bottom: 2px; font-weight: 500; }
.side nav a:hover { background: var(--card); }
.side nav a.on { background: var(--card2); color: var(--gold2); }
.main { padding: 22px; min-width: 0; }
.main h1 { margin: 0 0 18px; font-size: 24px; }
.mobilebar { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 60; transform: translateX(-102%); transition: transform .2s; height: 100%; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.55); }
  .mobilebar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--bg2); position: sticky; top: 0; z-index: 20; }
  .main { padding: 16px; }
}
.login { max-width: 380px; margin: 10vh auto; padding: 0 16px; }

/* scanner */
#reader { width: 100%; max-width: 460px; margin: 0 auto; border-radius: 16px; overflow: hidden; background: #000; }
#reader video { border-radius: 16px; }
.scanlog { max-height: 300px; overflow-y: auto; }
.scanlog div { padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
.flash-ok { animation: fok .6s; }
.flash-err { animation: ferr .6s; }
@keyframes fok { from { box-shadow: 0 0 0 4px var(--green); } to { box-shadow: none; } }
@keyframes ferr { from { box-shadow: 0 0 0 4px var(--red); } to { box-shadow: none; } }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.seg button { background: none; border: 0; color: var(--muted); padding: 8px 14px; border-radius: 9px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--card2); color: var(--gold2); }

/* sem zoom: toque duplo desligado e campos com 16px (iPhone dá zoom em campo menor) */
html, body { touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; }
button, a, .tk, .btn { touch-action: manipulation; }
input, select, textarea, .input { font-size: 16px !important; }
.safe ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.safe li { margin: 4px 0; }
.fakesite { position: fixed; left: 0; right: 0; top: 0; z-index: 999; background: #b91c1c; color: #fff; padding: 12px 16px; font-weight: 700; text-align: center; }
.drawnum { font-size: 64px; font-weight: 700; text-align: center; color: var(--gold2); letter-spacing: .12em; line-height: 1; margin: 16px 0 4px; text-shadow: 0 0 40px rgba(244,184,28,.3); }
.drawvid { width: 100%; max-height: 60vh; border-radius: 14px; background: #000; display: block; }
