/* ──────────────────────────────────────────────────────────────
   Design tokens — Assetify system (paper, teal ink, hairlines,
   ledger figures, 6px radii in the app, 12–16px on marketing).
   Single source of truth: never hard-code a colour anywhere else.
   ────────────────────────────────────────────────────────────── */
:root {
  /* Brand — teal ink ramp. One accent, nothing else. */
  --brand-50:  #E9F1EF;
  --brand-100: #CFE3DF;
  --brand-200: #A9CFC8;
  --brand-300: #7FB5AD;
  --brand-400: #3F938A;
  --brand-500: #12867A;
  --brand-600: #0E6B61;   /* primary action */
  --brand-700: #0B564E;   /* hover / active text */
  --brand-800: #0A463F;

  /* Surfaces */
  --paper:   #F4F4EF;     /* page background */
  --surface: #FFFFFF;     /* cards, sidebar, topbar */
  --hair:    #E3E4DD;     /* every border */
  --ink:     #1C2B2A;     /* primary text */

  /* Neutral ramp (slate) */
  --slate-50:  #F8FAFC;
  --slate-100: #F1F5F9;
  --slate-200: #E2E8F0;
  --slate-300: #CBD5E1;
  --slate-400: #94A3B8;
  --slate-500: #64748B;
  --slate-600: #475569;
  --slate-700: #334155;

  --muted: var(--slate-400);
  --body:  var(--slate-600);
  --line:  var(--slate-100);
  --field-border: var(--slate-300);

  /* Semantic — reserved for state, never decoration */
  --success: #166534; --success-soft: #DCFCE7; --success-line: #BBF7D0;
  --warning: #92400E; --warning-soft: #FEF3C7; --warning-line: #FDE68A;
  --danger:  #991B1B; --danger-soft:  #FEE2E2; --danger-line:  #FECACA;
  --info:    #6B21A8; --info-soft:    #F3E8FF;
  --amber-ink: #B5820A;

  /* Chart palette (spec §2.2 / Assetify) */
  --chart-1: var(--brand-600);
  --chart-2: var(--amber-ink);
  --chart-3: var(--slate-500);
  --chart-4: var(--brand-300);

  /* Radius — 6px inside the app, larger only on marketing/auth */
  --r-sm: 4px;
  --r:    6px;
  --r-md: 6px;
  --r-lg: 12px;
  --r-xl: 16px;
  --pill: 9999px;

  /* Elevation — hairline, not shadow */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / .05);
  --shadow-md: 0 2px 8px rgba(28,43,42,.06), 0 1px 2px rgba(28,43,42,.04);
  --shadow-lg: 0 16px 40px rgba(10,70,63,.14), 0 2px 6px rgba(28,43,42,.05);

  /* Spacing — 4pt base */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px; --s-24: 96px;

  /* Type */
  --font: 'Instrument Sans', ui-sans-serif, -apple-system, 'Segoe UI', system-ui, sans-serif;
  /* Numbers use the interface face (owner's call): same as the sidebar, tabular digits. */
  --font-fig: 'Instrument Sans', ui-sans-serif, -apple-system, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Motion — functional only: 150–250 ms ease-out, no bounce */
  --ease: cubic-bezier(.16, 1, .3, 1);
  --t-fast: 150ms;
  --t-base: 220ms;

  /* Layout */
  --sidebar: 240px;
  --sidebar-collapsed: 64px;
  --topbar: 56px;
  --content-max: 1240px;

  /* Z-index ladder (spec §7 conventions) */
  --z-drawer: 40; --z-topbar: 30; --z-dropdown: 45; --z-modal: 60; --z-toast: 70;
}

/* A business's own colour never leaks into app chrome — only into the card
   preview, which reads --card-bg / --card-fg set inline on the preview node. */

/* ── Reset + base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--brand-700); }

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }

img, svg { display: block; max-width: 100%; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none;
        stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i-lg { width: 20px; height: 20px; }
svg.i-sm { width: 16px; height: 16px; }

h1, h2, h3, h4 { font-weight: 600; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p  { color: var(--body); }

/* Figures: the interface face with tabular digits — every money and quantity. */
.fig, .num {
  font-family: var(--font-fig);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -.01em;
}

/* Quiet chrome: 11px uppercase labels */
.label-micro {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600;
}

/* Utility scraps used across views — deliberately few. */
.row      { display: flex; align-items: center; gap: var(--s-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.col      { display: flex; flex-direction: column; }
.grow     { flex: 1; min-width: 0; }
.stack > * + * { margin-top: var(--s-4); }
.muted    { color: var(--muted); }
.secondary{ color: var(--body); }
.small    { font-size: 12px; }
.strong   { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right    { text-align: right; }
.center   { text-align: center; }
.mono     { font-family: var(--font-mono); font-size: 12px; }
.hidden   { display: none !important; }
.sr-only  {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ──────────────────────────────────────────────────────────────
   Component library — build once, reuse everywhere (spec §2.4).
   Every class here is used by the app, scanner, portal and site.
   ────────────────────────────────────────────────────────────── */

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px;
  font-size: 14px; font-weight: 500; white-space: nowrap;
  border: 1px solid transparent; border-radius: var(--r);
  transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.btn-lg { height: 40px; padding: 0 20px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }

.btn-primary   { background: var(--brand-600); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-700); color: #fff; }
.btn-secondary { background: var(--slate-100); color: var(--slate-700); border-color: var(--slate-200); }
.btn-secondary:hover:not(:disabled) { background: var(--slate-200); }
.btn-ghost     { background: var(--surface); color: var(--body); border-color: var(--hair); }
.btn-ghost:hover:not(:disabled) { background: var(--paper); color: var(--ink); }
.btn-quiet     { background: transparent; color: var(--body); }
.btn-quiet:hover:not(:disabled) { background: var(--paper); color: var(--ink); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #7F1D1D; color: #fff; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

.btn-icon {
  width: 34px; height: 34px; padding: 0;
  background: var(--surface); border-color: var(--hair); color: var(--slate-500);
}
.btn-icon:hover:not(:disabled) { background: var(--paper); color: var(--ink); }
.btn-icon-danger { width: 34px; height: 34px; padding: 0; background: var(--surface);
                   border-color: var(--danger-line); color: var(--danger); }
.btn-icon-danger:hover { background: var(--danger-soft); }

/* Loading state keeps the button width so layout never jumps (spec §2.4). */
.btn[data-loading="true"] { color: transparent !important; position: relative; pointer-events: none; }
.btn[data-loading="true"]::after {
  content: ""; position: absolute; width: 16px; height: 16px;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
  color: #fff; animation: spin .6s linear infinite;
}
.btn-ghost[data-loading="true"]::after, .btn-secondary[data-loading="true"]::after { color: var(--slate-500); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Surfaces ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.card-pad  { padding: var(--s-5); }
.card-pad-lg { padding: var(--s-6); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: 12px var(--s-5); border-bottom: 1px solid var(--line);
}
.card-head h2, .card-head h3 { font-size: 14px; font-weight: 600; color: var(--ink); }
.card-head a { font-size: 13px; color: var(--body); }
.card-head a:hover { color: var(--brand-700); }
.card-body { padding: var(--s-5); }
.card-foot { padding: 12px var(--s-5); border-top: 1px solid var(--line); background: var(--paper); }

/* ── Forms ────────────────────────────────────────────────── */
.field-group { display: block; }
.field-group + .field-group { margin-top: var(--s-5); }
/* Side by side, or inside a container that already spaces its children, the gap does the work. */
:is(.row, .col, .stack) > .field-group + .field-group,
[style*="display:grid"] > .field-group + .field-group { margin-top: 0; }
.label { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 500; color: var(--slate-700); }
.label .req { color: #EF4444; }
.help  { margin-top: 4px; font-size: 12px; color: var(--muted); }
.error { margin-top: 4px; font-size: 12px; color: var(--danger); }

.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 12px;
  font-size: 14px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--field-border); border-radius: var(--r);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.textarea { height: auto; min-height: 88px; padding: 8px 12px; line-height: 1.5; resize: vertical; }
.select { appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748B' stroke-width='1.5'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand-500) 22%, transparent);
}
.input[aria-invalid="true"], .input.is-error { border-color: var(--danger); }
.input:read-only, .input[readonly] { background: var(--slate-50); color: var(--slate-600); border-color: var(--slate-200); }
.input::placeholder { color: var(--muted); }
.input-num  { text-align: right; font-family: var(--font-fig); font-variant-numeric: tabular-nums; }
.input-code { font-family: var(--font-mono); letter-spacing: .04em; }

/* Icon + input in one bordered box */
.field { display: flex; align-items: center; gap: 8px; padding-left: 10px;
         background: var(--surface); border: 1px solid var(--field-border);
         border-radius: var(--r); color: var(--muted); transition: box-shadow var(--t-fast); }
.field > .input { border: 0; background: transparent; padding-left: 0; }
.field:focus-within { border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand-500) 16%, transparent); }
.field .input:focus { box-shadow: none; border-color: transparent; }

.checkbox { display: inline-flex; align-items: flex-start; gap: 8px; font-size: 14px; color: var(--slate-700); }
.checkbox input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--brand-600); }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--slate-300); border-radius: var(--pill);
               transition: background-color var(--t-fast); cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
                      background: #fff; border-radius: 50%; transition: transform var(--t-fast); }
.switch input:checked + span { background: var(--brand-600); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand-500); outline-offset: 2px; }
/* A switch with words: <label class="toggle"><span class="switch"><input …><span></span></span> Text</label>.
   .switch is only the 40×22 track; the words never go inside it. */
.toggle { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--slate-700); cursor: pointer; }
.toggle:has(input:disabled) { cursor: default; opacity: .75; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
  position: sticky; top: 0; z-index: 1;
  padding: 10px var(--s-4); text-align: left; background: var(--slate-50);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); border-bottom: 1px solid var(--hair); white-space: nowrap;
}
.table tbody td { height: 44px; padding: 8px var(--s-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--brand-50); }
.table .num, .table .right { text-align: right; }
.table .pos { color: var(--success); font-weight: 600; }
.table .neg { color: var(--ink); font-weight: 600; }

/* ── Badges & chips ───────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  padding: 2px 8px; border-radius: var(--pill); font-size: 11px; font-weight: 500;
}
.badge-neutral { background: var(--slate-100); color: var(--slate-600); }
.badge-brand   { background: var(--brand-50);  color: var(--brand-800); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warn    { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-500); flex: none; }
.dot-warn { background: var(--amber-ink); } .dot-danger { background: var(--danger); }

/* ── Alerts ───────────────────────────────────────────────── */
.alert { display: flex; align-items: flex-start; gap: 8px; padding: 12px var(--s-4);
         border: 1px solid; border-radius: var(--r); font-size: 14px; }
.alert-success { background: var(--brand-50); border-color: var(--brand-200); color: var(--brand-800); }
.alert-error   { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.alert-warn    { background: var(--warning-soft); border-color: var(--warning-line); color: var(--warning); }
.alert-info    { background: var(--slate-50); border-color: var(--hair); color: var(--body); }

/* ── Stat tiles ───────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); }
.tile { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r);
        padding: var(--s-4) var(--s-5); box-shadow: var(--shadow-sm); }
.tile-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tile-value { margin-top: 6px; font-family: var(--font-fig); font-variant-numeric: tabular-nums;
              font-size: 28px; font-weight: 600; letter-spacing: -.02em; line-height: 1; color: var(--ink); }
.tile-delta { display: inline-flex; align-items: center; gap: 4px; margin-top: 10px;
              padding: 3px 8px; border-radius: var(--pill); font-size: 12px; font-weight: 500;
              background: var(--brand-50); color: var(--brand-700); }
.tile-delta.down { background: var(--danger-soft); color: var(--danger); }
.tile-delta.flat { background: var(--slate-100); color: var(--slate-500); }

/* KPI strip variant (hairline-separated, no gaps) */
.kpi-row { display: grid; grid-template-columns: repeat(2, 1fr); background: var(--surface);
           border: 1px solid var(--hair); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.kpi { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--hair); }
@media (min-width: 1024px) {
  .kpi-row { grid-template-columns: repeat(4, 1fr); }
  .kpi { border-top: 0; border-left: 1px solid var(--hair); }
  .kpi:first-child { border-left: 0; }
}

/* ── App shell ────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
           background: var(--surface); border-right: 1px solid var(--hair); padding: var(--s-4) 0; }
.sidebar-head { padding: 0 var(--s-4) var(--s-4); }
.biz { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px;
       border-radius: var(--r); transition: background-color var(--t-fast); }
.biz:hover { background: var(--paper); }
.biz-avatar { width: 30px; height: 30px; border-radius: var(--r); background: var(--brand-600);
              color: #fff; display: flex; align-items: center; justify-content: center;
              font-size: 13px; font-weight: 600; flex: none; }
.biz b { display: block; font-size: 14px; font-weight: 600; }
.biz small { color: var(--muted); font-size: 12px; }

.nav { flex: 1; overflow-y: auto; }
.nav-section { padding: var(--s-4) var(--s-5) 6px; font-size: 10px; font-weight: 600;
               text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px var(--s-4) 8px 18px;
            font-size: 14px; font-weight: 500; color: var(--slate-500);
            border-left: 2px solid transparent; transition: background-color var(--t-fast), color var(--t-fast); }
.nav-item:hover { background: var(--paper); color: var(--ink); }
.nav-item.is-active { border-left-color: var(--brand-600); background: var(--brand-50);
                      color: var(--brand-700); font-weight: 600; }
.nav-item .count { margin-left: auto; font-size: 11px; color: var(--muted); }

.topbar { position: sticky; top: 0; z-index: var(--z-topbar); height: var(--topbar);
          display: flex; align-items: center; gap: var(--s-4); padding: 0 var(--s-6);
          background: rgba(255,255,255,.95); backdrop-filter: blur(12px);
          border-bottom: 1px solid var(--hair); }
.main { display: flex; flex-direction: column; min-width: 0; }
.content { flex: 1; width: 100%; max-width: var(--content-max); padding: var(--s-6) var(--s-6) var(--s-10); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between;
             gap: var(--s-4); margin-bottom: var(--s-5); }
.page-head h1 { font-size: 24px; }
.page-head p { color: var(--muted); margin-top: 4px; font-size: 14px; }

.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-50);
          color: var(--brand-700); display: flex; align-items: center; justify-content: center;
          font-size: 12px; font-weight: 600; flex: none; }

.search { flex: 1; max-width: 420px; height: 34px; display: flex; align-items: center; gap: 8px;
          padding: 0 10px; background: var(--surface); border: 1px solid var(--hair);
          border-radius: var(--r); color: var(--muted); font-size: 13px; }
.search kbd { margin-left: auto; padding: 1px 5px; font-family: var(--font-mono); font-size: 11px;
              border: 1px solid var(--hair); border-radius: var(--r-sm); background: var(--paper); }

/* ── Drawer / modal / toast ───────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(28,43,42,.45); z-index: var(--z-drawer);
           opacity: 0; transition: opacity var(--t-base) var(--ease); }
.overlay[data-open="true"] { opacity: 1; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 92vw;
          background: var(--surface); border-left: 1px solid var(--hair);
          display: flex; flex-direction: column; z-index: var(--z-modal);
          transform: translateX(100%); transition: transform var(--t-base) var(--ease); }
.drawer[data-open="true"] { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between;
               padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--hair); }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--s-5); }
.drawer-foot { display: flex; justify-content: flex-end; gap: 8px;
               padding: var(--s-4) var(--s-5); border-top: 1px solid var(--hair); background: var(--paper); }

.modal { position: fixed; inset: 0; z-index: var(--z-modal); display: flex;
         align-items: center; justify-content: center; padding: var(--s-4); }
.modal-card { position: relative; width: 100%; max-width: 420px; background: var(--surface);
              border: 1px solid var(--hair); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }

.toasts { position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: var(--z-toast);
          display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 380px;
         padding: 12px var(--s-4); background: var(--ink); color: #fff;
         border-radius: var(--r); box-shadow: var(--shadow-lg); font-size: 14px;
         animation: toast-in var(--t-base) var(--ease); }
.toast-error { background: var(--danger); }
.toast a { text-decoration: underline; font-weight: 500; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Empty state & skeleton ───────────────────────────────── */
.empty { display: flex; flex-direction: column; align-items: center; gap: 12px;
         padding: 56px var(--s-4); text-align: center; }
.empty p { font-size: 14px; color: var(--muted); }
.empty-icon { width: 44px; height: 44px; border-radius: 50%; background: var(--paper);
              color: var(--slate-300); display: flex; align-items: center; justify-content: center; }

.skeleton { background: linear-gradient(90deg, var(--slate-100) 25%, var(--slate-50) 37%, var(--slate-100) 63%);
            background-size: 400% 100%; border-radius: var(--r-sm); animation: shimmer 1.2s ease-in-out infinite; }
.skeleton-line { height: 12px; margin: 6px 0; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ── Segmented control & chips (charts, filters) ──────────── */
.seg { display: inline-flex; border-radius: var(--r); overflow: hidden; }
.seg button { padding: 0 12px; height: 34px; font-size: 13px; color: var(--body);
              background: var(--surface); border: 1px solid var(--hair); }
.seg button + button { border-left: 0; }
.seg button:first-child { border-radius: var(--r) 0 0 var(--r); }
.seg button:last-child  { border-radius: 0 var(--r) var(--r) 0; }
.seg button[aria-pressed="true"] { background: var(--brand-600); border-color: var(--brand-600);
                                   color: #fff; font-weight: 600; }
.chip-toggle { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px;
               font-size: 12px; line-height: 1; color: var(--body);
               background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r); }
.chip-toggle:hover { background: var(--paper); }
.chip-toggle .swatch { width: 9px; height: 9px; border-radius: 2px; opacity: .3; transition: opacity var(--t-fast); }
.chip-toggle[aria-pressed="true"] { border-color: var(--brand-200); background: var(--brand-50);
                                    color: var(--brand-700); font-weight: 600; }
.chip-toggle[aria-pressed="true"] .swatch { opacity: 1; }

/* ── Entrance animation (auth / marketing only) ───────────── */
@keyframes floatUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.rise   { animation: floatUp .6s var(--ease) both; }
.rise-1 { animation-delay: .05s; } .rise-2 { animation-delay: .12s; }
.rise-3 { animation-delay: .19s; } .rise-4 { animation-delay: .26s; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: var(--z-drawer); width: 288px; max-width: 82%;
             transform: translateX(-100%); transition: transform var(--t-base) var(--ease); }
  .sidebar[data-open="true"] { transform: none; box-shadow: var(--shadow-lg); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .content { padding: var(--s-4) var(--s-4) var(--s-10); }
}
@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr; }
  .drawer { width: 100%; }
}

/* ── Sign-up / sign-in: business or card holder ─────────── */
.who-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.who-opt { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--field-border); border-radius: 10px;
  background: var(--surface); color: var(--slate-700); text-decoration: none; transition: border-color var(--t-fast), background-color var(--t-fast); }
.who-opt:hover { border-color: var(--brand-500); color: var(--ink); }
.who-opt.is-on { border-color: var(--brand-600); background: color-mix(in oklab, var(--brand-500) 7%, var(--surface)); color: var(--ink); box-shadow: inset 0 0 0 1px var(--brand-600); }
.who-opt svg.i { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--brand-700); }
.who-opt span { display: grid; gap: 2px; min-width: 0; }
.who-opt b { font-size: 14px; font-weight: 600; }
.who-opt small { font-size: 12px; color: var(--muted); line-height: 1.35; }

/* ── Confirmation dialog (layouts/app: form[data-confirm]) ── */
.confirm-dialog { border: 0; padding: 0; background: transparent; max-width: 420px; width: calc(100% - 32px); }
.confirm-dialog::backdrop { background: rgba(28, 43, 42, .45); }
.confirm-dialog form { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: 24px; display: grid; gap: 10px; }
.confirm-dialog[open] form { animation: confirm-in .18s var(--ease); }
.confirm-ic { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--danger-soft, #FEF2F2); color: var(--danger); }
.confirm-dialog h2 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
.confirm-dialog p { font-size: 14px; color: var(--body); line-height: 1.5; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
@keyframes confirm-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

/* ── Analytics (owner dashboard, spec §6.10) ─────────────────
   Chart palette validated with the dataviz checks on #FFFFFF:
   s1 teal / s2 amber / s3 indigo pass lightness, chroma, CVD and
   contrast all-pairs; s4 slate is the deliberate "gone" gray and is
   always paired with visible labels. Heatmap uses the brand ramp. */
.an { --an-s1: #0A8A7B; --an-s2: var(--amber-ink); --an-s3: #6366F1; --an-s4: var(--slate-400);
      --an-prev: var(--slate-400); --an-grid: var(--line); --an-axis: var(--slate-200);
      display: flex; flex-direction: column; gap: var(--s-4); }
.an-head { margin-bottom: 0; }
.an-head p { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.an-range { color: var(--ink); font-weight: 500; }
.an-sep { color: var(--slate-300); }

/* Filter bar: one block above everything it scopes. */
.an-filters { display: flex; flex-direction: column; gap: 12px; padding: 14px var(--s-4); }
.an-filters-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; }
.an-filters-row + .an-filters-row { padding-top: 12px; border-top: 1px solid var(--line); }
.an-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-right: auto; }
.an-presets .chip-toggle { height: 32px; padding: 0 12px; font-size: 13px; }
.an-dates { display: flex; align-items: flex-end; gap: 6px; }
.an-dash { padding-bottom: 8px; color: var(--muted); }
.an-date, .an-select { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.an-date .input { height: 32px; width: 150px; font-size: 13px; padding: 0 10px; }
.an-field-label { font-size: 12px; font-weight: 500; color: var(--slate-500); }
.an-selects { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; }
.an-selects .select { height: 34px; font-size: 13px; }
.an-actions { display: flex; gap: 6px; align-items: center; }

/* KPI grid: hairline-separated cells, four per row on desktop, two on phones. */
.an-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: hidden; }
.an-kpi { padding: 16px 20px 14px; border-left: 1px solid var(--line); border-top: 1px solid var(--line);
          min-width: 0; margin: -1px 0 0 -1px; }
.an-kpi-label { font-size: 13px; color: var(--slate-500); font-weight: 500; white-space: nowrap;
                overflow: hidden; text-overflow: ellipsis; cursor: help; }
.an-kpi-value { margin-top: 6px; font-size: 26px; font-weight: 600; line-height: 1.1; color: var(--ink);
                letter-spacing: -.02em; white-space: nowrap; }
.an-kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; min-height: 22px; }
.an-kpi-prev { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-delta { margin-top: 0; padding: 2px 7px; gap: 3px; white-space: nowrap; flex: none; }
.an-delta .i { width: 12px; height: 12px; stroke-width: 2.25; }
.an-delta.up { background: var(--success-soft); color: var(--success); }

/* Chart cards */
.an-card { display: flex; flex-direction: column; min-width: 0; }
.an-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
                padding: 16px 20px 0; }
.an-card-head h2 { font-size: 15px; font-weight: 600; color: var(--ink); }
.an-card-head p { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.an-card-body { padding: 14px 20px 18px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.an-seg button { height: 30px; font-size: 12.5px; }
.an-peak { flex: none; gap: 5px; }
.an-grid { display: grid; gap: var(--s-4); }
.an-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.an-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.an-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
            flex: 1; padding: 36px 24px 40px; text-align: center; }
.an-empty p { max-width: 360px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.an-note { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--slate-500); }

.an-summary { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; }
.an-summary-value { display: flex; align-items: center; gap: 10px; }
.an-summary-value > .fig { font-size: 28px; font-weight: 600; line-height: 1; color: var(--ink);
                           letter-spacing: -.02em; }
.an-summary-unit { font-size: 13px; color: var(--muted); }
.an-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--body); }
.an-key { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--body); }
.an-line-key { width: 14px; height: 2px; border-radius: 2px; background: var(--an-s1); }
.an-line-key.an-prev, .an-swatch.an-prev { background: var(--an-prev); }
.an-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.an-s1 { background: var(--an-s1); } .an-s2 { background: var(--an-s2); }
.an-s3 { background: var(--an-s3); } .an-s4 { background: var(--an-s4); }

/* SVG plots (drawn by analytics.js). Height includes the axis band. */
.an-plot { position: relative; height: 200px; outline: none; }
.an-plot-lg { height: 260px; }
.an-plot:focus-visible { box-shadow: 0 0 0 2px var(--brand-200); border-radius: var(--r-sm); }
.an-plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.an-plot text { font-family: var(--font); font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.an-dim { opacity: .45; transition: opacity var(--t-fast); }

/* Tooltip (one per page) */
.an-tip { position: fixed; z-index: var(--z-dropdown); pointer-events: none; min-width: 140px; max-width: 260px;
          padding: 8px 10px; background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r);
          box-shadow: var(--shadow-lg); font-size: 12px; color: var(--body); opacity: 0;
          transition: opacity 90ms linear; }
.an-tip[data-open="true"] { opacity: 1; }
.an-tip-title { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.an-tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.6; }
.an-tip-row b { margin-left: auto; padding-left: 10px; color: var(--ink); font-weight: 600;
                font-family: var(--font-fig); font-variant-numeric: tabular-nums; }
.an-tip-value { color: var(--ink); font-weight: 600; font-size: 13px; }

/* Split totals (new vs returning) */
.an-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.an-split-item { display: grid; gap: 2px; }
.an-split-item b { font-size: 22px; font-weight: 600; color: var(--ink); line-height: 1.15; }
.an-split-item small { font-size: 12px; color: var(--muted); }

/* 100% stacked bar + legend list (segments, wallet) */
.an-stack { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; background: var(--line); }
.an-stack-seg { flex-basis: 0; min-width: 3px; transition: filter var(--t-fast); }
.an-stack-seg:hover, .an-bar-fill:hover { filter: brightness(1.12); }
.an-legend-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.an-legend-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.an-legend-list li:first-child { border-top: 0; }
.an-legend-list b { display: block; font-size: 13.5px; font-weight: 500; color: var(--ink); }
.an-legend-list small { display: block; font-size: 12px; color: var(--muted); }
.an-legend-value { font-size: 14px; font-weight: 600; color: var(--ink); min-width: 40px; text-align: right; }
.an-legend-pct { font-size: 12.5px; color: var(--muted); min-width: 52px; text-align: right; }

/* Bar lists (programs, rewards, staff, locations) */
.an-bars { list-style: none; margin: 0; padding: 6px 20px 14px; }
.an-bars li { padding: 11px 0; border-top: 1px solid var(--line); }
.an-bars li:first-child { border-top: 0; }
.an-bar-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.an-bar-name { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; color: var(--ink); min-width: 0; }
.an-bar-value { font-size: 14px; font-weight: 600; color: var(--ink); }
.an-bar-track { display: block; height: 8px; margin: 7px 0 6px; border-radius: 4px; background: var(--line); }
.an-bar-fill { display: block; height: 100%; min-width: 3px; border-radius: 4px; background: var(--an-s1); }
.an-bar-fill[style*="width:0%"] { min-width: 0; }
.an-bar-sub { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); }
.an-bar-sub .badge { font-size: 11px; }
.an-avatar { width: 22px; height: 22px; font-size: 10px; }

/* Heatmap: weekday rows × trading hours, brand ramp, totals on the right. */
.an-heat { display: flex; flex-direction: column; gap: 3px; }
.an-heat-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) 96px; align-items: center; gap: 10px; }
.an-heat-day { font-size: 12px; color: var(--slate-500); }
.an-heat-cells { display: grid; grid-template-columns: repeat(var(--an-cols), minmax(0, 1fr)); gap: 3px; }
.an-heat-cell { display: block; height: 26px; border-radius: 3px; background: var(--slate-100); }
.an-heat-cell.l1 { background: var(--brand-100); }
.an-heat-cell.l2 { background: var(--brand-200); }
.an-heat-cell.l3 { background: var(--brand-300); }
.an-heat-cell.l4 { background: var(--brand-500); }
.an-heat-cell.l5 { background: var(--brand-800); }
.an-heat-cells .an-heat-cell:hover { outline: 2px solid var(--ink); outline-offset: -1px; }
.an-heat-hour { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.an-heat-axis { margin-top: 2px; }
.an-heat-total { position: relative; display: flex; align-items: center; justify-content: flex-end; height: 26px;
                 font-size: 12.5px; color: var(--ink); }
.an-heat-total .fig { position: relative; }
.an-heat-bar { position: absolute; left: 0; top: 50%; height: 6px; margin-top: -3px; max-width: 56%;
               border-radius: 3px; background: var(--brand-200); }
.an-heat-total-head { height: auto; font-size: 11px; color: var(--muted); }
.an-scale { display: flex; align-items: center; justify-content: flex-end; gap: 4px; font-size: 11.5px; color: var(--muted); }
.an-scale .an-heat-cell { width: 14px; height: 10px; border-radius: 2px; }
.an-scale span:first-child { margin-right: 4px; } .an-scale span:last-child { margin-left: 4px; }

/* Table view */
.an-details summary { cursor: pointer; font-size: 12.5px; color: var(--slate-500); width: max-content; }
.an-details summary:hover { color: var(--brand-700); }
.an-details .table-wrap { max-height: 320px; overflow: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: var(--r); }
.an-details .table tbody td { height: 36px; font-size: 13px; }

@media (max-width: 1180px) {
  .an-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .an-selects { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .an-actions { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .an-grid-2, .an-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .an-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .an-head { flex-direction: column; align-items: stretch; }
  .an-head .btn { align-self: flex-start; }
  .an-presets { margin: 0 -16px; padding: 0 16px 2px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; width: calc(100% + 32px); }
  .an-presets::-webkit-scrollbar { display: none; }
  .an-presets .chip-toggle { flex: none; }
  .an-heat-total-head { visibility: hidden; }
  .an-dates { width: 100%; }
  .an-date { flex: 1; }
  .an-date .input { width: 100%; }
  .an-kpi { padding: 14px 14px 12px; }
  .an-kpi-value { font-size: 22px; }
  .an-kpi-label { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 2.6em; line-height: 1.3; }
  .an-kpi-prev { display: none; }
  .an-card-head { flex-direction: column; padding: 14px 16px 0; }
  .an-card-body { padding: 12px 16px 16px; }
  .an-bars { padding: 4px 16px 12px; }
  .an-plot-lg { height: 220px; }
  .an-heat-row { grid-template-columns: 28px minmax(0, 1fr) 34px; gap: 6px; }
  .an-heat-cells { gap: 2px; }
  .an-heat-cell { height: 20px; border-radius: 2px; }
  .an-heat-total { height: 20px; }
  .an-heat-bar { display: none; }
}

/* ── Staff: one-time PIN reveal ───────────────────────────── */
.pin-reveal { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.pin-digits { font-size: 30px; font-weight: 600; letter-spacing: .18em; color: var(--ink); background: var(--surface);
  border: 1px solid var(--hair); border-radius: 10px; padding: 6px 16px; }

/* ── Customer page: activity timeline + profile ───────────── */
.tl-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px var(--s-5) 0; }
.tl-filters .chip-toggle { height: 30px; padding: 0 11px; font-size: 12.5px; text-decoration: none; }
.tl-filters .tl-sep { width: 1px; align-self: stretch; margin: 4px 4px; background: var(--hair); }
.tl { padding: 4px var(--s-5) var(--s-4); }
.tl-day { padding-top: 14px; }
.tl-day-label { position: sticky; top: var(--topbar); z-index: 1; padding: 6px 0; background: var(--surface);
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tl-list { list-style: none; margin: 0; padding: 0; }
.tl-item { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; padding: 9px 0; }
.tl-item::before { content: ""; position: absolute; left: 13.5px; top: 0; bottom: 0; width: 1px; background: var(--hair); }
.tl-list .tl-item:first-child::before { top: 18px; }
.tl-list .tl-item:last-child::before { bottom: calc(100% - 18px); }
.tl-list .tl-item:only-child::before { display: none; }
.tl-dot { position: relative; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--paper); color: var(--slate-500); box-shadow: 0 0 0 3px var(--surface); }
.tl-dot .i { width: 14px; height: 14px; }
.tl-dot[data-tone="brand"]   { background: var(--brand-50); color: var(--brand-700); }
.tl-dot[data-tone="success"] { background: var(--success-soft); color: var(--success); }
.tl-dot[data-tone="warn"]    { background: var(--warning-soft); color: var(--amber-ink); }
.tl-dot[data-tone="danger"]  { background: var(--danger-soft); color: var(--danger); }
.tl-body { min-width: 0; padding-top: 4px; }
.tl-title { font-size: 14px; color: var(--ink); line-height: 1.35; }
.tl-title .badge { margin-left: 6px; vertical-align: 1px; }
.tl-item.is-struck .tl-title-text { text-decoration: line-through; text-decoration-color: var(--slate-300); color: var(--muted); }
.tl-detail { margin-top: 2px; font-size: 13px; color: var(--body); }
.tl-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.tl-meta span { display: inline-flex; align-items: center; gap: 4px; }
.tl-meta .i { width: 12px; height: 12px; }
.tl-prog { color: var(--body); font-weight: 500; }
.tl-side { padding-top: 4px; text-align: right; white-space: nowrap; }
.tl-delta { font-size: 14px; font-weight: 600; color: var(--ink); }
.tl-delta.pos { color: var(--success); }
.tl-time { margin-top: 2px; font-size: 12px; color: var(--muted); }
.tl-foot { display: flex; justify-content: center; padding: 4px var(--s-5) var(--s-5); }
.cust-profile { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 13.5px; }
.cust-profile dt { color: var(--muted); }
.cust-profile dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.seg-field { display: flex; width: 100%; }
.seg-field button { flex: 1; padding: 0 8px; white-space: nowrap; }
.input[readonly] { background: var(--paper); color: var(--body); }
@media (max-width: 640px) {
  .tl-filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 12px 16px 2px; }
  .tl-filters::-webkit-scrollbar { display: none; }
  .tl-filters .chip-toggle { flex: none; }
  .tl { padding: 4px 16px 12px; }
  .tl-item { gap: 10px; }
}

/* ── Staff: manage dialog, add panel ──────────────────────── */
.staff-dialog { border: 0; padding: 0; width: min(460px, calc(100% - 24px)); border-radius: var(--r-lg); background: var(--surface);
  box-shadow: var(--shadow-lg); text-align: left; }
.staff-dialog::backdrop { background: rgba(28, 43, 42, .45); }
.staff-dialog-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--hair); }
.staff-dialog-head b { display: block; }
.staff-dialog-head small { display: block; font-size: 12px; }
.staff-block { padding: 16px 18px; border-bottom: 1px solid var(--hair); display: block; }
.staff-block .label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.staff-danger { border-bottom: 0; background: var(--paper); }
.staff-seg { margin: 14px 20px 0; display: grid; grid-template-columns: 1fr 1fr; }
.staff-seg button { font-size: 13px; }
.pw-field { position: relative; display: block; }
.pw-field .input { padding-right: 40px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border: 0; background: none;
  color: var(--muted); cursor: pointer; border-radius: 6px; display: grid; place-items: center; }
.pw-eye:hover { color: var(--ink); background: var(--paper); }

/* Native dialogs lose their auto margin to the global reset; centre them again. */
.staff-dialog[open], .confirm-dialog[open] { margin: auto; inset: 0; position: fixed; max-height: calc(100vh - 32px); overflow-y: auto; }

/* ──────────────────────────────────────────────────────────────
   Card preview — the one component that renders a card design JSON
   as an Apple Wallet pass, a Google Wallet card, or a web card.
   Used by the designer, the join page, the portal and the landing
   page, so it ships in every bundle. Namespace: .cpv
   The business colour never leaks outside this block: it arrives as
   --card-bg / --card-fg / --card-label set inline on .cpv.
   ────────────────────────────────────────────────────────────── */
.cpv {
  --card-bg: #1C2B2A;
  --card-fg: #FFFFFF;
  --card-label: rgba(255, 255, 255, .62);
  /* The pass is drawn in the phone's own face, not the app's: on an
     iPhone every field is SF Pro, so the preview uses it where it exists. */
  --card-font: -apple-system, 'SF Pro Text', 'SF Pro Display', var(--font, system-ui), sans-serif;
  width: 340px;
  border-radius: 16px;
  background: var(--card-bg);
  color: var(--card-fg);
  box-shadow:
    0 0 0 .5px rgba(0, 0, 0, .10),
    0 1px 2px rgba(0, 0, 0, .06),
    0 10px 24px -6px rgba(0, 0, 0, .18),
    0 28px 56px -18px rgba(0, 0, 0, .22);
  overflow: hidden;
  position: relative;
  isolation: isolate;
  transform-origin: top center;
  font-family: var(--card-font);
  -webkit-font-smoothing: antialiased;
}
/* Lacquer: a faint top-down light and an inner hairline, the way a pass
   catches the light in Wallet. Sits under the content, over the colour. */
.cpv::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, .10) 0%, rgba(255, 255, 255, 0) 38%);
  box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .14);
}
.cpv * { box-sizing: border-box; }
.cpv-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 18px 0; min-height: 50px;
}
.cpv-brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; letter-spacing: -.01em; min-width: 0; }
.cpv-brand b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cpv-mark {
  width: 28px; height: 28px; border-radius: 7px; flex: none;
  background: var(--card-fg); color: var(--card-bg);
  font-weight: 700; font-size: 11px; line-height: 28px; letter-spacing: .02em; text-align: center;
  font-style: normal; overflow: hidden;
}
.cpv-mark img { width: 100%; height: 100%; object-fit: contain; }
.cpv-lbl {
  font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--card-label); font-weight: 600; line-height: 1.3;
}
.cpv-val { font-size: 21px; font-weight: 500; letter-spacing: -.015em; line-height: 1.2; }
.cpv-val-lg { font-size: 34px; }
.cpv-val-sm { font-size: 15px; font-weight: 500; letter-spacing: -.005em; }
.cpv-fig { font-family: var(--card-font); font-variant-numeric: tabular-nums; font-weight: 500; letter-spacing: -.01em; }
/* Wallet sets its numbers in SF with tabular figures, never a serif. */
.cpv-apple .cpv-fig, .cpv-google .cpv-fig { font-family: var(--card-font); font-weight: 500; letter-spacing: -.01em; }
.cpv-top .cpv-fig { font-size: 22px; line-height: 1.1; }
.cpv-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 14px 18px 0; }
.cpv-fields > div:nth-child(even) { text-align: right; }
.cpv-fields-3 { grid-template-columns: repeat(3, 1fr); }
.cpv-fields-3 > div:nth-child(even) { text-align: left; }
.cpv-fields-3 > div:last-child { text-align: right; }
/* Secondary and auxiliary rows: 1–4 fields, first left, last right, the rest between. */
.cpv-fields-n { grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); }
.cpv-fields-n > div { text-align: left; min-width: 0; }
.cpv-fields-n > div:last-child:not(:first-child) { text-align: right; }
.cpv-fields-n .cpv-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Header: up to three fields at the top right, as Wallet lays them out. */
.cpv-heads { display: flex; gap: 14px; text-align: right; min-width: 0; }
.cpv-heads > div { min-width: 0; }
.cpv-heads .cpv-val { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.cpv-top .cpv-heads > div + div .cpv-val { font-size: 17px; }

/* Apple: strip band under the header. Without an image it is the card
   colour lifted by one step, so the name has a surface to sit on. */
.cpv-strip {
  margin-top: 14px; min-height: 112px;
  background-color: rgba(255, 255, 255, .06);
  background-image: linear-gradient(160deg, rgba(255, 255, 255, .12) 0%, rgba(255, 255, 255, 0) 60%, rgba(0, 0, 0, .05) 100%);
  background-size: cover; background-position: center;
  display: flex; align-items: flex-end; padding: 16px 18px;
}
.cpv-strip[style*="background-image"] { box-shadow: inset 0 -40px 40px -20px rgba(0, 0, 0, .35); }
/* No image: just enough band to carry the primary field, no empty slab. */
.cpv-strip-plain { min-height: 0; padding-top: 22px; }
.cpv-strip .cpv-val { font-size: 26px; font-weight: 400; letter-spacing: -.02em; }

/* Google: hero band on top */
.cpv-hero {
  height: 88px; padding: 0 18px; display: flex; align-items: center;
  font-size: 13px; letter-spacing: .01em; color: var(--card-fg);
  background: linear-gradient(120deg, rgba(255,255,255,.16), rgba(0,0,0,.18));
  background-size: cover; background-position: center;
}

/* Stamp grid: even rows, circles sized to the card, never a lone wrapped stamp. */
.cpv-stamps { display: grid; grid-template-columns: repeat(var(--cols, 5), 1fr); gap: 10px 8px;
  justify-items: center; padding: 18px 18px 0; }
.cpv-stamps i {
  width: 100%; max-width: 38px; aspect-ratio: 1; border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--card-fg) 30%, transparent);
  background: color-mix(in srgb, var(--card-fg) 6%, transparent);
  display: inline-flex; align-items: center; justify-content: center;
}
.cpv-stamps i.on { background: var(--card-fg); border-color: var(--card-fg); }
.cpv-stamps i.on::after {
  content: ""; width: 6px; height: 11px;
  border: solid var(--card-bg); border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px);
}
.cpv-stamps + .cpv-serial, .cpv-stamps + .cpv-qr { margin-top: 18px; }

/* Barcode: a white tile sized to the code and centred, as Wallet draws it. */
.cpv-qr {
  width: fit-content; margin: 22px auto 20px; padding: 10px 10px 8px; border-radius: 8px;
  background: #fff; color: #111;
  box-shadow: 0 0 0 .5px rgba(0, 0, 0, .12);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.cpv-qr img, .cpv-qr svg { width: 112px; height: 112px; display: block; }
.cpv-qr small { font-family: var(--card-font); font-size: 12.5px; font-weight: 600; letter-spacing: .06em; color: #1C1C1E; font-variant-numeric: tabular-nums; }

/* Web variant — flat surface card, no wallet chrome */
.cpv-web { border-radius: 14px; }
.cpv-web .cpv-body { padding: 20px; display: grid; gap: 14px; }
.cpv-web .cpv-rowfields { display: flex; justify-content: space-between; gap: 16px; }

.cpv-back { padding: 0 18px 18px; display: grid; gap: 10px; }
.cpv-back .cpv-lbl { margin-bottom: 2px; }
.cpv-back p { color: var(--card-label); font-size: 12px; line-height: 1.45; margin: 0; }

.cpv-status {
  position: absolute; top: 18px; right: 18px;
  font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, .16);
}
.cpv-expired { background: rgba(153, 27, 27, .85); }

/* Serial line shown when a card has no barcode image to draw. */
.cpv-serial {
  margin: 18px 18px 20px; padding-top: 14px;
  border-top: .5px solid color-mix(in srgb, var(--card-fg) 18%, transparent);
  font-family: var(--card-font); font-size: 11px; font-variant-numeric: tabular-nums;
  letter-spacing: .06em; color: var(--card-label);
}
.cpv-heads > div:only-child .cpv-val { max-width: 210px; }

