@font-face {
  font-family: "Nunito";
  src: url("/fonts/nunito-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  /* Set from the shop's settings by applyBrand() in api.js. */
  --brand: #8a5a2b;
  --on-brand: #ffffff;
  --bg: #f7f3ee;
  --surface: #ffffff;
  --text: #2a2119;
  --muted: #6b5f55;
  --border: #e6ddd3;
  --danger: #c9302c;
  --ok: #2e7d32;
  --radius: 18px;
  --shadow: 0 1px 3px rgba(60, 40, 20, 0.06), 0 8px 24px rgba(60, 40, 20, 0.08);
  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171412;
    --surface: #221e1b;
    --text: #f3ece6;
    --muted: #b0a59b;
    --border: #3a332e;
    --danger: #ff8a85;
    --ok: #7fd483;
    --shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 17px; line-height: 1.45; }
body { -webkit-tap-highlight-color: transparent; }
main { max-width: 480px; margin: 0 auto; padding: 20px 16px 40px; }
main.wide { max-width: 760px; }

h1 { font-size: 1.6rem; line-height: 1.2; margin: 0.4em 0 0.3em; }
h2 { font-size: 1.15rem; margin: 0 0 0.5em; }
p { margin: 0.5em 0; }
a { color: inherit; }

.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.center { text-align: center; justify-content: center; }
.error { color: var(--danger); }
.ok { color: var(--ok); }
.mt { margin-top: 16px; }
.hidden { display: none !important; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin: 16px 0; box-shadow: var(--shadow); }

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.row.end { justify-content: flex-end; }
.row > input { flex: 1 1 160px; }

button, .button {
  font: inherit; font-weight: 700; border: 0; border-radius: 999px; padding: 12px 20px; min-height: 48px;
  background: var(--brand); color: var(--on-brand); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
button:disabled { opacity: 0.5; cursor: default; }
button.secondary, .button.secondary { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
button.danger { background: var(--danger); color: #fff; }
button.link, a.link { background: none; color: inherit; padding: 4px 0; min-height: 0; font-weight: 600; text-decoration: underline; border: 0; border-radius: 0; display: inline-flex; align-items: center; gap: 8px; font-size: 1rem; }
button.big { width: 100%; font-size: 1.15rem; min-height: 60px; }

input, textarea, select {
  font: inherit; color: var(--text); background: var(--bg); border: 1.5px solid var(--border); border-radius: 12px; padding: 11px 14px; min-height: 48px; width: 100%;
}
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 60%, transparent); outline-offset: 2px; }
label { display: block; font-weight: 700; margin-top: 14px; }
label .muted { font-weight: 400; }
label input, label textarea { margin-top: 6px; }

footer { text-align: center; margin-top: 32px; font-size: 0.88rem; color: var(--muted); }

dialog { border: 0; border-radius: var(--radius); padding: 20px; max-width: min(420px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }

/* --- The loyalty card ---------------------------------------------------------------------- */

.loyalty-card {
  background: var(--brand); color: var(--on-brand); border-radius: 24px; padding: 22px 20px; box-shadow: var(--shadow);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 60%);
}
.loyalty-card .shop { font-size: 1.35rem; font-weight: 800; margin: 0; }
.loyalty-card .offer { opacity: 0.9; margin: 2px 0 0; }
.loyalty-card .count { font-weight: 800; margin-top: 14px; }

.stamps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 12px; }
.stamp {
  aspect-ratio: 1; border-radius: 50%; border: 2px dashed color-mix(in srgb, var(--on-brand) 55%, transparent); display: grid; place-items: center;
}
.stamp svg { width: 62%; height: 62%; }
.stamp.filled { background: var(--on-brand); border: 2px solid var(--on-brand); color: var(--brand); }
/* The last circle: the free reward, faint until it's earned. */
.stamp.reward { border-style: solid; flex-direction: column; gap: 0; display: flex; align-items: center; justify-content: center; opacity: 0.6; }
.stamp.reward svg { width: 46%; height: 46%; }
.stamp.reward small { font-size: 0.6rem; font-weight: 900; letter-spacing: 0.06em; line-height: 1; }
.stamp.reward.ready { opacity: 1; background: var(--on-brand); border-color: var(--on-brand); color: var(--brand); animation: glow 1.6s ease-in-out infinite alternate; }
.panel .stamp.reward.ready { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
@keyframes glow { to { box-shadow: 0 0 0 6px color-mix(in srgb, var(--on-brand) 35%, transparent); } }
.stamp.fresh { animation: stamp-in 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes stamp-in { from { transform: scale(0.2) rotate(-25deg); opacity: 0; } }
.panel .stamp { border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.panel .stamp.filled { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

.reward-banner {
  margin-top: 14px; background: var(--on-brand); color: var(--brand); border-radius: 14px; padding: 12px 14px; font-weight: 800; text-align: center;
  animation: pop 0.6s cubic-bezier(0.3, 1.6, 0.5, 1);
}
@keyframes pop { from { transform: scale(0.85); opacity: 0; } }

.qr-block { background: #fff; color: #111; border-radius: 18px; padding: 16px; margin-top: 16px; text-align: center; box-shadow: var(--shadow); }
.qr { width: min(240px, 70vw); margin: 0 auto; }
.qr svg { display: block; width: 100%; height: auto; }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 1.25rem; letter-spacing: 0.08em; font-weight: 700; margin: 8px 0 0; }

details { margin-top: 12px; }
summary { cursor: pointer; font-weight: 700; padding: 6px 0; }

@media (prefers-reduced-motion: reduce) {
  .stamp.fresh, .stamp.reward.ready, .reward-banner { animation: none; }
}

/* --- Staff ---------------------------------------------------------------------------------- */

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar .who { color: var(--muted); font-size: 0.9rem; }
.scanner { width: 100%; border-radius: 14px; background: #000; aspect-ratio: 1; object-fit: cover; margin-top: 12px; }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper button { width: 48px; padding: 0; }
.stepper output { min-width: 2ch; text-align: center; font-weight: 800; font-size: 1.2rem; }
.result-list { list-style: none; padding: 0; margin: 10px 0 0; }
.result-list button { width: 100%; justify-content: space-between; margin-top: 8px; }
.toast { font-weight: 700; margin-top: 12px; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--ok) 14%, transparent); }
.toast.reward { background: color-mix(in srgb, var(--brand) 18%, transparent); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--bg); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 1.5rem; }
.staff-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); }

/* --- Privacy notice --------------------------------------------------------------------------- */

.prose h2 { margin-top: 1.4em; }
.prose ul { padding-left: 1.2em; }
.prose li { margin: 0.3em 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; vertical-align: top; padding: 8px 6px; border-top: 1px solid var(--border); }

/* --- Poster ------------------------------------------------------------------------------------ */

.poster { text-align: center; padding: 40px 16px; }
/* The buttons above the poster aren't printed: a dashed line marks where the printed part begins. */
.poster-tools { margin: -24px -16px 32px; padding: 0 16px 20px; border-bottom: 2px dashed var(--border); }
.poster-tools p { margin: 10px 0 0; }
.poster h1 { font-size: 2.4rem; }
.poster .offer { font-size: 1.5rem; font-weight: 800; color: var(--brand); }
.poster .qr { width: min(360px, 80vw); }
.poster .steps { font-size: 1.15rem; }
@media print {
  .no-print { display: none !important; }
  body, html { background: #fff; color: #000; }
  .poster { padding-top: 0; }
}

/* --- Icons ------------------------------------------------------------------------------------ */

.icon { display: inline-flex; flex: none; }
.icon svg { width: 1.25em; height: 1.25em; }
h2 .icon, summary .icon { vertical-align: -0.2em; margin-right: 6px; }
.reward-banner { display: flex; align-items: center; justify-content: center; gap: 10px; }
.reward-banner .icon svg { width: 1.8em; height: 1.8em; }
.toast { display: flex; align-items: center; gap: 8px; }

/* --- Logo ------------------------------------------------------------------------------------- */

/* White behind the logo, so it reads on any card colour. */
.logo-badge { flex: none; display: inline-grid; place-items: center; background: #fff; border-radius: 14px; padding: 6px; width: 56px; height: 56px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }
.logo-badge img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.logo-badge.small { width: 40px; height: 40px; border-radius: 10px; padding: 4px; }
.logo-badge.big { width: 160px; height: 160px; border-radius: 28px; padding: 14px; }
/* The Home Screen icon, shown as the logo: the same rounded square phones give it. */
.brand-mark { flex: none; display: block; width: 56px; height: 56px; border-radius: 22.5%; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); }
.brand-mark.small { width: 40px; height: 40px; }
.mini-card .brand-mark.small { width: 32px; height: 32px; }
.brand-mark.big { width: 160px; height: 160px; margin: 0 auto; }
/* On the card, an icon drawn on the card colour would blend in: frame it in the card's text colour. */
.loyalty-card .brand-mark.on-colour, .mini-card .brand-mark.on-colour { box-shadow: 0 0 0 1.5px var(--on-brand); }
.mini-card .brand-mark.on-colour { box-shadow: 0 0 0 1px var(--on-brand); }
.card-head { display: flex; align-items: center; gap: 12px; }
.card-head > div { min-width: 0; }
.brand-title { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* Branding on the admin page: logo, colour and icon, each a block with a picture on the left. */
h3 { font-size: 1rem; margin: 0 0 8px; }
.brand-block { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.brand-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.brand-side { flex: 1 1 200px; min-width: 0; }
.brand-side > p:first-child { margin-top: 0; }
.logo-preview { flex: none; display: grid; place-items: center; background: var(--bg); border: 1.5px dashed var(--border); border-radius: 16px; width: 120px; height: 120px; padding: 10px; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

.mini-card { flex: none; width: 168px; background: var(--brand); color: var(--on-brand); border-radius: 16px; padding: 12px; box-shadow: var(--shadow); transition: background 0.15s; }
.mini-card .card-head { gap: 8px; }
.mini-card .shop { margin: 0; font-weight: 800; font-size: 0.95rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-card .logo-badge.small { width: 32px; height: 32px; border-radius: 8px; padding: 3px; }
.mini-stamps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-top: 10px; }
/* As on the real card, not the in-panel stamps of the staff page. */
.panel .mini-stamps .stamp { border: 1.5px dashed color-mix(in srgb, var(--on-brand) 55%, transparent); }
.panel .mini-stamps .stamp.filled { background: var(--on-brand); border-style: solid; border-color: var(--on-brand); }

.colour-pick { display: inline-flex; align-items: center; gap: 12px; margin: 0; cursor: pointer; }
.colour-pick > span { display: flex; flex-direction: column; line-height: 1.25; }
.hex { font-size: 0.85rem; color: var(--muted); font-weight: 400; }
.colour-well { appearance: none; -webkit-appearance: none; width: 48px; height: 48px; min-height: 0; padding: 0; border: 2px solid var(--border); border-radius: 50%; background: none; cursor: pointer; overflow: hidden; }
.colour-well::-webkit-color-swatch-wrapper { padding: 0; }
.colour-well::-webkit-color-swatch { border: 0; border-radius: 50%; }
.colour-well::-moz-color-swatch { border: 0; border-radius: 50%; }
.icon-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 10px; }
.icon-choice { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border: 2px solid var(--border); border-radius: 14px; cursor: pointer; font-weight: 600; font-size: 0.85rem; text-align: center; margin: 0; }
.icon-choice img { width: 60px; height: 60px; border-radius: 14px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); }
.icon-choice input { position: absolute; opacity: 0; pointer-events: none; }
.icon-choice:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.icon-choice:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--brand) 60%, transparent); outline-offset: 2px; }
.swatch { display: inline-block; width: 1.1em; height: 1.1em; border-radius: 50%; vertical-align: -0.2em; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }

/* --- Activity log ------------------------------------------------------------------------------- */

.activity { list-style: none; padding: 0; margin: 8px 0 0; }
.activity li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--border); }
.activity li > .icon { color: var(--brand); margin-top: 2px; }
.activity p { margin: 0; }
.activity li.undone > div > p:first-child { text-decoration: line-through; color: var(--muted); }
.topbar select { width: auto; min-width: 140px; }
.nowrap { white-space: nowrap; }
.staff-totals { margin-top: 6px; }
.staff-totals th:not(:first-child), .staff-totals td:not(:first-child) { text-align: right; width: 22%; }
.activity .link { font-size: inherit; padding: 0; }
