:root {
  --brand: #F2542D;
  --brand-ink: #B83A18;
  --yolk: #FFC145;
  --cream: #FFF8F0;
  --paper: #FFFFFF;
  --ink: #1D1A16;
  --ink-2: #5C554C;
  --ink-3: #8F877C;
  --line: #EDE3D6;
  --ok: #1F9D61;
  --ok-soft: #E3F5EC;
  --bad: #C8352B;
  --bad-soft: #FBE7E4;
  --pv: #4C38F2;          /* Payvein violet, only on Payvein screens */
  --pv-soft: #EEEBFF;
  --r: 18px;
  --display: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
  --text: "Inter", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 var(--text); color: var(--ink); background: var(--cream); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.02em; margin: 0; }
[hidden] { display: none !important; }

/* Phone column; on a desktop it sits next to an "open on your phone" panel */
.phone { position: relative; max-width: 440px; margin: 0 auto; min-height: 100%; background: var(--cream); display: flex; flex-direction: column; }
.view { flex: 1; padding: 0 0 calc(84px + var(--safe-b)); }
.desk { display: none; }
@media (min-width: 900px) {
  body { display: flex; align-items: center; justify-content: center; gap: 64px; min-height: 100vh; background: #F4EADF; }
  .phone { margin: 24px 0; width: 400px; height: min(860px, calc(100vh - 48px)); min-height: 0; border-radius: 44px; overflow: hidden auto;
    box-shadow: 0 0 0 10px #1D1A16, 0 30px 60px -20px rgba(0,0,0,.45); scrollbar-width: none; }
  .phone::-webkit-scrollbar { display: none; }
  .desk { display: block; max-width: 340px; }
  .desk-logo { width: 56px; }
  .desk h1 { font-size: 30px; margin: 18px 0 8px; }
  .desk p { color: var(--ink-2); }
  .desk-qr { width: 180px; height: 180px; background: #fff; border-radius: 16px; padding: 12px; margin: 18px 0; }
  .desk-qr svg { width: 100%; height: 100%; }
  .desk-foot { font-size: 13px; }
  .tabbar { position: sticky !important; }
}

/* Top bars */
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 14px 18px; background: color-mix(in srgb, var(--cream) 92%, transparent); backdrop-filter: blur(10px); }
.bar h2 { font-size: 18px; flex: 1; }
.back { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); display: grid; place-items: center; cursor: pointer; }
.back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pad { padding: 4px 18px 18px; }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; padding: 0 20px; border-radius: 16px; border: 0;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none; transition: transform .08s, opacity .2s; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.pv { background: var(--pv); }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1.5px solid var(--bad-soft); }
.btn.small { min-height: 40px; width: auto; font-size: 14px; border-radius: 12px; padding: 0 14px; }
.btn .spin { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.stack { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input { height: 52px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--paper); padding: 0 16px; font-size: 16px; outline: none; transition: border-color .15s; }
.field input:focus { border-color: var(--ink); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.err { color: var(--bad); font-size: 14px; font-weight: 500; min-height: 1.2em; margin: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* Auth */
.hero { position: relative; padding: 56px 24px 30px; background: var(--brand); color: #fff; overflow: hidden; border-radius: 0 0 32px 32px; }
.hero::after { content: ""; position: absolute; right: -60px; top: -50px; width: 220px; height: 220px; border-radius: 50%; background: var(--yolk); opacity: .9; }
.hero > * { position: relative; z-index: 1; }
.hero img { width: 52px; border-radius: 15px; box-shadow: 0 0 0 3px rgba(255,255,255,.25); }
.hero h1 { font-size: 34px; line-height: 1.05; margin: 22px 0 10px; max-width: 280px; }
.hero p { margin: 0; opacity: .92; max-width: 290px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: #F1E6D9; border-radius: 14px; padding: 4px; margin: 22px 18px 16px; }
.seg button { border: 0; background: transparent; height: 42px; border-radius: 11px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* Home */
.greet { display: flex; align-items: center; justify-content: space-between; padding: 22px 18px 10px; }
.greet h1 { font-size: 26px; }
.greet .logo { width: 40px; border-radius: 12px; }
.loyalty { margin: 6px 18px 0; border-radius: 24px; padding: 20px; color: #fff; background: radial-gradient(120% 140% at 100% 0%, #FF8A3D 0%, var(--brand) 45%, #C73E1C 100%); box-shadow: 0 18px 30px -18px rgba(199,62,28,.7); }
.loyalty .top { display: flex; justify-content: space-between; align-items: baseline; }
.loyalty .pts { font-family: var(--display); font-size: 44px; font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.loyalty .lvl { font-size: 12px; font-weight: 700; background: rgba(255,255,255,.2); padding: 4px 10px; border-radius: 99px; }
.loyalty .code { margin-top: 18px; background: #fff; border-radius: 14px; padding: 10px 14px 8px; color: var(--ink); text-align: center; }
.barcode { height: 46px; display: flex; gap: 0; align-items: stretch; justify-content: center; }
.barcode i { display: block; background: var(--ink); }
.loyalty .code small { font: 12px/1.6 ui-monospace, monospace; letter-spacing: .2em; color: var(--ink-2); }

.section { padding: 22px 18px 0; }
.section h3 { font-size: 18px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: baseline; }
.section h3 a { font: 600 14px var(--text); color: var(--brand-ink); text-decoration: none; }

.pvcard { position: relative; overflow: hidden; display: grid; grid-template-columns: 1fr 84px; gap: 6px; align-items: center; border-radius: 22px; padding: 18px; background: var(--paper); border: 1.5px solid var(--line); text-decoration: none; }
.pvcard.on { background: var(--ok-soft); border-color: transparent; }
.pvcard.todo { background: var(--pv-soft); border-color: transparent; }
.pvcard h4 { margin: 0 0 4px; font: 700 17px/1.2 var(--display); }
.pvcard p { margin: 0; font-size: 14px; color: var(--ink-2); }
.pvcard .go { margin-top: 12px; display: inline-flex; font-weight: 700; color: var(--pv); font-size: 14px; }
.pvcard.on .go { color: var(--ok); }
.pvcard .palm-ico { width: 84px; height: 84px; }
.pvcard .by { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-3); margin-bottom: 8px; }
.pvcard .by img { height: 12px; }

.offers { display: flex; gap: 12px; overflow-x: auto; padding: 0 18px 4px; margin: 0 -18px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.offers::-webkit-scrollbar { display: none; }
.offer { flex: 0 0 72%; scroll-snap-align: start; border-radius: 20px; padding: 16px; background: var(--paper); border: 1.5px solid var(--line); display: grid; gap: 6px; }
.offer .badge { justify-self: start; font: 800 20px var(--display); color: var(--brand); }
.offer b { font-size: 15px; }
.offer p { margin: 0; font-size: 13px; color: var(--ink-2); }
.offer .btn { margin-top: 6px; }
.offer.active .btn { background: var(--ok-soft); color: var(--ok); }
.offers.grid { display: grid; grid-template-columns: 1fr; overflow: visible; margin: 0; padding: 0; }

.tx { display: grid; gap: 2px; background: var(--paper); border-radius: 18px; border: 1.5px solid var(--line); }
.tx > div { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; }
.tx > div + div { border-top: 1px solid var(--line); }
.tx .ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--cream); }
.tx .ico svg { width: 20px; height: 20px; fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tx b { display: block; font-size: 14px; }
.tx small { color: var(--ink-3); font-size: 12px; }
.tx .amt { text-align: right; font-weight: 700; font-size: 14px; }
.tx .amt small { display: block; color: var(--ok); font-weight: 600; }
.empty { padding: 18px; text-align: center; color: var(--ink-3); font-size: 14px; }

/* Payvein onboarding */
.pvhead { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: 12px; }
.pvhead img { height: 14px; }
.steps { display: flex; gap: 6px; margin: 6px 18px 0; }
.steps i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.steps i.on { background: var(--pv); }
.intro-art { height: 200px; margin: 10px 18px 0; border-radius: 26px; background: linear-gradient(160deg, #EEEBFF, #DCD6FF); display: grid; place-items: center; }
.intro-art svg { width: 150px; height: 150px; }
.lead h2 { font-size: 26px; line-height: 1.1; margin: 18px 0 8px; }
.lead p { color: var(--ink-2); margin: 0; }
.bullets { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 12px; }
.bullets li { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; font-size: 14px; color: var(--ink-2); }
.bullets li b { color: var(--ink); display: block; font-size: 15px; }
.bullets .n { width: 34px; height: 34px; border-radius: 11px; background: var(--pv-soft); color: var(--pv); display: grid; place-items: center; font-weight: 800; }
.check { display: grid; grid-template-columns: 26px 1fr; gap: 12px; align-items: start; padding: 14px; border-radius: 16px; background: var(--paper); border: 1.5px solid var(--line); cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--pv); }
.check span { font-size: 14px; color: var(--ink-2); }
.check b { color: var(--ink); }
details.terms { font-size: 13px; color: var(--ink-2); background: var(--paper); border-radius: 14px; border: 1.5px solid var(--line); padding: 12px 14px; }
details.terms summary { font-weight: 600; color: var(--ink); cursor: pointer; }
details.terms ol { padding-left: 18px; margin: 10px 0 0; display: grid; gap: 6px; }

.cardface { position: relative; aspect-ratio: 1.586; border-radius: 20px; padding: 20px; color: #fff; background: linear-gradient(135deg, #2A2540, #4C38F2 70%, #7C6CFF); display: grid; align-content: space-between; box-shadow: 0 20px 30px -18px rgba(76,56,242,.8); overflow: hidden; }
.cardface::after { content: ""; position: absolute; right: -40px; bottom: -60px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255,255,255,.08); }
.cardface .chip { width: 40px; height: 30px; border-radius: 7px; background: linear-gradient(135deg, #F3D27A, #C9A13D); }
.cardface .num { font: 600 20px/1 ui-monospace, monospace; letter-spacing: .08em; }
.cardface .meta { display: flex; justify-content: space-between; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; opacity: .9; }
.cardface .brand { position: absolute; right: 20px; top: 18px; font: 800 italic 20px var(--display); }
.testcard { border: 0; background: none; color: var(--pv); font-weight: 600; font-size: 14px; padding: 0; cursor: pointer; justify-self: start; }

.tokenise { text-align: center; padding: 24px 6px; }
.tokenise .flow { display: grid; grid-template-columns: 1fr 40px 1fr; align-items: center; gap: 6px; margin: 22px 0; }
.tokenise .box { border-radius: 14px; padding: 12px 8px; background: var(--paper); border: 1.5px solid var(--line); font-size: 12px; color: var(--ink-3); }
.tokenise .box b { display: block; font: 600 15px ui-monospace, monospace; color: var(--ink); margin-top: 4px; }
.tokenise .box.tok { border-color: var(--pv); background: var(--pv-soft); }
.tokenise .arrow svg { width: 32px; stroke: var(--pv); fill: none; stroke-width: 2.4; stroke-linecap: round; }

.done-badge { width: 84px; height: 84px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; margin: 30px auto 8px; animation: pop .45s cubic-bezier(.3,1.6,.5,1); }
.done-badge svg { width: 42px; stroke: currentColor; fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.bad-badge { background: var(--bad); }

.store-steps { counter-reset: s; list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 10px; }
.store-steps li { counter-increment: s; display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: center; background: var(--paper); border: 1.5px solid var(--line); padding: 12px; border-radius: 16px; font-size: 14px; }
.store-steps li::before { content: counter(s); width: 36px; height: 36px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; }

/* Scanner */
.scan { position: relative; margin: 6px 18px 0; aspect-ratio: 3/4; border-radius: 28px; overflow: hidden; background: #111; }
.scan video { width: 100%; height: 100%; object-fit: cover; }
.scan .frame { position: absolute; inset: 18% 14%; border-radius: 22px; box-shadow: 0 0 0 999px rgba(0,0,0,.45); }
.scan .frame::before, .scan .frame::after { content: ""; position: absolute; inset: -3px; border-radius: 24px; border: 3px solid #fff; clip-path: polygon(0 0, 30% 0, 30% 3px, 3px 3px, 3px 30%, 0 30%, 0 70%, 3px 70%, 3px calc(100% - 3px), 30% calc(100% - 3px), 30% 100%, 70% 100%, 70% calc(100% - 3px), calc(100% - 3px) calc(100% - 3px), calc(100% - 3px) 70%, 100% 70%, 100% 30%, calc(100% - 3px) 30%, calc(100% - 3px) 3px, 70% 3px, 70% 0, 100% 0, 100% 100%, 0 100%); }
.scan .line { position: absolute; left: 16%; right: 16%; top: 20%; height: 2px; background: var(--yolk); box-shadow: 0 0 12px var(--yolk); animation: scanline 2.2s ease-in-out infinite; }
.scan .msg { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; color: #fff; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.scan.off { display: grid; place-items: center; color: #fff; text-align: center; padding: 24px; }

/* Pairing */
.terminal-card { display: grid; grid-template-columns: 52px 1fr; gap: 14px; align-items: center; padding: 16px; border-radius: 20px; background: var(--paper); border: 1.5px solid var(--line); }
.terminal-card .t-ico { width: 52px; height: 52px; border-radius: 16px; background: var(--ink); display: grid; place-items: center; }
.terminal-card .t-ico svg { width: 26px; stroke: #fff; fill: none; stroke-width: 2; }
.link-what { display: grid; gap: 8px; margin: 14px 0; }
.link-what div { display: flex; justify-content: space-between; padding: 12px 14px; border-radius: 14px; background: var(--paper); border: 1.5px solid var(--line); font-size: 14px; }
.link-what b { font-weight: 600; }
.live { text-align: center; padding: 18px 6px 6px; }
.live h2 { font-size: 24px; margin: 14px 0 6px; }
.live p { color: var(--ink-2); margin: 0 auto; max-width: 300px; }
.palm-live { width: 150px; height: 150px; margin: 10px auto 0; position: relative; }
.palm-live svg { width: 100%; height: 100%; }
.palm-live .outline { fill: var(--pv-soft); stroke: var(--pv); stroke-width: 3; stroke-linejoin: round; }
.palm-live.hover svg { animation: hover 1.8s ease-in-out infinite; }
.palm-live.read .outline { fill: #D6F1E3; stroke: var(--ok); }
.palm-live .ring { position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--pv); opacity: 0; animation: ring 1.8s ease-out infinite; }
.timer { font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: 13px; margin-top: 10px; }

/* Profile */
.plist { background: var(--paper); border: 1.5px solid var(--line); border-radius: 18px; }
.plist > div { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; font-size: 14px; }
.plist > div + div { border-top: 1px solid var(--line); }
.plist span { color: var(--ink-3); }
.plist b { font-weight: 600; text-align: right; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: var(--line); color: var(--ink-2); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.pv { background: var(--pv-soft); color: var(--pv); }
.mono { font-family: ui-monospace, monospace; }

/* Tab bar */
.tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 440px; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 8px 8px calc(8px + var(--safe-b)); background: rgba(255,255,255,.94); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
@media (min-width: 900px) { .tabbar { left: auto; transform: none; } }
.tabbar a { display: grid; justify-items: center; gap: 3px; text-decoration: none; color: var(--ink-3); font-size: 11px; font-weight: 600; padding: 4px 0; }
.tabbar a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--brand); }
.tabbar .tab-scan svg { width: 46px; height: 46px; padding: 11px; margin-top: -22px; border-radius: 16px; background: var(--brand); color: #fff; stroke: #fff; box-shadow: 0 10px 20px -10px rgba(242,84,45,.9); }

.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); max-width: 360px; width: calc(100% - 36px); z-index: 30;
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 14px; font-size: 14px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); animation: rise .25s ease-out; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
@keyframes rise { from { transform: translate(-50%, 10px); opacity: 0; } }
@keyframes scanline { 50% { top: 78%; } }
@keyframes hover { 50% { transform: translateY(-8px); } }
@keyframes ring { 0% { transform: scale(.6); opacity: .7; } 100% { transform: scale(1.15); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Fixes: grid children must be allowed to shrink; palm drawings outside the live view */
.stack > *, .pad > * { min-width: 0; }
.field input { width: 100%; min-width: 0; }
.pvcard .palm-ico .outline, .intro-art .outline { fill: #fff; stroke: var(--pv); stroke-width: 3; stroke-linejoin: round; }
.pvcard.on .palm-ico .outline { fill: #fff; stroke: var(--ok); }
.intro-art .outline { fill: rgba(255,255,255,.7); }
.link-what div, .plist > div { gap: 12px; }
.link-what b, .plist b { text-align: right; overflow-wrap: anywhere; }
.link-what span, .plist span { white-space: nowrap; }
