/* CardKeep styles — mobile-first, responsive, no horizontal scroll.
   Touch targets >= 44px. Shared across index / app / admin / learn. */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 17px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: hidden;
  /* card-security micro-dot texture — the signature motif, very faint */
  background-image: radial-gradient(var(--line-2) 0.6px, transparent 0.7px);
  background-size: 14px 14px; background-position: -7px -7px; background-attachment: fixed;
}
a { color: var(--brand); }
img { max-width: 100%; height: auto; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.12; letter-spacing: -0.02em; margin: 0 0 .4em; }
h1 { font-size: clamp(2rem, 6vw, 3.4rem); font-weight: 700; }
h2 { font-size: clamp(1.4rem, 3.5vw, 2rem); font-weight: 600; }
p { margin: 0 0 1em; }
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.center { text-align: center; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 48px; padding: 0 20px; border-radius: 999px; border: 1px solid transparent;
  font-family: var(--font-display); font-size: 1rem; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: transform .06s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--accent-deep); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--border);
}
.topbar .wrap { display: flex; align-items: center; gap: 12px; height: 60px; }
.brandmark { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; }
.brandmark img { width: 30px; height: 30px; border-radius: 8px; display: block; }
.brandmark b { font-size: 1.15rem; letter-spacing: -0.02em; }
.spacer { flex: 1; }
[data-theme-toggle] { background: none; border: 0; padding: 4px; cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; }
[data-theme-toggle] img { width: 56px; height: auto; display: block; }

/* ---------- marketing (index) — dark "vault" hero ---------- */
.hero {
  position: relative; overflow: hidden; color: #fff;
  padding: clamp(44px, 8vw, 92px) 0 clamp(40px, 7vw, 76px);
  background: linear-gradient(145deg, #071A16 0%, #0A6E5C 150%);
  background-attachment: scroll;
}
.hero::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(58% 85% at 88% 8%, rgba(16,199,164,.32), transparent 60%); }
.hero > .wrap { position: relative; z-index: 1; }
.hero h1 { color: #fff; }
.hero .eyebrow { display: inline-block; font-family: var(--font-mono); font-weight: 400;
  font-size: .74rem; letter-spacing: .18em; text-transform: uppercase; color: #EAF7F3;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.26);
  padding: 6px 14px; border-radius: 999px; margin-bottom: 18px; }
.hero p.lead { font-size: clamp(1.1rem, 2.5vw, 1.32rem); color: rgba(255,255,255,.9); max-width: 44ch; }
.hero .cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.hero .note { margin-top: 14px; font-size: .95rem; color: rgba(255,255,255,.72); }
.hero .btn-ghost { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.3); }
.hero .btn-ghost:hover { background: rgba(255,255,255,.18); }

.section { padding: clamp(32px, 6vw, 64px) 0; }
.section.alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.grid { display: grid; gap: 18px; }
.grid.features { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.feature .ico { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-deep);
  display: grid; place-items: center; margin-bottom: 14px; }
.feature h3 { font-size: 1.1rem; margin-bottom: .3em; }
.feature p { margin: 0; color: var(--muted); font-size: .98rem; }

/* compare table */
.compare { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; }
.compare th, .compare td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.compare th { font-weight: 700; }
.compare td.yes { color: var(--accent-deep); font-weight: 600; }
.compare td.no { color: var(--muted); }
.compare tr:last-child td { border-bottom: 0; }

/* pricing */
.price-cards { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.price { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
.price.highlight { border-color: var(--accent); }
.price .tag { font-size: 2rem; font-weight: 700; }
.price ul { list-style: none; padding: 0; margin: 16px 0 0; }
.price li { padding: 7px 0 7px 26px; position: relative; color: var(--muted); }
.price li::before { content: "✓"; position: absolute; left: 0; color: var(--accent-deep); font-weight: 700; }

/* install badges */
.badges { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 18px; }
.badges img { height: 46px; width: auto; }

/* ---------- app shell ---------- */
.app-main { padding: 16px 0 96px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin: 6px 0 16px; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 0 14px; min-height: 48px; }
.search input { border: 0; background: none; font: inherit; color: var(--ink); width: 100%; outline: none; }

.cards { display: block; }
.cards-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-bottom: 8px; }
.card-tile {
  position: relative; border-radius: var(--radius); padding: 18px; min-height: 128px; cursor: pointer;
  color: #fff; border: 0; text-align: left; font: inherit; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: var(--shadow); overflow: hidden; transition: transform .08s ease;
}
/* ticket-notch (bg-colored half-circles cut into each side) + laminated sheen,
   both as pseudo-elements so the JS-built tile markup is unchanged */
.card-tile::before {
  content: ""; position: absolute; inset: 0; border-radius: var(--radius); z-index: 2; pointer-events: none;
  background:
    radial-gradient(circle 10px at left center, var(--bg) 96%, transparent 100%),
    radial-gradient(circle 10px at right center, var(--bg) 96%, transparent 100%);
}
.card-tile::after {
  content: ""; position: absolute; inset: 0; border-radius: var(--radius); z-index: 1; pointer-events: none;
  background: linear-gradient(115deg, transparent 42%, rgba(255,255,255,.15) 50%, transparent 58%);
}
.card-tile > * { position: relative; z-index: 3; }
.card-tile:active { transform: scale(.985); }
.card-tile .store { font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.card-tile .num { font-family: var(--font-mono); font-size: .9rem; opacity: .92; margin-top: 10px; letter-spacing: 1px; }
.card-tile .chip { align-self: flex-start; background: rgba(255,255,255,.22); color: #fff; font-size: .72rem;
  padding: 3px 9px; border-radius: 999px; font-weight: 600; backdrop-filter: blur(2px); }
.card-tile .mini { position: absolute; right: 14px; bottom: 14px; background: #fff; border-radius: 6px; padding: 4px; width: 68px; }
.card-tile .mini svg { display: block; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { width: 72px; height: 72px; margin: 0 auto 16px; opacity: .5; }

/* floating add */
.fab { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 25; min-height: 56px; padding: 0 22px; border-radius: 999px; box-shadow: 0 8px 24px rgba(10,110,92,.42); }

/* ---------- sheets / modals ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(8,10,14,.55); display: none; align-items: flex-end; justify-content: center; }
.overlay.open { display: flex; }
@media (min-width: 640px) { .overlay { align-items: center; } }
.sheet { background: var(--surface); color: var(--ink); width: 100%; max-width: 520px; border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow); }
@media (min-width: 640px) { .sheet { border-radius: 20px; } }
.sheet h2 { margin-top: 4px; }
.field { margin: 14px 0; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg); color: var(--ink); font: inherit; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatches button { width: 40px; height: 40px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; }
.swatches button[aria-pressed="true"] { border-color: var(--ink); outline: 2px solid var(--surface); }
.preview-box { background: #fff; border-radius: 12px; padding: 12px; margin-top: 8px; border: 1px solid var(--border); }
.preview-box svg { display: block; max-height: 150px; margin: 0 auto; }
.err { color: var(--danger); font-size: .92rem; min-height: 1.2em; margin-top: 6px; }
.scanwrap { position: relative; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 4/3; }
.scanwrap video { width: 100%; height: 100%; object-fit: cover; }
.scanwrap .reticle { position: absolute; inset: 18% 10%; border: 3px solid rgba(255,255,255,.85); border-radius: 12px; }

/* segmented */
.seg { display: flex; background: var(--surface-2); border-radius: 999px; padding: 4px; gap: 4px; }
.seg button { flex: 1; min-height: 40px; border: 0; background: none; border-radius: 999px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- checkout mode (always black canvas / white barcode) ---------- */
.checkout { position: fixed; inset: 0; z-index: 70; background: #000; color: #fff; display: none; flex-direction: column; }
.checkout.open { display: flex; }
.checkout .head { display: flex; align-items: center; gap: 12px; padding: max(14px, env(safe-area-inset-top)) 16px 10px; }
.checkout .head .x { margin-left: auto; background: rgba(255,255,255,.14); border: 0; color: #fff; width: 44px; height: 44px; border-radius: 999px; font-size: 1.3rem; cursor: pointer; }
.checkout .stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 10px 18px 28px; }
.checkout .store { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; }
/* the live barcode — the ONLY place scan-mint appears: a soft glow + a pass line */
.checkout .bc {
  position: relative; background: #fff; border-radius: 16px; padding: 20px; width: min(92vw, 560px);
  box-shadow: 0 0 0 2px rgba(77,232,196,.55), 0 0 44px -4px var(--scan-glow);
}
.checkout .bc svg { display: block; width: 100%; }
.checkout .bc::after {
  content: ""; position: absolute; left: 14px; right: 14px; top: 16px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--scan-glow), transparent);
  box-shadow: 0 0 10px 1px var(--scan-glow); opacity: .9;
  animation: ck-scan 2.4s ease-in-out infinite;
}
@keyframes ck-scan { 0%,100% { transform: translateY(0); } 50% { transform: translateY(clamp(80px, 22vw, 150px)); } }
@media (prefers-reduced-motion: reduce) { .checkout .bc::after { animation: none; opacity: .5; } }
.checkout .num { font-family: var(--font-mono); font-size: 1.1rem; letter-spacing: 2px; opacity: .85; }
.checkout .hint { color: rgba(255,255,255,.6); font-size: .9rem; }

/* learn / doc pages */
.doc { max-width: 760px; }
.doc h1 { margin-top: 24px; }
.doc .flag { background: var(--accent-soft); color: var(--accent-deep); border-radius: 8px; padding: 2px 8px; font-size: .85rem; font-weight: 600; }
.doc ul { padding-left: 1.2em; }
.doc li { margin: .3em 0; }

/* footer */
.site-foot { border-top: 1px solid var(--border); margin-top: 40px; padding: 28px 0 40px; color: var(--muted); font-size: .92rem; }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; }
.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--ink); text-decoration: underline; }
.site-foot .pub { display: flex; align-items: center; gap: 8px; }
.site-foot .pub img { width: 22px; height: 22px; border-radius: 5px; }
.site-foot .rel { font-family: var(--font-mono); font-size: .82rem; }

.visually-hidden { position: absolute; width: 1px; height: 1px; clip: rect(0 0 0 0); overflow: hidden; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 80; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* large ("senior") view — bigger tiles + type */
:root.large body { font-size: 19px; }
:root.large .card-tile { min-height: 150px; }
:root.large .card-tile .store { font-size: 1.35rem; }
:root.large .card-tile .num { font-size: 1.05rem; }
:root.large .cards-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

/* settings rows */
.set-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.set-row:last-child { border-bottom: 0; }
.set-row .grow { flex: 1; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; transition: .15s; }
.switch .track::before { content: ""; position: absolute; width: 24px; height: 24px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::before { transform: translateX(22px); }

/* hero two-column layout */
.hero-grid { display: grid; gap: clamp(24px, 5vw, 56px); align-items: center; grid-template-columns: 1fr; }
@media (min-width: 860px) { .hero-grid { grid-template-columns: 1.05fr 1fr; } }
@media (max-width: 859px) { .hero-art { order: -1; margin-bottom: 6px; } }

/* hero card mock — a loyalty card glowing on a dark screen (the moment that matters) */
.hero-mock { perspective: 1200px; display: grid; place-items: center; padding: 6px; }
.mockcard {
  position: relative; width: min(92%, 380px); aspect-ratio: 1.6 / 1; border-radius: 20px; overflow: hidden;
  background: linear-gradient(150deg, #0E8E78, #063C30); color: #fff; padding: 20px;
  box-shadow: 0 30px 60px -22px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.08) inset;
  transform: rotate(-4deg); display: flex; flex-direction: column; justify-content: space-between;
}
.mockcard::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(circle 13px at left center, #071A16 96%, transparent 100%),
    radial-gradient(circle 13px at right center, #071A16 96%, transparent 100%); z-index: 2; }
.mockcard::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,.22) 50%, transparent 60%); }
.mockcard > * { position: relative; z-index: 3; }
.mockcard .mc-top { display: flex; align-items: center; justify-content: space-between; }
.mockcard .mc-name { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; }
.mockcard .mc-tag { font-family: var(--font-mono); font-size: .62rem; letter-spacing: .14em; text-transform: uppercase;
  background: rgba(255,255,255,.2); padding: 3px 9px; border-radius: 999px; }
.mockcard .mc-bc { align-self: flex-end; background: #fff; border-radius: 9px; padding: 8px 10px;
  display: flex; gap: 3px; align-items: flex-end; height: 58px;
  box-shadow: 0 0 0 2px rgba(77,232,196,.6), 0 0 26px -2px var(--scan-glow); }
.mockcard .mc-bc i { display: block; width: 4px; background: #06211A; border-radius: 1px; }
.mockcard .mc-no { font-family: var(--font-mono); font-size: .82rem; letter-spacing: 2px; opacity: .9; }

/* ---------- filter chip row ---------- */
.filter-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 0 6px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.fchip { flex: none; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.fchip:hover { background: var(--surface-2); }
.fchip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.fchip .fn { opacity: .7; font-size: .82em; margin-left: 2px; }
.fchip.tagc { font-family: var(--font-mono); font-size: .82rem; }

/* ---------- category section headers ---------- */
.cat-head { display: flex; align-items: center; gap: 8px; margin: 14px 2px 10px; font-weight: 700; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.cat-head::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.cat-head .n { color: var(--muted); font-weight: 600; }

/* ---------- tile tags ---------- */
.tile-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.tag-pill { background: rgba(255,255,255,.22); color: #fff; font-size: .7rem; padding: 2px 8px; border-radius: 999px; font-weight: 600; backdrop-filter: blur(2px); }

/* ---------- tag editor in the add sheet ---------- */
.tag-edit { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag-edit[hidden] { display: none; }
.tag-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent-deep); border-radius: 999px; padding: 4px 6px 4px 12px; font-weight: 600; font-size: .88rem; }
.tag-chip button { border: 0; background: rgba(0,0,0,.08); color: inherit; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-size: .8rem; line-height: 1; }
.tag-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag-sug { border: 1px dashed var(--border); background: transparent; color: var(--muted); border-radius: 999px; padding: 5px 11px; font: inherit; font-size: .85rem; cursor: pointer; min-height: 34px; }
.tag-sug:hover { border-color: var(--accent); color: var(--accent-deep); }

/* ---------- reports ---------- */
#reports-body h3 { font-size: 1rem; margin: 18px 0 10px; }
.rep-kpis { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin: 6px 0 4px; }
.rep-kpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 8px; text-align: center; }
.rep-kpi .k { font-family: var(--font-mono); font-size: 1.7rem; font-weight: 600; color: var(--accent-deep); }
.rep-kpi .l { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: 2px; }
.repbar { display: grid; grid-template-columns: minmax(80px, 36%) 1fr auto; align-items: center; gap: 10px; margin: 7px 0; }
.repbar-l { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repbar-track { background: var(--surface-2); border-radius: 999px; height: 10px; overflow: hidden; }
.repbar-fill { background: var(--accent); height: 100%; border-radius: 999px; }
.repbar-n { font-size: .85rem; color: var(--muted); min-width: 2ch; text-align: right; }
.rep-list { margin: 6px 0 0; padding-left: 1.2em; color: var(--muted); }
.rep-list li { margin: 3px 0; }
