:root {
  --red: #8e0f13; --red-d: #5c0608; --gold: #f9c21a; --gold-d: #e39a00; --cream: #fff7e6; --ink: #2b0a0a;
  --muted: #7d5d4f; --line: #ecd9b4; --ok: #15803d; --ok-bg: #dcfce7; --warn: #c2410c; --warn-bg: #ffedd5;
  --bad: #b91c1c; --bad-bg: #fee2e2;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: var(--ink); background: var(--cream); }
button, input, select, textarea { font: inherit; }
.muted { color: var(--muted); }
.err { color: var(--bad); font-weight: 600; }

.btn { border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--red); color: #fff; }
.btn-gold { background: var(--gold); color: var(--red-d); }
.btn-ghost { background: #fff; color: var(--red); border: 1.5px solid var(--line); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 50% 30%, #b3171d, #3a0304); }
.login-card { background: var(--cream); border-radius: 20px; padding: 28px; width: 100%; max-width: 360px; display: grid; gap: 12px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-card h1 { margin: 0; color: var(--red); }
.login-card p { margin: 0; }
.login-logo { width: 220px; margin: 0 auto; }
.login-card input { padding: 12px 14px; border-radius: 10px; border: 1.5px solid var(--line); font-size: 16px; }

/* public pass page */
.pass-body { min-height: 100vh; background: radial-gradient(circle at 50% 20%, #a3141a, #3a0304 80%); color: #fff; }
.pass-wrap { max-width: 520px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }
.pass-frame { position: relative; aspect-ratio: 1080 / 1920; border-radius: 16px; overflow: hidden; background: rgba(0,0,0,.2); box-shadow: 0 16px 40px rgba(0,0,0,.4); }
.pass-frame img { width: 100%; height: 100%; display: block; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--gold); }
.pass-actions { display: flex; gap: 10px; }
.pass-actions .btn { flex: 1; padding: 14px; font-size: 16px; }
.pass-note { text-align: center; margin: 0; color: #ffe7b0; font-size: 14px; }
.notice { background: var(--cream); color: var(--ink); border-radius: 16px; padding: 24px; text-align: center; margin-top: 30vh; }
.notice.bad h2 { color: var(--bad); margin-top: 0; }
.admin-box { border-radius: 16px; padding: 16px; background: #fff; color: var(--ink); display: grid; gap: 8px; border: 4px solid #ccc; }
.admin-box.ok { border-color: var(--ok); } .admin-box.warn { border-color: var(--warn); } .admin-box.idle { border-color: var(--gold); }
.ab-title { font-weight: 800; color: var(--red); letter-spacing: .05em; font-size: 13px; }
.ab-btns { display: flex; gap: 8px; flex-wrap: wrap; } .ab-btns .btn { flex: 1; }
.ab-link { color: var(--red); font-size: 14px; }

/* dashboard */
.topbar { background: linear-gradient(90deg, var(--red-d), var(--red)); color: #fff; padding: 12px 20px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; box-shadow: 0 2px 12px rgba(0,0,0,.2); }
.topbar img { height: 40px; background: #fff; border-radius: 8px; padding: 3px 6px; }
.topbar h1 { font-size: 20px; margin: 0; }
.topbar h1 small { display: block; font-size: 12px; font-weight: 400; color: #ffd98a; }
.topbar .sp { flex: 1; }
.live { font-size: 12px; color: #ffd98a; }
.main { padding: 18px 20px 60px; max-width: 1400px; margin: 0 auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border-radius: 14px; padding: 14px 16px; border: 1px solid var(--line); }
.stat .k { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 30px; font-weight: 800; color: var(--red); line-height: 1.2; }
.stat .s { font-size: 13px; color: var(--muted); }
.bar { height: 6px; border-radius: 3px; background: #f3e6c9; margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.search { flex: 1; min-width: 220px; padding: 11px 14px; border-radius: 10px; border: 1.5px solid var(--line); font-size: 16px; background: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.chip.on { background: var(--red); border-color: var(--red); color: #fff; }
.tablewrap { background: #fff; border-radius: 14px; border: 1px solid var(--line); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fffbf2; position: sticky; top: 0; }
td { padding: 10px 12px; border-bottom: 1px solid #f5ead2; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.in td { background: #f6fdf8; }
.code { font-weight: 700; color: var(--red); white-space: nowrap; }
.nm { font-weight: 600; }
.sub { font-size: 12px; color: var(--muted); }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.b-ok { background: var(--ok-bg); color: var(--ok); } .b-warn { background: var(--warn-bg); color: var(--warn); }
.b-idle { background: #f1ece2; color: var(--muted); }
.acts { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(30,0,0,.55); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal[hidden] { display: none; }
.sheet { background: var(--cream); border-radius: 18px; padding: 20px; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; display: grid; gap: 12px; }
.sheet h2 { margin: 0; color: var(--red); font-size: 20px; }
.sheet.wide { max-width: 760px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label.f { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
label.f input, label.f textarea, label.f select { padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line); font-size: 15px; color: var(--ink); background: #fff; }
.row-end { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.preview-img { width: 100%; max-width: 330px; margin: 0 auto; display: block; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.activity { font-size: 13px; display: grid; gap: 6px; }
.activity div { display: flex; gap: 10px; } .activity span:first-child { color: var(--muted); min-width: 64px; }

/* scanner */
.scan-body { background: #111; color: #fff; min-height: 100vh; }
.scan-top { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--red-d); }
.scan-top b { font-size: 16px; } .scan-top .sp { flex: 1; }
.scan-count { background: rgba(255,255,255,.12); border-radius: 999px; padding: 4px 12px; font-size: 14px; font-weight: 700; color: var(--gold); }
#reader { width: 100%; max-width: 520px; margin: 0 auto; }
#reader video { border-radius: 0; }
.scan-help { text-align: center; color: #bbb; font-size: 14px; padding: 10px 16px; }
.scan-manual { padding: 0 14px 30px; max-width: 520px; margin: 0 auto; display: grid; gap: 8px; }
.scan-manual input { padding: 12px 14px; border-radius: 10px; border: 0; font-size: 16px; }
.mres { background: #222; border-radius: 12px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.mres .nm { flex: 1; }
.result { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 10px; }
.result[hidden] { display: none; }
.result.ok { background: #15803d; } .result.warn { background: #c2410c; } .result.bad { background: #b91c1c; } .result.already { background: #7c2d12; }
.result .big { font-size: 40px; font-weight: 800; line-height: 1.1; }
.result .who { font-size: 26px; font-weight: 700; }
.result .meta { font-size: 18px; opacity: .95; }
.result .pay { font-size: 22px; font-weight: 800; background: rgba(0,0,0,.25); border-radius: 14px; padding: 12px 18px; }
.result .btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; width: 100%; max-width: 420px; }
.result .btns .btn { flex: 1; padding: 16px; font-size: 18px; }
.result .icon { font-size: 72px; line-height: 1; }

@media (max-width: 640px) {
  .main { padding: 12px 12px 60px; }
  .topbar { padding: 10px 12px; }
  .grid2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
.pass-frame img:not([src]) { visibility: hidden; }

/* payment QR screen */
.payqr { position: fixed; inset: 0; z-index: 50; background: #fff; color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px; text-align: center; }
.payqr img { width: 100%; max-width: 420px; max-height: 62vh; object-fit: contain; }
.pq-amt { font-size: 34px; font-weight: 800; color: var(--red); }
.pq-who { font-size: 16px; color: var(--muted); }
.pq-missing { padding: 30px 16px; border: 2px dashed var(--line); border-radius: 14px; color: var(--muted); }
.pq-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: 100%; max-width: 420px; }
.pq-btns .btn { flex: 1; padding: 14px; font-size: 16px; }
.pq-btns .btn-ok { flex-basis: 100%; font-size: 18px; padding: 16px; }
