/* Freedom Receipts — Freedom style guide: Raleway Bold/Black, green #7fb539, black #000, gray #808285, mountain mark. */
:root {
  --green: #7fb539;      /* fills, rules, primary buttons (black text) */
  --green-ink: #4b7618;  /* green for text on white (5.6:1) */
  --green-wash: #eef5e4;
  --black: #000;
  --ink: #111312;
  --ink-2: #4d5052;
  --gray: #808285;       /* wordmark, large labels only */
  --mist: #f3f5f1;
  --line: #dfe3dc;
  --warn: #8a5a00;
  --warn-wash: #fff6e0;
  --err: #a1261b;
  --radius: 12px;
  --font: "Raleway", "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--mist); color: var(--ink); font: 500 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; min-height: 100dvh; }
[hidden] { display: none !important; }
h1, h2 { font-weight: 900; letter-spacing: -.02em; line-height: 1.1; margin: 0 0 .4em; text-wrap: balance; }
h1 { font-size: 1.75rem; }
p { margin: 0 0 1em; }
.muted { color: var(--ink-2); }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }

/* Header */
.top { position: sticky; top: 0; z-index: 10; background: var(--black); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 18px 10px; }
.logo { display: inline-flex; flex-direction: column; align-items: center; color: #fff; text-decoration: none; line-height: 1; }
.logo svg { width: 26px; height: 18px; fill: var(--green); margin-bottom: 3px; }
.logo .l1 { font-weight: 800; font-size: 1rem; letter-spacing: .06em; }
.logo .l2 { font-weight: 800; font-size: .5rem; letter-spacing: .5em; margin-right: -.5em; margin-top: 3px; color: #c9cbcd; }
.app-name { font-weight: 700; font-size: .8rem; letter-spacing: .04em; color: #c9cbcd; }

main { max-width: 680px; margin: 0 auto; padding: 24px 18px calc(48px + env(safe-area-inset-bottom)); }
.view { animation: in .35s var(--ease); }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .view, .pulse { animation: none !important; } }

.card { background: #fff; border-radius: var(--radius); padding: 24px; box-shadow: 0 1px 0 var(--line); }
.narrow { max-width: 420px; margin: 8vh auto 0; }

/* Home */
.hero { font-size: clamp(2rem, 8vw, 2.8rem); margin-top: 8px; }
.lead { font-size: 1.05rem; max-width: 34em; }
.capture { display: grid; gap: 12px; margin: 24px 0 8px; }
@media (min-width: 560px) { .capture { grid-template-columns: 1fr 1fr; } }
.drop-hint { font-size: .85rem; text-align: center; }
body.dragging main { outline: 3px dashed var(--green); outline-offset: -8px; border-radius: var(--radius); }
.status { font-size: .85rem; min-height: 1.5em; }
.status.bad { color: var(--err); }
.section-h { font-size: 1rem; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; color: var(--ink-2); margin: 28px 0 10px; }
.recent { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.recent li { background: #fff; border-radius: 10px; padding: 12px 14px; display: flex; justify-content: space-between; gap: 12px; font-size: .92rem; }
.recent li b { font-weight: 700; }
.recent .amt { font-weight: 800; white-space: nowrap; }

/* Buttons */
.btn { font: 700 1rem/1 var(--font); border: 0; border-radius: 10px; padding: 14px 18px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; transition: transform .15s var(--ease), background .2s; min-height: 48px; }
.btn:active { transform: scale(.98); }
.btn svg { width: 22px; height: 22px; fill: currentColor; }
.btn.primary { background: var(--green); color: var(--black); }
.btn.primary:hover { background: #8cc443; }
.btn.secondary { background: var(--black); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.big { padding: 22px; font-size: 1.1rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: progress; }

/* Fields */
.field { display: block; margin: 0 0 16px; min-width: 0; }
.field > span { display: block; font-weight: 700; font-size: .85rem; margin-bottom: 6px; }
input, select { font: 600 1rem var(--font); color: var(--ink); width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; min-height: 48px; }
input:focus, select:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 3px var(--green-wash); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { display: block; font-size: .8rem; color: var(--ink-2); margin-top: 6px; }
.error { color: var(--err); font-weight: 700; min-height: 1.2em; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; margin: 8px 0 16px; }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--green); }

/* Picker (searchable dropdown) */
.picker { position: relative; }
.picker input { padding-right: 40px; }
.picker .clear { position: absolute; right: 6px; top: 6px; width: 36px; height: 36px; border: 0; background: none; font-size: 1.2rem; color: var(--ink-2); cursor: pointer; border-radius: 8px; }
.picker ul { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); max-height: 280px; overflow: auto; margin: 0; padding: 4px; list-style: none; background: #fff; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15), 0 0 0 1px var(--line); }
.picker li { padding: 10px 12px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.picker li small { color: var(--ink-2); font-weight: 600; }
.picker li[aria-selected="true"], .picker li:hover { background: var(--green-wash); }
.picker li.group { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); cursor: default; background: none; padding-top: 12px; }
.picker.filled input { border-color: var(--green); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { font: 700 .82rem/1.2 var(--font); border: 1.5px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px; padding: 8px 12px; cursor: pointer; text-align: left; }
.chip small { display: block; font-weight: 600; color: var(--ink-2); font-size: .72rem; margin-top: 2px; }
.chip.on { border-color: var(--green); background: var(--green-wash); }
.chip .pct { color: var(--green-ink); }

/* Segmented control */
.seg { border: 0; padding: 0; margin: 0 0 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 12px 14px; border-radius: 10px; background: #fff; border: 1.5px solid var(--line); }
.seg b { display: block; font-weight: 800; }
.seg small { color: var(--ink-2); font-weight: 600; }
.seg input:checked + span { border-color: var(--black); box-shadow: inset 0 0 0 1px var(--black); }
.seg input:focus-visible + span { outline: 3px solid var(--green); outline-offset: 2px; }

/* Reading */
.reading { position: relative; border-radius: var(--radius); overflow: hidden; background: #fff; min-height: 50vh; display: grid; place-items: center; }
.reading img { width: 100%; max-height: 70vh; object-fit: contain; opacity: .35; }
.reading-msg { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; font-weight: 800; font-size: 1.1rem; }
.pulse { width: 64px; height: 44px; fill: var(--green); margin: 0 auto 8px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: translateY(-6px); opacity: .6; } }

/* Review */
.review-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.review-head h1 { margin: 0; }
.eyebrow { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--green-ink); margin: 0 0 4px; }
.thumb { flex: none; width: 72px; height: 92px; border-radius: 10px; overflow: hidden; border: 0; padding: 0; background: #fff; box-shadow: 0 0 0 1px var(--line); cursor: zoom-in; display: grid; place-items: center; font-weight: 900; color: var(--ink-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }

.questions { background: var(--green-wash); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; }
.questions h2 { font-size: 1rem; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.questions h2 svg { width: 22px; height: 15px; fill: var(--green-ink); }
.q { margin-bottom: 14px; }
.q:last-child { margin-bottom: 0; }
.q p { font-weight: 700; margin-bottom: 4px; }
.q.answered p::after { content: "  ✓"; color: var(--green-ink); }
.note { background: #fff; border-radius: 10px; padding: 12px 14px; font-size: .9rem; color: var(--ink-2); }
.warn { background: var(--warn-wash); color: var(--warn); border-radius: 10px; padding: 12px 14px; font-weight: 600; font-size: .92rem; margin-bottom: 16px; }

.line { background: #fff; border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 0 var(--line); }
.line-top { display: grid; grid-template-columns: 1fr 120px auto; gap: 10px; align-items: start; }
.line .rm { margin-top: 26px; }
.line-top .field { margin-bottom: 12px; }
.line .rm { border: 0; background: none; color: var(--ink-2); font-size: 1.3rem; width: 40px; height: 48px; margin-bottom: 12px; cursor: pointer; border-radius: 8px; }
.line .field:last-of-type { margin-bottom: 0; }
.lines-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.balance { font-weight: 800; font-size: .9rem; }
.balance.ok { color: var(--green-ink); }
.balance.bad { color: var(--err); }

.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.actions .btn.primary { flex: 1; max-width: 280px; }

/* Done */
.done { text-align: center; }
.done-mark { width: 72px; height: 50px; fill: var(--green); margin-bottom: 8px; }

/* Dialogs */
dialog { border: 0; border-radius: 16px; padding: 22px; width: min(480px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0,0,0,.3); font-family: var(--font); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.55); }
.summary { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 14px 0 18px; font-size: .95rem; }
.summary dt { color: var(--ink-2); font-weight: 600; }
.summary dd { margin: 0; font-weight: 700; }
#viewer { width: min(900px, calc(100vw - 16px)); max-height: 92vh; padding: 12px; }
#viewer .close { margin-bottom: 8px; }
#viewer img, #viewer iframe { width: 100%; max-height: 80vh; object-fit: contain; border: 0; }
#viewer iframe { height: 80vh; }

@media (max-width: 420px) {
  .row { grid-template-columns: 1fr; gap: 0; }
  .line-top { grid-template-columns: 1fr 104px auto; }
}
#add-vendor { margin-top: 8px; font-size: .9rem; min-height: 40px; padding: 10px 14px; }
