/* =========================================================================
   QR Store — shared design system
   Mobile-first, works on iOS Safari / Android Chrome / desktop.
   ========================================================================= */

:root {
  --brand: #4f46e5;
  --brand-600: #4338ca;
  --brand-700: #3730a3;
  --brand-soft: #eef2ff;
  --accent: #06b6d4;

  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;

  --bg: #f4f5f7;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e6e8ee;
  --text: #0f172a;
  --text-2: #64748b;
  --text-3: #94a3b8;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-md: 0 6px 16px rgba(15, 23, 42, .08), 0 2px 6px rgba(15, 23, 42, .06);
  --shadow-lg: 0 20px 40px rgba(15, 23, 42, .16);

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --r-xl: 28px;

  --maxw: 480px;
  --tap: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI",
    Roboto, "Noto Sans KR", "Malgun Gothic", "Helvetica Neue", Arial, sans-serif;
}

/* Dark mode is driven by a data-theme attribute on <html>; "system" is
   resolved to light/dark in JS (and an inline <head> script) so there is no
   token duplication and the user can override the OS preference. */
:root[data-theme="dark"] {
  --brand: #818cf8;
  --brand-600: #6366f1;
  --brand-700: #a5b4fc;
  --brand-soft: #1e1b4b;
  --bg: #0b1020;
  --bg-2: #0f152a;
  --surface: #161c30;
  --surface-2: #1b2236;
  --line: #283049;
  --text: #f1f5f9;
  --text-2: #aeb8cc;
  --text-3: #7c879e;
  --ok-soft: #0f3d24;
  --warn-soft: #3d2c08;
  --danger-soft: #45161a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, .45);
  --shadow-lg: 0 24px 50px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

button { font-family: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px; }

.app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ----- Top bar ------------------------------------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + var(--safe-t)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em;
}
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: transparent;            /* light mode: no tile/background behind the logo */
  display: grid; place-items: center; overflow: hidden;
}
.brand-logo img { width: 76%; height: 76%; object-fit: contain; display: block; }
.brand-logo--wide { width: auto; min-width: 120px; padding: 0 10px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.brand-logo--wide img { width: 100%; height: 28px; object-fit: contain; }
.brand-mark small { display: block; font-weight: 600; font-size: 11px; color: var(--text-2); letter-spacing: 0; }
.spacer { flex: 1; }

/* Store identifier badge — shown on both the customer header and the cashier
   console. Value comes from /api/config (the STORE_ID env var). */
.store-badge {
  display: inline-flex; align-items: baseline; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--shadow-sm); white-space: nowrap; line-height: 1;
}
.store-badge-label {
  font-size: 9.5px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-3);
}
.store-badge-id {
  font-size: 12px; font-weight: 800; letter-spacing: .02em;
  color: var(--text); font-variant-numeric: tabular-nums;
}
/* Stack the title and the store badge in the cashier header. */
.admin-titles { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.admin-titles .store-badge { align-self: flex-start; }

.lang-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  flex: none; height: 38px; padding: 0 12px; white-space: nowrap;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  font-weight: 700; font-size: 13px; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, background .2s ease;
}
.lang-toggle svg { flex: none; }
.lang-toggle:active { transform: scale(.96); }
.lang-toggle svg { width: 16px; height: 16px; opacity: .7; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer;
  box-shadow: var(--shadow-sm); transition: transform .12s ease, background .2s ease;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 18px; height: 18px; opacity: .85; }

/* ----- Content ------------------------------------------------------------ */
.content { flex: 1; padding: 18px 16px calc(28px + var(--safe-b)); }
.section { margin-bottom: 18px; }


.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card.pad { padding: 18px; }

/* ----- Product ------------------------------------------------------------ */
.product-hero {
  position: relative;
  border-radius: var(--r-xl);
  padding: 26px 20px;
  color: #fff;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  isolation: isolate;
  background-color: #1f2937;          /* fallback shown behind the product image */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
/* brand-colour overlay sitting on top of the product image (when one is set) */
.product-hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--hero-gradient, transparent);
  filter: grayscale(1) brightness(0.4);   /* greyscale overlay, darkened toward black */
  opacity: var(--hero-overlay, 1);
}
.product-hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(120% 90% at 85% 0%, rgba(255,255,255,.28), transparent 60%);
}
.product-hero .cat {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  background: rgba(255,255,255,.22); color: #fff;
  padding: 5px 11px; border-radius: 999px; margin-bottom: 16px;
  backdrop-filter: blur(4px);
}
.product-hero .icon { font-size: 52px; line-height: 1; filter: drop-shadow(0 6px 12px rgba(0,0,0,.25)); }
.product-hero .row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.product-hero .brand { font-size: 13px; font-weight: 700; opacity: .92; margin: 14px 0 2px; }
.product-hero .name { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.product-hero .price { font-size: 30px; font-weight: 850; letter-spacing: -.03em; white-space: nowrap; }

.muted { color: var(--text-2); }
.desc { color: var(--text-2); font-size: 14.5px; margin: 14px 2px 0; }

.highlights { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.highlights li { display: flex; align-items: center; gap: 11px; font-size: 14.5px; font-weight: 550; }
.highlights .tick {
  flex: none; width: 22px; height: 22px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-size: 12px; font-weight: 900;
}

.terms { margin-top: 6px; }
.terms summary {
  list-style: none; cursor: pointer; font-weight: 700; font-size: 13.5px;
  padding: 14px 4px; color: var(--text-2);
  display: flex; align-items: center; justify-content: space-between;
}
.terms summary::-webkit-details-marker { display: none; }
.terms summary::after {
  content: ""; flex: none; width: 16px; height: 16px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%223%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M6%209l6%206%206-6%22%2F%3E%3C%2Fsvg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%223%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M6%209l6%206%206-6%22%2F%3E%3C%2Fsvg%3E") center / contain no-repeat;
  transition: transform .2s ease;
}
.terms[open] summary::after { transform: rotate(180deg); }
.terms p { margin: 0 4px 8px; font-size: 13px; color: var(--text-3); line-height: 1.6; }

/* ----- Order history (device-local) --------------------------------------- */
.hist-head { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.hist-count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--brand-soft); color: var(--brand-700);
  font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.hist-list { display: flex; flex-direction: column; gap: 8px; padding: 2px 2px 10px; }
.hist-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 12px; border-radius: 12px;
  background: var(--bg); border: 1px solid var(--line);
}
.hist-main { flex: 1; min-width: 0; }
.hist-name { font-weight: 750; font-size: 14px; color: var(--text); letter-spacing: -.01em; }
.hist-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
  margin-top: 3px; font-size: 12px; color: var(--text-3);
}
.hist-ref { font-weight: 800; letter-spacing: .06em; color: var(--text-2); font-variant-numeric: tabular-nums; }
.hist-sep { opacity: .5; }
.hist-code {
  display: block; width: 100%; margin-top: 9px; padding: 8px 10px;
  border: 1px dashed var(--brand); border-radius: 10px; background: var(--brand-soft);
  color: var(--brand-700); font-weight: 800; font-size: 14px; letter-spacing: .08em;
  text-align: center; cursor: pointer; word-break: break-all;
  font-variant-numeric: tabular-nums; font-family: inherit;
}
.hist-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.hist-side .pill { margin: 0; }
.hist-show { padding: 2px 4px; font-size: 12.5px; }

/* ----- Section label ------------------------------------------------------ */
.label {
  display: flex; align-items: center; gap: 8px;
  font-size: 22px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; justify-content: center;
  color: var(--text-3); margin: 0 4px 10px;
}
.label::before { content: ""; width: 18px; height: 2px; border-radius: 2px; background: var(--brand); }

/* ----- Payment ticket ----------------------------------------------------- */
.ticket {
  position: relative;
  background: #fff;            /* QR must stay on white for reliable scanning */
  color: #0f172a;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  border: 1px solid #eef0f5;
  overflow: hidden;
}
.ticket-top { padding: 14px 16px 4px; text-align: center; }
.ticket .qr-tap {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent;
  display: block; width: 100%; cursor: pointer; padding: 0;
}
.qr-frame {
  position: relative;
  width: min(44vw, 180px);
  aspect-ratio: 1 / 1;
  margin: 4px auto 2px;
  padding: 10px;
  background: #fff;
  border-radius: 18px;
  border: 1px solid #eef0f5;
}
.qr-frame svg, .qr-frame img { display: block; width: 100%; height: 100%; }
.qr-frame.skeleton { background: linear-gradient(100deg, #eef0f5 30%, #f7f8fb 50%, #eef0f5 70%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-color: transparent; }
.qr-hint {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 6px; font-size: 12.5px; font-weight: 700; color: var(--brand);
}
.qr-hint svg { width: 15px; height: 15px; }
.qr-hint .ping { animation: ping 1.6s ease-in-out infinite; }

.ticket .perf {
  position: relative; height: 10px; margin: 2px 0;
  border-top: 2px dashed #d9dde6;
}
.ticket .perf::before, .ticket .perf::after {
  content: ""; position: absolute; top: -13px; width: 24px; height: 24px;
  border-radius: 999px; background: var(--bg);
}
.ticket .perf::before { left: -13px; }
.ticket .perf::after { right: -13px; }

.ticket-bottom {
  padding: 6px 18px 16px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; text-align: left;
}
.ticket-bottom .pill { margin-top: 0; flex: none; }
.ref-meta { display: flex; flex-direction: column; min-width: 0; }
.ref-label { font-size: 10.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #94a3b8; }
.ref-number {
  font-size: 23px; font-weight: 850; letter-spacing: .14em; margin: 1px 0 0;
  font-variant-numeric: tabular-nums; color: #0f172a;
}

/* status pill */
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 14px; padding: 9px 16px; border-radius: 999px;
  font-weight: 750; font-size: 13.5px;
}
.pill .dot { width: 9px; height: 9px; border-radius: 999px; background: currentColor; }
.pill.pending {
  position: relative; isolation: isolate;
  background: var(--ok); color: #fff;          /* positive green — matches the Reveal button */
  box-shadow: 0 8px 20px rgba(22, 163, 74, .32);  /* same drop shadow as .btn-success */
  --pulse: rgba(22, 163, 74, .5);
}
.pill.pending .dot { animation: pulse 1.4s ease-in-out infinite; }
/* Same expanding pulse the CTA buttons (Reveal / Redeem) use — no zoom. */
.pill.pending::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 0 0 var(--pulse);
  animation: ctaPulse 1.9s cubic-bezier(.4, 0, .2, 1) infinite;
}
@media (prefers-reduced-motion: reduce) {
  .pill.pending::after { animation: none; }
}
.pill.paid { background: var(--ok-soft); color: #15803d; }
.pill.expired { background: var(--surface-2); color: var(--text-2); }
.pill.expired .dot { background: var(--text-3); }

/* ----- Collapsed payment summary (after payment, relocated below) -------- */
.ticket-summary {
  display: none; /* shown only when the section is collapsed */
  width: 100%; appearance: none; -webkit-appearance: none; border: 0; background: transparent;
  align-items: center; gap: 12px; padding: 15px 18px; cursor: pointer; text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.ticket-summary .ts-ico {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  background: #eef2ff; color: #4f46e5; display: grid; place-items: center;
}
.ticket-summary .ts-ico svg { width: 21px; height: 21px; }
.ticket-summary .ts-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.ticket-summary .ts-text > span:first-child { font-weight: 750; font-size: 14px; color: #0f172a; }
.ticket-summary .ts-ref { font-weight: 800; font-size: 13px; letter-spacing: .14em; color: #64748b; font-variant-numeric: tabular-nums; margin-top: 1px; }
.ticket-summary .ts-paid { flex: none; width: 22px; height: 22px; border-radius: 999px; background: #16a34a; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 900; }
.ticket-summary .ts-chevron { flex: none; color: #94a3b8; font-size: 18px; transition: transform .2s ease; }

#paySection.collapsed { margin-top: 2px; }
#paySection.collapsed > .label { display: none; }
#paySection.collapsed .ticket-summary { display: flex; }
#paySection.collapsed .ticket-body { display: none; }
#paySection.collapsed.open .ticket-body { display: block; padding-bottom: 4px; }
#paySection.collapsed.open .ts-chevron { transform: rotate(180deg); }

/* ----- Buttons ------------------------------------------------------------ */
.btn {
  appearance: none; -webkit-appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: var(--tap); padding: 0 20px;
  border-radius: 14px; border: 1px solid transparent;
  font-size: 16px; font-weight: 750; letter-spacing: -.01em;
  cursor: pointer; user-select: none; text-decoration: none;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, opacity .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.975); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-block { width: 100%; }
.btn-lg { min-height: 58px; font-size: 17px; border-radius: 16px; }
.btn svg { width: 20px; height: 20px; }

.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 8px 20px color-mix(in srgb, var(--brand) 35%, transparent); }
.btn-primary:hover { background: var(--brand-600); }
.btn-success { background: var(--ok); color: #fff; box-shadow: 0 8px 20px rgba(22,163,74,.32); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn-danger-ghost { background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.btn-tonal { background: var(--brand-soft); color: var(--brand-700); border: none; }
.btn-steam { background: linear-gradient(90deg, #06bfff 0%, #2d73ff 100%); color: #fff; box-shadow: 0 8px 20px rgba(45, 115, 255, .35); border: none; }
.btn-steam:hover { filter: brightness(1.05); }

/* Pulsating call-to-action: an expanding ring drawn on a pseudo-element so it
   never fights the button's own drop shadow. Colour adapts to the variant. */
.btn-pulse { position: relative; isolation: isolate; }
.btn-pulse::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 0 0 var(--pulse, color-mix(in srgb, var(--brand) 50%, transparent));
  animation: ctaPulse 1.9s cubic-bezier(.4, 0, .2, 1) infinite;
}
.btn-primary.btn-pulse { --pulse: color-mix(in srgb, var(--brand) 50%, transparent); }
.btn-success.btn-pulse { --pulse: rgba(22, 163, 74, .5); }
.btn-tonal.btn-pulse   { --pulse: color-mix(in srgb, var(--brand) 42%, transparent); }
.btn-steam.btn-pulse   { --pulse: rgba(45, 115, 255, .55); }
@keyframes ctaPulse {
  0%   { box-shadow: 0 0 0 0 var(--pulse, rgba(79,70,229,.5)); }
  70%  { box-shadow: 0 0 0 14px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .btn-pulse::after { animation: none; }
}

.center { text-align: center; }
.stack { display: grid; gap: 12px; }
.linkish { background: none; border: 0; color: var(--text-2); font-weight: 700; font-size: 13.5px; cursor: pointer; padding: 8px; text-decoration: underline; text-underline-offset: 3px; }

/* ----- Paid / reveal ------------------------------------------------------ */
.celebrate {
  text-align: center; padding: 22px;
  background: linear-gradient(180deg, var(--ok-soft), var(--surface));
  border: 1px solid color-mix(in srgb, var(--ok) 20%, var(--line));
  border-radius: var(--r-xl);
}
.check {
  width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 999px;
  background: var(--ok); color: #fff; display: grid; place-items: center;
  box-shadow: 0 10px 24px rgba(22,163,74,.4);
  animation: pop .45s cubic-bezier(.18,.9,.32,1.4) both;
}
.check svg { width: 34px; height: 34px; }
.celebrate h2 { margin: 6px 0 2px; font-size: 20px; letter-spacing: -.02em; }
.celebrate p { margin: 0 0 16px; color: var(--text-2); font-size: 14px; }

/* expired variant (unpaid order timed out) */
.celebrate.expired {
  background: linear-gradient(180deg, var(--warn-soft), var(--surface));
  border-color: color-mix(in srgb, var(--warn) 22%, var(--line));
}
.celebrate.expired .check { background: var(--warn); box-shadow: 0 10px 24px rgba(217, 119, 6, .4); }

/* out-of-stock notice + hero badge */
.celebrate.oos { background: var(--surface-2); border-color: var(--line); }
.celebrate.oos .check { background: var(--text-3); box-shadow: 0 10px 24px rgba(100, 116, 139, .35); }
.oos-badge {
  display: inline-flex; align-items: center; vertical-align: top;
  font-size: 12px; font-weight: 800; letter-spacing: .02em;
  background: #dc2626; color: #fff; padding: 5px 11px; border-radius: 999px;
  margin: 0 0 16px 8px;
}

.code-reveal {
  text-align: center; padding: 22px;
  border-radius: var(--r-xl);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.code-box {
  margin: 6px 0 14px; padding: 18px 14px; border-radius: 16px;
  background: var(--surface-2); border: 1.5px dashed var(--brand);
  font-size: clamp(19px, 6.4vw, 26px); font-weight: 800; letter-spacing: .12em;
  font-variant-numeric: tabular-nums; word-break: break-all; color: var(--text);
  animation: pop .4s ease both;
}
.code-reveal .btn + .btn { margin-top: 18px; }
.redeem-note { font-size: 13px; color: var(--text-3); margin-top: 12px; line-height: 1.55; }

/* Post-purchase engagement: follow Play-Asia (subtle, secondary to the actions) */
.social-follow { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
.social-follow.page-foot { margin-top: 24px; padding-top: 4px; }

/* App version — stamped on each deploy, shown at the very bottom of both pages */
.app-version {
  text-align: center; margin-top: 18px;
  padding-bottom: calc(8px + var(--safe-b));
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  color: var(--text-3); opacity: .75; font-variant-numeric: tabular-nums;
}
.app-version:empty { display: none; }

/* One-shot confetti overlay fired when payment is confirmed */
.confetti-canvas {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 200;
}

/* ----- Slide-in menu drawer (hamburger) ----------------------------------- */
.drawer-scrim {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(8, 12, 24, .5); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.drawer-scrim.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; z-index: 121;
  height: 100%; width: min(86vw, 340px);
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}
.drawer.show { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(16px + var(--safe-t)) 16px 12px; border-bottom: 1px solid var(--line);
}
.drawer-title { font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.drawer-body { flex: 1; overflow-y: auto; padding: 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.menu-label {
  font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3); padding: 12px 8px 4px;
}
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 13px 12px; border-radius: 12px; border: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 15px; font-weight: 650; text-align: left;
  cursor: pointer; text-decoration: none; transition: background .15s ease;
}
.menu-item:hover, .menu-item:active { background: var(--surface-2); }
.menu-item svg { width: 19px; height: 19px; flex: none; opacity: .8; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger svg { opacity: 1; }
.lang-seg, .theme-seg { display: flex; gap: 6px; padding: 2px 8px 4px; }
.lang-seg .seg, .theme-seg .seg {
  flex: 1; padding: 11px 6px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text-2); font: inherit; font-weight: 750; font-size: 14px;
  cursor: pointer; transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.lang-seg .seg.active, .theme-seg .seg.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.drawer-foot {
  padding: 14px 18px calc(16px + var(--safe-b)); border-top: 1px solid var(--line);
  font-size: 12px; color: var(--text-3); text-align: center; letter-spacing: .03em;
  font-variant-numeric: tabular-nums;
}
.drawer-foot .df-sep { opacity: .5; margin: 0 6px; }
.drawer-foot:empty { display: none; }
.social-link {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); font-weight: 700; font-size: 13px;
  text-decoration: none; box-shadow: var(--shadow-sm);
  transition: transform .12s ease, color .2s ease, border-color .2s ease;
}
.social-link:hover { color: var(--text); border-color: color-mix(in srgb, var(--text-2) 30%, var(--line)); }
.social-link:active { transform: scale(.96); }
.social-link svg { width: 16px; height: 16px; }

/* ----- Bright "boarding-pass" overlay ------------------------------------- */
.bright {
  position: fixed; inset: 0; z-index: 100;
  background: #fff; color: #0b1020;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center;
}
.bright.show { display: flex; animation: fade .2s ease; }
.bright .bqr {
  width: min(82vw, 82vh, 460px); aspect-ratio: 1/1; padding: 16px;
  background: #fff; border-radius: 22px; box-shadow: 0 0 0 1px #eef0f5;
}
.bright .bqr svg, .bright .bqr img { width: 100%; height: 100%; display: block; }
.bright .bref { margin-top: 18px; font-size: 26px; font-weight: 850; letter-spacing: .2em; font-variant-numeric: tabular-nums; }
.bright .bsub { margin-top: 4px; color: #475569; font-size: 14px; font-weight: 600; }
.bright .bclose {
  position: absolute; top: calc(16px + var(--safe-t)); right: 16px;
  width: 44px; height: 44px; border-radius: 999px; border: 0;
  background: #0f172a0d; color: #0f172a; font-size: 22px; cursor: pointer;
  display: grid; place-items: center;
}
.bright .bbadge {
  position: absolute; top: calc(20px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 800; letter-spacing: .04em; color: #b45309;
  background: #fef3c7; padding: 7px 14px; border-radius: 999px;
}

/* ----- Toast -------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  z-index: 120; max-width: 90vw;
  background: #0f172a; color: #fff; font-weight: 650; font-size: 14px;
  padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease;
  display: inline-flex; align-items: center; gap: 9px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: #15803d; }
.toast.err { background: #b91c1c; }

/* ----- Error box ---------------------------------------------------------- */
.errorbox { text-align: center; padding: 40px 20px; color: var(--text-2); }
.errorbox .big { font-size: 44px; }

/* =========================================================================
   Cashier-specific
   ========================================================================= */
.gate {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 80% at 50% -10%, var(--brand-soft), var(--bg));
}
.gate-card { width: 100%; max-width: 360px; text-align: center; }
.gate-card .brand-logo { width: auto; height: auto; border-radius: 0; overflow: visible; margin: 4px auto 26px; }
.gate-card .brand-logo img { width: min(260px, 74%); height: auto; }
.gate-card .brand-logo--wide { width: auto; min-width: 160px; height: 52px; border-radius: 12px; padding: 0 14px; }
.gate-card h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.02em; }
.gate-card p { color: var(--text-2); font-size: 14px; margin: 0 0 20px; }
.pin-input {
  width: 100%; height: 60px; text-align: center; font-size: 26px; font-weight: 800;
  letter-spacing: .4em; border-radius: 16px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--text); margin-bottom: 12px;
  font-variant-numeric: tabular-nums;
}
.pin-input::placeholder { letter-spacing: .3em; color: var(--text-3); font-weight: 700; }
.pin-error { color: var(--danger); font-size: 13.5px; font-weight: 700; min-height: 20px; margin-bottom: 8px; }

.admin-head {
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + var(--safe-t)) 16px 12px;
}
.admin-head h1 { font-size: 18px; margin: 0; line-height: 1; letter-spacing: -.02em; }
.conn {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--text-2);
}
.conn .dot { width: 8px; height: 8px; border-radius: 999px; background: var(--text-3); }
.conn.online .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.conn.offline .dot { background: var(--danger); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.stat .n { font-size: 28px; font-weight: 850; letter-spacing: -.03em; line-height: 1; }
.stat .k { font-size: 12px; font-weight: 700; color: var(--text-2); margin-top: 6px; }
.stat.pending .n { color: var(--warn); }
.stat.paid .n { color: var(--ok); }

.wallet {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 14px; margin-bottom: 12px; box-shadow: var(--shadow-sm);
  color: var(--text); cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease;
}
.wallet:active { transform: scale(.99); }
.wallet .w-ico { flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--brand-soft); display: grid; place-items: center; font-size: 20px; }
.wallet .w-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wallet .w-label { font-size: 12px; font-weight: 700; color: var(--text-2); }
.wallet .w-amt { font-weight: 850; font-size: 17px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.wallet.empty .w-amt { color: var(--warn); }
.wallet .w-refresh { flex: none; width: 18px; height: 18px; opacity: .7; }
.wallet .w-refresh.spin { animation: spin .8s linear infinite; }

.scan-cta { margin-bottom: 16px; }

.orders { display: grid; gap: 12px; }
.order {
  display: flex; align-items: center; gap: 13px; width: 100%;
  text-align: left; cursor: pointer; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 13px; box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .2s ease, border-color .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.order:active { transform: scale(.99); }
.order.paid { opacity: .82; }
.order .ico {
  flex: none; width: 50px; height: 50px; border-radius: 14px; color: #fff;
  display: grid; place-items: center; font-size: 24px; box-shadow: var(--shadow-sm);
}
.order .meta { flex: 1; min-width: 0; }
.order .meta .nm { font-weight: 750; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order .meta .sub { font-size: 12.5px; color: var(--text-2); display: flex; gap: 7px; align-items: center; margin-top: 3px; white-space: nowrap; overflow: hidden; }
.order .meta .ref { font-weight: 800; letter-spacing: .08em; color: var(--text); font-variant-numeric: tabular-nums; }
.order .right { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; }
.order .right .amt { font-weight: 800; font-size: 15px; letter-spacing: -.01em; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 800; padding: 4px 9px; border-radius: 999px; margin-top: 6px; }
.badge .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.badge.pending { background: var(--warn-soft); color: #b45309; }
.badge.pending .dot { animation: pulse 1.4s infinite; }
.badge.paid { background: var(--ok-soft); color: #15803d; }

@keyframes flash-bg { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 60%, transparent); border-color: var(--brand); } 100% { box-shadow: 0 0 0 14px transparent; } }
.order.flash { animation: flash-bg 1.1s ease-out 2; border-color: var(--brand); }

.empty { text-align: center; color: var(--text-3); padding: 50px 20px; }
.empty .big { font-size: 46px; margin-bottom: 8px; }
.empty .spin { width: 30px; height: 30px; border-radius: 999px; border: 3px solid var(--line); border-top-color: var(--brand); margin: 0 auto 14px; animation: spin 1s linear infinite; }

/* ----- Bottom sheet & modal ---------------------------------------------- */
.scrim {
  position: fixed; inset: 0; z-index: 60; background: rgba(15,23,42,.55);
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
  backdrop-filter: blur(2px);
}
.scrim.show { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  background: var(--surface); border-radius: 24px 24px 0 0;
  padding: 10px 18px calc(22px + var(--safe-b));
  box-shadow: var(--shadow-lg);
  transform: translateY(110%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
  max-width: var(--maxw); margin: 0 auto;
}
.sheet.show { transform: translateY(0); }
.sheet .grip { width: 42px; height: 5px; border-radius: 999px; background: var(--line); margin: 6px auto 16px; }

/* product hero inside the action sheet — mirrors the customer hero */
.sheet-hero {
  position: relative; border-radius: 18px; overflow: hidden; isolation: isolate;
  padding: 14px 16px; color: #fff; margin-bottom: 14px; min-height: 92px;
  display: flex; flex-direction: column; justify-content: flex-end;
  background-color: #1f2937; background-size: cover; background-position: center; background-repeat: no-repeat;
}
.sheet-hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--hero-gradient, transparent);
  filter: grayscale(1) brightness(0.4); opacity: var(--hero-overlay, 1);
}
.sheet-hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(120% 90% at 85% 0%, rgba(255,255,255,.22), transparent 60%);
}
.sheet-hero .cat {
  position: absolute; top: 12px; left: 14px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  background: rgba(255,255,255,.22); color: #fff;
  padding: 4px 10px; border-radius: 999px; backdrop-filter: blur(4px);
}
.sheet-hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.sheet-hero-brand { font-size: 12px; font-weight: 700; opacity: .9; margin-bottom: 2px; }
.sheet-hero-name { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.sheet-hero-price { font-size: 22px; font-weight: 850; letter-spacing: -.02em; white-space: nowrap; }

/* mockup barcode — always light so it reads like a printed label */
.sheet-barcode {
  background: #fff; border: 1px solid #e6e8ef; border-radius: 14px;
  padding: 14px 16px 10px; margin-bottom: 14px; text-align: center;
}
.sheet-barcode .bars { display: block; height: 56px; }
.sheet-barcode .bars svg { display: block; width: 100%; height: 100%; }
.sheet-barcode .bc-ref {
  margin-top: 9px; font-weight: 800; font-size: 13.5px;
  letter-spacing: .22em; text-indent: .22em; color: #0b0f19; font-variant-numeric: tabular-nums;
}

.sheet-sub { color: var(--text-2); font-size: 13px; margin: -2px 2px 16px; text-align: center; }

/* scanner modal */
.modal {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  background: var(--surface); border-radius: 24px 24px 0 0;
  padding: 10px 16px calc(20px + var(--safe-b));
  box-shadow: var(--shadow-lg); max-width: var(--maxw); margin: 0 auto;
  transform: translateY(110%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
}
.modal.show { transform: translateY(0); }
.modal .grip { width: 42px; height: 5px; border-radius: 999px; background: var(--line); margin: 6px auto 14px; }
.modal h2 { font-size: 18px; margin: 0 0 4px; text-align: center; letter-spacing: -.02em; }
.modal .hint { text-align: center; color: var(--text-2); font-size: 13px; margin: 0 0 14px; }
#reader {
  width: 100%; border-radius: 18px; overflow: hidden; background: #000;
  aspect-ratio: 1/1; max-height: 52vh; margin: 0 auto 14px;
}
#reader video { object-fit: cover !important; }
/* hide html5-qrcode's default chrome for a cleaner look */
#reader img[alt="Info icon"], #reader__dashboard_section_csr span:first-child { display: none !important; }
#reader__dashboard_section { padding: 0 !important; }
#reader__status_span { display: none !important; }
.scan-status { text-align: center; font-size: 13px; font-weight: 700; min-height: 20px; color: var(--text-2); margin-bottom: 12px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12px; font-weight: 700; margin: 6px 0 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.manual { display: flex; gap: 10px; }
.manual input {
  flex: 1; height: var(--tap); border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--surface-2); color: var(--text); padding: 0 16px; font-size: 16px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
}
.manual input::placeholder { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--text-3); }

.hidden { display: none !important; }

/* ----- Animations --------------------------------------------------------- */
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes ping { 0% { transform: scale(1); opacity: 1; } 70%,100% { transform: scale(1.5); opacity: 0; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* Brighter status text on dark backgrounds for legibility */
:root[data-theme="dark"] .badge.pending,
:root[data-theme="dark"] .stat.pending .n,
:root[data-theme="dark"] .wallet.empty .w-amt { color: #fbbf24; }
:root[data-theme="dark"] .pill.paid,
:root[data-theme="dark"] .badge.paid,
:root[data-theme="dark"] .stat.paid .n { color: #4ade80; }

/* Dark mode: keep the ticket dark (matches the theme) and brighten ONLY the
   QR tile — it must stay light to scan reliably. */
:root[data-theme="dark"] .ticket {
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
}
:root[data-theme="dark"] .qr-frame {
  background: #fff; border-color: transparent;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .4);
}
:root[data-theme="dark"] .ref-number { color: var(--text); }
:root[data-theme="dark"] .ticket .perf { border-top-color: rgba(255, 255, 255, .16); }
/* Logo: transparent bg, invert SVG to white */
:root[data-theme="dark"] .brand-logo { background: transparent; border-color: transparent; box-shadow: none; }
:root[data-theme="dark"] .brand-logo img { filter: brightness(0) invert(1); }
:root[data-theme="dark"] .gate-card .brand-logo { background: transparent; border-color: transparent; }
