:root {
  --bg: #fafaf9; --bg-alt: #f1f5f9; --text: #0f172a; --muted: #475569;
  --border: #e2e8f0; --card: #ffffff; --accent: #0f172a;
  --easy: #10b981; --easy-bg: #ecfdf5;
  --warn: #f59e0b; --warn-bg: #fffbeb;
  --danger: #ef4444; --danger-bg: #fef2f2;
  --brand: #0ea5e9; --brand-bg: #e0f2fe;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
  --shadow-lg: 0 4px 12px rgba(15,23,42,.08), 0 24px 48px rgba(15,23,42,.12);
  --radius: 16px; --radius-sm: 10px; --radius-lg: 22px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  line-height: 1.55; -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(at 100% 0%, color-mix(in srgb, var(--easy) 6%, transparent) 0px, transparent 50%),
    radial-gradient(at 0% 100%, color-mix(in srgb, var(--brand) 6%, transparent) 0px, transparent 50%);
  background-attachment: fixed;
}
img, svg { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 11px; }

/* ---------- Layout ---------- */
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding: 0 16px 96px; }
@media (min-width: 768px) { .app { max-width: 760px; } }
@media (min-width: 1024px) { .app { max-width: 1000px; padding: 0 24px 96px; } }
@media (min-width: 1440px) { .app { max-width: 1200px; } }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; max-width: 1200px; margin: 0 auto; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; }
.brand-dot {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #10b981 0%, #0ea5e9 100%);
  display: grid; place-items: center; color: #fff; font-size: 16px;
  box-shadow: 0 4px 12px rgba(14,165,233,.35); flex-shrink: 0;
}
.brand-dot.big { width: 64px; height: 64px; font-size: 30px; border-radius: 16px; margin: 0 auto 14px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 14px; }
.brand-text small { font-size: 11px; color: var(--muted); font-weight: 500; }
.topbar-nav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.navlink { padding: 8px 10px; font-size: 13px; font-weight: 600; color: var(--muted); border-radius: 8px; }
.navlink:hover { background: var(--bg-alt); color: var(--text); }
.user-pill { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; background: var(--bg-alt); border-radius: 999px; border: 1px solid var(--border); margin-left: 4px; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, #38bdf8, #0ea5e9); color: #fff; font-weight: 700; font-size: 12px; display: grid; place-items: center; }
.user-info { display: flex; flex-direction: column; line-height: 1.1; }
.user-info strong { font-size: 12px; }
.user-info small { font-size: 10px; color: var(--muted); }
@media (max-width: 640px) { .user-info { display: none; } }

/* ---------- Hero ---------- */
.hero { padding: 28px 0 18px; }
.hero-greeting { font-size: 13px; color: var(--muted); margin: 0 0 4px; font-weight: 500; }
.hero h1 { font-size: clamp(26px, 5.4vw, 34px); line-height: 1.1; margin: 0 0 6px; letter-spacing: -0.02em; font-weight: 800; }
.hero .lead { font-size: 14px; color: var(--muted); margin: 0; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin: 16px 0 12px; font-size: 13px; color: var(--muted); font-weight: 500; }
.back-link:hover { color: var(--text); }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card-flush { padding: 0; overflow: hidden; }
h2 { font-size: clamp(17px, 3.6vw, 20px); margin: 24px 0 10px; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
h2 .badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg-alt); color: var(--muted); font-weight: 600; }

/* ---------- Stats ---------- */
.stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin-bottom: 12px;
}
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.stat-delta { font-size: 11px; color: var(--muted); }
.stat-warn .stat-value { color: var(--warn); }
.stat-easy .stat-value { color: var(--easy); }

/* ---------- Quick actions ---------- */
.quick-actions .action-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.action-card {
  border: 1px solid var(--border); background: var(--card);
  border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  transition: transform .1s ease;
}
.action-card:active { transform: scale(.98); }
.action-card .ico {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #38bdf8, #0ea5e9); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 18px;
  margin-bottom: 8px;
}
.action-card strong { font-size: 14px; font-weight: 700; }
.action-card small { font-size: 12px; color: var(--muted); }

/* ---------- Wallet ---------- */
.wallet-wrap { perspective: 1000px; margin-bottom: 16px; }
.wallet {
  position: relative; overflow: hidden;
  border-radius: 22px;
  background: linear-gradient(135deg, #0f172a 0%, #082f49 50%, #0e7490 100%);
  color: #fff; padding: 22px;
  box-shadow: 0 20px 40px rgba(8,47,73,.4), inset 0 1px 0 rgba(255,255,255,.1);
  isolation: isolate;
}
.wallet::before { content: ""; position: absolute; top: -40%; right: -20%; width: 280px; height: 280px; border-radius: 50%; background: radial-gradient(circle, rgba(14,165,233,.55), transparent 65%); pointer-events: none; }
.wallet::after { content: ""; position: absolute; bottom: -60%; left: -20%; width: 280px; height: 280px; border-radius: 50%; background: radial-gradient(circle, rgba(16,185,129,.35), transparent 65%); pointer-events: none; }
.wallet-top { display: flex; align-items: flex-start; justify-content: space-between; position: relative; z-index: 1; gap: 12px; }
.wallet-name { font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.wallet-email { display: block; font-weight: 500; font-size: 12px; opacity: .7; margin-top: 2px; }
.wallet-brand { font-size: 10px; font-weight: 700; padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,.15); backdrop-filter: blur(8px); letter-spacing: .06em; text-transform: uppercase; border: 1px solid rgba(255,255,255,.18); white-space: nowrap; }
.wallet-prize { margin: 14px 0; padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,.08); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,.1); position: relative; z-index: 1; font-size: 12px; }
.wallet-prize .label { opacity: .7; display: block; margin-bottom: 2px; }
.wallet-prize strong { font-size: 15px; }
.wallet-stamps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 16px 0 12px; position: relative; z-index: 1; }
@media (min-width: 480px) { .wallet-stamps { grid-template-columns: repeat(10, 1fr); } }
.wallet-stamp { aspect-ratio: 1; border-radius: 50%; background: rgba(255,255,255,.06); border: 1.5px solid rgba(255,255,255,.18); display: grid; place-items: center; font-size: 11px; color: rgba(255,255,255,.6); }
.wallet-stamp.filled { background: linear-gradient(135deg, #6ee7b7 0%, #10b981 100%); border-color: #10b981; color: #022c22; font-weight: 800; box-shadow: 0 4px 12px rgba(16,185,129,.4); }
.wallet-stamp.redeemed { background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%); border-color: #f59e0b; box-shadow: 0 4px 12px rgba(245,158,11,.4); }
.wallet-meta { display: flex; align-items: flex-end; justify-content: space-between; position: relative; z-index: 1; margin-top: 8px; }
.wallet-meta .label { font-size: 10px; opacity: .65; text-transform: uppercase; letter-spacing: .08em; }
.wallet-meta strong { font-size: 18px; }
.wallet-meta strong.prize-text { color: #fbbf24; }

/* ---------- Progress ---------- */
.progress { height: 10px; background: var(--bg-alt); border-radius: 999px; overflow: hidden; margin: 4px 0 16px; }
.progress > div { height: 100%; background: linear-gradient(90deg, #34d399, #10b981); border-radius: 999px; transition: width .6s cubic-bezier(.4,0,.2,1); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; min-height: 44px;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 8px 12px; font-size: 13px; min-height: 36px; }
.btn-primary { background: var(--accent); color: var(--bg); width: 100%; }
.btn-primary:hover:not(:disabled) { box-shadow: var(--shadow); }
.btn-primary:disabled, .btn-primary.btn-disabled { opacity: .35; cursor: not-allowed; }
.btn-success { background: linear-gradient(135deg, #34d399, #10b981); color: #022c22; box-shadow: 0 4px 12px rgba(16,185,129,.3); width: 100%; }
.btn-success:disabled { opacity: .35; cursor: not-allowed; }
.btn-warn { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #422006; box-shadow: 0 4px 12px rgba(245,158,11,.3); width: 100%; }
.btn-warn:disabled, .btn-warn.btn-disabled { opacity: .35; cursor: not-allowed; }
.btn-ghost { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-alt); }
.btn-danger { background: var(--danger); color: #fff; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.action-form { margin: 0; display: contents; }
@media (max-width: 380px) { .actions { grid-template-columns: 1fr; } }

/* ---------- QR ---------- */
.qr-card {
  display: grid; grid-template-columns: 1fr; gap: 16px;
  align-items: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  margin-top: 12px;
  box-shadow: var(--shadow);
}
@media (min-width: 640px) { .qr-card { grid-template-columns: 180px 1fr; } }
.qr-frame { width: 160px; height: 160px; background: #fff; padding: 10px; border-radius: 14px; box-shadow: 0 4px 16px rgba(15,23,42,.12), inset 0 0 0 1px var(--border); display: grid; place-items: center; }
.qr-frame img { width: 100% !important; height: 100% !important; }
.qr-info h3 { margin: 0 0 4px; font-size: 15px; }
.qr-info p { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- Client list ---------- */
.client-row {
  display: grid; grid-template-columns: 48px 1fr; gap: 12px;
  align-items: center; padding: 14px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 10px;
  position: relative; overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease;
}
.client-row:active { transform: scale(.99); }
.client-row.alert::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: linear-gradient(180deg, #fbbf24, #f59e0b); }
.client-row.redeemed::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: linear-gradient(180deg, #94a3b8, #64748b); }
.avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%);
  color: #fff; font-weight: 700; font-size: 16px;
  display: grid; place-items: center; box-shadow: var(--shadow-sm);
}
.client-info strong { display: block; font-size: 15px; }
.client-info small { color: var(--muted); font-size: 12px; }
.client-info .count {
  display: inline-block; margin-top: 6px; font-size: 11px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--easy-bg); color: var(--easy); font-weight: 700;
}
.client-info .count.full { background: var(--warn-bg); color: var(--warn); animation: pulse 2s infinite; }
.client-info .count.done { background: var(--bg-alt); color: var(--muted); }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.client-row .chev { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 18px; }

/* ---------- History ---------- */
.history-item { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); align-items: center; }
.history-item:last-child { border-bottom: 0; }
.history-item .dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 700; }
.history-item.stamp .dot { background: var(--easy-bg); color: var(--easy); }
.history-item.redeem .dot { background: var(--warn-bg); color: var(--warn); }
.history-item .label { font-weight: 600; font-size: 14px; }
.history-item .sub { font-size: 12px; color: var(--muted); }
.history-item time { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---------- Celebrate ---------- */
.celebrate {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #ea580c 100%);
  color: #422006; border: 0; padding: 16px;
  box-shadow: 0 12px 32px rgba(245,158,11,.4);
  animation: celebrateIn .5s cubic-bezier(.34,1.56,.64,1);
}
.celebrate h3 { margin: 0; font-size: 16px; font-weight: 800; }
.celebrate p { margin: 4px 0 0; font-size: 13px; opacity: .9; }
.celebrate .trophy { font-size: 32px; }
@keyframes celebrateIn { 0% { transform: scale(.85); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* ---------- Confetti ---------- */
.confetti-host { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti { position: absolute; top: -20px; width: 10px; height: 14px; animation: confettiFall linear forwards; }
@keyframes confettiFall { 0% { transform: translateY(0) rotate(0); opacity: 1; } 100% { transform: translateY(110vh) rotate(720deg); opacity: .6; } }

/* ---------- Toast ---------- */
.toast-host { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; pointer-events: none; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--accent); color: var(--bg);
  padding: 12px 18px; border-radius: 999px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
  display: flex; align-items: center; gap: 10px;
  max-width: 90%;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: linear-gradient(135deg, #34d399, #10b981); color: #022c22; }
.toast.error { background: linear-gradient(135deg, #fb7185, #ef4444); color: #fff; }
.toast.warn { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #422006; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.65); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; z-index: 80; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.modal-back.show { opacity: 1; pointer-events: auto; }
.modal { background: var(--card); border-radius: var(--radius); padding: 22px; width: 100%; max-width: 460px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); transform: scale(.92); transition: transform .25s cubic-bezier(.34,1.56,.64,1); max-height: 90vh; overflow-y: auto; }
.modal-back.show .modal { transform: scale(1); }
.modal h3 { margin: 0 0 6px; font-size: 18px; }
.modal > p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.modal-actions.single { grid-template-columns: 1fr; }
.modal-actions .btn { width: 100%; }
.modal-list { display: flex; flex-direction: column; gap: 8px; }
.modal-list-item { display: grid; grid-template-columns: 32px 1fr; gap: 10px; align-items: center; padding: 8px 12px; background: var(--bg-alt); border-radius: 10px; }
.modal-list-item .dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.modal-list-item .dot.stamp { background: var(--easy-bg); color: var(--easy); }
.modal-list-item .dot.redeem { background: var(--warn-bg); color: var(--warn); }
.modal-list-item strong { font-size: 14px; }
.modal-list-item small { font-size: 11px; color: var(--muted); display: block; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 4px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 15px; font-family: inherit; min-height: 44px;
  transition: border-color .15s ease;
}
.field input:focus, .field select:focus { outline: 0; border-color: var(--accent); }
.form-card { display: flex; flex-direction: column; }

/* ---------- Login ---------- */
.login-wrap { min-height: 80vh; display: grid; place-items: center; padding: 32px 0; }
.login-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px 24px;
  box-shadow: var(--shadow-lg); width: 100%; max-width: 420px;
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.login-brand p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.login-hint { margin-top: 24px; padding: 14px; background: var(--bg-alt); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.login-hint h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .06em; }
.hint-table { width: 100%; border-collapse: collapse; font-size: 11px; font-family: 'JetBrains Mono', monospace; }
.hint-table th, .hint-table td { padding: 4px 6px; text-align: left; border-bottom: 1px solid var(--border); }
.hint-table th { color: var(--muted); font-weight: 700; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 14px; font-weight: 500; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 20%, transparent); }
.alert-success { background: var(--easy-bg); color: var(--easy); border: 1px solid color-mix(in srgb, var(--easy) 20%, transparent); }
.alert-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 20%, transparent); }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty .ico { font-size: 40px; margin-bottom: 8px; }
.empty h3 { margin: 0 0 4px; font-size: 16px; color: var(--text); }
.empty p { margin: 0 0 14px; font-size: 13px; }

/* ---------- Danger zone ---------- */
.danger-zone { margin-top: 24px; padding: 16px; background: var(--danger-bg); border: 1px solid color-mix(in srgb, var(--danger) 18%, transparent); border-radius: var(--radius); }
.danger-zone h2 { margin-top: 0; color: var(--danger); }
.danger-zone .btn-danger { width: auto; padding: 10px 16px; min-height: 38px; font-size: 13px; }

/* ---------- Print / Reduced motion ---------- */
@media print { .topbar, .toast-host, .modal-back, .confetti-host, .btn { display: none !important; } body { background: #fff; color: #000; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }