/* Phuto Shop V2 — one stylesheet for the shop and the back office.
   Visual world: the prepaid top-up card. See DESIGN.md.
   --primary / --secondary / --accent and --on-primary / --on-accent come from the shop theme (src/domain/theme.rs).
   primary   = card faces and the main action      secondary = links, selected filters, focus
   accent    = price tags, "ขายดี", wallet balance  (always a fill, never text on paper) */

:root {
  --primary: #C8175D;
  --secondary: #0F6E78;
  --accent: #F2A900;
  --on-primary: #FFFFFF;
  --on-accent: #1B2433;

  --ink: #1B2433;
  --paper: #F5F6F8;
  --surface: #FFFFFF;
  --rule: #D9DDE3;
  --rule-strong: #B9C0CA;
  --muted: #5E6878;
  --foil: #C5CBD3;
  --ok: #1E7F3C;
  --warn: #9A5B00;
  --danger: #C42B2B;

  --font-display: "Bai Jamjuree", "IBM Plex Sans Thai Looped", sans-serif;
  --font-body: "IBM Plex Sans Thai Looped", "Noto Sans Thai", system-ui, sans-serif;
  --font-code: "IBM Plex Mono", ui-monospace, Consolas, monospace;

  /* type scale 1.25 from 16px */
  --t-xs: 0.8125rem;
  --t-sm: 0.875rem;
  --t-md: 1rem;
  --t-lg: 1.25rem;
  --t-xl: 1.5625rem;
  --t-2xl: 1.9375rem;
  --t-3xl: 2.4375rem;
  --t-4xl: 3.0625rem;

  --r-face: 12px;
  --r-btn: 8px;
  --r-field: 6px;
  --r-panel: 4px;
  --face-shadow: 0 1px 0 rgba(27, 36, 51, 0.18), 0 8px 18px -8px rgba(27, 36, 51, 0.35);

  /* fine security print, used only where trust matters (wallet balance, delivered keys) */
  --security-print:
    repeating-linear-gradient(45deg, transparent 0 7px, color-mix(in srgb, var(--secondary) 9%, transparent) 7px 8px),
    repeating-linear-gradient(-45deg, transparent 0 7px, color-mix(in srgb, var(--secondary) 9%, transparent) 7px 8px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--t-md);
  line-height: 1.7;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-variant-numeric: tabular-nums;
}
a { color: var(--secondary); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--secondary); outline-offset: 2px; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.3; margin: 0 0 0.6em; letter-spacing: -0.005em; }
h1 { font-size: var(--t-2xl); }
h2 { font-size: var(--t-xl); }
.h3, h3 { font-size: var(--t-lg); }
p { margin: 0 0 0.8em; }
code, .mono { font-family: var(--font-code); font-size: 0.95em; }
[hidden] { display: none !important; }

.container { width: min(1180px, 100% - 32px); margin-inline: auto; }
.narrow { max-width: 860px; }
.container.narrow { width: min(860px, 100% - 32px); }
.page { flex: 1; padding: 32px 0 72px; }
.section { margin-top: 56px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-head h2, .section-head h1, .section-head .h3 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: var(--t-sm); }
.center { text-align: center; }
.pre { white-space: pre-line; }
.break { word-break: break-all; }
.grow { flex: 1 1 auto; min-width: 0; }
.mt { margin-top: 1.4em; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.error-text { color: var(--danger); margin-top: 8px; }

/* ---------- panels, buttons, inputs ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-panel);
  padding: 24px;
}
.card + .card { margin-top: 16px; }
.empty { color: var(--muted); padding: 32px 24px; }
.empty a { font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--r-btn);
  padding: 10px 18px; font: inherit; font-weight: 600; line-height: 1.4; cursor: pointer; white-space: nowrap;
  color: var(--ink); background: var(--surface); border-color: var(--rule-strong); text-decoration: none;
}
.btn:hover { text-decoration: none; background: var(--paper); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 88%, var(--ink)); }
.btn-light { background: var(--surface); color: var(--ink); border-color: var(--rule-strong); }
.btn-ghost { background: transparent; border-color: var(--rule-strong); }
.btn-ghost:hover { background: var(--surface); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 85%, black); }
.btn-sm { padding: 5px 12px; font-size: var(--t-sm); }
.btn-lg { padding: 13px 26px; font-size: var(--t-lg); }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--secondary); font: inherit; font-weight: 600; cursor: pointer; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: var(--t-sm); color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r-field);
  padding: 9px 12px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--secondary); outline-offset: 0; border-color: var(--secondary); }
/* the generic input padding would stretch these into ovals inside a flex row, so they get a fixed round/square size */
input[type="checkbox"], input[type="radio"] { width: 1.15rem; height: 1.15rem; padding: 0; margin: 0; flex: none; accent-color: var(--secondary); }
input[type="color"] { padding: 3px; height: 44px; width: 96px; }
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; cursor: pointer; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > .field { flex: 1 1 160px; }
.row > input, .row > select { flex: 1 1 160px; width: auto; }
.input-group { display: flex; gap: 8px; }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }
.fieldset { border: 1px solid var(--rule); border-radius: var(--r-panel); padding: 16px 18px 4px; margin: 0 0 16px; }
.fieldset legend { padding: 0 6px; font-weight: 600; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }

.flash { border-radius: var(--r-panel); padding: 12px 16px; margin: 16px 0; border: 1px solid; border-left-width: 4px; background: var(--surface); }
.flash-ok { border-color: var(--ok); }
.flash-err { border-color: var(--danger); }

/* one-time messages (saved, signed in, errors): a small card that slides in at the top and goes away by itself */
.toast-stack {
  position: fixed; z-index: 80; top: 72px; left: 50%; transform: translateX(-50%);
  width: min(94vw, 460px); display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px;
  padding: 11px 10px 11px 12px; border-radius: 14px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--rule-strong);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  animation: toast-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.toast.is-out { opacity: 0; transform: translateY(-8px); transition: opacity 0.2s ease, transform 0.2s ease; }
.toast-icon {
  display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--ok); color: #fff;
}
.toast-err .toast-icon { background: var(--danger); }
.theme-dark .toast-ok .toast-icon { color: #052e16; }
.toast-text { flex: 1; min-width: 0; line-height: 1.6; overflow-wrap: anywhere; white-space: pre-line; }
.toast-close {
  flex: none; width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent;
  color: var(--muted); font-size: 14px; cursor: pointer;
}
.toast-close:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes toast-in-side { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
/* wide screens: the top-right corner, just under the top bar so the menu and balance stay clickable */
@media (min-width: 721px) {
  .toast-stack { top: 76px; left: auto; right: 16px; transform: none; width: min(420px, calc(100vw - 32px)); }
  .toast { animation-name: toast-in-side; }
  .toast.is-out { transform: translateX(14px); }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .toast.is-out { transition: none; }
}
.notice { color: var(--muted); font-size: var(--t-sm); margin: 14px 0; }
.notice-warn { color: var(--warn); font-size: var(--t-sm); margin: 4px 0 12px; }

.chip, .badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: var(--r-panel); font-size: var(--t-xs); font-weight: 500; background: var(--surface); border: 1px solid var(--rule); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip-ok { color: var(--ok); border-color: currentColor; }
.chip-out { color: var(--danger); border-color: currentColor; }
.chip-accent, .tag-accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.tag-accent { display: inline-block; padding: 1px 8px; border-radius: var(--r-panel); font-size: var(--t-xs); }
/* "HOT" corner tag: always red, whatever the theme, with a flame and a soft glow so it lifts off any picture. */
.tag-hot {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px 3px 7px; border-radius: 9999px;
  background: #E5252A; color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; line-height: 1.2;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85), 0 3px 10px rgba(229, 37, 42, 0.5);
}
.tag-hot svg { flex: none; }
/* a date box with its small label, in a row of filters */
.date-field { display: flex; align-items: center; gap: 6px; margin: 0; }
.date-field input { width: auto; }
@media (max-width: 720px) { .date-field { width: 100%; } .date-field input { flex: 1; } }

/* sign in with Google */
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; }
.google-btn + p { margin-top: 10px; }
.auth-card form + form { margin-top: 10px; }
.auth-or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: var(--t-sm); margin: 6px 0 14px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; border-top: 1px solid var(--rule-strong); }
.status { display: inline-block; padding: 1px 8px; border-radius: var(--r-panel); font-size: var(--t-xs); font-weight: 600; border: 1px solid currentColor; }
.status-pending { color: var(--warn); }
.status-completed { color: var(--ok); }
.status-rejected { color: var(--danger); }

/* ledger tables: thin rules, numbers right-aligned */
.table-wrap { overflow-x: auto; }
.card.table-wrap { padding: 4px 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--rule); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: var(--t-xs); color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom-color: var(--rule-strong); }
tbody tr:hover { background: color-mix(in srgb, var(--paper) 70%, transparent); }
td.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 16px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px; border-bottom: 1px solid var(--rule); }
.tab { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active { color: var(--ink); border-bottom-color: var(--secondary); font-weight: 600; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 24px; }
.pill { padding: 6px 14px; border-radius: var(--r-field); border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink); font-size: var(--t-sm); font-weight: 500; }
.pill:hover { text-decoration: none; border-color: var(--secondary); }
.pill.active { background: var(--secondary); border-color: var(--secondary); color: #fff; }
.crumbs { font-size: var(--t-sm); color: var(--muted); margin-bottom: 8px; }

/* ---------- header and footer ---------- */
.announce { background: var(--ink); color: #fff; overflow: hidden; font-size: var(--t-sm); }
.announce-track { display: inline-block; white-space: nowrap; padding: 6px 0; padding-left: 100%; animation: marquee 24s linear infinite; }
@keyframes marquee { to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .announce-track { animation: none; padding-left: 16px; } }

.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--rule); }
.topbar-inner { display: flex; align-items: center; gap: 20px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-family: var(--font-display); font-weight: 700; font-size: var(--t-lg); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 36px; width: auto; border-radius: var(--r-field); }
.brand-mark { width: 44px; height: 28px; border-radius: 5px; display: grid; place-items: center; font-size: var(--t-md); color: var(--on-primary); background: var(--primary); box-shadow: var(--face-shadow); }
.nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav > a, .nav .nav-menu > summary { color: var(--muted); padding: 7px 14px; border-radius: 999px; white-space: nowrap; font-weight: 500; border: 0; transition: background-color .15s, color .15s; }
.nav > a:hover, .nav .nav-menu > summary:hover, .nav .nav-menu[open] > summary { color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); text-decoration: none; }
.nav > a.active, .nav .nav-menu.active > summary { color: var(--ink); font-weight: 600; background: color-mix(in srgb, var(--primary) 16%, transparent); box-shadow: none; border-radius: 999px; }
.nav-account { margin-left: auto; display: flex; align-items: center; gap: 8px; }
/* the signed-in member: one pill with avatar, name, balance and role; it opens the account menu */
.nav-account .menu > summary.user-card {
  gap: 8px; padding: 3px 12px 3px 3px; border-radius: 9999px; color: var(--ink);
  background: color-mix(in srgb, var(--primary) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--rule-strong));
  transition: background-color .15s, border-color .15s;
}
.nav-account .menu > summary.user-card:hover, .nav-account .menu[open] > summary.user-card {
  background: color-mix(in srgb, var(--primary) 16%, transparent); border-color: var(--primary);
}
.user-card::after { display: none; }
.user-card-text { display: grid; justify-items: start; line-height: 1.2; }
.user-card-name { font-weight: 700; font-size: var(--t-sm); max-width: 10em; overflow: hidden; text-overflow: ellipsis; }
.user-card-balance { font-weight: 600; font-size: var(--t-xs); color: var(--secondary); font-variant-numeric: tabular-nums; }
.user-card-role { font-size: 10px; padding: 0 6px; line-height: 1.5; margin-top: 1px; }
.avatar.avatar-md { width: 40px; height: 40px; font-size: var(--t-sm); flex: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 55%, transparent); }
.nav-toggle { display: none; background: none; border: 1px solid var(--rule-strong); color: var(--ink); border-radius: var(--r-field); padding: 6px 12px; font: inherit; cursor: pointer; margin-left: auto; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; padding: 5px 12px; border-radius: var(--r-field); border: 1px solid var(--rule-strong); white-space: nowrap; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: ""; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform .15s; opacity: .7; }
.menu[open] > summary::after { transform: translateY(1px) rotate(225deg); }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-panel); padding: 6px; min-width: 200px; box-shadow: 0 12px 28px -12px rgba(27, 36, 51, 0.35); display: flex; flex-direction: column; }
.menu-list a, .menu-list button { color: var(--ink); padding: 8px 12px; border-radius: var(--r-panel); text-align: left; background: none; border: 0; font: inherit; cursor: pointer; }
.menu-list a:hover, .menu-list button:hover { background: var(--paper); text-decoration: none; }

.footer { border-top: 1px solid var(--rule); background: var(--surface); padding: 40px 0 20px; }
.footer-inner { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
.footer-brand { font-family: var(--font-display); font-weight: 700; font-size: var(--t-lg); margin-bottom: 6px; }
.footer-links { display: flex; flex-direction: column; gap: 6px; }
.footer-links a { color: var(--muted); }
.copyright { color: var(--muted); font-size: var(--t-xs); margin-top: 28px; }

/* ---------- the prepaid card face ---------- */
.product-face {
  position: relative; aspect-ratio: 1 / 1; border-radius: var(--r-face); overflow: hidden;
  background: var(--primary); color: var(--on-primary); box-shadow: var(--face-shadow);
  display: grid; place-items: center;
}
.product-face::after { /* print margin, like the inner border on a real card */
  content: ""; position: absolute; inset: 7px; border-radius: 7px; pointer-events: none;
  border: 1px solid color-mix(in srgb, var(--on-primary) 28%, transparent);
}
.product-face img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.face-initial { font-family: var(--font-display); font-weight: 700; font-size: var(--t-3xl); line-height: 1; opacity: 0.95; }
.face-initial.big { font-size: 6rem; }
.face-price {
  position: absolute; right: 12px; bottom: 12px; z-index: 1;
  /* frosted dark pill: the picture shows through, the price stays readable on any artwork */
  font-family: var(--font-display); font-weight: 700; font-size: var(--t-lg); line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
  background: rgba(14, 9, 24, 0.62); color: #fff; padding: 7px 13px; border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  -webkit-backdrop-filter: blur(10px) saturate(1.4); backdrop-filter: blur(10px) saturate(1.4);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.face-tag { position: absolute; left: 12px; top: 12px; z-index: 1; }
.face-out { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; background: rgba(217, 221, 227, 0.94); color: var(--ink); font-weight: 700; }

/* a shelf of cards without pictures gets slight shade steps of the one primary colour */
/* --tone-mix points away from --on-primary, so a shade never makes the card text harder to read */
.tone-1 { background: color-mix(in srgb, var(--primary) 90%, var(--tone-mix, var(--ink))); }
.tone-2 { background: color-mix(in srgb, var(--primary) 80%, var(--tone-mix, var(--ink))); }
.tone-3 { background: color-mix(in srgb, var(--primary) 94%, var(--tone-mix, var(--ink))); }
.tone-4 { background: color-mix(in srgb, var(--primary) 85%, var(--tone-mix, var(--ink))); }
.tone-5 { background: color-mix(in srgb, var(--primary) 74%, var(--tone-mix, var(--ink))); }

/* ---------- home ---------- */
.hero { padding: 24px 0 8px; }
.hero-banner { margin-bottom: 28px; }
.hero-inner.no-visual { grid-template-columns: 1fr; }
.hero-inner.no-visual .hero-visual { display: none; }
.hero-inner { display: grid; grid-template-columns: 1.15fr 1fr; gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(var(--t-2xl), 4.5vw, var(--t-4xl)); line-height: 1.2; margin-bottom: 16px; max-width: 14em; }
.hero-desc { color: var(--muted); font-size: var(--t-lg); line-height: 1.6; max-width: 30em; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.hero-stack { position: relative; display: block; padding: 28px 24px 36px; }
.hero-stack .product-face { width: 100%; }
.hero-stack .stack-back {
  position: absolute; inset: 28px 24px 36px; transform: rotate(-6deg) translate(-4%, 4%);
  border-radius: var(--r-face); background: color-mix(in srgb, var(--primary) 75%, var(--ink)); box-shadow: var(--face-shadow);
}
.hero-stack .stack-front { position: relative; z-index: 1; transform: rotate(2deg); }
.hero-stack .face-initial.big { opacity: 0.18; font-size: 9rem; }
.face-issuer { position: absolute; left: 18px; bottom: 16px; z-index: 1; font-size: var(--t-sm); font-weight: 600; opacity: 0.85; }
.hero-stack a:hover { text-decoration: none; }
.hero-stack .face-name {
  position: absolute; left: 18px; top: 16px; z-index: 1; max-width: 70%;
  font-family: var(--font-display); font-weight: 700; font-size: var(--t-lg); line-height: 1.3; color: var(--on-primary);
}
.slider { position: relative; aspect-ratio: 4 / 1; border-radius: var(--r-face); overflow: hidden; background: var(--surface); border: 1px solid var(--rule); }
.slide { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.6s ease; }
.slide.active { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .slide { transition: none; } }

.stats { display: flex; flex-wrap: wrap; gap: 0; margin-top: 40px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.stat { flex: 1 1 180px; padding: 14px 20px; display: flex; align-items: center; gap: 14px; transition: background-color 0.2s ease; }
.stat:hover { background: color-mix(in srgb, var(--primary) 5%, transparent); }
.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-icon {
  display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 50%;
  color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.stat:hover .stat-icon { box-shadow: 0 0 0 5px color-mix(in srgb, var(--primary) 12%, transparent); transform: translateY(-1px); }
.stat-value [data-count] { font-variant-numeric: tabular-nums; }
/* on the dark theme the figures glow faintly in the theme colour, like the sign-in button does */
.theme-dark .stat-value [data-count] { text-shadow: 0 0 20px color-mix(in srgb, var(--primary) 60%, transparent); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) { .stat, .stat-icon { transition: none; } .stat:hover .stat-icon { transform: none; } }
.stat + .stat { border-left: 1px solid var(--rule); }
.stat-value { font-family: var(--font-display); font-size: var(--t-xl); font-weight: 700; line-height: 1.2; }
.stat-value small { font-family: var(--font-body); font-size: var(--t-sm); color: var(--muted); font-weight: 400; }

.category-banner { width: 100%; aspect-ratio: 28 / 9; object-fit: cover; border-radius: var(--r-face); margin-bottom: 20px; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
.step { padding: 20px 24px 8px 0; display: flex; gap: 14px; align-items: baseline; }
.step p { margin: 0; }
.step-no { flex: none; font-family: var(--font-display); font-weight: 700; font-size: var(--t-2xl); line-height: 1; color: var(--primary); }
.faq { border-top: 1px solid var(--rule); }
.faq-item { border-bottom: 1px solid var(--rule); padding: 14px 0; }
.faq-item summary { cursor: pointer; font-weight: 600; }
.faq-item p { margin: 10px 0 0; color: var(--muted); max-width: 70ch; }

/* ---------- store ---------- */
.store-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.store-filter { display: flex; gap: 8px; flex-wrap: wrap; }
.store-filter input { width: 240px; }
.store-filter select { width: auto; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 28px 20px; }
.product-card { color: var(--ink); display: flex; flex-direction: column; gap: 10px; }
.product-card:hover { text-decoration: none; }
.product-card:hover .product-name { text-decoration: underline; text-underline-offset: 3px; }
.product-card:hover .product-face { transform: translateY(-2px); }
.product-card .product-face { transition: transform 0.15s ease; }
@media (prefers-reduced-motion: reduce) { .product-card .product-face { transition: none; } }
.product-card.is-out .product-face { filter: grayscale(0.85); }
.product-body { display: flex; flex-direction: column; gap: 2px; padding: 0 2px; }
.product-cat { font-size: var(--t-xs); color: var(--muted); }
.product-name { font-weight: 600; line-height: 1.45; }
.product-stock { font-size: var(--t-sm); color: var(--muted); }
.price { font-family: var(--font-display); font-weight: 700; font-size: var(--t-lg); }

/* ---------- product page ---------- */
.product-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; margin-top: 12px; }
.gallery { position: sticky; top: 88px; }
.gallery-main { width: 100%; }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 14px; overflow-x: auto; }
.gallery-thumb { padding: 0; border: 2px solid transparent; border-radius: var(--r-field); overflow: hidden; width: 76px; aspect-ratio: 1 / 1; flex: none; cursor: pointer; background: none; }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumb.active { border-color: var(--secondary); }
.video { margin-top: 16px; aspect-ratio: 16 / 9; border-radius: var(--r-panel); overflow: hidden; }
.video iframe { width: 100%; height: 100%; border: 0; }
.product-info h1 { margin-bottom: 10px; }
.buy-form .h3 { margin-bottom: 12px; }
.plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.plan { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--rule-strong); border-radius: var(--r-field); cursor: pointer; background: var(--surface); }
.plan input { position: absolute; top: 14px; right: 14px; margin: 0; }
.plan .plan-name { padding-right: 24px; }
.plan:has(input:checked) { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.plan:has(input:focus-visible) { outline: 2px solid var(--secondary); outline-offset: 2px; }
.plan-name { font-weight: 600; line-height: 1.4; }
.plan-price { font-family: var(--font-display); font-weight: 700; font-size: var(--t-lg); }
.plan-stock { color: var(--muted); }
.plan-out { opacity: 0.5; cursor: not-allowed; }
.buy-row { display: flex; gap: 14px; flex-wrap: wrap; }
.buy-row .field { min-width: 140px; }
.stepper { display: flex; border: 1px solid var(--rule-strong); border-radius: var(--r-field); overflow: hidden; background: var(--surface); }
.stepper button { width: 42px; background: none; border: 0; color: var(--ink); font-size: var(--t-lg); cursor: pointer; }
.stepper button:hover { background: var(--paper); }
.stepper input { border: 0; border-radius: 0; text-align: center; width: 64px; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.summary { border-top: 1px dashed var(--rule-strong); margin: 8px 0 16px; padding-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.summary > div { display: flex; justify-content: space-between; gap: 12px; }
.summary-total { font-weight: 700; font-size: var(--t-lg); border-top: 1px solid var(--rule); padding-top: 8px; margin-top: 4px; }
.summary-note { color: var(--warn); margin: 6px 0 0; }
.summary-note.ok { color: var(--ok); }
.wallet-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; font-size: var(--t-sm); color: var(--muted); }
.wallet-line strong { color: var(--ink); }
.description { margin-top: 20px; }
.description .pre { max-width: 70ch; }
.clamp { max-height: 14em; overflow: hidden; position: relative; }
.clamp.open { max-height: none; }

/* ---------- account, top-up, orders ---------- */
.auth { display: grid; place-items: center; padding-top: 24px; }
.auth-card { width: min(440px, 100%); }
.profile-summary { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.profile-page { display: grid; gap: 16px; }
.profile-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin: 0; }
.profile-who h1 { margin: 0; font-size: var(--t-2xl); line-height: 1.2; }
.profile-who p { margin: 4px 0 0; }
.profile-actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.avatar { position: relative; overflow: hidden; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.avatar-lg { width: 84px; height: 84px; font-size: var(--t-2xl); flex: none; }
.profile-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; padding: 0; margin: 0; overflow: hidden; }
.profile-stats > div { display: flex; flex-direction: column; padding: 16px 20px; border-left: 1px solid var(--rule); }
.profile-stats > div:first-child { border-left: 0; }
.profile-stats strong { font-family: var(--font-display); font-size: var(--t-xl); line-height: 1.3; }
.profile-balance { color: var(--primary); }
.profile-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
.profile-grid > .card { margin: 0; }
.profile-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.profile-card-head h2 { margin: 0; }
.profile-order { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--r-btn); color: var(--ink); }
.profile-order:hover { text-decoration: none; background: color-mix(in srgb, var(--primary) 8%, transparent); }
.profile-order-total { font-weight: 600; }
.profile-links { display: grid; gap: 2px; }
.profile-links a { display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: var(--r-btn); color: var(--ink); }
.profile-links a:hover { text-decoration: none; background: color-mix(in srgb, var(--primary) 10%, transparent); }
.profile-settings-title { margin: 12px 0 0; }
@media (max-width: 720px) {
  .profile-stats { grid-template-columns: 1fr 1fr; }
  .profile-stats > div:nth-child(odd) { border-left: 0; }
  .profile-stats > div:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .profile-grid { grid-template-columns: 1fr; }
  .profile-actions { margin-left: 0; }
}
.avatar { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-size: var(--t-xl); font-weight: 700; color: var(--on-primary); background: var(--primary); }
.profile-money { margin-left: auto; display: flex; gap: 28px; }
.profile-money > div, .balance-box { display: flex; flex-direction: column; }
.profile-money strong, .balance-box strong { font-family: var(--font-display); font-size: var(--t-xl); line-height: 1.3; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.two-col .card + .card { margin-top: 0; }
.topup-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.topup-head h1 { margin: 0; }
.balance-box { padding: 12px 20px; background-color: var(--surface); background-image: var(--security-print); border-left: 4px solid var(--accent); }
.balance-box + .card { margin-top: 0; }
.quick-amounts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.qr-layout { display: flex; gap: 28px; flex-wrap: wrap; align-items: flex-start; }
.qr-box { text-align: center; background: #fff; color: var(--ink); border: 1px solid var(--rule-strong); border-top: 6px solid var(--secondary); border-radius: var(--r-panel); padding: 16px; }
.qr-code svg { width: 240px; height: 240px; display: block; }
.qr-amount { font-family: var(--font-display); font-size: var(--t-xl); font-weight: 700; margin-top: 6px; }
.howto { padding-left: 1.2em; margin: 0 0 16px; max-width: 60ch; }
.bank-box { display: grid; gap: 10px; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-panel); padding: 14px 16px; margin-bottom: 16px; }
.bank-box > div { display: flex; flex-direction: column; }
.bank-box .key-row { padding: 6px 0 0; border-bottom: 0; }

/* delivered keys: security print + scratch cover added by app.js */
.keys-card { background-image: var(--security-print); }
.key-row { display: flex; gap: 10px; align-items: stretch; padding: 12px 0; border-bottom: 1px dashed var(--rule-strong); }
/* The copy button matches the key box beside it, so the pair reads as one row. */
.key-row .btn { display: inline-flex; align-items: center; justify-content: center; flex: none; padding: 0 18px; border-radius: var(--r-field); }
.scratch { position: relative; flex: 1; min-width: 0; border-radius: var(--r-field); overflow: hidden; }
.key { display: block; background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r-field); padding: 12px 14px; word-break: break-all; font-family: var(--font-code); }
.scratch-cover {
  position: absolute; inset: 0; z-index: 1; width: 100%; border: 0; border-radius: var(--r-field); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; color: var(--ink);
  background:
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.35) 0 2px, transparent 2px 6px),
    linear-gradient(100deg, #b9c0c9, #e3e7ec 35%, #aeb5bf 60%, #d9dde3);
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.45s ease;
}
.scratch.revealed .scratch-cover { transform: translateX(102%); opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .scratch-cover { transition: none; } }
.key-inline { word-break: break-all; }

.receipt { border-top: 1px dashed var(--rule-strong); }
.summary-list { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.summary-list > div { display: flex; justify-content: space-between; gap: 16px; }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; text-align: right; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(27, 36, 51, 0.55); padding: 16px; }
.modal-card { position: relative; width: min(480px, 100%); }
.modal-close { position: absolute; right: 12px; top: 10px; z-index: 2; background: none; border: 0; color: var(--muted); font-size: var(--t-lg); cursor: pointer; }

/* home pop-up: pictures the admin pastes as links, cycled with dots */
.modal-card.popup-card { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 0; }
.popup-card .modal-close { width: 34px; height: 34px; border-radius: 50%; background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--ink); }
.popup-slides { display: grid; padding: 20px 20px 0; }
.popup-slide { grid-area: 1 / 1; width: 100%; max-height: 62vh; object-fit: contain; border-radius: var(--r-panel); opacity: 0; visibility: hidden; transition: opacity 0.35s ease, visibility 0.35s; }
.popup-slide.active { opacity: 1; visibility: visible; }
@media (prefers-reduced-motion: reduce) { .popup-slide { transition: none; } }
.popup-nav { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 20px 0; }
.popup-dots { display: flex; gap: 8px; }
.popup-dot { width: 10px; height: 10px; padding: 0; border-radius: 50%; border: 0; cursor: pointer; background: var(--rule-strong); }
.popup-dot.active { background: var(--primary); }
.popup-count { font-size: var(--t-xs); color: var(--muted); }
.popup-body { padding: 16px 24px 0; }
.popup-body h2 { margin-bottom: 6px; }
.popup-body p { margin: 0; }
.popup-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 20px; padding: 16px 24px; border-top: 1px solid var(--rule); }
.popup-foot .check { margin: 0; }
.popup-card:not(:has(.popup-slides)) .popup-body { padding-top: 28px; padding-right: 48px; }

.error-body { display: grid; place-items: center; }
.error-card { max-width: 440px; margin: 80px auto; }
.error-code { font-family: var(--font-display); font-size: var(--t-4xl); font-weight: 700; color: var(--primary); line-height: 1; margin-bottom: 12px; }

/* ---------- back office: quiet, dense, same paper and ink ---------- */
.admin-body { display: block; }
.admin-shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--rule); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { margin-bottom: 18px; padding: 0 8px; font-size: var(--t-md); }
.side-nav { display: flex; flex-direction: column; gap: 1px; }
.side-nav a { color: var(--muted); padding: 7px 12px; border-radius: var(--r-panel); display: flex; align-items: center; gap: 6px; font-weight: 500; }
.side-nav a:hover { color: var(--ink); background: var(--paper); text-decoration: none; }
.side-nav a.active { color: var(--ink); background: var(--paper); box-shadow: inset 3px 0 0 var(--primary); font-weight: 600; }
.side-group { font-size: var(--t-xs); color: var(--muted); margin: 16px 12px 4px; font-weight: 600; }
.count { margin-left: auto; background: var(--danger); color: #fff; border-radius: var(--r-panel); font-size: var(--t-xs); padding: 0 7px; font-weight: 700; }
.admin-main { min-width: 0; display: flex; flex-direction: column; }
.admin-top { display: flex; align-items: center; gap: 12px; padding: 12px 28px; border-bottom: 1px solid var(--rule); background: var(--surface); position: sticky; top: 0; z-index: 10; }
.admin-top .nav-toggle { margin-left: 0; }
.admin-top-title { font-weight: 600; }
.admin-user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.admin-main > .flash { margin: 16px 28px 0; }
.admin-content { padding: 28px; }
.admin-content h1 { font-size: var(--t-xl); }
.admin-content .card { padding: 20px; }
.admin-content > .card, .admin-content > section.card, .admin-content > form.card { margin-bottom: 16px; }
.admin-content .card + .card { margin-top: 0; }
.admin-content th, .admin-content td { padding: 8px 14px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; align-items: start; }
.admin-grid > div > .card + .card { margin-top: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; margin-bottom: 20px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-panel); }
.kpi.card { display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; border: 0; border-radius: 0; margin: 0; }
.kpi + .kpi { border-left: 1px solid var(--rule); }
.kpi strong { font-family: var(--font-display); font-size: var(--t-xl); line-height: 1.3; }
.chart { display: flex; align-items: flex-end; gap: 10px; height: 200px; padding-top: 10px; border-bottom: 1px solid var(--rule-strong); }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.chart-bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.bar { width: 40%; min-height: 2px; border-radius: 2px 2px 0 0; }
.bar-sales { background: var(--primary); }
.bar-topup { background: var(--secondary); }
.chart-label { font-size: var(--t-xs); color: var(--muted); margin-top: 6px; }
.legend { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-left: 8px; }
.dot-sales { background: var(--primary); }
.dot-topup { background: var(--secondary); }
.plan-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.plan-row { display: grid; grid-template-columns: 1.4fr 0.8fr 1fr auto auto; gap: 8px; align-items: center; }
.danger-zone { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-color: var(--danger); border-left-width: 4px; }
.danger-zone p { margin: 0; }
.inline-edit { position: relative; }
.inline-edit summary { list-style: none; }
.inline-edit summary::-webkit-details-marker { display: none; }
.inline-edit[open] > form { position: absolute; right: 0; z-index: 5; width: 320px; margin-top: 6px; box-shadow: 0 12px 28px -12px rgba(27, 36, 51, 0.35); }
.topup-list { display: flex; flex-direction: column; gap: 14px; }
.topup-list .card + .card { margin-top: 0; }
.topup-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.topup-item-body { display: flex; gap: 16px; align-items: flex-start; }
.slip-thumb img { width: 140px; max-height: 220px; object-fit: contain; border-radius: var(--r-panel); background: #fff; border: 1px solid var(--rule); }
.review-form { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--rule-strong); }
.review-form .field { margin-bottom: 0; }
.check-list { max-height: 360px; overflow-y: auto; border: 1px solid var(--rule); border-radius: var(--r-panel); padding: 10px 12px; margin-top: 8px; }
.narrow-card { max-width: 480px; }
.thumb-sm { width: 56px; aspect-ratio: 1 / 1; border-radius: 4px; }

/* theme picker */
.theme-picker { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; margin-bottom: 8px; }
.theme-options { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.theme-options legend { font-weight: 600; margin-bottom: 10px; padding: 0; }
.theme-option { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--rule-strong); border-radius: var(--r-field); cursor: pointer; background: var(--surface); }
.theme-option:has(input:checked) { border-color: var(--secondary); box-shadow: inset 0 0 0 1px var(--secondary); }
.swatches { display: flex; flex: none; }
.swatches i { width: 18px; height: 26px; display: block; }
.swatches i:first-child { border-radius: 4px 0 0 4px; width: 26px; }
.swatches i:last-child { border-radius: 0 4px 4px 0; }
.swatch-custom { width: 62px !important; border-radius: 4px !important; background: conic-gradient(from 90deg, #C8175D, #F2A900, #1F7A4D, #2B3F8C, #6A1F5C, #C8175D); }
.theme-preview { position: sticky; top: 80px; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-panel); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.preview-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.custom-colours { margin-top: 16px; }

/* ---------- small screens ---------- */
@media (max-width: 960px) {
  .hero-inner, .product-layout, .admin-grid, .two-col, .theme-picker { grid-template-columns: 1fr; }
  .hero-stack { max-width: 460px; }
  .gallery, .theme-preview { position: static; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .footer-inner > :first-child { grid-column: 1 / -1; }
  .steps { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; align-items: stretch; background: var(--surface); border-bottom: 1px solid var(--rule); padding: 10px 16px 16px; }
  .nav.open { display: flex; }
  .nav > a.active { box-shadow: inset 3px 0 0 var(--secondary); }
  .nav-account { margin-left: 0; flex-wrap: wrap; padding-top: 10px; border-top: 1px solid var(--rule); margin-top: 6px; }
  .menu-list { position: static; box-shadow: none; margin-top: 6px; }
  .nav-menu > summary { display: flex; justify-content: space-between; }
  .nav-menu .menu-list { min-width: 0; animation: none; }
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(27, 36, 51, 0.3); }
  .admin-top .nav-toggle { display: block; }
  .admin-content { padding: 16px; }
  .kpi + .kpi { border-left: 0; border-top: 1px solid var(--rule); }
}

@media (min-width: 861px) {
  .admin-top .nav-toggle { display: none; }
}

@media (max-width: 560px) {
  .page { padding-top: 20px; }
  .card { padding: 18px; }
  .stats { display: grid; grid-template-columns: 1fr 1fr; }
  .stat { padding: 12px 14px; gap: 10px; }
  .stat-icon { width: 36px; height: 36px; }
  .stat + .stat { border-left: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--rule); }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--rule); }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 20px 12px; }
  .face-price { font-size: var(--t-md); right: 9px; bottom: 9px; padding: 5px 10px; }
  .face-initial { font-size: var(--t-2xl); }
  .store-filter, .store-filter input { width: 100%; }
  .plan-row { grid-template-columns: 1fr 1fr; }
  .profile-money { margin-left: 0; }
  .topup-head { flex-direction: column; align-items: flex-start; }
  .topup-item-body { flex-direction: column; }
  .danger-zone { flex-direction: column; align-items: flex-start; }
  .inline-edit[open] > form { position: static; width: auto; }
  /* buy button stays reachable on phones */
  .buy-form .buy-submit { position: sticky; bottom: 12px; z-index: 5; box-shadow: 0 8px 20px -8px rgba(27, 36, 51, 0.5); }
}

/* ---------- dark palettes (นีออน, ราตรี): night ground, neon glow, softer pill shapes ----------
   Applied by class `theme-dark` on <body> (or on the admin theme preview box). */
.theme-dark {
  color-scheme: dark;
  --ink: #F6F0F5;
  --paper: #120A12;
  --surface: #1C121C;
  --rule: #2E2030;
  --rule-strong: #4A3449;
  --muted: #B3A3B1;
  --ok: #4ADE80;
  --warn: #FBBF24;
  --danger: #F87171;
  --font-display: "Poppins", "Kanit", "IBM Plex Sans Thai Looped", sans-serif;
  --font-body: "Inter", "IBM Plex Sans Thai Looped", "Noto Sans Thai", system-ui, sans-serif;
  --r-face: 16px;
  --r-btn: 9999px;
  --r-field: 10px;
  --r-panel: 12px;
  --face-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 35%, transparent), 0 18px 44px -18px color-mix(in srgb, var(--primary) 60%, transparent);
  --glow: 0 0 28px -6px color-mix(in srgb, var(--primary) 70%, transparent);
  --security-print:
    repeating-linear-gradient(45deg, transparent 0 7px, color-mix(in srgb, var(--primary) 8%, transparent) 7px 8px),
    repeating-linear-gradient(-45deg, transparent 0 7px, color-mix(in srgb, var(--primary) 8%, transparent) 7px 8px);
}
body.theme-dark {
  background:
    radial-gradient(1000px 460px at 50% -160px, color-mix(in srgb, var(--primary) 26%, transparent), transparent 70%),
    var(--paper);
  background-repeat: no-repeat;
}
.theme-dark .card { background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 5%, var(--surface)), var(--surface)); }
.theme-dark .topbar, .theme-dark .admin-top { background: color-mix(in srgb, var(--paper) 82%, transparent); backdrop-filter: blur(12px); }
.theme-dark .footer, .theme-dark .sidebar { background: var(--paper); }
.theme-dark .announce { background: color-mix(in srgb, var(--primary) 18%, var(--paper)); color: var(--ink); border-bottom: 1px solid var(--rule); }
.theme-dark input, .theme-dark select, .theme-dark textarea, .theme-dark .stepper { background: color-mix(in srgb, var(--paper) 60%, var(--surface)); }

.theme-dark .btn-primary { box-shadow: var(--glow); }
.theme-dark .btn-primary:hover { background: color-mix(in srgb, var(--primary) 85%, white); }
.theme-dark .btn-danger { color: var(--paper); }
.theme-dark .pill, .theme-dark .chip, .theme-dark .badge, .theme-dark .status, .theme-dark .tag-accent { border-radius: 9999px; }
.theme-dark .pill.active { color: var(--paper); }
.theme-dark .nav > a.active, .theme-dark .nav-menu.active > summary { box-shadow: none; color: var(--ink); }
.theme-dark .side-nav a.active { box-shadow: inset 3px 0 0 var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--paper)); }

/* card faces become glowing glass cards instead of solid print */
.theme-dark .product-face {
  background: linear-gradient(155deg, color-mix(in srgb, var(--primary) 40%, var(--surface)), var(--surface) 72%);
  color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--rule));
}
.theme-dark .product-face::after { border-color: color-mix(in srgb, var(--primary) 22%, transparent); }
.theme-dark .hero-stack .stack-back { background: color-mix(in srgb, var(--primary) 22%, var(--surface)); }
.theme-dark .hero-stack .face-initial.big { opacity: 0.12; }
.theme-dark .face-out { background: rgba(18, 10, 18, 0.86); color: var(--ink); }
.theme-dark .product-card:hover .product-face { box-shadow: var(--face-shadow), var(--glow); }

/* things that must stay light to work: QR codes, the silver scratch foil, slips */
.theme-dark .qr-box { color: #1B2433; }
.theme-dark .qr-box .muted { color: #5E6878; }
.theme-dark .scratch-cover { color: #1B2433; }
.theme-dark .hero-stack .face-name, .theme-dark .face-issuer { color: var(--ink); }

/* PromptPay (InwCloud) payment page */
.charge-waiting { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 0 0 16px; }
.spinner { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2px solid var(--rule-strong); border-top-color: var(--primary); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-top-color: var(--rule-strong); } }
.charge-paid h2 { color: var(--ok); }
.charge-state > p { max-width: 60ch; }
.charge-state .btn + .btn { margin-left: 8px; }
.quick-amounts .pill { cursor: pointer; font: inherit; font-size: var(--t-sm); }

/* InwCloud LINE connection countdown */
.token-card { border-left-width: 4px; }
.token-card.token-ok { border-left-color: var(--ok); }
.token-card.token-soon { border-left-color: var(--warn); }
.token-card.token-expired, .token-card.token-unknown { border-left-color: var(--danger); }
.token-left { font-family: var(--font-display); font-size: var(--t-xl); font-weight: 700; line-height: 1.3; margin-bottom: 4px; }
.token-ok .token-left { color: var(--ok); }
.token-soon .token-left { color: var(--warn); }
.token-expired .token-left, .token-unknown .token-left { color: var(--danger); }

/* QR logo editor */
.qr-logo-editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.qr-logo-preview { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.qr-logo-preview .qr-code svg { width: 240px; height: 240px; }
.qr-logo-fields input[type="range"] { padding: 0; }
@media (max-width: 960px) { .qr-logo-editor { grid-template-columns: 1fr; } }

/* PromptPay payment page */
.pay-shell { margin-top: 8px; }
.pay-panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-panel); padding: 24px; }
.pay { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 0; background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r-panel); overflow: hidden; }
.pay-qr { justify-content: center; background: #fff; color: #1B2433; padding: 24px 20px 18px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; border-right: 2px dashed var(--rule-strong); position: relative; }
.pay-qr-title { margin: 0; font-weight: 700; font-size: var(--t-md, 1.05rem); }
.pay-qr-foot { margin: 0; color: #5E6878; font-size: var(--t-sm); }
.pay-frame { position: relative; padding: 14px; }
.pay-frame::before, .pay-frame::after { content: ""; position: absolute; width: 28px; height: 28px; border: 0 solid var(--primary); }
.pay-frame::before { top: 0; left: 0; border-width: 4px 0 0 4px; border-top-left-radius: 8px; }
.pay-frame::after { right: 0; bottom: 0; border-width: 0 4px 4px 0; border-bottom-right-radius: 8px; }
.pay-frame .qr-code svg { width: 240px; height: 240px; display: block; max-width: 100%; }
.pay-info { padding: 28px 32px; display: flex; flex-direction: column; gap: 16px; }
.pay-total-box { border-left: 4px solid var(--accent); padding-left: 16px; }
.pay-label { margin: 0; color: var(--muted); font-size: var(--t-sm); }
.pay-total { margin: 2px 0; font-family: var(--font-display); font-size: clamp(2.4rem, 6vw, 3.4rem); font-weight: 700; line-height: 1.1; }
.pay-credit { margin: 0; color: var(--muted); }
.pay-credit strong { color: var(--ink); }
.pay-note { margin: 0; padding: 10px 14px; border-radius: var(--r-panel); background: color-mix(in srgb, var(--accent) 16%, transparent); font-size: var(--t-sm); }
.pay-steps { list-style: none; counter-reset: s; margin: 0; padding: 0; display: grid; gap: 10px; }
.pay-steps li { counter-increment: s; display: flex; gap: 12px; align-items: center; }
.pay-steps li::before { content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: var(--t-sm); }
.pay-info .charge-waiting { margin: 0; padding: 10px 14px; border: 1px solid var(--rule); border-radius: var(--r-panel); }
.pay-info form { margin: 0; }
@media (max-width: 720px) {
  .pay { grid-template-columns: 1fr; }
  .pay-qr { border-right: 0; border-bottom: 2px dashed var(--rule-strong); }
  .pay-info { padding: 20px; }
}
.pay-payee { margin: 0; display: flex; flex-wrap: wrap; gap: 8px 32px; }
.pay-payee dt { color: var(--muted); font-size: var(--t-sm); }
.pay-payee dd { margin: 0; font-weight: 700; }
.delete-form { margin-top: 12px; }

/* themed confirm / alert dialog */
.app-dialog { width: min(440px, calc(100% - 32px)); padding: 24px; margin: auto; color: var(--ink); background: var(--surface); border: 1px solid var(--rule-strong); border-top: 4px solid var(--primary); border-radius: var(--r-panel); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35); }
.app-dialog.is-danger { border-top-color: var(--danger); }
.app-dialog::backdrop { background: rgba(10, 8, 16, 0.6); backdrop-filter: blur(2px); }
.app-dialog-title { margin: 0 0 8px; font-family: var(--font-display); font-size: var(--t-lg); line-height: 1.3; }
.app-dialog-text { margin: 0 0 20px; color: var(--muted); line-height: 1.6; }
.app-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.app-dialog[open] { animation: dialog-in 0.16s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } }
@media (prefers-reduced-motion: reduce) { .app-dialog[open] { animation: none; } }
.app-dialog.is-form { width: min(520px, calc(100% - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; }
.app-dialog.is-form .field { margin-bottom: 14px; }
.app-dialog.is-form .check { margin-bottom: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.btn-icon { width: 44px; height: 44px; padding: 0; font-size: 1.6rem; line-height: 1; display: inline-grid; place-items: center; border-radius: 50%; }

/* file picker: dashed drop area with a pill button */
input[type="file"] { padding: 12px 14px; cursor: pointer; color: var(--muted); border: 2px dashed var(--rule-strong); background: color-mix(in srgb, var(--primary) 5%, var(--paper)); transition: border-color 0.15s ease, background-color 0.15s ease; }
input[type="file"]:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--paper)); }
input[type="file"]::file-selector-button { margin-right: 14px; padding: 8px 18px; border: 0; border-radius: 9999px; background: var(--primary); color: var(--on-primary); font: inherit; font-weight: 600; cursor: pointer; transition: filter 0.15s ease; }
input[type="file"]::file-selector-button:hover { filter: brightness(1.08); }
.supply-card h2 { display: flex; align-items: center; gap: 10px; }
.supply-card.is-refunded h2 { color: var(--ok); }

/* Claims chat */
.presence { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-sm); color: var(--muted); }
.presence-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--rule-strong); display: inline-block; }
.stack .h4 { margin: 16px 0 8px; }
.is-online .presence-dot { background: var(--ok); }
.presence-bar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; font-size: var(--t-sm); background: var(--paper); color: var(--muted); border-bottom: 1px solid var(--rule); }
.presence-bar.is-online { color: var(--ok); }
.claim-list { display: grid; gap: 12px; }
.claim-row { display: grid; gap: 6px; color: inherit; text-decoration: none; }
.claim-row:hover { border-color: var(--primary); }
.claim-row-head, .claim-row-foot, .chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.claim-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.claim-chip { display: inline-flex; padding: 2px 10px; border-radius: var(--r-panel); font-size: var(--t-xs); font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.claim-chip-open { color: var(--primary); }
.claim-chip-investigating { color: var(--warn); }
.claim-chip-fixed { color: var(--ok); }
.claim-chip-closed { color: var(--muted); }
.chat { padding: 0; overflow: hidden; }
.chat-head { padding: 14px 16px; border-bottom: 1px solid var(--rule); }
.chat-log { display: flex; flex-direction: column; gap: 8px; padding: 16px; min-height: 240px; max-height: 60vh; overflow-y: auto; background: var(--paper); }
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--rule); align-self: flex-start; overflow-wrap: anywhere; }
.bubble-mine { align-self: flex-end; background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.bubble-system { align-self: center; max-width: 92%; background: transparent; border-style: dashed; color: var(--muted); font-size: var(--t-sm); text-align: center; }
.bubble-text { white-space: pre-wrap; }
.bubble-img { display: block; max-width: 100%; max-height: 260px; margin-top: 6px; border-radius: 8px; }
.bubble-time { font-size: var(--t-xs); opacity: 0.65; margin-top: 2px; }
.chat-form { display: grid; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--rule); background: var(--surface); }
.chat-form textarea { width: 100%; resize: vertical; }
.chat-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chat-closed { padding: 14px 16px; margin: 0; border-top: 1px solid var(--rule); }
.claim-card { margin-top: 16px; }

/* Floating chat button */
.chat-fab { position: fixed; right: 18px; bottom: 18px; z-index: 40; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28); text-decoration: none; }
.chat-fab:hover { filter: brightness(1.08); }
.chat-fab:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.chat-fab-dot { position: absolute; right: 2px; top: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--rule-strong); border: 2px solid var(--surface); }
.chat-fab-dot.is-online { background: var(--ok); }
.chat-fab-badge { position: absolute; left: -6px; top: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--danger); color: #fff; font-size: var(--t-xs); font-weight: 700; display: grid; place-items: center; }
.chat-fab[hidden], .chat-fab-badge[hidden] { display: none; }
@media (max-width: 640px) { .chat-fab { bottom: 14px; right: 14px; } .chat-log { max-height: 55vh; } .bubble { max-width: 88%; } }

/* Back office: one card per supplier shop */
.supplier-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; }
.admin-content .supplier-card { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.supplier-card.is-off { opacity: 0.7; }
.supplier-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--t-lg, 1.1rem); }
.supplier-balance { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--r-panel); background: var(--surface); }
.supplier-balance > strong { font-size: 1.6rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.supplier-balance > .balance-none { font-size: 1rem; font-weight: 500; color: var(--muted, inherit); }
.supplier-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0; }
.supplier-facts dt { font-size: var(--t-xs); opacity: 0.7; }
.supplier-facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.supplier-url { overflow-wrap: anywhere; }
.supplier-actions { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Product page: what the buyer must type first (a game ID, an e-mail) */
.buyer-input { display: grid; gap: 10px; padding: 12px 14px; margin: 4px 0 12px; border: 1px solid var(--rule); border-radius: var(--r-panel); background: var(--surface); }
.buyer-input .field { margin: 0; }
.buyer-input p { margin: 0; }

/* Back office: search box above a long list */
.search-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; }
.search-form input[type="search"] { flex: 1 1 220px; min-width: 0; }

/* Back office: import several items as one product, or add an item to an existing product */
.group-import { margin: 0 0 12px; padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--r-panel); background: var(--surface); }
.group-import p { margin: 0 0 8px; }
.group-import .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.group-import input[type="text"] { flex: 1 1 220px; min-width: 0; }
.add-to { margin-top: 6px; }
.add-to summary { cursor: pointer; list-style: none; }
.add-to summary::-webkit-details-marker { display: none; }
.add-to form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.add-to select { max-width: 220px; }

/* Cloudflare Turnstile widget on sign-in and sign-up */
.human-check { display: flex; justify-content: center; margin: 4px 0 12px; min-height: 65px; }

/* Navbar: the tools menu sits among the links, so it has no outline of its own */
.nav-menu .menu-list { left: 0; right: auto; min-width: 260px; padding: 8px; gap: 2px; border-radius: var(--r-face); border-color: var(--rule-strong); box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.55); animation: menu-in .12s ease-out; }
.nav-menu .menu-list a { display: grid; gap: 1px; padding: 10px 12px; border-radius: var(--r-btn); }
.nav-menu .menu-list a strong { font-weight: 600; }
.nav-menu .menu-list a small { color: var(--muted); font-size: var(--t-xs); line-height: 1.4; }
.nav-menu .menu-list a:hover { background: color-mix(in srgb, var(--primary) 14%, transparent); }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .nav-menu .menu-list { animation: none; } .menu summary::after { transition: none; } }

/* The image tool */
.upload-form { display: grid; gap: 12px; margin: 0 0 16px; }
.upload-form p { margin: 0; }
.upload-row { display: flex; gap: 14px; align-items: flex-start; margin: 0 0 12px; }
.upload-preview { display: grid; gap: 10px; }
.upload-preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.upload-preview-list { display: flex; flex-wrap: wrap; gap: 10px; }
.upload-preview-remove { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0; }
.upload-preview-remove:hover, .upload-preview-remove:focus-visible { background: var(--danger, #e5484d); }
.upload-preview[hidden] { display: none; }
.upload-preview-item { position: relative; margin: 0; width: 120px; display: grid; gap: 4px; }
.upload-preview-item img { width: 120px; height: 120px; object-fit: cover; border-radius: var(--r-panel); background: var(--surface); }
.upload-preview-item figcaption { font-size: var(--t-xs); color: var(--muted); overflow-wrap: anywhere; }
.upload-preview-item.too-big figcaption { color: var(--danger, #e5484d); }
.upload-thumb { width: 96px; height: 96px; object-fit: cover; border-radius: var(--r-panel); background: var(--surface); flex: none; }
.upload-info { flex: 1; min-width: 0; }
.upload-info .key-row { margin: 0 0 6px; }
.upload-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.upload-meta p { margin: 0; }
.upload-meta form { margin: 0; }
.btn-danger-text { color: var(--danger); }
.upload-info .key { overflow-wrap: anywhere; }
.upload-info p { margin: 0; }
