/* One column on phones, wider column on desktop; bottom tab bar; money first. */
:root {
  --bg: #f6f7f8; --surface: #ffffff; --ink: #18232b; --muted: #46525b; --line: #dde2e6;
  --accent: #0f6e6a; --accent-ink: #ffffff; --accent-soft: #e2f1ef; --tag: #f2c14e; --tag-ink: #3d2f00;
  --good: #1d7a43; --warn: #a36100; --bad: #b3261e; --bad-soft: #fbe9e7; --warn-soft: #fbf1df; --good-soft: #e3f3e8;
  --f-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-body: "Source Sans 3", "Segoe UI", Roboto, sans-serif;
  --f-num: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --tabs-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #11171b; --surface: #182128; --ink: #e6ecef; --muted: #b4c0c8; --line: #2a353d;
  --accent: #4fc2b8; --accent-ink: #0b1a19; --accent-soft: #163a38; --tag: #f2c14e; --tag-ink: #2b2100;
  --good: #5fcf8b; --warn: #f0b04f; --bad: #ff8a80; --bad-soft: #3a1d1b; --warn-soft: #362a15; --good-soft: #17301f;
  color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #11171b; --surface: #182128; --ink: #e6ecef; --muted: #b4c0c8; --line: #2a353d;
  --accent: #4fc2b8; --accent-ink: #0b1a19; --accent-soft: #163a38; --tag: #f2c14e; --tag-ink: #2b2100;
  --good: #5fcf8b; --warn: #f0b04f; --bad: #ff8a80; --bad-soft: #3a1d1b; --warn-soft: #362a15; --good-soft: #17301f;
  color-scheme: dark }

* { box-sizing: border-box }
[hidden] { display: none !important }
html, body { margin: 0 }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 var(--f-body); -webkit-text-size-adjust: 100% }
#app { max-width: 760px; margin: 0 auto; padding-inline: 16px;
  padding-block: calc(env(safe-area-inset-top, 0px) + 16px) calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px) + 32px);
  display: grid; gap: 20px }
body.no-tabs #app { padding-bottom: 40px }
h1, h2, h3 { font-family: var(--f-display); margin: 0; text-wrap: balance }
h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em }
h2 { font-size: 1.12rem; font-weight: 700 }
h3 { font-size: 1rem; font-weight: 700 }
p { margin: 0 }
a { color: var(--accent) }
.muted { color: var(--muted) }
.small { font-size: .88rem }
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums }
.eyebrow { font: 600 .74rem/1.2 var(--f-body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted) }
.stack { display: grid; gap: 12px; min-width: 0 }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap }
.row.between { justify-content: space-between }
.grow { flex: 1 1 auto; min-width: 0 }
.over { color: var(--bad) }
.rise { color: var(--warn) }
.ok { color: var(--good) }

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 10px; min-width: 0 }
.card.key { border-color: var(--accent); background: var(--accent-soft) }
.alert { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--tag); border-radius: 10px; padding: 12px 14px; display: grid; gap: 4px }
.alert.reminder { border-left-color: var(--accent) }
.alert.bad { border-left-color: var(--bad); background: var(--bad-soft) }
.alert.warn { border-left-color: var(--warn); background: var(--warn-soft) }
.alert.good { border-left-color: var(--good); background: var(--good-soft) }
.big { font-family: var(--f-num); font-size: 2rem; font-weight: 500; line-height: 1.1 }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 2px }
.stat .v { font-family: var(--f-num); font-size: 1.1rem; overflow-wrap: anywhere }

/* controls */
button, .btn { font: 600 1rem/1 var(--f-body); border-radius: 10px; padding: 13px 16px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; min-height: 46px }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent) }
button.danger { color: var(--bad); border-color: var(--bad) }
button.link { background: none; border: 0; color: var(--accent); padding: 6px 0; min-height: 0 }
button:disabled { opacity: .55; cursor: default }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
.full { width: 100% }
label { display: grid; gap: 4px; font-weight: 600; font-size: .92rem; min-width: 0 }
label .hint { font-weight: 400; color: var(--muted); font-size: .85rem }
input, select, textarea { font: 400 1rem var(--f-body); color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 11px 12px; width: 100%; min-width: 0; min-height: 44px }
input.num { font-family: var(--f-num) }
.check { display: flex; gap: 10px; align-items: center; font-weight: 400; font-size: 1rem }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent) }
.chips { display: flex; flex-wrap: wrap; gap: 8px }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 9px 14px; font: 600 .92rem/1 var(--f-body);
  cursor: pointer; min-height: 40px; color: var(--ink) }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent) }
.pill { font: 600 .72rem/1 var(--f-body); padding: 4px 8px; border-radius: 99px; white-space: nowrap; display: inline-block }
.pill.best { background: var(--accent); color: var(--accent-ink) }
.pill.sale { background: var(--tag); color: var(--tag-ink) }
.pill.bad { background: var(--bad); color: var(--surface) }
.pill.muted { background: var(--line); color: var(--ink) }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px }
@media (max-width: 420px) { .grid3 { grid-template-columns: 1fr 1fr } }

/* lists */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden }
.li { display: flex; gap: 12px; align-items: center; padding: 13px 14px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; min-width: 0 }
.li:last-child { border-bottom: 0 }
a.li:hover, button.li:hover { background: var(--accent-soft) }
button.li { width: 100%; border-radius: 0; border: 0; border-bottom: 1px solid var(--line); text-align: left; font-weight: 400; min-height: 0 }
.li .grow > * { overflow: hidden; text-overflow: ellipsis }

/* review lines */
.line { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 10px }
.line.removed { opacity: .5 }
.line .lgrid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px }
.totals { display: grid; gap: 6px; padding: 12px 14px; border-radius: 10px }
.totals .t { display: flex; justify-content: space-between; gap: 12px }
.photo { width: 100%; max-height: 340px; object-fit: contain; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; cursor: zoom-in }
.photo.open { max-height: none; cursor: zoom-out }
.sticky-actions { position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px) + 8px); display: grid; gap: 8px;
  background: var(--bg); padding-block: 10px; z-index: 2 }

/* table */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px }
table { width: 100%; border-collapse: collapse; min-width: 560px }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top }
th { font: 600 .74rem/1.2 var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted) }
td.r, th.r { text-align: right }
tr.item { cursor: pointer }
tr.item:hover td { background: var(--accent-soft) }
tr.detail td { background: var(--bg) }
.src { display: grid; grid-template-columns: minmax(100px, 1.2fr) 1fr 1fr 120px; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); align-items: baseline }
.src:last-child { border-bottom: 0 }

/* match card */
.match { display: grid; gap: 14px; text-align: center; padding: 22px 16px }
.match .prod { font-family: var(--f-num); font-size: 1.05rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-wrap: anywhere }

/* tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 10 }
.tabs a { display: grid; justify-items: center; gap: 2px; padding: 8px 0 10px; font: 600 .74rem/1 var(--f-body); color: var(--muted); text-decoration: none; position: relative; min-height: var(--tabs-h) }
.tabs a .ti { font-size: 1.25rem; line-height: 1.2 }
.tabs a.on { color: var(--accent) }
.tabs a.add .ti { background: var(--accent); color: var(--accent-ink); width: 36px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-size: 1.4rem }
.tabs b { position: absolute; top: 5px; left: calc(50% + 6px); background: var(--bad); color: #fff; font: 600 .7rem/1 var(--f-body); padding: 3px 6px; border-radius: 99px }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px) + 14px);
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 10px; z-index: 20; max-width: calc(100% - 32px); font-weight: 600 }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; margin: 0 auto }
@keyframes spin { to { transform: rotate(360deg) } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s } }
.center { text-align: center }
.auth { max-width: 420px; margin: 6vh auto 0; width: 100% }
.brand { font-family: var(--f-display); font-weight: 800; font-size: 1.05rem; color: var(--accent); letter-spacing: .01em }

/* item linking */
.linked { display: flex; gap: 8px; align-items: center; background: var(--accent-soft); border-radius: 8px; padding: 8px 10px; font-weight: 600; min-width: 0 }
.linked .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.results { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: 6px }
.results .li { padding: 10px 12px }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; align-items: baseline }
.kv dt { color: var(--muted); font-size: .88rem }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere }
.search { position: relative }
.search input { padding-left: 38px }
.search::before { content: "⌕"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 1.2rem; pointer-events: none }
textarea { resize: vertical; font-family: var(--f-num) }
details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; list-style: none }
details > summary::-webkit-details-marker { display: none }
details > summary::after { content: "›"; margin-left: auto; color: var(--muted); transition: transform .15s }
details[open] > summary::after { transform: rotate(90deg) }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0 }
.big .num { font-size: inherit }
.row.wrap { flex-wrap: wrap; gap: 8px 16px }
label.inline { display: flex; align-items: center; gap: 10px; font-weight: 500 }
label.inline select { width: auto; flex: 1; min-width: 0 }

/* ---- easier to read and tap */
body { font-size: 17px }
.li { min-height: 60px }
.li .r, .r { text-align: right; flex: none }
.chev { color: var(--muted); font-size: 1.4rem; line-height: 1; flex: none }
.ok-mark { color: var(--good); font-weight: 700; font-size: 1.2rem }
.gain { color: var(--good) }
.pill.warn { background: var(--warn-soft); color: var(--warn) }
.item-row strong { font-size: 1.02rem }

/* ---- item popup: bottom sheet on phones, centered window on wider screens */
.sheet { border: 0; padding: 0; background: var(--surface); color: var(--ink); width: 100%; max-width: 560px;
  max-height: 92dvh; border-radius: 18px 18px 0 0; margin: auto auto 0; box-shadow: 0 -8px 40px rgb(0 0 0 / .25); overflow: hidden }
.sheet::backdrop { background: rgb(0 0 0 / .45) }
.sheet[open] { animation: sheet-up .22s ease-out }
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4 } to { transform: none; opacity: 1 } }
#sheet-body { display: grid; gap: 14px; padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px)); overflow-y: auto; max-height: 92dvh; overscroll-behavior: contain }
#sheet-body::before { content: ""; justify-self: center; width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin-top: 2px }
.sheet-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; position: sticky; top: -8px;
  background: var(--surface); padding: 8px 0 6px; z-index: 1 }
.sheet-head h2 { font-size: 1.3rem; overflow-wrap: anywhere }
.sheet-x { flex: none; width: 48px; height: 48px; min-height: 48px; padding: 0; border-radius: 50%; font-size: 1.2rem; line-height: 1 }
.sheet .card.key .big { font-size: 1.7rem; font-family: var(--f-display) }
.sheet-price { font-size: 1.25rem; font-weight: 600 }
.sheet .card.key p { margin-top: 6px }
.sheet-profit p + p { margin-top: 4px }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; position: sticky; bottom: 0; background: var(--surface); padding-top: 6px }
.sheet-actions > * { min-height: 52px; display: flex; align-items: center; justify-content: center; text-align: center }
@media (min-width: 700px) {
  .sheet { border-radius: 18px; margin: auto; max-height: 86vh }
  #sheet-body { max-height: 86vh }
  #sheet-body::before { display: none }
}
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none } }
.num.price { font-size: 1.08rem; font-weight: 600 }

/* ---- reports */
.choice-list { display: grid; gap: 8px }
.choice { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 14px; font-weight: 400; min-height: 60px }
.choice strong { display: block; margin-bottom: 2px }
.choice .dot { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); margin-top: 1px }
.choice[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent) }
.choice[aria-checked="true"] .dot { border-color: var(--accent); background: radial-gradient(var(--accent) 0 5px, transparent 6px) }
.big-btn { min-height: 56px; font-size: 1.08rem }
.dl-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px }
.btn.dl { display: grid; gap: 4px; justify-items: center; text-align: center; padding: 14px 8px; min-height: 72px; text-decoration: none; color: var(--ink) }
.btn.dl strong { font-size: 1.05rem }
.hint { font: 400 .85rem var(--f-body); color: var(--muted) }
tfoot td { border-top: 2px solid var(--ink) }
table.fit { min-width: 0 } table.fit th, table.fit td { padding-inline: 8px }
@media (max-width: 520px) { table.report td, table.report th { font-size: .82rem; padding: 8px 6px } table.report td.num { font-size: .8rem } }

/* ---- price tag (NIST SP 1181: bold, large, own background, contrast >= 7:1) */
:root { --tag-bg: #e2f1ef; --tag-ink: #0b4f4c; --tag-line: #0f6e6a }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --tag-bg: #163a38; --tag-ink: #ffffff; --tag-line: #4fc2b8 } }
:root[data-theme="dark"] { --tag-bg: #163a38; --tag-ink: #ffffff; --tag-line: #4fc2b8 }
.ptag { flex: none; display: grid; justify-items: center; align-content: center; min-width: 96px; padding: 8px 12px;
  background: var(--tag-bg); color: var(--tag-ink); border: 2px solid var(--tag-line); border-radius: 12px; line-height: 1.05 }
.ptag-v { font: 800 1.75rem/1 var(--f-display); font-variant-numeric: tabular-nums lining-nums; letter-spacing: -0.01em }
.ptag-u { font: 700 .85rem/1.2 var(--f-body); margin-top: 3px }
.ptag-oz { font: 600 .78rem/1.2 var(--f-body); margin-top: 2px }
.ptag.big { min-width: 130px; padding: 10px 16px }
.ptag.big .ptag-v { font-size: 2.4rem }
.where { color: var(--ink) }
.best-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 }
.place-price { font: 800 1.2rem/1 var(--f-display); font-variant-numeric: tabular-nums }
.item-row { align-items: center }
.place-price.no { color: var(--muted); text-decoration: line-through; font-weight: 600 }

/* ---- many receipts */
.bar { height: 14px; border-radius: 99px; background: var(--line); overflow: hidden }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease }
.big-count { font: 800 1.5rem/1.2 var(--f-display); text-align: center }
.check input { width: 22px; height: 22px; min-height: 0; flex: none }

/* ---- select many in To do */
.selrow { gap: 14px }
.selrow .box { flex: none; width: 26px; height: 26px; border: 2px solid var(--muted); border-radius: 7px; display: grid; place-items: center }
.selrow[aria-checked="true"] { background: var(--accent-soft) }
.selrow[aria-checked="true"] .box { background: var(--accent); border-color: var(--accent) }
.selrow[aria-checked="true"] .box::after { content: "✓"; color: var(--accent-ink); font-weight: 800; font-size: 1rem; line-height: 1 }
.actionbar { position: fixed; left: 0; right: 0; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px)); z-index: 5;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgb(0 0 0 / .12);
  padding: 12px 16px; display: grid; gap: 10px; max-width: 760px; margin: 0 auto }
.actionbar .grid2 > * { min-height: 52px }
body.has-actionbar #app { padding-bottom: calc(var(--tabs-h) + 170px) }
button.danger-fill { background: var(--bad); color: var(--bg); border-color: var(--bad); font-weight: 700 }
button.danger-fill:disabled { opacity: .45 }
button.link.selall { padding: 8px 4px; min-height: 44px; font-weight: 600; text-decoration: underline }

/* ---- savings chart (colors validated for color-blind safety and contrast on the box) */
:root { --chart-total: #00897b; --chart-week: #b86e00; --chart-grid: #c9dedb }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --chart-total: #26a396; --chart-week: #c27f17; --chart-grid: #2b4c4a } }
:root[data-theme="dark"] { --chart-total: #26a396; --chart-week: #c27f17; --chart-grid: #2b4c4a }
.savechart { display: grid; gap: 8px; margin-top: 6px; min-width: 0 }
.savechart .legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .88rem; color: var(--ink) }
.savechart .legend span { display: inline-flex; align-items: center; gap: 8px }
.savechart .k { display: inline-block; width: 22px; border-radius: 2px; flex: none }
.savechart .k.thick { height: 4px; background: var(--chart-total) }
.savechart .k.thin { height: 2px; background: var(--chart-week) }
.savechart .plot { position: relative }
.savechart svg { display: block; overflow: visible; touch-action: pan-y }
.savechart .grid { stroke: var(--chart-grid); stroke-width: 1 }
.savechart .ax { fill: var(--muted); font: 500 11px var(--f-body) }
.savechart .area { fill: var(--chart-total); opacity: .12 }
.savechart .l-total { fill: none; stroke: var(--chart-total); stroke-width: 3.5; stroke-linejoin: round; stroke-linecap: round }
.savechart .l-week { fill: none; stroke: var(--chart-week); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round }
.savechart .d-total { fill: var(--chart-total); stroke: var(--accent-soft); stroke-width: 2 }
.savechart .d-week { fill: var(--chart-week); stroke: var(--accent-soft); stroke-width: 2 }
.savechart .cross { stroke: var(--muted); stroke-width: 1 }
.savechart .endlabel { fill: var(--ink); font: 700 13px var(--f-body) }
.savechart .hit { cursor: crosshair; outline: none }
.savechart .hit:focus-visible { outline: 2px solid var(--accent) }
.savechart .tip { display: grid; gap: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: .92rem; color: var(--ink); margin-top: 6px }
.savechart .tip span { display: flex; align-items: center; gap: 8px; flex-wrap: wrap }
.savechart .tbl-toggle { justify-self: start }
.save-head { display: flex; justify-content: space-between; align-items: center; gap: 12px }
.seg { display: inline-flex; border: 1px solid var(--accent); border-radius: 10px; overflow: hidden; flex: none; background: var(--surface) }
.seg button { min-height: 40px; min-width: 44px; padding: 0 12px; border: 0; border-radius: 0; background: transparent; color: var(--ink); font: 700 .95rem var(--f-body) }
.seg button + button { border-left: 1px solid var(--accent) }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink) }

/* ---- item search dropdown on receipt lines */
.combo { position: relative; display: grid; gap: 6px }
.combo > label { font-weight: 600 }
.combo-list { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 4px; max-height: min(60vh, 420px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--accent); border-radius: 12px; box-shadow: 0 12px 32px rgb(0 0 0 / .22); overscroll-behavior: contain }
.combo-head { position: sticky; top: 0; background: var(--surface); padding: 10px 14px; font-size: .85rem; color: var(--muted); border-bottom: 1px solid var(--line) }
.combo-list .opt { display: grid; gap: 2px; padding: 12px 14px; min-height: 56px; border-bottom: 1px solid var(--line); cursor: pointer; color: var(--ink) }
.combo-list .opt:last-child { border-bottom: 0 }
.combo-list .opt.on, .combo-list .opt:hover { background: var(--accent-soft) }
.combo-list .opt.new strong { color: var(--accent) }

/* ---- To do: four kinds, each with a color AND a written name (colors checked for color-blind safety) */
:root { --k-receipts: #e34948; --k-pricebook: #eda100; --k-prices: #008300; --k-reorder: #2a78d6 }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --k-receipts: #df4f6a; --k-pricebook: #c98500; --k-prices: #008300; --k-reorder: #3987e5 } }
:root[data-theme="dark"] { --k-receipts: #df4f6a; --k-pricebook: #c98500; --k-prices: #008300; --k-reorder: #3987e5 }
.k-receipts { --k: var(--k-receipts) } .k-pricebook { --k: var(--k-pricebook) } .k-prices { --k: var(--k-prices) } .k-reorder { --k: var(--k-reorder) }
.kdot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: var(--k, var(--muted)); flex: none; vertical-align: -1px }
.kdot.all { background: conic-gradient(var(--k-receipts) 0 25%, var(--k-pricebook) 0 50%, var(--k-prices) 0 75%, var(--k-reorder) 0) }
.ktag { display: inline-flex; align-items: center; gap: 6px; font: 700 .72rem/1 var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: var(--ink) }
.ktag .kdot { width: 10px; height: 10px }
.note { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--k);
  border-radius: 12px; padding: 12px 14px; text-align: left; width: 100%; font-weight: 400; color: var(--ink) }
.note .grow { display: grid; gap: 4px; min-width: 0 }
.ntitle { font-size: 1.02rem; overflow-wrap: anywhere }
.note-act { display: flex; flex-direction: column; gap: 6px; flex: none; align-items: stretch }
.small-btn { min-height: 40px; padding: 8px 12px; font-size: .9rem; text-align: center; text-decoration: none; color: var(--ink) }
.gotit { white-space: nowrap }
.note.selrow[aria-checked="true"] { background: var(--accent-soft) }
.nhead { display: inline-flex; align-items: center; gap: 10px }
.nhead .kdot { width: 16px; height: 16px }
.kfilter { display: grid; gap: 6px }
.dd { position: relative }
.dd-btn { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; min-height: 52px; background: var(--surface); font-size: 1.02rem }
.dd-menu { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 12px 32px rgb(0 0 0 / .22); overflow: hidden; display: grid }
.dd-menu button { display: flex; align-items: center; gap: 12px; text-align: left; border: 0; border-radius: 0; border-bottom: 1px solid var(--line);
  min-height: 60px; padding: 10px 14px; background: transparent; font-weight: 400 }
.dd-menu button:last-child { border-bottom: 0 }
.dd-menu button .grow { display: grid; gap: 2px }
.dd-menu button[aria-selected="true"] { background: var(--accent-soft) }
.dd-menu button:disabled { opacity: .45 }
.dd-menu .kdot { width: 18px; height: 18px }
#toast .toast-act { margin-left: 10px; min-height: 0; padding: 4px 10px; font-weight: 700; background: transparent; color: inherit; border: 1px solid currentColor }
@media (max-width: 420px) { .note { flex-wrap: wrap } .note-act { flex-direction: row; width: 100%; } .note-act > * { flex: 1 } }
.ktag, .kname { background: color-mix(in srgb, var(--k) 20%, transparent); border: 1.5px solid var(--k); border-radius: 99px; padding: 4px 9px 4px 7px; justify-self: start; width: fit-content }
.kname { display: inline-flex; align-items: center; font-size: .95rem; padding: 3px 10px }

/* ---- camera window on computers */
.camdlg { max-width: 760px }
.cam-body { display: grid; gap: 12px; padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px)) }
.cam-frame { background: #000; border-radius: 12px; overflow: hidden; display: grid; place-items: center; min-height: 240px }
.cam-frame video, .cam-frame img { width: 100%; max-height: 62vh; object-fit: contain; display: block }

/* ---- confirm pop-up */
.confirm-dlg { max-width: 460px }
.confirm-dlg[open] { margin: auto }
.cd-body { display: grid; gap: 14px; padding: 22px 20px calc(20px + env(safe-area-inset-bottom, 0px)) }
.cd-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font: 800 1.5rem var(--f-display);
  background: var(--bad-soft); color: var(--bad); border: 2px solid var(--bad) }
.cd-text p { margin: 0 }
.cd-list { margin: 0; padding-left: 20px; display: grid; gap: 4px }
.confirm-dlg .danger-fill:disabled { opacity: .4; cursor: not-allowed }

/* ---- import / receipt history */
.hist { gap: 8px }
.hist details summary { min-height: 40px; font-weight: 600 }
.danger-outline { color: var(--bad); border-color: var(--bad); background: transparent; font-weight: 700 }

/* Home: one W / M / Y switch for the whole screen */
.home-head { align-items: flex-end; gap: 12px }
.home-head .seg { flex: none; margin-bottom: 4px }
body.home-busy #app { opacity: .55; transition: opacity .15s; pointer-events: none }
.now-tag { font: 600 .68rem/1 var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--line); border-radius: 99px; padding: 4px 8px; vertical-align: middle; margin-left: 6px; white-space: nowrap }
.pill.old { background: var(--line); color: var(--ink); font-weight: 500 }

/* Sort menus */
.sortrow { gap: 12px 16px; align-items: flex-end }
.sortby { margin-left: auto }
.sortby select { min-height: 44px }
@media (max-width: 520px) { .sortby { margin-left: 0 } }

/* Install steps */
.steps { margin: 0; padding-left: 1.4em; display: grid; gap: 10px; font-size: 1.05rem; line-height: 1.45 }
