/* The Core Buyer brand: one dark theme. Every text/background pair meets normal contrast (4.5:1+):
   on Black, Silver text is 6.6:1, Bright Silver 10.3:1, Gold 9.4:1, Deep Gold 5.4:1; Black on Gold 9.4:1.
   Steel Gray (3.8:1 on Black) is for borders and dividers only, never text. Gold = tappable;
   Deep Gold = pressed/hover. Never gold text on silver. Green/red only for profit and loss. */
:root {
  --black: #1E1E1D;
  --silver: #A5A2A1;
  --bright: #CDCBC9;
  --steel: #7B7776;
  --gold: #F5B90C;
  --gold-deep: #C98404;
  --bg: var(--black);
  --card: var(--black);
  --ink: var(--silver);         /* main text */
  --hi: var(--bright);          /* headings, totals, highlights */
  --muted: var(--silver);       /* small labels: Silver, since Steel Gray is too faint for text */
  --line: var(--steel);
  --accent: var(--gold);
  --accent-press: var(--gold-deep);
  --accent-ink: var(--black);   /* text on gold */
  --pos: #4cc485;               /* profit, 7.6:1 */
  --neg: #ff7a6b;               /* loss, 6.6:1 */
  --warn-bg: var(--black);
  --warn-ink: var(--bright);
  --warn-line: var(--bright);
  --chip: var(--black);
  --bar: var(--black);
  --bar-ink: var(--bright);
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 22px; margin: 0; color: var(--hi); }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 26px 2px 8px; }
h3 { font-size: 14px; color: var(--muted); margin: 18px 2px 6px; }

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--bar); color: var(--bar-ink);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  font-weight: 700; border-bottom: 1px solid var(--line);
}
/* The emblem beside the name: a 72px copy shown at 22px (sharp at 3x). Its black square
   blends into the bar's black, so only the emblem shows. */
.appname { display: flex; align-items: center; gap: 8px; min-width: 0; }
.appname img { width: 22px; height: 22px; flex: none; mix-blend-mode: lighten; border-radius: 50%; }
.badge {
  border: 0; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 600;
  background: var(--black); color: var(--silver); box-shadow: inset 0 0 0 1px var(--line);
}
.badge.ok { color: var(--bright); }
.badge.warn { background: var(--gold); color: var(--black); box-shadow: none; }

main { padding: 14px 16px 24px; max-width: 640px; margin: 0 auto; }
.top { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; min-height: 40px; }
.back { background: none; border: 0; font: inherit; color: var(--accent); font-weight: 600; padding: 8px 4px; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-height: 92px; }
.tl { color: var(--muted); font-size: 14px; font-weight: 600; }
.tv { color: var(--hi); font-size: 27px; font-weight: 800; margin-top: 8px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tiles.small .tile { min-height: 0; padding: 10px 12px; }
.tiles.small .tv { font-size: 19px; margin-top: 4px; }
.tile.pos .tv, .pos { color: var(--pos); }
.tile.neg .tv, .neg { color: var(--neg); }

.seg { display: flex; background: var(--chip); border-radius: 12px; padding: 4px; gap: 4px; margin: 4px 0 10px; }
.seg button {
  flex: 1; border: 0; background: none; font: inherit; font-size: 15px; font-weight: 600; color: var(--muted);
  padding: 11px 6px; border-radius: 9px; min-height: 44px;
}
.seg button.on { background: var(--accent); color: var(--accent-ink); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.card.subtle { background: transparent; }
.card.resume { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--warn-bg); color: var(--warn-ink); border: 2px solid var(--warn-line); margin-top: 0; }
.card.resume span:first-child { display: flex; flex-direction: column; }
.card.resume small { font-size: 14px; margin-top: 2px; }
.card.resume span:last-child { font-weight: 700; white-space: nowrap; }
.card.warn { background: var(--warn-bg); color: var(--warn-ink); border: 2px solid var(--warn-line); }
.ch { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-size: 18px; }
.ch span { font-weight: 800; font-variant-numeric: tabular-nums; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-variant-numeric: tabular-nums; }
.kv > span:first-child { color: var(--muted); }
.kv > :last-child { text-align: right; }
.muted, .kv.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 14px; margin: 8px 2px; }
.center { text-align: center; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; }

.rowlink {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; font-weight: 600; min-height: 56px;
}
.rowlink span { color: var(--accent); font-size: 22px; }

.actions { display: grid; gap: 10px; margin-top: 18px; }
.btn {
  display: flex; align-items: center; justify-content: center; width: 100%;
  border: 1px solid var(--accent); background: var(--card); color: var(--accent);
  font: inherit; font-weight: 700; border-radius: var(--radius); padding: 12px 16px; min-height: 50px; margin: 8px 0;
}
.btn.big { min-height: 60px; font-size: 19px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:not(:disabled):active, .btn:not(:disabled):hover { border-color: var(--accent-press); color: var(--accent-press); }
.btn.primary:not(:disabled):active, .btn.primary:not(:disabled):hover { background: var(--accent-press); border-color: var(--accent-press); color: var(--accent-ink); }
.btn.add { border-style: dashed; border-width: 2px; color: var(--accent); }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: 14px; width: auto; }
.btn.danger-text { border: 0; background: none; color: var(--neg); font-weight: 600; }
.btn:disabled { opacity: .45; }
.btn:active, .pick button:active, .line:active, .item:active { transform: scale(.985); }

.lbl { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin: 14px 2px 6px; }
.lbl em { font-style: normal; color: var(--hi); }
input:not([type=checkbox]) {
  width: 100%; font: inherit; font-size: 19px; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 52px; margin: 0 0 6px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.money { position: relative; }
.money::before { content: "$"; position: absolute; left: 14px; top: 14px; color: var(--muted); font-size: 19px; pointer-events: none; }
.money input { padding-left: 30px; }
.money.sm::before { font-size: 16px; top: 12px; left: 11px; }
.money.sm input { font-size: 17px; min-height: 46px; padding-left: 24px; }
.bigin input { font-size: 26px; font-weight: 700; min-height: 62px; }
.bigin .money::before, .money.bigin::before { font-size: 26px; top: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; gap: 10px; align-items: center; margin: 18px 2px; font-weight: 600; }
.check input { width: 22px; height: 22px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.chips button {
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: 15px; font-weight: 600;
  padding: 10px 14px; border-radius: 999px; min-height: 44px;
}
.chips button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chips.small button { min-height: 38px; padding: 6px 12px; font-size: 14px; }

.pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pick button {
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 700;
  border-radius: var(--radius); min-height: 72px; padding: 10px;
}
.pick button.wide { grid-column: 1 / -1; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); min-height: 80px; font-size: 20px; }

.lines { margin: 12px 0 4px; display: grid; gap: 8px; }
.line, .item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-height: 60px;
  font: inherit; color: inherit;
}
.ln, .item > span:first-child { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ln small, .item small { color: var(--muted); font-size: 14px; margin-top: 2px; }
.la { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list { display: grid; gap: 8px; }
.item.dim { opacity: .55; }
.item.static { min-height: 54px; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; flex: none; background: var(--chip); }

.total { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 2px; font-size: 18px; }
.total b { font-size: 30px; font-variant-numeric: tabular-nums; }
.avg { text-align: center; padding: 14px; font-size: 17px; color: var(--muted); }
.avg b { color: var(--hi); font-size: 22px; }
.hero { font-size: 46px; font-weight: 800; text-align: center; margin: 14px 0 0; font-variant-numeric: tabular-nums; }

/* What Save is still waiting for (seller, ID, signature). */
.missing { outline: 2px solid var(--neg); outline-offset: 3px; border-radius: 10px; }
.missing small { color: var(--neg); font-weight: 700; }
.sticky {
  position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); padding: 8px 0 2px;
  background: linear-gradient(transparent, var(--bg) 22%);
}

.can { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 10px 0; }
.canhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.x { border: 0; background: var(--chip); color: var(--ink); font-size: 22px; width: 40px; height: 40px; border-radius: 50%; }
.canrow { display: grid; grid-template-columns: 1fr 96px; gap: 10px; align-items: start; }
.photo-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; border: 1px dashed var(--line);
  border-radius: 12px; min-height: 52px; color: var(--accent); font-weight: 600; margin: 8px 0;
}
.photo-btn.small { margin: 0; }

.prhead, .pr { display: grid; grid-template-columns: 1fr 92px 92px; gap: 8px; align-items: center; }
.prhead { font-size: 13px; color: var(--muted); text-align: center; padding: 0 2px; }
.pr { border-bottom: 1px solid var(--line); padding: 8px 0; }
.pr.dim { opacity: .6; }
.prn { display: flex; flex-direction: column; min-width: 0; }
.prn small { color: var(--muted); font-size: 13px; }
.prf { display: contents; }
.pr input { margin: 0; }
.grade { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin: 8px 0; }
.grade.dim { opacity: .6; }

/* Sign in. Nav and sync badge are hidden until someone is signed in. */
body.signed-out nav, body.signed-out #sync { display: none; }
body.signed-out { padding-bottom: 24px; }
.login { max-width: 420px; margin: 24px auto 0; }
.login h1 { font-size: 28px; margin-bottom: 8px; }
.login h1.login-logo { text-align: center; margin: 0 0 12px; line-height: 0; }
.login-logo img { width: 181px; height: auto; max-width: 60vw; }
.lead { font-size: 17px; color: var(--muted); margin: 8px 0 18px; }
.lead b { color: var(--hi); }
.err { color: var(--neg); font-weight: 600; margin: 4px 2px 8px; }
.codein { font-size: 32px !important; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; }
.smsbox { display: flex; gap: 12px; align-items: flex-start; margin: 16px 2px 4px; font-size: 14px; line-height: 1.4; color: var(--ink); }
.smsbox input { width: 24px; height: 24px; flex: none; margin: 1px 0 0; accent-color: var(--accent); }
.fine.smsnote { margin: 6px 2px 16px 38px; font-size: 13px; }
.smsnote a, .policy a { color: var(--accent); text-decoration: underline; }
.code { font-size: 22px; letter-spacing: .15em; font-variant-numeric: tabular-nums; }

/* By category: one section per category — the period table, then "On the truck now". */
.cat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0; overflow: hidden; }
.cat-name { margin: 0; padding: 12px 14px 4px; font-size: 19px; color: var(--hi); }
.part { padding: 0 14px 10px; }
.ptbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 15px; table-layout: fixed; }
.ptbl th { font-size: 12px; font-weight: 600; color: var(--muted); text-align: right; padding: 4px 0 6px; text-transform: uppercase; letter-spacing: .03em; }
.ptbl th:first-child { text-align: left; color: var(--hi); width: 31%; }
.ptbl td { padding: 5px 0; text-align: right; white-space: nowrap; }
.ptbl td:first-child { text-align: left; color: var(--muted); font-weight: 600; white-space: normal; line-height: 1.15; }
.ptbl th:nth-child(2), .ptbl td:nth-child(2) { width: 14%; }
.ptbl th:nth-child(3), .ptbl td:nth-child(3) { width: 31%; }
.ptbl td.none { text-align: left; color: var(--muted); font-style: italic; padding-left: 8px; }
.ptbl tr.bought td { color: var(--muted); }
.ptbl tr.gap td { padding: 2px 0; border-bottom: 1px dashed var(--line); }
.ptbl tr.sum td { color: var(--hi); border-top: 2px solid var(--line); font-weight: 800; font-size: 16px; padding-top: 7px; }
.ptbl tr.sum td:first-child { color: var(--hi); }
.ptbl tr.sum.pos td:not(:first-child) { color: var(--pos); }
.ptbl tr.sum.neg td:not(:first-child) { color: var(--neg); }
.eq { margin: 6px 0 0; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.eq b { font-size: 15px; }
.eq span, .eq b { white-space: nowrap; }
.fine { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.truck {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; align-items: baseline;
  background: var(--chip); padding: 10px 14px; font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 600;
}
.truck-h { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }

.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 15px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 13px; padding: 4px 4px 8px; }
.tbl td { padding: 8px 4px; border-top: 1px solid var(--line); }
.tbl td:not(:first-child), .tbl th:not(:first-child) { text-align: right; }

nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 0; min-height: 56px; }
nav svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
nav a.on { color: var(--accent); }
nav a.buy svg { background: var(--accent); color: var(--accent-ink); border-radius: 50%; padding: 3px; width: 30px; height: 30px; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 9;
  background: var(--ink); color: var(--bg); padding: 14px 16px; border-radius: 12px; font-weight: 600; text-align: center;
  opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none;
}
#toast.show { opacity: 1; transform: none; }

/* Phase C: a record of who sold it to you, the signature pad. */
.record { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; }
.record-h { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.rec-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.rec-row:first-of-type { border-top: 0; }
.rec-row .btn.small { margin: 0; flex: none; }
.rec-row .ln small .btn.small { margin-left: 6px; min-height: 32px; padding: 2px 10px; }
/* Signatures: dark ink on a white card in both themes, wide enough to read without zooming. */
.thumb.sig { width: 96px; height: 48px; background: #fff; object-fit: contain; border: 1px solid var(--line); padding: 2px; }
.statement { font-size: 18px; line-height: 1.45; font-weight: 600; margin: 4px 2px 8px; }
.sigpad { display: block; width: 100%; background: #fff; border: 2px dashed var(--line); border-radius: 12px; touch-action: none; }
.recpics { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.recpic { margin: 0; width: calc(50% - 5px); }
.recpic img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: var(--chip); display: block; }
.recpic.sig { width: 100%; }
.recpic.sig img { aspect-ratio: auto; height: 120px; object-fit: contain; background: #fff; border: 1px solid var(--line); padding: 8px; }
.recpic figcaption { font-size: 13px; color: var(--muted); margin-top: 4px; }
.record a { color: var(--accent); }

/* Phase D: trial banner, plan cards. */
.card.trial { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 0; font-size: 15px; }
.card.trial span:last-child { color: var(--accent); font-weight: 700; white-space: nowrap; }
.card.trial.soon { background: var(--warn-bg); color: var(--warn-ink); border: 2px solid var(--warn-line); }
.card.trial.soon span:last-child { color: inherit; }
.card.trial small { display: block; font-size: 14px; margin-top: 4px; }
.card.starter-note { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 0; font-size: 15px; }
.card.starter-note .btn { margin: 0; flex: none; }
.card.starter-note.used { background: var(--warn-bg); color: var(--warn-ink); border: 2px solid var(--warn-line); }
.plans { display: grid; gap: 10px; margin: 14px 0 6px; }
.plan { display: grid; gap: 2px; text-align: left; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; font: inherit; }
.plan.best { border: 2px solid var(--accent); }
.plan-name { font-weight: 700; }
.plan-price { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.plan-price small { font-size: 16px; color: var(--muted); font-weight: 600; }
.plan-price .was { font-size: 18px; color: var(--muted); font-weight: 600; text-decoration-thickness: 2px; margin-right: 4px; }
.plan-note { color: var(--accent); font-weight: 600; font-size: 14px; }
.plan:disabled { opacity: .5; }
.plan-was { color: var(--muted); font-size: 13px; text-decoration: line-through; }
.plan.soon { cursor: default; margin-bottom: 10px; }
.plan.soon ul { margin: 6px 0 10px; padding-left: 20px; color: var(--muted); font-size: 15px; }
.plan-lead { color: var(--muted); font-size: 15px; }
.badge-soon { display: inline-block; font-size: 12px; font-weight: 700; color: var(--hi); background: var(--chip); box-shadow: inset 0 0 0 1px var(--line); border-radius: 999px; padding: 2px 8px; margin-left: 6px; vertical-align: 2px; }
.plan-small { color: var(--muted); font-size: 13px; }

/* More: "Everyday" on top, "Account" set apart below it. */
h2.section { margin-top: 18px; }
h2.section.apart { margin-top: 44px; padding-top: 22px; border-top: 1px solid var(--line); }
.sync-card { margin-top: 12px; }
