/* Receipts app styles. Simple, phone first. - Claude */
:root {
  --bg: #f6f7f5; --card: #fff; --ink: #1c2421; --muted: #6a756f; --line: #e2e6e3;
  --accent: #1f6f5c; --accent-ink: #fff; --warn: #fff6e0; --warn-line: #f0d48a; --bad: #b3261e; --ok: #1f7a3d; --okbg: #e7f5ec;
  --r: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121614; --card: #1c211f; --ink: #e8ece9; --muted: #9aa69f; --line: #2d3531; --warn: #3a2f12; --warn-line: #6b5520; --okbg: #17321f; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; padding-bottom: 90px; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 1.2rem 0 .8rem; }
h2 { font-size: 1.3rem; margin: .4rem 0; }
h3 { font-size: 1.05rem; margin: 0 0 .6rem; }
main { max-width: 760px; margin: 0 auto; padding: 12px 16px; }
.narrow { max-width: 420px; margin: 0 auto; padding: 0 16px; }
header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); font-size: 1.1rem; }
header nav { display: flex; gap: 4px; }
header nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: .95rem; }
header nav a.on { color: var(--ink); background: var(--bg); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin: 12px 0; }
.form label { display: block; margin: 0 0 12px; font-size: .9rem; color: var(--muted); }
.form input, .form select, .form textarea { display: block; width: 100%; margin-top: 4px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; max-width: 100%; }
textarea { min-height: 80px; }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px; padding: 10px 16px; min-height: 44px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:disabled { opacity: .6; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.ghost, .btn.ghost { background: transparent; }
button.small, .btn.small { padding: 6px 12px; min-height: 36px; font-size: .9rem; }
button.tiny { padding: 2px 8px; min-height: 28px; font-size: .8rem; }
button.big { font-size: 1.1rem; padding: 14px 28px; min-width: 60%; margin: 8px 0; }
button.wide { width: 100%; margin: 8px 0; }
.danger { color: var(--bad) !important; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.between, .between { justify-content: space-between; }
.row.center, .center { justify-content: center; text-align: center; }
.pad { padding: 24px 8px; }
.pad-s { padding: 6px 2px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--bad); }
.grow { flex: 1; min-width: 0; }
.searchbar { display: flex; gap: 8px; margin: 6px 0; }
.searchbar input { flex: 1; min-width: 0; }
.filters { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.filters[hidden] { display: none; }
.filters .pair { display: flex; gap: 8px; grid-column: span 2; }
.filters .pair input { flex: 1; min-width: 0; }
.summary { margin: 8px 2px; color: var(--muted); font-size: .9rem; }
.items-sum { color: var(--ink); font-weight: 600; margin-top: 2px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.rcard { display: flex; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; text-decoration: none; color: var(--ink); }
.rcard img, .rcard .nothumb { width: 56px; height: 72px; object-fit: cover; object-position: top; border-radius: 6px; background: #ddd; flex: none; }
.rcard .nothumb { display: flex; align-items: center; justify-content: center; font-size: .75rem; color: #777; }
.rbody { flex: 1; min-width: 0; }
.rbody strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.ret { color: var(--ok); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 1px 10px; font-size: .8rem; display: inline-flex; align-items: center; gap: 2px; }
.tags.edit { margin: 10px 0; align-items: center; }
.tags.edit input { min-height: 34px; padding: 4px 10px; border-radius: 999px; font-size: .9rem; width: 9em; }
.tag .x { border: 0; background: none; min-height: 0; padding: 0 2px 0 4px; color: var(--muted); font-size: 1rem; }
.pill { display: inline-block; border-radius: 999px; padding: 0 8px; font-size: .75rem; margin-left: 6px; background: var(--bg); border: 1px solid var(--line); }
.pill.ok { background: var(--okbg); color: var(--ok); border-color: transparent; }
.pill.bad { background: #fde7e5; color: var(--bad); border-color: transparent; }
.mitems { list-style: none; margin: 6px 0 0; padding: 6px 0 0; border-top: 1px dashed var(--line); font-size: .85rem; }
.mitems li { display: flex; justify-content: space-between; gap: 8px; }
.banner { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; margin: 8px 0; text-decoration: none; color: var(--ink); }
.banner.warn { background: var(--warn); border-color: var(--warn-line); }
.banner.ok { background: var(--okbg); border-color: transparent; }
.banner p { margin: 0 0 8px; }
.rhead { margin: 4px 0 8px; }
.rhead .big { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pages { display: flex; flex-direction: column; gap: 8px; align-items: center; margin: 10px 0; }
canvas.page { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; max-height: 70vh; object-fit: contain; cursor: zoom-in; }
canvas.page.zoom { max-height: none; cursor: zoom-out; }
dl.fields { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 10px; }
dl.fields dt { color: var(--muted); }
dl.fields dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
ul.items { list-style: none; padding: 0; margin: 0; }
ul.items li { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.itools { margin-top: 2px; }
.more { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; margin: 8px 0; }
.more[hidden] { display: none; }
.fab { position: fixed; right: 18px; bottom: max(18px, env(safe-area-inset-bottom)); background: var(--accent); color: #fff; border-radius: 999px; padding: 14px 22px; display: flex; align-items: center; gap: 8px;
  text-decoration: none; font-weight: 700; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); z-index: 6; }
.fab[hidden] { display: none; }
#toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px); background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw; z-index: 10; }
#toast.show { opacity: 1; transform: translateX(-50%); }
.stage { margin: 10px 0; }
.preview canvas { display: block; max-width: 100%; max-height: 65vh; margin: 0 auto 10px; border: 1px solid var(--line); background: #fff; object-fit: contain; height: auto; }
.cropper { position: relative; margin: 0 auto 10px; touch-action: none; }
.cropper canvas { display: block; }
.cropper .overlay { position: absolute; left: 0; top: 0; pointer-events: none; }
.cropper polygon { fill: rgba(31, 111, 92, .15); stroke: #1fd1a5; stroke-width: 2; }
.handle { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; background: rgba(31, 209, 165, .35); border: 3px solid #1fd1a5; touch-action: none; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.bar span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
ul.stats { list-style: none; padding: 0; margin: 0 0 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
ul.plain { list-style: none; padding: 0; margin: 0 0 10px; }
ul.plain li { padding: 6px 0; border-top: 1px solid var(--line); }
.sub { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 8px; }
label.check { display: flex; gap: 10px; align-items: center; }
label.check input { min-height: 0; width: 20px; height: 20px; }
input.copy { flex: 1; min-width: 0; font-size: .85rem; }
details summary { cursor: pointer; color: var(--muted); margin: 8px 0; }
