/* QuickSale v2: "the money you keep".
   Neutral platform, one accent (keep-green) reserved for savings and the primary action.
   Store brands appear only as a small dot in their own colour. */

@font-face { font-family: 'Public Sans'; font-weight: 400; font-display: swap; src: url('/vendor/fonts/public-sans-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Public Sans'; font-weight: 500; font-display: swap; src: url('/vendor/fonts/public-sans-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Public Sans'; font-weight: 600; font-display: swap; src: url('/vendor/fonts/public-sans-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Public Sans'; font-weight: 700; font-display: swap; src: url('/vendor/fonts/public-sans-latin-700-normal.woff2') format('woff2'); }

:root {
  --paper: #FFFFFF;
  --ink: #1A1A1A;
  --ink-2: #4E4E4A;
  --line: #D8D8D3;
  --surface: #F3F3F0;
  --keep: #0E6B3C;       /* savings, primary action */
  --keep-soft: #E3F1E8;
  --warn: #9A3B00;       /* "probably gone", errors */
  --warn-soft: #F8E7DC;
  --sans: 'Public Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --tap: 48px;
  --r: 8px;
  --max: 680px;
  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--sans); font-size: 17px; line-height: 1.45; color: var(--ink); background: var(--paper); min-height: 100dvh; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, p, figure { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Type */
.h1 { font-size: 28px; font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; }
.h2 { font-size: 22px; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; }
.h3 { font-size: 18px; font-weight: 600; line-height: 1.25; }
.meta { color: var(--ink-2); font-size: 15px; }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }
.keep { color: var(--keep); font-weight: 700; }
.warn { color: var(--warn); font-weight: 600; }

/* Frame */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.frame { width: 100%; max-width: var(--max); margin: 0 auto; }
main { flex: 1; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 84px); }
.pad { padding: 16px; }
.stack > * + * { margin-top: 12px; }
.row-between { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

/* Top bar */
.topbar { border-bottom: 1px solid var(--line); background: var(--paper); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.wordmark { font-weight: 700; font-size: 20px; letter-spacing: -0.02em; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.wordmark i { width: 10px; height: 10px; border-radius: 50%; background: var(--keep); display: inline-block; }
.loc-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; max-width: 58%; font-weight: 500; font-size: 15px; }
.loc-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loc-btn svg { flex: none; width: 18px; height: 18px; }

/* Savings hero: the headline is the total you could keep */
.hero { padding: 18px 16px 14px; border-bottom: 1px solid var(--line); }
.hero .big { font-size: 40px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; color: var(--keep); font-variant-numeric: tabular-nums; }
.hero .sub { margin-top: 6px; color: var(--ink-2); font-size: 15px; }

/* Controls */
.controls { background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.controls-inner { display: flex; align-items: center; gap: 8px; padding: 10px 16px; overflow-x: auto; scrollbar-width: none; }
.controls-inner::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 40px; padding: 6px 14px; border: 1px solid var(--ink); border-radius: 999px; background: var(--paper); font-weight: 500; font-size: 15px; cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.chip-group { display: inline-flex; border: 1px solid var(--ink); border-radius: 999px; overflow: hidden; flex: none; }
.chip-group .chip { border: 0; border-radius: 0; min-width: 52px; text-align: center; }
.chip-group .chip + .chip { border-left: 1px solid var(--ink); }

/* Sighting rows */
.rows { border-top: 1px solid var(--line); }
.row { display: grid; grid-template-columns: 84px 1fr; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.row:active { background: var(--surface); }
.thumb { width: 84px; height: 84px; object-fit: cover; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.row-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-store { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-2); min-width: 0; }
.row-store span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-store .dist { flex: none; margin-left: auto; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--line); border: 1px solid rgba(0,0,0,.15); }
.row-title { font-size: 18px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-save { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.row-save .keep { font-size: 22px; line-height: 1; font-variant-numeric: tabular-nums; }
.row-save .price { font-size: 15px; color: var(--ink-2); }
.row-save .price s { color: #8A8A85; }
.row-line { font-size: 14px; color: var(--ink-2); }
.fresh { display: inline-flex; align-items: center; gap: 6px; }
.fresh::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--keep); }
.fresh.mid::before { background: #C98A00; }
.fresh.low::before { background: var(--warn); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 10px 18px; border: 1px solid var(--ink); border-radius: var(--r); background: var(--paper); color: var(--ink); font-weight: 600; font-size: 17px; line-height: 1; cursor: pointer; text-decoration: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { background: var(--keep); border-color: var(--keep); color: var(--paper); }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-quiet { border-color: var(--line); background: var(--surface); }
.btn-warn { color: var(--warn); border-color: var(--warn); }
.btn-sm { min-height: 40px; padding: 6px 12px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 140px; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ''; position: absolute; width: 18px; height: 18px; border: 3px solid var(--ink); border-color: var(--ink) var(--ink) transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.btn-primary.is-busy::after, .btn-ink.is-busy::after { border-color: var(--paper) var(--paper) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.linkish { background: none; border: 0; padding: 4px 0; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 32px; color: inherit; }

/* Floating "Snap" action above the nav */
.fab-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b) + 12px); z-index: 29; display: flex; justify-content: center; pointer-events: none; padding: 0 16px; }
.fab { pointer-events: auto; display: inline-flex; align-items: center; gap: 10px; min-height: 54px; padding: 12px 22px; border-radius: 999px; background: var(--keep); color: var(--paper); font-weight: 700; font-size: 17px; text-decoration: none; box-shadow: 0 4px 14px rgba(14,107,60,.35); border: 2px solid var(--paper); }
.fab svg { width: 22px; height: 22px; }

/* Bottom nav */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--paper); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.nav-inner { display: grid; grid-template-columns: repeat(4, 1fr); max-width: var(--max); margin: 0 auto; height: var(--nav-h); }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.nav a svg { width: 24px; height: 24px; }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 700; }
.nav a[aria-current="page"] svg { color: var(--keep); }

/* Banners, empty states, toast */
.banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); font-size: 15px; }
.banner-keep { background: var(--keep-soft); }
.banner-warn { background: var(--warn-soft); }
.banner .btn { margin-left: auto; flex: none; }
.empty { padding: 40px 16px; text-align: center; }
.empty .h2 { margin-bottom: 8px; }
.empty p { color: var(--ink-2); max-width: 38ch; margin: 0 auto 16px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 80px); transform: translate(-50%, 20px); background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: var(--r); font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--warn); }

/* Sheets */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: var(--max); background: var(--paper); border-radius: 16px 16px 0 0; max-height: 92dvh; overflow: auto; padding: 16px 16px calc(16px + var(--safe-b)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .legend { font-weight: 600; font-size: 15px; }
.hint { font-size: 14px; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--ink); border-radius: var(--r); background: var(--paper); }
textarea.input { min-height: 80px; resize: vertical; }
.input:user-invalid { border-color: var(--warn); }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.input-money { position: relative; }
.input-money::before { content: '$'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-weight: 600; color: var(--ink-2); }
.input-money .input { padding-left: 26px; font-weight: 700; font-size: 22px; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice span { display: inline-flex; align-items: center; min-height: 40px; padding: 6px 14px; border: 1px solid var(--ink); border-radius: 999px; font-weight: 500; font-size: 15px; }
.choice input:checked + span { background: var(--ink); color: var(--paper); }
.choice input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 2px; }
.error { color: var(--warn); font-weight: 600; font-size: 15px; }
.form-error { border: 1px solid var(--warn); background: var(--warn-soft); color: var(--warn); padding: 10px 12px; border-radius: var(--r); font-weight: 600; }

/* Snap flow */
.steps { display: flex; gap: 6px; padding: 12px 16px 0; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.steps i.on { background: var(--keep); }
.camera-pick { display: block; position: relative; border: 2px dashed var(--ink); border-radius: 12px; min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 16px; cursor: pointer; background: var(--surface); }
.camera-pick svg { width: 44px; height: 44px; }
.camera-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.camera-pick img { width: 100%; max-height: 320px; object-fit: contain; border-radius: 8px; }
.camera-pick.has-photo { border-style: solid; padding: 6px; background: var(--paper); }
.store-pick { border-top: 1px solid var(--line); }
.store-pick li { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; min-height: 56px; }
.store-pick li[aria-selected="true"] { background: var(--keep-soft); }
.store-pick .grow { flex: 1; min-width: 0; }
.store-pick .grow div:first-child { font-weight: 600; }

/* Detail */
.hero-photo { background: var(--surface); border-bottom: 1px solid var(--line); }
.hero-photo img { width: 100%; aspect-ratio: 4 / 3; max-height: 60dvh; object-fit: contain; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 10px 6px 4px; font-weight: 600; text-decoration: none; }
.back svg { width: 20px; height: 20px; }
.save-block { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.save-block .keep { font-size: 34px; line-height: 1; }
.facts { border-top: 1px solid var(--line); margin-top: 16px; }
.fact { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 16px; }
.fact dt { color: var(--ink-2); }
.fact dd { margin: 0; font-weight: 500; }
.vote-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.vote-row .btn { font-size: 15px; padding-left: 10px; padding-right: 10px; }
.vote-row .btn[aria-pressed="true"] { background: var(--keep-soft); border-color: var(--keep); color: var(--keep); }
.vote-row .btn-warn[aria-pressed="true"] { background: var(--warn-soft); }

/* Map */
.map-wrap { height: calc(100dvh - 62px - 62px - var(--nav-h) - var(--safe-b)); min-height: 320px; position: relative; isolation: isolate; z-index: 0; border-bottom: 1px solid var(--line); }
.map { height: 100%; width: 100%; background: var(--surface); }
.pin { background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; padding: 4px 9px; font-weight: 700; font-size: 14px; line-height: 1; white-space: nowrap; color: var(--keep); box-shadow: 0 2px 6px rgba(0,0,0,.25); display: inline-flex; align-items: center; gap: 5px; }
.pin i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.pin-me { width: 18px; height: 18px; border-radius: 50%; background: var(--ink); border: 3px solid var(--paper); box-shadow: 0 0 0 2px var(--ink); }
.leaflet-popup-content-wrapper { border-radius: 8px; font-family: var(--sans); }
.leaflet-popup-content { margin: 10px 12px; font-size: 15px; }
.map-list { max-height: 40dvh; overflow: auto; }

/* Store page / sections */
.section-title { padding: 18px 16px 8px; }
.store-head { display: flex; gap: 12px; align-items: flex-start; padding: 0 16px; }
.brand-badge { width: 44px; height: 44px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: 16px; }

/* Admin */
.admin-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.admin-row .grow { flex: 1 1 200px; min-width: 0; }
.admin-row img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.stat { padding: 12px 14px; background: var(--paper); }
.stat .big { font-size: 28px; font-weight: 700; line-height: 1; }
.tabs { display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto; }
.status-pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--ink); }

@media (min-width: 640px) {
  .row { grid-template-columns: 104px 1fr; }
  .thumb { width: 104px; height: 104px; }
  .map-wrap { height: 60dvh; }
  .stat-row { grid-template-columns: repeat(4, 1fr); }
}
