:root {
  --orange: #f47b20;
  --dark: #1a1a1a;
  --bg: #f2f2f2;
  --card: #fff;
  --text: #1a1a1a;
  --muted: #666;
  --green: #12a150;
  --red: #d32f2f;
  --grey: #616161;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
.hidden { display: none !important; }
.brand { background: var(--orange); color: #fff; font-weight: 800; letter-spacing: .5px; padding: 6px 12px; display: inline-block; }

/* Login */
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--dark); padding: 16px; }
.login-box { background: #fff; padding: 28px 22px; border-radius: 12px; width: 100%; max-width: 360px; text-align: center; }
.login-box h1 { margin: 14px 0 20px; }
#pin { width: 100%; font-size: 28px; text-align: center; letter-spacing: 8px; padding: 12px; border: 2px solid #ccc; border-radius: 8px; margin-bottom: 12px; }
.err { color: var(--red); min-height: 1.2em; }

/* Header + tabs */
header { background: var(--dark); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 0; }
.hdr-right { font-size: 14px; display: flex; gap: 8px; align-items: center; }
nav { display: flex; background: #2b2b2b; overflow-x: auto; }
nav button { flex: 1; background: none; border: 0; color: #ccc; padding: 12px 10px; font-size: 15px; white-space: nowrap; border-bottom: 3px solid transparent; }
nav button.active { color: #fff; border-bottom-color: var(--orange); }
.tab { padding: 12px; max-width: 900px; margin: 0 auto; }

/* Buttons */
.btn { display: inline-block; border: 0; border-radius: 8px; padding: 10px 16px; font-size: 16px; background: #e0e0e0; color: var(--text); cursor: pointer; text-decoration: none; text-align: center; }
.btn.primary { background: var(--orange); color: #fff; font-weight: 700; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.big { width: 100%; padding: 14px; font-size: 18px; }
.btn.huge { width: 100%; padding: 22px; font-size: 26px; font-weight: 800; }
.btn.white { background: #fff; color: var(--green); }
.btn.outline { background: transparent; color: #fff; border: 2px solid rgba(255,255,255,.8); }
.btn.danger { background: var(--red); color: #fff; }
.btn.mode.active { background: var(--dark); color: #fff; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }

/* Scan */
.video-wrap { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 1 / 1; max-height: 60vh; margin: 0 auto; }
#video { width: 100%; height: 100%; object-fit: cover; display: block; }
.aim { position: absolute; inset: 15%; border: 3px solid rgba(244,123,32,.9); border-radius: 12px; pointer-events: none; }
.cam-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; text-align: center; padding: 20px; }
.manual { display: flex; gap: 8px; margin-top: 12px; }
.manual input { flex: 1; font-size: 18px; padding: 10px; border: 2px solid #ccc; border-radius: 8px; min-width: 0; }
.mini-stats { text-align: center; margin-top: 12px; font-size: 18px; font-weight: 700; }

/* Cards / forms */
.card { background: var(--card); border-radius: 10px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card h3 { margin: 0 0 10px; }
.card.danger { border: 2px solid #f3c1c1; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
label { display: block; margin-bottom: 10px; font-size: 14px; color: var(--muted); }
label input { display: block; width: 100%; font-size: 16px; padding: 8px; border: 1px solid #ccc; border-radius: 6px; margin-top: 4px; color: var(--text); }
.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-row label { flex: 1; min-width: 120px; margin-bottom: 0; }
input[type=color] { height: 40px; padding: 2px; }

/* Stats */
.stat-big { font-size: 48px; font-weight: 800; }
.bar { height: 14px; background: #eee; border-radius: 7px; overflow: hidden; margin: 14px 0; }
.bar div { height: 100%; background: var(--orange); width: 0; transition: width .4s; }
.stat-row { display: flex; justify-content: space-around; margin: 10px 0; }
.stat-row div { display: flex; flex-direction: column; }
.stat-row b { font-size: 24px; }
.stat-row span { color: var(--muted); font-size: 13px; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #eee; font-size: 15px; }

/* Invite */
.invite-qr { width: 100%; max-width: 420px; margin: 16px auto 0; display: block; image-rendering: pixelated; }
.invite-label { font-size: 26px; font-weight: 800; margin: 8px 0; }
#inviteResult .btn-row { justify-content: center; }

/* Template editor */
.tpl-wrap { overflow: auto; border: 1px solid #ddd; border-radius: 6px; background: #fafafa; }
#tplCanvas { max-width: 100%; display: block; cursor: crosshair; }
.preview { max-width: 100%; margin-top: 10px; border: 1px solid #ddd; }

/* Result overlay */
.result { position: fixed; inset: 0; z-index: 50; color: #fff; display: flex; align-items: center; justify-content: center; padding: 20px; }
.result.VALID, .result.REDEEMED { background: var(--green); }
.result.USED, .result.INVALID { background: var(--red); }
.result.EXPIRED, .result.NOT_YET { background: var(--grey); }
.result-inner { width: 100%; max-width: 480px; text-align: center; display: flex; flex-direction: column; gap: 14px; }
.res-title { font-size: 38px; font-weight: 900; line-height: 1.1; }
.res-sub { font-size: 22px; font-weight: 600; }
.res-label { font-size: 20px; opacity: .9; margin-bottom: 20px; }
