/* Brand: Limestone ground, Storm (headers, selected, cold), Red earth (the one main action),
   Turmeric (due today, warm, check this), Gum (money won).
   Type: Archivo. ExtraBold (800) for headlines and numbers, 400–600 for everything else.
   Spacing: 4-point grid. 24 gutter, 24 between sections, 16 card padding, 12 inside cards, 8 label to field. */
:root {
  --limestone: #F3F2EC;
  --paper: #FFFFFF;
  --field: #FBFAF7;
  --storm: #3A4F63;
  --storm-2: #4F6578;
  --storm-tint: #DCE3EA;
  --ink: #1C2833;
  --ink-2: #4E5B66;
  --line: #D8D6CC;
  --line-soft: #ECEBE4;
  --red-earth: #A8431E;
  --red-earth-press: #8E3818;
  --red-earth-tint: #F6E3DA;
  --turmeric: #D99A2B;
  --turmeric-tint: #F7E6C4;
  --turmeric-ink: #7A5310;
  --sand-tint: #ECE5D6;
  --sand-ink: #6A5636;
  --gum: #2E6B47;
  --gum-tint: #DDEBE1;
  --neutral-tint: #E6E4DC;
  --focus: #1F5FD1;

  --display: 'Archivo', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --body: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px;
  --gutter: 24px;

  font-family: var(--body);
  color: var(--ink);
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--limestone); }
body { min-height: 100vh; font-size: 16px; line-height: 1.5; }
.num, .amt, .tile .n, .facts dd, .count, .otp { font-variant-numeric: tabular-nums; }
/* Stops double-tap zoom on buttons; pinch-zoom still works. */
a, button, label, input, select, textarea, .chip, .qrow { touch-action: manipulation; }
button, input, select, textarea { font: inherit; color: inherit; }
/* iOS zooms into any field under 16px. Never go below 16. */
input, select, textarea { font-size: 16px !important; }
a { color: inherit; }

#app { max-width: 560px; margin: 0 auto; padding: var(--s4) max(var(--gutter), env(safe-area-inset-right)) 112px max(var(--gutter), env(safe-area-inset-left)); }
#app.wide { max-width: 1320px; }
#app.flush { padding-top: 0; }
#app.full { max-width: none; padding: 0; }

/* Type scale: 34 / 24 / 18 / 16 / 14 / 12 */
h1 { font-family: var(--display); font-weight: 800; font-size: 34px; line-height: 1.08; letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
h2 { font-family: var(--display); font-weight: 800; font-size: 24px; line-height: 1.15; letter-spacing: -0.01em; margin: 0; }
h3 { font-size: 18px; font-weight: 600; margin: 0; }
.label { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.lede { color: var(--ink-2); margin: 0; font-size: 16px; }
.small { font-size: 14px; color: var(--ink-2); }
.tiny { font-size: 12px; color: var(--ink-2); }
.num { font-family: var(--display); font-weight: 800; }
.stack { display: flex; flex-direction: column; gap: var(--s6); }
.stack-md { display: flex; flex-direction: column; gap: var(--s4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s3); }
.stack-xs { display: flex; flex-direction: column; gap: var(--s2); }
.row { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s2); }
.spacer { flex: 1; }

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 48px; margin-bottom: var(--s4); }
.brand { white-space: nowrap; display: inline-flex; align-items: center; gap: var(--s3); font-family: var(--display); font-weight: 800; font-size: 18px; text-decoration: none; }
.mark { height: 24px; width: auto; flex: none; display: block; }
.mark .e { fill: var(--red-earth); }
.mark .r { fill: var(--storm); }
.on-dark .mark .e, .on-dark .mark .r { fill: #fff; }
.iconbtn { white-space: nowrap; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); padding: 0 var(--s2); border: 0; background: none; border-radius: var(--r-md); font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; color: inherit; }

/* Storm band (landing + dashboard header) */
.band { background: var(--storm); color: #fff; border-radius: 0 0 var(--r-xl) var(--r-xl); margin: 0 calc(-1 * max(var(--gutter), env(safe-area-inset-left))) var(--s6); padding: var(--s5) max(var(--gutter), env(safe-area-inset-right)) var(--s8) max(var(--gutter), env(safe-area-inset-left)); display: flex; flex-direction: column; gap: var(--s6); }
.band .lede, .band .small { color: var(--storm-tint); }
.pill { align-self: flex-start; font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); background: var(--turmeric); padding: var(--s1) var(--s3); border-radius: 99px; }

/* Cards */
.card { background: var(--paper); border-radius: var(--r-lg); padding: var(--s4); }
.card.hero { padding: var(--s5); }
.list { background: var(--paper); border-radius: var(--r-lg); display: flex; flex-direction: column; }
.list > * + * { border-top: 1px solid var(--line-soft); }
.listrow { display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: var(--s3) var(--s4); background: none; border: 0; width: 100%; text-align: left; cursor: pointer; text-decoration: none; color: inherit; }
.listrow .t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.listrow strong { font-weight: 600; }
.listrow .sub { font-size: 13px; color: var(--ink-2); }
.chev { width: 16px; height: 16px; flex: none; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 48px; padding: 0 var(--s5); border-radius: var(--r-md); border: 0; background: var(--paper); color: var(--ink); font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; box-shadow: inset 0 0 0 1px var(--line); transition: transform .05s, background .15s; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.primary { min-height: 56px; border-radius: var(--r-lg); background: var(--red-earth); color: #fff; font-size: 17px; box-shadow: none; }
.btn.primary:hover { background: var(--red-earth-press); }
.btn.dark { background: var(--storm); color: #fff; box-shadow: none; }
.btn.ink { background: var(--ink); color: #fff; box-shadow: none; }
.btn.light { background: var(--limestone); box-shadow: none; }
.btn.won { background: var(--gum-tint); color: var(--gum); box-shadow: none; }
.btn.ghost { background: none; box-shadow: none; color: var(--ink); }
.btn.danger { color: var(--red-earth); }
.btn.block { width: 100%; }
.textlink { background: none; border: 0; padding: 0 var(--s1); min-height: 44px; font-weight: 600; font-size: 15px; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.textlink.accent { color: var(--red-earth); text-decoration: none; }

/* Forms */
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: var(--s2); }
.field { display: flex; flex-direction: column; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=number], input[inputmode], select, textarea {
  width: 100%; min-height: 48px; padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--field); line-height: 1.4;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .chip:focus-visible, .qrow:focus-visible, .iconbtn:focus-visible, .listrow:focus-visible, .textlink:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.field.review input, .field.review select, .field.review textarea { border: 2px solid var(--turmeric); background: #FDF6E8; }
.flag { display: inline-block; margin-left: var(--s2); padding: 2px var(--s2); border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--turmeric-tint); color: var(--turmeric-ink); vertical-align: 1px; }
.hint { font-size: 13px; color: var(--turmeric-ink); margin-top: var(--s1); }
.check { display: flex; gap: var(--s3); align-items: flex-start; font-weight: 500; font-size: 15px; line-height: 1.45; cursor: pointer; margin: 0; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--storm); }
.otp { letter-spacing: 0.5em; text-align: center; font-family: var(--display); font-weight: 800; font-size: 24px !important; }

/* Chips */
.chip { min-height: 44px; padding: 0 var(--s4); border-radius: var(--r-md); border: 0; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; font-size: 15px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--storm); color: #fff; box-shadow: none; }

/* Upload */
.pick { position: relative; display: flex; align-items: center; gap: var(--s4); padding: var(--s4); border-radius: var(--r-lg); background: var(--paper); cursor: pointer; border: 0; width: 100%; text-align: left; }
.pick.main { box-shadow: inset 0 0 0 2px var(--red-earth); }
.pick input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.pick .ic { width: 48px; height: 48px; border-radius: var(--r-md); display: grid; place-items: center; flex: none; background: var(--line-soft); }
.pick.main .ic { background: var(--red-earth-tint); }
.pick .t { display: flex; flex-direction: column; min-width: 0; }
.pick strong { font-weight: 600; overflow-wrap: anywhere; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 2px var(--s2); border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.t-warm { color: var(--turmeric-ink); background: var(--turmeric-tint); }
.t-cooling { color: var(--sand-ink); background: var(--sand-tint); }
.t-cold { color: var(--storm); background: var(--storm-tint); }
.t-fresh, .t-hold, .t-stop { color: var(--ink-2); background: var(--neutral-tint); }
.t-won { color: var(--gum); background: var(--gum-tint); }
.t-due { color: var(--ink); background: var(--turmeric); }

/* Verdict (storm card) */
.verdict { background: var(--storm); color: #fff; border-radius: var(--r-xl); padding: var(--s4) var(--s5); display: flex; flex-direction: column; gap: var(--s3); }
.verdict.soft { background: var(--paper); color: var(--ink); }
.verdict.won { background: var(--gum-tint); color: var(--ink); }
.verdict .head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); }
.verdict .head strong { font-family: var(--display); font-weight: 800; font-size: 20px; }
.verdict .meta { font-size: 14px; color: var(--storm-tint); }
.verdict.soft .meta, .verdict.won .meta { color: var(--ink-2); }
.verdict p { margin: 0; font-size: 15px; line-height: 1.45; color: var(--limestone); }
.verdict.soft p, .verdict.won p { color: var(--ink-2); }
.tbar { display: flex; flex-direction: column; gap: var(--s2); }
.tbar .track { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s1); }
.tbar .track span { height: 8px; border-radius: 4px; background: var(--storm-2); }
.tbar .track span.on { background: var(--storm-tint); }
.tbar .marker { position: absolute; top: -5px; width: 4px; height: 18px; border-radius: 2px; background: var(--turmeric); transform: translateX(-2px); }
.tbar .labels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); font-size: 12px; color: #C9D2DA; }
.tbar .labels .on { color: #fff; font-weight: 600; }

/* Sequence */
.seq { display: inline-flex; align-items: center; gap: var(--s1); font-size: 13px; color: var(--ink-2); font-weight: 600; }
.seq i { width: 22px; height: 5px; border-radius: 3px; background: var(--line); display: inline-block; }
.seq i.on { background: var(--storm); }
.seq i.next { background: var(--turmeric); }
.seq span { margin-left: var(--s1); }

/* Message preview */
.preview { background: var(--paper); border-radius: var(--r-xl); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.preview .who { display: flex; align-items: center; gap: var(--s3); padding-bottom: var(--s3); border-bottom: 1px solid var(--line-soft); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--storm-tint); color: var(--storm); display: grid; place-items: center; font-weight: 800; font-size: 14px; flex: none; }
.bubble { align-self: flex-end; max-width: 88%; background: var(--storm); color: #fff; border-radius: 20px 20px 4px 20px; padding: var(--s3) var(--s4); font-size: 16px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; }
.mail { font-size: 15px; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; }
.count { align-self: flex-end; font-size: 12px; color: var(--ink-2); }
.ticket { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-md); border: 1.5px dashed var(--storm); background: #FDFBF6; font-size: 14px; }
.script { white-space: pre-line; font-size: 15px; line-height: 1.55; color: var(--limestone); margin: 0; }

/* Tabs */
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s1); padding: var(--s1); border-radius: var(--r-md); background: var(--neutral-tint); }
.seg button { min-height: 44px; border: 0; border-radius: var(--r-sm); background: none; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(28,40,51,.12); }
.seg button[disabled] { opacity: .45; cursor: not-allowed; }

/* Dashboard */
.tiles { display: grid; grid-template-columns: 1.2fr 1fr; gap: var(--s3); }
.tile { border-radius: var(--r-lg); padding: var(--s3) var(--s4); display: flex; flex-direction: column; gap: 2px; }
.tile .l { font-size: 13px; }
.tile .n { font-family: var(--display); font-weight: 800; font-size: 26px; }
.tile.won { background: var(--gum); }
.tile.won .l { color: var(--gum-tint); }
.tile.chase { background: var(--storm-2); }
.tile.chase .l { color: var(--storm-tint); }
.due { background: var(--turmeric); border-radius: var(--r-xl); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s2); color: var(--ink); text-align: left; border: 0; width: 100%; cursor: pointer; }
.due .top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); }
.due strong { font-family: var(--display); font-weight: 800; font-size: 20px; }
.prompt { background: var(--paper); border-radius: var(--r-lg); padding: var(--s3) var(--s4); display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.prompt .t { flex: 1 1 160px; font-size: 14px; line-height: 1.4; }
.prompt .btn { min-height: 44px; padding: 0 var(--s3); font-size: 14px; }
.qrow { display: flex; gap: var(--s3); align-items: center; width: 100%; text-align: left; background: none; border: 0; border-radius: 0; padding: var(--s3) var(--s4); min-height: 64px; cursor: pointer; color: inherit; }
.qrow .main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.qrow .who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qrow .what { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qrow .val { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s1); flex: none; }
.qrow .amt { font-weight: 600; }
.qrow.on { background: #FBF8F1; box-shadow: inset 4px 0 0 var(--storm); }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 var(--s2); }
.empty-note { background: var(--paper); border-radius: var(--r-lg); padding: var(--s6) var(--s4); text-align: center; color: var(--ink-2); font-size: 15px; }
.banner { display: flex; gap: var(--s3); align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--ink); color: #fff; border-radius: var(--r-lg); padding: var(--s3) var(--s4); }

/* Desktop */
.desk { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--storm); color: #fff; padding: var(--s6) var(--s4); display: flex; flex-direction: column; gap: var(--s6); position: sticky; top: 0; height: 100vh; }
.side nav { display: flex; flex-direction: column; gap: var(--s1); }
.side nav a { min-height: 44px; display: flex; align-items: center; padding: 0 var(--s3); border-radius: var(--r-md); color: var(--storm-tint); font-weight: 500; text-decoration: none; }
.side nav a[aria-current="page"] { background: var(--storm-2); color: #fff; font-weight: 600; }
.side .won-box { margin-top: auto; background: var(--gum); border-radius: var(--r-lg); padding: var(--s4); display: flex; flex-direction: column; gap: 2px; }
.desk-main { padding: var(--s8) var(--s10) var(--s12); display: flex; flex-direction: column; gap: var(--s6); min-width: 0; }
.desk-cols { display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); gap: var(--s6); align-items: start; }
.pane { background: var(--paper); border-radius: var(--r-xl); padding: var(--s6); position: sticky; top: var(--s6); max-height: calc(100vh - 48px); overflow: auto; display: flex; flex-direction: column; gap: var(--s4); }
.pane .preview { background: var(--limestone); }
.pane .card, .pane .list { background: var(--limestone); }

/* Facts */
.facts { display: grid; grid-template-columns: auto 1fr; gap: var(--s2) var(--s4); margin: 0; font-size: 15px; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* Sheet */
.scrim { position: fixed; inset: 0; background: rgba(28,40,51,.45); z-index: 30; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; background: var(--limestone); border-radius: var(--r-xl) var(--r-xl) 0 0; padding: var(--s3) max(var(--gutter), env(safe-area-inset-right)) max(var(--s8), env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left)); max-height: 92vh; overflow: auto; box-shadow: 0 -12px 32px rgba(28,40,51,.18); }
.sheet .grab { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto var(--s3); }
.sheet-inner { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--s4); }
@media (min-width: 700px) { .sheet { left: 50%; right: auto; bottom: 50%; transform: translate(-50%, 50%); width: 480px; border-radius: var(--r-xl); } .sheet .grab { display: none; } }
.opt { width: 100%; display: flex; gap: var(--s3); align-items: center; padding: var(--s3); border-radius: var(--r-lg); background: var(--paper); border: 2px solid transparent; cursor: pointer; text-align: left; }
.opt.on { border-color: var(--storm); }
.opt .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #9AA3AB; flex: none; }
.opt.on .dot { border: 6px solid var(--storm); }
.opt .t { flex: 1; display: flex; flex-direction: column; }
.opt strong { font-weight: 600; font-size: 15px; }
.opt span.sub { font-size: 13px; color: var(--ink-2); }

/* Loading + states */
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line-soft); border-top-color: var(--red-earth); animation: spin .8s linear infinite; flex: none; }
.btn.primary .spinner { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } .btn:active { transform: none; } }
.steps { list-style: none; margin: 0; padding: 0; background: var(--paper); border-radius: var(--r-lg); }
.steps li { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); }
.steps li + li { border-top: 1px solid var(--line-soft); }
.tick { width: 24px; height: 24px; border-radius: 50%; background: var(--gum); display: grid; place-items: center; flex: none; }
.notice { background: var(--turmeric-tint); color: var(--turmeric-ink); border-radius: var(--r-md); padding: var(--s3) var(--s4); font-size: 14px; }
.error { background: var(--red-earth-tint); color: var(--red-earth-press); border-radius: var(--r-md); padding: var(--s3) var(--s4); font-size: 14px; }
.fab { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(var(--s6), env(safe-area-inset-bottom)); width: min(512px, calc(100% - 48px)); z-index: 10; box-shadow: 0 10px 24px rgba(28,40,51,.25) !important; }
.fab:active { transform: translateX(-50%) scale(.98); }
#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: var(--s3) var(--s4); border-radius: var(--r-md); font-size: 14px; font-weight: 500; z-index: 40; max-width: calc(100% - 48px); }
.divider { height: 1px; background: var(--line); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Legal pages */
.legal { font-size: 15px; line-height: 1.6; }
.legal h1 { font-size: 28px; }
.legal a { color: var(--red-earth); }
