:root {
  --brand: #7c3aed;
  --bg: #f6f6f8;
  --card: #ffffff;
  --text: #1f1f24;
  --muted: #6b6b75;
  --line: #e4e4ea;
  --ok: #157347;
  --err: #b42318;
  --warn: #a15c07;
  --radius: 12px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--brand); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .6rem; }
h2 { font-size: 1.25rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1.2rem 0 .4rem; }
.container { max-width: 1040px; margin: 0 auto; padding: 20px 16px 60px; }
.container.narrow { max-width: 620px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .04em; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.inline { display: inline; }

/* Topbar */
.topbar { background: #1f1f24; color: #fff; display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 10px 16px; flex-wrap: wrap; }
.topbar.admin { background: #3b1d6e; }
.topbar a, .topbar .linkbtn { color: #fff; text-decoration: none; font-size: .95rem; }
.topbar nav { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.brandname { font-weight: 700; }
.linkbtn { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: var(--brand); text-decoration: underline; }

/* Forms */
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: .95rem; }
label.check { font-weight: 400; display: flex; gap: 10px; align-items: flex-start; }
label.check input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
input[type=text], input[type=email], input[type=number], input[type=url], input[type=tel], input[type=search], input[type=date], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid #cfcfd8; border-radius: 9px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
textarea { min-height: 90px; resize: vertical; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 4px; font-weight: 400; }
button, .btn {
  display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 9px; padding: 12px 20px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
}
button:hover, .btn:hover { filter: brightness(1.08); }
.btn.secondary, button.secondary { background: #fff; color: var(--text); border: 1px solid #cfcfd8; }
.btn.danger, button.danger { background: var(--err); }
.btn.block, button.block { width: 100%; }
.btn.small, button.small { padding: 7px 12px; font-size: .9rem; }

/* Alerts & badges */
.alert { padding: 12px 14px; border-radius: 9px; margin: 0 0 16px; overflow-wrap: anywhere; }
.alert.ok { background: #e7f6ee; color: var(--ok); border: 1px solid #b7e2c8; }
.alert.error { background: #fdecea; color: var(--err); border: 1px solid #f5c2bd; }
.alert.warn { background: #fff5e0; color: var(--warn); border: 1px solid #f1d39b; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.st-active { background: #e7f6ee; color: var(--ok); }
.st-redeemed { background: #ececf1; color: #45454f; }
.st-expired { background: #fff5e0; color: var(--warn); }
.st-voided { background: #fdecea; color: var(--err); }
.st-suspended { background: #fdecea; color: var(--err); }

/* Tables */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.list { width: 100%; border-collapse: collapse; background: #fff; font-size: .93rem; }
table.list th, table.list td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.list td.num, table.list th.num { text-align: right; white-space: nowrap; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 1.45rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .85rem; }

/* Shop */
.shop-hero { background: var(--brand); color: #fff; }
.shop-hero .inner { max-width: 620px; margin: 0 auto; padding: 26px 16px; display: flex; gap: 16px; align-items: center; }
.shop-hero img { width: 76px; height: 76px; object-fit: contain; background: #fff; border-radius: 12px; padding: 6px; flex: none; }
.shop-hero h1 { margin: 0; color: #fff; }
.shop-hero p { margin: 4px 0 0; opacity: .92; }
.amounts { display: flex; flex-wrap: wrap; gap: 10px; }
.amounts label { margin: 0; font-weight: 600; }
.amounts input { position: absolute; opacity: 0; pointer-events: none; }
.amounts span { display: inline-block; padding: 11px 16px; border: 2px solid #d5d5de; border-radius: 10px; background: #fff; cursor: pointer; min-width: 96px; text-align: center; }
.amounts input:checked + span { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, #fff); color: var(--brand); }
.amounts input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.custom-amount { display: none; }
form:has(#amount-custom:checked) .custom-amount { display: block; }
.recipient-email { display: none; }
form:has(#delivery-recipient:checked) .recipient-email { display: block; }
.contact { font-size: .92rem; color: var(--muted); }
.contact div { margin: 2px 0; }

/* Voucher view */
.voucher { border-top: 8px solid var(--brand); }
.voucher .amount { font-size: 2.6rem; font-weight: 800; color: var(--brand); line-height: 1.1; }
.voucher .code { font-size: 1.7rem; font-weight: 700; }
.qr svg { width: 180px; height: 180px; }
.message { background: #f6f6f8; border-left: 4px solid var(--brand); padding: 10px 14px; font-style: italic; }

/* Redeem */
#scanner { display: none; margin-top: 12px; }
#scanner.on { display: block; }
#scanner video { width: 100%; max-width: 420px; border-radius: 10px; background: #000; }
.bigcode input { font-size: 1.4rem; text-transform: uppercase; letter-spacing: .08em; font-family: ui-monospace, Menlo, Consolas, monospace; }
.confirm-box { border: 2px solid var(--brand); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

/* Legal */
.legal { background: #fff; }
.legal h2 { font-size: 1.1rem; }
.draft-banner { background: #fff5e0; border: 2px dashed var(--warn); color: var(--warn); padding: 12px 14px; border-radius: 10px; font-weight: 600; margin-bottom: 16px; }

footer.site { text-align: center; color: var(--muted); font-size: .85rem; padding: 20px 16px 40px; }
footer.site a { color: var(--muted); }

@media print {
  .topbar, .noprint, footer.site { display: none !important; }
  body { background: #fff; }
  .card { border: 0; }
}
