/* Tap Loyalty admin. One accent, soft surfaces, quiet motion. */
:root {
  --ink: #1D3A5F;
  --ink-deep: #142A46;
  --ink-soft: #E8EEF6;
  --marigold: #F2B230;
  --bg: #F3F5F8;
  --surface: #FFFFFF;
  --surface-2: #EEF1F5;
  --text: #14181D;
  --muted: #5B6572;
  --line: #E3E7EC;
  --ok: #1F7A4D;
  --warn: #9A5B00;
  --err: #B3261E;
  --focus: #1D3A5F;
  --shadow: 0 1px 2px rgba(20, 24, 29, .04), 0 8px 24px -12px rgba(20, 24, 29, .12);
  --shadow-lift: 0 2px 4px rgba(20, 24, 29, .06), 0 16px 36px -16px rgba(20, 24, 29, .22);
  --radius: 16px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #9EC1EA; --ink-deep: #C3DBF5; --ink-soft: #1D2A3B; --bg: #0F1318; --surface: #171D25; --surface-2: #1F2731;
    --text: #EDF0F3; --muted: #A3ADB8; --line: #2A323C; --ok: #5FC08E; --warn: #E2A84B; --err: #F08C84; --focus: #F2B230;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .5);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .4), 0 16px 36px -16px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3 { color: var(--text); margin: 0; letter-spacing: -.02em; }
h1 { font-size: 1.9rem; font-weight: 800; line-height: 1.15; }
h2 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 30; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--surface); border-right: 1px solid var(--line); align-self: start; padding: 22px 14px; display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1rem; letter-spacing: -.01em; padding: 0 8px; white-space: nowrap; min-width: 0; }
.brand svg { width: 28px; height: 28px; flex: none; }
.brand .tag { font-size: .6rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); background: var(--ink-soft); padding: 2px 7px; border-radius: 999px; margin-left: 2px; flex: none; }
.venue-switch { width: 100%; }
.venue-name { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-weight: 600; font-size: .9rem; }
.venue-name i { width: 8px; height: 8px; border-radius: 50%; background: var(--marigold); flex: none; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; text-decoration: none; color: var(--muted); font-weight: 500;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.nav a svg { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a:active { transform: scale(.98); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--ink-soft); font-weight: 600; }
.side-foot { margin-top: auto; display: grid; gap: 8px; padding: 0 8px; font-size: .86rem; }
.side-foot a { color: var(--muted); text-decoration: none; overflow-wrap: anywhere; }
.side-foot a:hover, .side-foot a[aria-current="page"] { color: var(--text); }
.side-foot .btn.quiet { padding: 0; justify-self: start; }
.main { padding: 36px clamp(16px, 4vw, 52px) 72px; max-width: 1180px; width: 100%; animation: rise .32s cubic-bezier(.2, .7, .2, 1) both; }
.main:focus { outline: none; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 26px; }
.page-head p { margin-top: 6px; }
.topbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 25% 0 0; z-index: 20; transform: translateX(-105%); transition: transform .25s ease, visibility 0s .25s; height: 100%; visibility: hidden; border-right: 0; box-shadow: var(--shadow-lift); }
  .side.open { transform: none; visibility: visible; transition: transform .25s ease; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
  .main { padding-top: 22px; }
}

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--ink); background: var(--ink); color: #fff;
  font: 600 .95rem var(--font); cursor: pointer; text-decoration: none; transition: background .15s ease, transform .12s ease, box-shadow .15s ease;
}
.btn:hover { background: var(--ink-deep); border-color: var(--ink-deep); box-shadow: 0 6px 16px -8px rgba(29, 58, 95, .5); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; box-shadow: none; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: var(--surface-2); border-color: var(--line); box-shadow: none; }
.btn.quiet { background: transparent; border-color: transparent; color: var(--ink); padding: 0 10px; min-height: 34px; }
.btn.quiet:hover { background: var(--ink-soft); box-shadow: none; }
.btn.danger { background: transparent; border-color: transparent; color: var(--err); padding: 0 10px; min-height: 34px; }
.btn.danger:hover { background: color-mix(in srgb, var(--err) 10%, transparent); box-shadow: none; }
.btn.wide { width: 100%; }
.btn.tall { min-height: 46px; padding: 0 16px; }

label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
label .hint, .label .hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
.label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
input, select, textarea {
  font: inherit; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); width: 100%; transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--ink-soft); }
input[type="color"] { padding: 3px; height: 42px; width: 56px; cursor: pointer; }
input[aria-invalid="true"] { border-color: var(--err); }
.field-error { color: var(--err); font-weight: 500; font-size: .85rem; }
.field-error:empty { display: none; }
.form { display: grid; gap: 18px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; }
.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grow { flex: 1 1 220px; max-width: 320px; }
#add { align-items: end; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 18px; }
.panel h2 { margin-bottom: 14px; }

.notice { padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); margin-bottom: 20px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; border-left-width: 4px; }
.notice.warn { border-left-color: var(--warn); }
.notice.err { border-left-color: var(--err); }
.notice.ok { border-left-color: var(--ok); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 7px 14px; font: 500 .88rem var(--font); cursor: pointer; transition: background .15s ease; }
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: .86rem; font-weight: 600; padding: 3px 10px 3px 8px; border-radius: 999px; background: var(--surface-2); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.status.ok::before { background: var(--ok); }
.status.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); }
.status.warn::before { background: var(--warn); }
.status.err { background: color-mix(in srgb, var(--err) 12%, transparent); color: var(--err); }
.status.err::before { background: var(--err); }

label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
label.check input { width: 18px; height: 18px; margin-top: 3px; flex: none; accent-color: var(--ink); }
label.check a { display: inline-block; padding: 12px 2px; margin: -12px -2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
td.actions { width: 1%; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.right, th.right { text-align: right; }
tbody tr.link { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.empty { padding: 40px 12px; text-align: center; color: var(--muted); }

/* ---------- Overview ---------- */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.figure { padding: 18px 20px; display: grid; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.figure::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--marigold); }
.figure b { font-weight: 800; font-size: 2rem; line-height: 1.1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.figure span { color: var(--muted); font-size: .86rem; }
@media (max-width: 860px) { .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .bar { fill: var(--ink); transition: fill .12s ease; }
.chart .bar.hover { fill: var(--marigold); }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--text); color: var(--bg); padding: 6px 10px; border-radius: 8px;
  font-size: .82rem; white-space: nowrap; transform: translate(-50%, -110%);
}
details.small summary { cursor: pointer; color: var(--muted); }

/* ---------- Devices ---------- */
.pairing { display: grid; gap: 8px; justify-items: start; padding: 20px; border: 1px dashed var(--ink); border-radius: 14px; margin-top: 16px; background: var(--ink-soft); animation: rise .3s ease both; }
.pairing .qr { background: #fff; padding: 8px; border-radius: 12px; line-height: 0; box-shadow: var(--shadow); }
.pairing .qr svg { display: block; width: 200px; height: 200px; }
.pairing .code { font-weight: 800; font-size: 2.4rem; line-height: 1; letter-spacing: .18em; font-variant-numeric: tabular-nums; }

/* ---------- Card design ---------- */
.design { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
@media (max-width: 980px) { .design { grid-template-columns: 1fr; } }
.preview { position: sticky; top: 24px; display: grid; gap: 12px; justify-items: center; }
.pass { width: 320px; border-radius: 18px; overflow: hidden; color: #fff; box-shadow: var(--shadow-lift); transition: background .2s ease; }
.pass-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; }
.pass-head .logo { display: flex; align-items: center; gap: 10px; font-weight: 600; color: inherit; }
.pass-head img { width: 28px; height: 28px; border-radius: 7px; object-fit: cover; background: #fff; }
.pass-head .mark { width: 28px; height: 28px; border-radius: 50%; background: var(--marigold); }
.pass-label { font-size: .68rem; letter-spacing: .04em; opacity: .9; }
.pass-strip { display: grid; gap: 10px; padding: 18px 22px; }
.pass-strip i { aspect-ratio: 1; border-radius: 50%; display: block; }
.pass-fields { display: flex; justify-content: space-between; padding: 12px 16px 16px; gap: 8px; }
.pass-fields div { display: grid; gap: 2px; }
.pass-fields b { font-weight: 600; }

.logo-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-box { width: 72px; height: 72px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; flex: none; }
.logo-box img { width: 100%; height: 100%; object-fit: cover; }
.logo-box .muted { font-size: .78rem; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-hero { background: var(--ink); color: #fff; padding: clamp(28px, 6vw, 72px); display: flex; flex-direction: column; justify-content: space-between; gap: 40px; position: relative; overflow: hidden; }
.auth-hero::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; right: -200px; bottom: -220px; background: radial-gradient(circle, rgba(242, 178, 48, .35), transparent 65%); }
.auth-hero .brand { color: #fff; padding: 0; }
.auth-hero h2 { color: #fff; font-size: clamp(1.7rem, 3vw, 2.4rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; max-width: 16ch; }
.auth-hero p { color: rgba(255, 255, 255, .78); max-width: 38ch; margin-top: 12px; }
.auth-hero ul { list-style: none; margin: 24px 0 0; padding: 0; display: grid; gap: 10px; color: rgba(255, 255, 255, .9); }
.auth-hero li { display: flex; gap: 10px; align-items: center; }
.auth-hero li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--marigold); flex: none; }
.auth-hero .small { color: rgba(255, 255, 255, .6); position: relative; }
.auth-box { width: min(420px, 100%); display: grid; gap: 22px; align-self: center; justify-self: center; padding: 32px 20px; animation: rise .35s ease both; }
.auth-box .brand { padding: 0; }
.auth-box h1 { font-size: 1.6rem; }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}
.auth.single { grid-template-columns: 1fr; place-items: center; }

/* ---------- First run ---------- */
.checklist ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.checklist li { display: flex; align-items: center; gap: 10px; }
.checklist .tick { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.checklist li.done .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.checklist li.done > span:last-child { color: var(--muted); text-decoration: line-through; }
.checklist li.done a { color: inherit; }

/* ---------- Platform ---------- */
.result-box { margin-top: 14px; padding: 14px 16px; border-radius: 12px; background: var(--ink-soft); display: grid; gap: 8px; }
.result-box code { font: 500 .85rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }

/* ---------- Invoice sheet ---------- */
.sheet { padding: 32px; }
.sheet-head { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.sheet-to { margin-bottom: 20px; }
.sheet tfoot td { border-bottom: 0; padding-top: 6px; padding-bottom: 6px; }
.sheet tfoot tr:first-child td { padding-top: 14px; }
input.right { text-align: right; }
textarea { resize: vertical; }
@media print {
  body { background: #fff; }
  .side, .topbar, .no-print, .skip { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; animation: none; }
  .panel.sheet { border: 0; box-shadow: none; padding: 0; }
}

/* ---------- Phones: 44px tap targets, no sideways scroll ---------- */
@media (max-width: 760px) {
  .btn, .btn.quiet, .btn.danger, .chip, .nav a, .side-foot a { min-height: 44px; }
  .nav a, .side-foot a { display: flex; align-items: center; }
  .hide-sm { display: none; }
  th, td { padding: 10px 8px; }
  td .small { overflow-wrap: anywhere; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
