:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --ink: #0f1b2b;
  --muted: #5a6878;
  --line: #d8dee6;
  --accent: #ffc300;          /* yellow: buttons and highlights */
  --accent-ink: #1a1300;      /* text on yellow */
  --accent-soft: #fff3c4;
  --link: #0f1b2b;            /* links and text-style buttons */
  --wait-ink: #6b4f00;
  --stub: #ffc300;
  --stub-ink: #3a2900;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #2c6a1d;
  --ok-soft: #e7f2e2;
  --focus: #0f1b2b;
  /* header */
  --header-bg: linear-gradient(100deg, #ffffff 0%, #f1f7ff 45%, #d8eaff 100%);
  --header-ink: #0f1b2b;
  --header-muted: #4d5f73;
  --header-line: #0f1b2b;
  --header-edge: #d8e3f0;
  --header-button-border: rgb(15 27 43 / 0.25);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", sans-serif;
}

/* Dark mode: chosen with the switch, or the device setting when nothing was chosen. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c121b;
  --surface: #141d29;
  --ink: #e8eef5;
  --muted: #9fb0c2;
  --line: #263344;
  --accent: #ffc300;
  --accent-ink: #1a1300;
  --accent-soft: #3a2f08;
  --link: #ffd34d;
  --wait-ink: #ffd34d;
  --stub: #ffc300;
  --stub-ink: #3a2900;
  --danger: #ff8f84;
  --danger-soft: #3a1714;
  --ok: #92d47c;
  --ok-soft: #1b3315;
  --focus: #ffc300;
  --header-bg: linear-gradient(100deg, #0a1220 0%, #0f2440 50%, #133c6b 100%);
  --header-ink: #ffffff;
  --header-muted: #b4c3d4;
  --header-line: #ffffff;
  --header-edge: transparent;
  --header-button-border: rgb(255 255 255 / 0.35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  color-scheme: dark;
  --bg: #0c121b;
  --surface: #141d29;
  --ink: #e8eef5;
  --muted: #9fb0c2;
  --line: #263344;
  --accent: #ffc300;
  --accent-ink: #1a1300;
  --accent-soft: #3a2f08;
  --link: #ffd34d;
  --wait-ink: #ffd34d;
  --stub: #ffc300;
  --stub-ink: #3a2900;
  --danger: #ff8f84;
  --danger-soft: #3a1714;
  --ok: #92d47c;
  --ok-soft: #1b3315;
  --focus: #ffc300;
  --header-bg: linear-gradient(100deg, #0a1220 0%, #0f2440 50%, #133c6b 100%);
  --header-ink: #ffffff;
  --header-muted: #b4c3d4;
  --header-line: #ffffff;
  --header-edge: transparent;
  --header-button-border: rgb(255 255 255 / 0.35);
  }
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

h1, h2 { line-height: 1.2; margin: 0 0 0.5rem; }
h1 { font-size: 1.75rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.125rem; font-weight: 600; }
p { margin: 0 0 1rem; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.lead { color: var(--muted); max-width: 60ch; margin-bottom: 1.75rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---------- Buttons and inputs ---------- */

button {
  font: inherit;
  font-weight: 550;
  border-radius: var(--radius);
  padding: 0.65rem 1.1rem;
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 44px;
}
button:disabled { opacity: 0.6; cursor: progress; }
button.primary { background: var(--accent); color: var(--accent-ink); }
button.danger { background: var(--danger); color: var(--surface); }
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.ghost:hover { border-color: var(--muted); }
button.wide { width: 100%; }
button.link { background: none; border: 0; padding: 0.25rem 0.5rem; min-height: 0; color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
button.link.danger-text { color: var(--danger); }

.field { margin-bottom: 1rem; }
label { display: block; font-weight: 550; margin-bottom: 0.35rem; }
.hint { color: var(--muted); font-size: 0.875rem; margin: 0 0 0.35rem; }

input, select, textarea {
  font: inherit;
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.password-row { display: flex; gap: 0.5rem; }
.password-row input { flex: 1; }

.field-error { display: none; color: var(--danger); font-size: 0.875rem; margin: 0.35rem 0 0; }
.field-error span { display: inline-grid; place-items: center; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: var(--danger); color: var(--surface); font-size: 0.75rem; font-weight: 700; margin-right: 0.25rem; }

:is(input, select):user-invalid { border-color: var(--danger); background: var(--danger-soft); }
.field:has(:user-invalid) .field-error { display: block; }
.field:has(:user-invalid) .hint { color: var(--danger); }

.form-message { padding: 0.75rem 1rem; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); }
.form-message.success { background: var(--ok-soft); color: var(--ok); }
.form-problems { color: var(--danger); margin: 0 0 1rem; padding-left: 1.25rem; }

/* ---------- Sign-in screens ---------- */

.center-screen { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 2rem 1.75rem;
}
.auth-card h1 { font-size: 1.5rem; }
.auth-card form > .wide + .wide { margin-top: 0.5rem; }
.auth-card .small { margin: 1rem 0 0; }

/* ---------- App layout ---------- */

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1; }
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 0.5rem 1.25rem;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
.brand { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.tabs { display: flex; gap: 0.25rem; flex: 1; flex-wrap: wrap; }
.tabs a {
  color: var(--muted); text-decoration: none; font-weight: 550;
  padding: 0.6rem 0.85rem; border-radius: var(--radius);
}
.tabs a[aria-current="page"] { color: var(--ink); }
.whoami { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); }

.page { max-width: 1080px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.page section + section { margin-top: 2.25rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.25rem 1.25rem 0.25rem; }

.inline-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; align-items: start; }
.inline-form > button { margin-top: 1.85rem; margin-bottom: 1rem; }

/* ---------- Ticket stub: the registration code ---------- */

.ticket {
  display: grid;
  grid-template-columns: auto 1fr;
  margin: 0.5rem 0 1.25rem;
  background: var(--stub);
  color: var(--stub-ink);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
}
.ticket-qr {
  padding: 1rem;
  display: grid;
  place-items: center;
  border-right: 2px dashed var(--stub-ink);
}
.ticket-qr svg { width: 168px; height: 168px; display: block; background: #ffffff; border-radius: 8px; padding: 6px; }
.ticket-body { padding: 1.25rem 1.5rem; }
.ticket-for { margin-bottom: 0.25rem; }
.ticket-code {
  font-size: clamp(2rem, 6vw, 3.25rem);
  font-weight: 750;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin-bottom: 0.75rem;
}
.ticket-url { font-weight: 650; overflow-wrap: anywhere; }
.ticket-expiry { font-weight: 600; }
.ticket-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.ticket-actions button.ghost { color: var(--stub-ink); border-color: var(--stub-ink); }
/* Perforation notches where a ticket would tear */
.ticket::before, .ticket::after {
  content: "";
  position: absolute;
  left: calc(168px + 2rem - 11px);
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--surface);
}
.ticket::before { top: -11px; }
.ticket::after { bottom: -11px; }

@media (max-width: 560px) {
  .ticket { grid-template-columns: 1fr; }
  .ticket-qr { border-right: 0; border-bottom: 2px dashed var(--stub-ink); }
  .ticket::before, .ticket::after { display: none; }
}

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); position: relative; /* keeps hidden screen-reader text inside the scroll area */ }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
td { overflow-wrap: normal; }
th:first-child, td:first-child { padding-left: 1rem; }
th { font-size: 0.875rem; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; padding-right: 1rem; }
td .status { white-space: nowrap; }

.status { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.8125rem; font-weight: 600; }
.status.on { background: var(--ok-soft); color: var(--ok); }
.status.off { background: var(--danger-soft); color: var(--danger); }
.status.wait { background: var(--accent-soft); color: var(--wait-ink); }

.empty { color: var(--muted); padding: 1rem 0; }

/* ---------- Holidays ---------- */

.holiday-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.holiday { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.25rem; }
.holiday h2 { margin-bottom: 0.15rem; }
.holiday .code { color: var(--muted); font-size: 0.875rem; margin-bottom: 1rem; }
.stock { display: flex; align-items: baseline; gap: 0.4rem; margin-bottom: 0.5rem; }
.stock strong { font-size: 2rem; font-variant-numeric: tabular-nums; line-height: 1; }
.meter { height: 8px; background: var(--accent-soft); border-radius: 999px; overflow: hidden; margin-bottom: 0.75rem; }
.meter > span { display: block; height: 100%; background: var(--accent); }

/* ---------- Dialogs ---------- */

dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.5rem;
  max-width: min(440px, calc(100vw - 2rem));
  background: var(--surface);
  color: var(--ink);
}
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop { background: rgb(0 0 0 / 0.45); overflow: hidden; overscroll-behavior: contain; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }
.secret {
  font-size: 1.75rem; font-weight: 700; letter-spacing: 0.04em;
  background: var(--accent-soft); border-radius: var(--radius);
  padding: 0.75rem 1rem; text-align: center; overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .topbar-inner { gap: 0.5rem 1rem; }
  .tabs { order: 3; flex-basis: 100%; }
  h1 { font-size: 1.5rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .ticket:not([hidden]) { animation: tear-in 220ms ease-out; }
  @keyframes tear-in { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* Links styled as buttons (home page) */
.button-link {
  display: block; text-align: center; text-decoration: none; font-weight: 550;
  border-radius: var(--radius); padding: 0.7rem 1.1rem; border: 1px solid transparent;
}
.button-link.primary { background: var(--accent); color: var(--accent-ink); }
.button-link.ghost { color: var(--ink); border-color: var(--line); }

.role-hint { margin: 0.35rem 0 0; }

/* ---------- Voucher design editor ---------- */

@font-face { font-family: "VE Sans Bold"; src: url("/fonts/LiberationSans-Bold.ttf") format("truetype"); font-display: block; }
@font-face { font-family: "VE Sans"; src: url("/fonts/LiberationSans-Regular.ttf") format("truetype"); font-display: block; }
@font-face { font-family: "VE Serif Bold"; src: url("/fonts/LiberationSerif-Bold.ttf") format("truetype"); font-display: block; }

.back { margin-bottom: 0.75rem; }
.back a { color: var(--link); }
.editor-head { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.editor-head p { margin: 0; }

.editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.5rem; align-items: start; }
@media (max-width: 960px) { .editor { grid-template-columns: 1fr; } }

.stage-wrap { position: sticky; top: 4.5rem; }
@media (max-width: 960px) { .stage-wrap { position: static; } }

.stage {
  position: relative;
  width: 100%;
  border-radius: 10px;
  overflow: visible; /* handles and labels stay visible on boxes at the artwork's edge */
  background: var(--line);
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  margin-bottom: 0.5rem;
}
.stage img { display: block; width: 100%; height: auto; pointer-events: none; border-radius: 10px; }

.box {
  position: absolute;
  outline: 2px dashed #ffc300;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.55);
  outline-offset: 0;
  cursor: grab;
  display: flex;
  align-items: center;
  overflow: visible;
}
.box:focus-visible { outline: 3px solid var(--focus); }
.box.selected { outline: 2px solid #ffc300; background: rgb(255 195 0 / 0.12); }
.box-text { display: block; width: 100%; white-space: nowrap; line-height: 1; overflow: visible; }
.box-tag {
  position: absolute; left: 0; top: 0; transform: translateY(-100%);
  background: #ffc300; color: #1a1300; font-size: 11px; font-weight: 700;
  padding: 1px 6px; border-radius: 4px 4px 0 0; white-space: nowrap; pointer-events: none;
}
.box:not(.selected) .box-tag { opacity: 0.75; }
.handle {
  position: absolute; right: -11px; bottom: -11px; width: 22px; height: 22px; z-index: 2;
  background: #ffffff; border: 2px solid #1a1300; border-radius: 50%; cursor: nwse-resize;
}
.qr-art { display: block; width: 100%; height: 100%; }
.qr-art svg { display: block; width: 100%; height: 100%; }

.editor-side { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.25rem; }
.editor-side hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }
.seg { border: 0; padding: 0; margin: 0 0 1.25rem; display: grid; gap: 0.35rem; }
.seg legend { font-weight: 600; margin-bottom: 0.4rem; padding: 0; }
.seg label {
  display: flex; align-items: center; gap: 0.6rem; margin: 0;
  padding: 0.55rem 0.75rem; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; font-weight: 500;
}
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.seg input { width: auto; min-height: 0; accent-color: var(--accent); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
input[type="color"] { padding: 0.25rem; height: 44px; cursor: pointer; }
input[type="file"] { padding: 0.5rem; }
.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.check input { width: auto; min-height: 0; accent-color: var(--accent); }
.editor-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 0.5rem; }

.versions { margin-top: 2.5rem; }
.version-list { list-style: none; padding: 0; margin: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.version-list li { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.version-list li:last-child { border-bottom: 0; }
.version-list .v-name { font-weight: 600; min-width: 6.5rem; }
.version-list .v-meta { color: var(--muted); flex: 1; }

.holiday .open-design { margin-top: 0.25rem; }

.stage:active .box.selected { cursor: grabbing; }

textarea { resize: vertical; line-height: 1.5; }
.prize-details { margin-top: 2rem; padding-bottom: 1.25rem; }
.prize-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1rem; }
.prize-details .check { margin: 0.25rem 0 1rem; }
.status.hidden-prize { background: var(--line); color: var(--ink); } /* readable contrast in both themes */

/* ---------- Reports ---------- */

.report-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 1rem; align-items: end; padding-bottom: 0.25rem; }
.report-buttons { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.report-buttons button { flex: 1; }
#report-out { margin-top: 1.75rem; }
.report-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.25rem; }
.report-head h2 { margin: 0; font-size: 1.25rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; margin: 1rem 0 2rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1rem 1.1rem; }
.stat strong { display: block; font-size: 2rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 0.9rem; }
.stat.alert { border-color: var(--danger); background: var(--danger-soft); }
.stat.alert strong, .stat.alert span { color: var(--danger); }
.report-section { margin-bottom: 2rem; }
.report-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 1.5rem; align-items: start; }
.page .report-columns > section { margin-top: 0; }
.report-buttons button { white-space: nowrap; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
.unsent-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.unsent-list:empty { display: none; }
.unsent-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem 1rem; align-items: center; padding: 0.75rem 1rem; }
.unsent-list li + li { border-top: 1px solid var(--line); }
.unsent-who { font-weight: 600; }
.unsent-meta { color: var(--muted); font-size: 0.875rem; }
.unsent-actions { display: flex; gap: 0.5rem; grid-row: 1 / span 2; grid-column: 2; }
.unsent-actions .wa { background: #1f7a4d; color: #ffffff; padding: 0.55rem 0.9rem; border-radius: var(--radius); text-decoration: none; font-weight: 600; white-space: nowrap; }
@media (max-width: 600px) { .unsent-list li { grid-template-columns: 1fr; } .unsent-actions { grid-row: auto; grid-column: 1; } }

/* ---------- Redeem ---------- */

.redeem-search { padding-bottom: 1.25rem; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem; }
.search-row input { font-size: 1.125rem; }
.redeem-results { display: grid; gap: 1rem; margin-top: 1.25rem; }
.vcard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.25rem; }
.vcard-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.vcard-prize { font-weight: 650; margin: 0; }
.vcard-serial { font-size: 1.5rem; font-weight: 750; letter-spacing: 0.03em; font-variant-numeric: tabular-nums; margin: 0.15rem 0 0.75rem; overflow-wrap: anywhere; }
.vcard dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.35rem 1rem; margin: 0 0 1rem; }
.vcard dt { color: var(--muted); }
.vcard dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.vcard-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.vcard-actions .wa { background: #1f7a4d; color: #ffffff; padding: 0.65rem 1rem; border-radius: var(--radius); text-decoration: none; font-weight: 600; }
.status.redeemed, .status.cancelled { background: var(--danger-soft); color: var(--danger); }
.status.valid { background: var(--ok-soft); color: var(--ok); }
.status.expired { background: color-mix(in srgb, var(--stub) 35%, var(--surface)); color: var(--stub-ink); }
.big-status { font-size: 0.95rem; padding: 0.3rem 0.8rem; }
#action-dialog { width: min(480px, calc(100vw - 2rem)); }

/* ---------- Header: TokiDip at the far left; the client (tenant) beside the signed-in user ---------- */

.topbar { background: var(--header-bg); border-bottom: 1px solid var(--header-edge); color: var(--header-ink); }
.topbar-inner { max-width: none; padding: 0.55rem 1.5rem; gap: 0.75rem 2rem; }
.brand-lockup { display: flex; align-items: center; gap: 0.9rem; text-decoration: none; color: var(--header-ink); margin: 0; }
.brand-lockup img { height: 26px; width: auto; display: block; }
.brand-lockup .product-logo { height: 52px; width: auto; margin: -4px 0; } /* slightly taller than the bar's text line */

/* The client using this copy of TokiDip (name and logos come from the server settings) */
.client-label { display: inline-flex; align-items: center; }
.client-label img { height: 24px; width: auto; max-width: 170px; object-fit: contain; display: block; }
.client-label .client-name { font-weight: 650; color: var(--header-ink); white-space: nowrap; }
.topbar .client-label { padding-right: 0.9rem; margin-right: 0.1rem; border-right: 1px solid var(--header-button-border); }
.client-row { margin: -0.25rem 0 1.1rem; }
.client-row .client-name { color: var(--ink); }
@media (max-width: 560px) {
  .brand-lockup img { height: 20px; }
  .brand-lockup .product-logo { height: 40px; }
}

/* Right logo for the mode: blue on light, white on dark */
.logo-on-dark { display: none !important; }
:root[data-theme="dark"] .logo-on-light { display: none !important; }
:root[data-theme="dark"] .logo-on-dark { display: block !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-on-light { display: none !important; }
  :root:not([data-theme="light"]) .logo-on-dark { display: block !important; }
}

/* Menu: its own bar below the header; plain text with a line under the page you're on */
.topbar-inner { justify-content: space-between; }
.subnav { background: var(--surface); border-bottom: 1px solid var(--line); }
.subnav .tabs {
  display: flex; gap: 1.75rem; padding: 0 1.5rem; margin: 0;
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
}
.subnav .tabs::-webkit-scrollbar { display: none; }
.subnav .tabs a {
  color: var(--muted); background: none; border-radius: 0; white-space: nowrap;
  padding: 0.8rem 0 0.65rem; border-bottom: 3px solid transparent; font-weight: 550;
}
.subnav .tabs a:hover { color: var(--ink); }
.subnav .tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 650; }
.topbar .whoami { color: var(--header-muted); }
.topbar button.ghost { color: var(--header-ink); border-color: var(--header-button-border); background: transparent; }
.topbar button.ghost:hover { border-color: var(--header-ink); }
.topbar :focus-visible { outline-color: var(--header-ink); }

/* Light / dark switch */
.theme-toggle {
  display: inline-grid; place-items: center; width: 44px; height: 44px; min-height: 0; padding: 0;
  border-radius: 50%; background: transparent; color: var(--header-ink); border: 1px solid var(--header-button-border);
}
.theme-toggle:hover { border-color: var(--header-ink); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle[data-mode="dark"] .icon-sun { display: block; }
.theme-toggle[data-mode="dark"] .icon-moon { display: none; }

/* Sign-in and other single cards: the same header across the top of the card */
.brand-band {
  background: var(--header-bg); border-bottom: 1px solid var(--header-edge); color: var(--header-ink);
  margin: -2rem -1.75rem 1.5rem; padding: 1.1rem 1.25rem 1.1rem 1.75rem; border-radius: 15px 15px 0 0;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand-band .brand-lockup { min-width: 0; gap: 0.7rem; }
.brand-band .brand-lockup img { height: 20px; }
.brand-band .brand-lockup .product-logo { height: 44px; margin: -4px 0; }
.brand-band .theme-toggle { flex: none; width: 38px; height: 38px; }
@media (max-width: 420px) {
  .brand-band { padding: 0.9rem 0.9rem 0.9rem 1.1rem; margin-left: -1.75rem; margin-right: -1.75rem; gap: 0.5rem; }
  .brand-band .brand-lockup { gap: 0.5rem; }
  .brand-band .brand-lockup img { height: 15px; }
  .brand-band .brand-lockup .product-logo { height: 36px; }
  .brand-band .theme-toggle { width: 38px; height: 38px; }
  .auth-card { padding-left: 1.25rem; padding-right: 1.25rem; }
  .auth-card .brand-band { margin-left: -1.25rem; margin-right: -1.25rem; }
}

/* ---------- Redeem codes ---------- */

.codes-panel { margin-top: 2rem; padding-bottom: 1.25rem; }
.code-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.75rem; margin: 0.75rem 0 1.25rem; }
.code-stat { border: 1px solid var(--line); border-radius: 12px; padding: 0.75rem 0.9rem; }
.code-stat strong { display: block; font-size: 1.75rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.code-stat span { color: var(--muted); font-size: 0.875rem; }
.code-stat.main { background: var(--accent-soft); border-color: transparent; }
.code-stat.alert { background: var(--danger-soft); border-color: transparent; }
.code-stat.alert strong, .code-stat.alert span { color: var(--danger); }
.code-upload a { color: var(--link); }
.codes-history { margin-top: 0.5rem; }
.holiday .codes-line { display: flex; align-items: baseline; gap: 0.4rem; margin-bottom: 0.5rem; }
.holiday .codes-line strong { font-size: 2rem; font-variant-numeric: tabular-nums; line-height: 1; }
.holiday .codes-sub { color: var(--muted); font-size: 0.875rem; margin-bottom: 0.75rem; }
.holiday .codes-empty { color: var(--danger); font-weight: 600; }
.terms-box .box-text { white-space: normal; line-height: 1.28; align-self: flex-start; overflow: visible; }
.terms-box { align-items: flex-start; }

/* ---------- Counter tab ---------- */

.page-wide { max-width: 1320px; }
.counter-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem 2rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.counter-head h1 { margin-bottom: 0.15rem; }
.counter-head p { margin: 0; }
.today-stats { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.today-stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0.55rem 1rem; min-width: 7.5rem; }
.today-stat strong { display: block; font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.today-stat span { color: var(--muted); font-size: 0.85rem; }
#tab-counter .counter-layout { padding: 0; max-width: none; }
#tab-counter .register { top: 8.5rem; }
#tab-counter .counter-layout > section { margin-top: 0; }

@media (max-width: 560px) {
  .topbar .client-label img { height: 18px; max-width: 120px; }
  /* phones: the client sits above the user's name, with the switch and Sign out beside them */
  .topbar .whoami { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; column-gap: 0.6rem; row-gap: 0.15rem; align-items: center; }
  .topbar .whoami .client-label { grid-column: 1; grid-row: 1; border-right: 0; padding-right: 0; }
  .topbar #whoami-name { grid-column: 1; grid-row: 2; font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .whoami .theme-toggle { grid-column: 2; grid-row: 1 / span 2; }
  .topbar .whoami .js-signout { grid-column: 3; grid-row: 1 / span 2; white-space: nowrap; }
}

/* ---------- Services ---------- */

.services-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.services-head .lead { margin-bottom: 1rem; }
.services-head > button { flex: none; margin-top: 0.4rem; }
.holiday .svc-mode { margin: 0.15rem 0; font-size: 0.875rem; color: var(--muted); overflow-wrap: anywhere; }
.holiday .svc-left, .type-list .svc-left { margin: 0.15rem 0 0.4rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.svc-left.warn { color: var(--danger); }
.card-types { list-style: none; margin: 0.5rem 0; padding: 0; display: grid; gap: 0.5rem; }
.card-types li { border: 1px solid var(--line); border-radius: 10px; padding: 0.55rem 0.7rem; }
.card-types a, .type-list a { font-weight: 650; color: var(--link); }
.card-types .svc-mode, .type-list .svc-mode { margin: 0.1rem 0; font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.card-types .small, .type-list .small { margin: 0; }

.types-panel, .code-settings { margin: 0 0 1.5rem; }
.type-list { list-style: none; margin: 0.5rem 0 1rem; padding: 0; display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.type-list:empty { display: none; }
.type-list li { border: 1px solid var(--line); border-radius: 12px; padding: 0.75rem 0.9rem; background: var(--surface); }

.wide-seg { display: grid; gap: 0.5rem; }
.wide-seg label { display: flex; gap: 0.6rem; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.75rem; cursor: pointer; }
.wide-seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.wide-seg input { margin-top: 0.25rem; }
.code-settings form { max-width: 34rem; }

.design-heading { margin-top: 0.5rem; }
.optional-boxes { border: 0; padding: 0; margin: 0 0 1rem; }
.optional-boxes legend { font-weight: 550; margin-bottom: 0.3rem; padding: 0; }
.optional-boxes .check { margin: 0.2rem 0; }

.danger-zone { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.danger-zone p { margin: 0 0 0.5rem; }

#service-dialog { width: min(32rem, calc(100vw - 2rem)); }
#service-dialog h2 { margin-top: 0; }
#service-dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

/* Design area before any artwork is uploaded */
.stage.no-art { aspect-ratio: 4 / 5; max-width: 380px; border: 2px dashed var(--line-strong, var(--line)); border-radius: 14px;
  background: var(--surface); display: grid; place-items: center; }
.stage.no-art img, .stage.no-art .box { display: none !important; }
.stage.no-art::after { content: "Upload your artwork to start\A PNG or JPG, any shape (e.g. 1080 × 1350)"; white-space: pre-line;
  text-align: center; color: var(--muted); font-weight: 550; line-height: 1.5; padding: 1rem; }

/* Voucher images (a separate image per voucher) */
.image-pool { list-style: none; margin: 0.75rem 0 1rem; padding: 0; display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.image-pool:empty { display: none; }
.image-pool li { border: 1px solid var(--line); border-radius: 10px; padding: 0.45rem; background: var(--surface); text-align: center; }
.image-pool img { display: block; width: 100%; height: auto; border-radius: 6px; background: var(--line); }
.image-pool .pool-code { margin: 0.4rem 0 0.1rem; font-weight: 650; font-size: 0.85rem; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.image-pool .pool-status { margin: 0 0 0.2rem; font-size: 0.78rem; color: var(--muted); }
.image-pool .pool-status.on { color: var(--ok, var(--muted)); font-weight: 600; }

/* Exact position and size of the selected box */
.pos-fields { border: 0; padding: 0; margin: 0 0 1.25rem; }
.pos-fields legend { font-weight: 600; margin-bottom: 0.4rem; padding: 0; }
.pos-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem 0.75rem; }
.pos-grid label { font-size: 0.85rem; margin-bottom: 0.2rem; }
.pos-grid input { font-variant-numeric: tabular-nums; }
.scale-field { margin-top: 0.75rem; }
.scale-field label { display: flex; justify-content: space-between; }
.scale-field output { font-variant-numeric: tabular-nums; color: var(--muted); }
.scale-field input[type="range"] { width: 100%; height: 44px; accent-color: var(--accent); padding: 0; margin: 0; cursor: pointer; } /* 44px: easy to use with a finger */
.stage-wrap { padding: 0 12px 12px 0; } /* room for the corner handle at the right and bottom edges */

/* Delete dialog: "this was a test voucher" option */
#delete-dialog { width: min(32rem, calc(100vw - 2rem)); }
#delete-dialog h2 { margin-top: 0; }
.test-check { align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 0.8rem; margin: 0.75rem 0; font-weight: 400; cursor: pointer; }
.test-check input { margin-top: 0.2rem; flex: none; }
.test-check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.image-pool .pool-edit { display: grid; gap: 0.35rem; margin: 0.4rem 0 0.2rem; }
.image-pool .pool-edit input { font-size: 0.85rem; text-align: center; }
.image-pool .pool-error { display: none; font-size: 0.78rem; margin: 0; }
.image-pool .link { font-size: 0.82rem; }
