:root {
  --blue: #1b3c8f;
  --blue-dark: #11285f;
  --blue-soft: #e8eefb;
  --red: #e3171f;
  --red-dark: #b80f16;
  --red-deep: #8f0a10;
  --red-soft: #fdeaea;
  --gold: #f5b700;
  --ink: #14182b;
  --muted: #5d6478;
  --line: #dfe3ec;
  --bg: #f3f5fa;
  --card: #ffffff;
  --ok: #128a4a;
  --ok-soft: #e4f6ec;
  --warn: #b25c00;
  --warn-soft: #fff3e0;
  --err: #c4141b;
  --err-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(17, 40, 95, 0.08);
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); min-height: 100vh; font-size: 15px; line-height: 1.45; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.topbar {
  background: linear-gradient(100deg, var(--red-deep), var(--red));
  color: #fff;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 10;
  border-bottom: 4px solid var(--blue);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.brand-logo {
  height: 40px; padding: 4px 10px; border-radius: 10px; background: #fff;
  display: flex; align-items: center; flex: none;
}
.brand-logo img { height: 30px; width: auto; display: block; }
.tvs-word { font-style: italic; font-weight: 900; font-size: 22px; color: var(--blue); letter-spacing: -0.5px; line-height: 1; }
.brand-text { line-height: 1.1; min-width: 0; }
.brand-text b { display: block; font-size: 16px; letter-spacing: 0.5px; white-space: nowrap; }
.brand-text small { display: block; font-size: 11.5px; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.chip {
  background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 5px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.link-btn {
  background: none; border: 0; color: #fff; opacity: 0.85; font-size: 13px; padding: 6px 4px; cursor: pointer; text-decoration: underline; white-space: nowrap;
}
@media (max-width: 520px) { .topbar .chip { display: none; } .topbar { gap: 8px; } }

/* ---------- layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 460px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card, .card + .demo-note { margin-top: 16px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 16px; font-size: 14px; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.field label .req { color: var(--red); }
.input, .select {
  width: 100%; height: 50px; border: 1.5px solid var(--line); border-radius: 11px; padding: 0 14px;
  background: #fff; font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(227, 23, 31, 0.15); }
.field.invalid .input, .field.invalid .select, .field.invalid .phone { border-color: var(--err); }
.model-other { margin-top: 8px; }
.input[hidden] { display: none; }
.field .msg { font-size: 12.5px; margin-top: 5px; min-height: 0; }
.field.invalid .msg { color: var(--err); }
.phone {
  display: flex; align-items: stretch; height: 50px; border: 1.5px solid var(--line); border-radius: 11px; overflow: hidden; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.phone:focus-within { border-color: var(--red); box-shadow: 0 0 0 3px rgba(227, 23, 31, 0.15); }
.phone .cc {
  display: grid; place-items: center; padding: 0 12px; background: var(--red-soft); color: var(--red);
  font-weight: 700; border-right: 1.5px solid var(--line); font-size: 16px;
}
.phone input { flex: 1; border: 0; outline: none; padding: 0 14px; font-size: 17px; letter-spacing: 1px; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 52px; padding: 0 22px; border-radius: 12px; border: 0; cursor: pointer;
  font-weight: 700; font-size: 16px; transition: transform .08s, background .15s, opacity .15s;
}
.btn:active { transform: scale(0.98); }
.btn.block { width: 100%; }
.btn.primary { background: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.red { background: var(--red); color: #fff; box-shadow: 0 6px 16px rgba(227, 23, 31, 0.3); }
.btn.red:hover { background: var(--red-dark); }
.btn.red:disabled { box-shadow: none; }
.btn.ghost { background: var(--red-soft); color: var(--red-dark); }
.btn.small { height: 36px; padding: 0 14px; font-size: 13.5px; border-radius: 9px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.alert { border-radius: 11px; padding: 11px 13px; font-size: 14px; margin-bottom: 14px; }
.alert.err { background: var(--err-soft); color: var(--err); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert b { display: block; }

.mobile-status { font-size: 13px; margin-top: 6px; display: flex; gap: 6px; align-items: center; }
.mobile-status.ok { color: var(--ok); }
.mobile-status.dup { color: var(--err); }
.mobile-status.checking { color: var(--muted); }

/* ---------- landing ---------- */
.branch-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.branch-tile {
  display: flex; flex-direction: column; justify-content: space-between; gap: 18px; min-height: 104px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
  text-decoration: none; color: var(--ink); border: 2px solid transparent; transition: border-color .15s, transform .1s;
}
.branch-tile:hover { border-color: var(--red); }
.branch-tile:active { transform: scale(0.98); }
.branch-tile small { color: var(--muted); font-size: 12px; }
.branch-tile b { font-size: 17px; }
.branch-tile.reports { grid-column: 1 / -1; background: var(--red); color: #fff; min-height: 0; flex-direction: row; align-items: center; }
.branch-tile.reports small { color: rgba(255, 255, 255, 0.8); }

/* ---------- branch spin page ---------- */
.staff { max-width: 640px; }
.staff .card + .card { margin-top: 16px; }
.wheel-box { position: relative; width: min(100%, 420px); margin: 0 auto; aspect-ratio: 1; }
.wheel-box svg.wheel { width: 100%; height: 100%; display: block; transition: transform 5.2s cubic-bezier(0.12, 0.72, 0.08, 1); }
.wheel-pointer {
  position: absolute; left: 50%; top: -6px; transform: translateX(-50%); width: 34px; height: 44px; z-index: 2;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.25));
}
.wheel-hub {
  position: absolute; inset: 0; margin: auto; width: 22%; height: 22%; border-radius: 50%;
  background: #fff; border: 5px solid var(--red); display: grid; place-items: center;
  font-weight: 800; color: var(--red); font-size: clamp(13px, 3.4vw, 22px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); z-index: 1;
  cursor: pointer; padding: 0; letter-spacing: 1px;
}
.wheel-hub:disabled { cursor: default; }

.entries { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.entries td { padding: 10px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
.entries .who b { display: block; }
.entries .who small { color: var(--muted); }
.entries .r { text-align: right; white-space: nowrap; }
.empty { color: var(--muted); text-align: center; padding: 18px 0 6px; font-size: 14px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge.registered { background: var(--warn-soft); color: var(--warn); }
.badge.spun { background: var(--blue-soft); color: var(--blue); }
.badge.redeemed { background: var(--ok-soft); color: var(--ok); }

/* ---------- confetti ---------- */
.confetti { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.prize-card > :not(.confetti) { position: relative; z-index: 1; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 13px; border-radius: 2px; animation: fall 1.8s ease-in forwards; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } }
@keyframes fall { to { transform: translateY(520px) rotate(540deg); opacity: 0.2; } }

/* ---------- reports ---------- */
.filters { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.filters .field { margin: 0; }
.filters .field label { font-size: 12px; margin-bottom: 4px; color: var(--muted); }
.filters .input, .filters .select { height: 42px; font-size: 14px; border-radius: 9px; padding: 0 10px; }
.filters .actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
@media (min-width: 760px) { .filters { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1100px) { .filters { grid-template-columns: repeat(7, 1fr); } .filters .actions { grid-column: auto / span 7; } }

.stats { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); margin: 16px 0; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat small { color: var(--muted); font-size: 12.5px; display: block; }
.stat b { font-size: 26px; display: block; line-height: 1.25; }
.stat .bar { height: 6px; background: var(--red-soft); border-radius: 9px; margin-top: 8px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: var(--gold); border-radius: 9px; }

.breakdowns { display: grid; gap: 16px; }
@media (min-width: 900px) { .breakdowns { grid-template-columns: repeat(3, 1fr); } }
.hlist { list-style: none; margin: 0; padding: 0; }
.hlist li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 7px 0; font-size: 13.5px; }
.hlist li small { color: var(--muted); font-size: 11.5px; }
.hlist .track { grid-column: 1 / -1; height: 6px; background: var(--bg); border-radius: 9px; overflow: hidden; }
.hlist .track i { display: block; height: 100%; background: var(--red); border-radius: 9px; }
.hlist li.cashback .track i { background: var(--gold); }

.table-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.table-head h2 { margin: 0; flex: 1; }
.table-scroll { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.report { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 900px; }
table.report th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 9px 8px; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.report td { padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.report tr:hover td { background: #fafbfe; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: 13px; color: var(--muted); gap: 8px; }

.demo-note {
  font-size: 12px; color: var(--warn); background: var(--warn-soft); border-radius: 9px; padding: 8px 12px; margin-top: 16px; text-align: center;
}
.demo-note button { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font-size: inherit; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 18px 16px 28px; }

/* ---------- customer screen (full screen, customer holds the device) ---------- */
body.cust-open { overflow: hidden; }
body.cust-open > .topbar { display: none; }
.cust {
  position: fixed; inset: 0; z-index: 40; overflow-y: auto; color: #fff;
  background:
    repeating-conic-gradient(from 0deg at 50% 45%, rgba(255, 255, 255, 0.06) 0 9deg, transparent 9deg 18deg),
    radial-gradient(circle at 50% 40%, #ff4248 0%, #d0121a 45%, #6e050a 100%);
  display: flex; flex-direction: column; align-items: center;
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.cust-top { width: 100%; max-width: 900px; display: flex; align-items: center; gap: 10px; }
.cust-brand { font-weight: 800; letter-spacing: 1px; font-size: 15px; }
.cust-top .spacer { flex: 1; }
.sound-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer; font-size: 20px;
  background: rgba(255, 255, 255, 0.16);
}
.cust-stage { flex: 1; width: 100%; max-width: 640px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 10px 0; }
.cust-hello { text-align: center; }
.cust-hello small { font-size: 14px; opacity: 0.85; letter-spacing: 0.3px; }
.cust-hello h1 { font-size: clamp(30px, 8vw, 46px); line-height: 1.1; margin: 2px 0; }
.cust-hello p { margin: 0; font-weight: 600; opacity: 0.9; }
.wheel-box.big { width: min(88vw, 58vh, 560px); filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.35)); }
.wheel-box.big .wheel-pointer { width: 46px; height: 60px; top: -10px; transform-origin: 50% 25%; }
.wheel-pointer.tick { animation: tick 0.12s ease-out; }
@keyframes tick { 40% { transform: translateX(-50%) rotate(-14deg); } }
.tap-btn {
  width: min(100%, 420px); height: 72px; border: 0; border-radius: 999px; cursor: pointer;
  background: linear-gradient(180deg, #ffd23f, var(--gold)); color: #6e050a;
  font-size: 24px; font-weight: 800; letter-spacing: 1.5px;
  box-shadow: 0 8px 0 #b98a00, 0 14px 28px rgba(0, 0, 0, 0.3);
  animation: pulse 1.6s ease-in-out infinite;
}
.tap-btn:active { transform: translateY(5px); box-shadow: 0 3px 0 #b98a00, 0 6px 14px rgba(0, 0, 0, 0.3); }
.tap-btn:disabled { animation: none; opacity: 0.9; cursor: default; }
@keyframes pulse { 50% { transform: scale(1.04); } }
.cust.spinning .tap-btn { transform: none; }

.prize-card {
  position: relative; overflow: hidden; width: 100%; background: #fff; color: var(--ink);
  border-radius: 24px; padding: 34px 22px 26px; text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35); animation: pop .45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.prize-card .congrats { color: var(--blue); font-weight: 800; letter-spacing: 3px; font-size: 14px; }
.prize-card .who { font-size: 22px; font-weight: 700; margin-top: 6px; }
.prize-card .you-won { color: var(--muted); margin-top: 18px; font-size: 15px; }
.prize-card .prize { color: var(--red); font-size: clamp(30px, 8vw, 44px); font-weight: 800; line-height: 1.15; margin: 6px 0 18px; }
.prize-card .ref { display: inline-block; background: var(--bg); border-radius: 10px; padding: 8px 14px; font-weight: 700; font-size: 15px; }
.prize-card .show { color: var(--muted); font-size: 14px; margin: 16px 0 0; }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } }

.hold-wrap { min-height: 44px; }
.hold-btn {
  position: relative; overflow: hidden; height: 44px; padding: 0 20px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.45); background: rgba(0, 0, 0, 0.22); color: rgba(255, 255, 255, 0.9);
  font-size: 13.5px; font-weight: 600; touch-action: none; -webkit-touch-callout: none;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.hold-btn i { position: absolute; inset: 0; width: 0; background: rgba(255, 255, 255, 0.3); }
.hold-btn.holding i { width: 100%; transition: width var(--hold, 1.2s) linear; }
.hold-btn span { position: relative; pointer-events: none; }
.hold-btn i { pointer-events: none; }
.cust.spinning #cancel-wrap { visibility: hidden; }
@media (max-height: 640px) { .cust-hello small, .cust-hello p { display: none; } .tap-btn { height: 60px; font-size: 20px; } }

/* ---------- login back link ---------- */
.back-link {
  display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 4px;
  color: var(--red); font-weight: 600; font-size: 15px; text-decoration: none;
}
.back-link:hover { text-decoration: underline; }
.foot a { color: inherit; font-weight: 600; }
.cust-credit { font-size: 10px; letter-spacing: 0.5px; opacity: 0.4; padding-bottom: env(safe-area-inset-bottom); pointer-events: none; }
