/* 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; grid-template-columns: minmax(0, 1fr) }
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; grid-template-columns: minmax(0, 1fr) }
.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 }

/* Lines the reader wasn't sure about */
.line.check { border-left: 4px solid var(--warn, #b86e00); padding-left: 10px }

/* =====================================================================================
   CaseCost look (v0.15): navy, teal and gold; Albert Sans; cards with soft shadows.
   Phone: bottom tabs with a raised Add button. Computer (1024px+): navy sidebar, wide pages.
   ===================================================================================== */
:root {
  --bg: #F4F6F8; --surface: #FFFFFF; --ink: #0B1932; --muted: #5A6B7F; --line: #E3E8EE;
  --navy: #0B1932; --navy-2: #1A2C4C; --on-navy: #FFFFFF; --on-navy-muted: #C9D3E0;
  --accent: #12796B; --accent-ink: #FFFFFF; --accent-soft: #E7F6F3; --accent-strong: #0E6E61;
  --gold: #F8BC2E; --gold-ink: #0B1932; --tag: #F8BC2E; --tag-ink: #0B1932;
  --good: #1D7A43; --warn: #8A5A00; --warn-line: #B57A00; --bad: #C2362F;
  --bad-soft: #FDF0EF; --warn-soft: #FFF4D6; --good-soft: #E7F6F3; --blue: #2A6BC4; --blue-soft: #EAF1FB;
  --shadow: 0 1px 2px rgb(11 25 50 / .05), 0 6px 18px rgb(11 25 50 / .06);
  --f-display: "Albert Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-body: "Albert Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-num: "Albert Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tabs-h: 72px; --side-w: 248px;
  --tag-bg: transparent; --tag-line: transparent;
  --chart-total: #12796B; --chart-week: #B57A00; --chart-grid: #E3E8EE;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #08111F; --surface: #10203A; --ink: #E8EEF6; --muted: #A9B6C8; --line: #22365A;
  --navy: #0B1932; --navy-2: #1A2C4C;
  --accent: #4DC1B4; --accent-ink: #0B1932; --accent-soft: #12343A; --accent-strong: #7FD6CB;
  --good: #5FCF8B; --warn: #F0B04F; --warn-line: #F0B04F; --bad: #FF8A80;
  --bad-soft: #3A1D22; --warn-soft: #362A15; --good-soft: #12343A; --blue: #79A8EE; --blue-soft: #16294A;
  --shadow: 0 1px 2px rgb(0 0 0 / .3); --tag-ink: #0B1932;
  --chart-total: #4DC1B4; --chart-week: #F8BC2E; --chart-grid: #22365A } }
:root[data-theme="dark"] {
  --bg: #08111F; --surface: #10203A; --ink: #E8EEF6; --muted: #A9B6C8; --line: #22365A;
  --accent: #4DC1B4; --accent-ink: #0B1932; --accent-soft: #12343A; --accent-strong: #7FD6CB;
  --good: #5FCF8B; --warn: #F0B04F; --warn-line: #F0B04F; --bad: #FF8A80;
  --bad-soft: #3A1D22; --warn-soft: #362A15; --good-soft: #12343A; --blue: #79A8EE; --blue-soft: #16294A;
  --shadow: 0 1px 2px rgb(0 0 0 / .3); --chart-total: #4DC1B4; --chart-week: #F8BC2E; --chart-grid: #22365A }

body { font: 400 16.5px/1.5 var(--f-body); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased }
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em }
h2 { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.01em }
.num, .big, .stat .v, .place-price, .ptag-v { font-family: var(--f-num); font-variant-numeric: tabular-nums lining-nums }
.eyebrow { font: 700 .74rem/1.2 var(--f-body); letter-spacing: .07em }
.muted, .small.muted { color: var(--muted) }

/* surfaces */
.card, .list, .table-wrap, .stat, .line, .choice, .note, .alert { border-radius: 16px; border-color: var(--line) }
.card, .list, .table-wrap, .stat { box-shadow: var(--shadow) }
.card { padding: 18px; gap: 12px }
.alert { border-left-width: 1px; border-color: var(--line); background: var(--surface); padding: 14px 16px; box-shadow: var(--shadow) }
.alert.warn { background: var(--warn-soft); border-color: transparent; color: var(--ink) }
.alert.bad { background: var(--bad-soft); border-color: transparent }
.alert.good { background: var(--good-soft); border-color: transparent }
.alert.warn strong, .alert.warn .small { color: inherit }

/* the navy "hero" card: best price, savings */
.card.key { background: var(--navy); border-color: var(--navy); color: var(--on-navy);
  --ink: #FFFFFF; --muted: #C9D3E0; --line: #2A3E63; --surface: #13284B; --accent-soft: #163B57;
  --chart-total: #4DC1B4; --chart-week: #F8BC2E; --chart-grid: #22365A }
.card.key .eyebrow, .card.key .muted { color: #C9D3E0 }
.card.key a { color: #7FD6CB }
.card.key .big, .card.key .big.over { color: var(--gold); font-weight: 800; font-size: 2.4rem; letter-spacing: -0.02em }
.card.key .gain { color: #7FE0B0 } .card.key .over { color: #FFB3AC }
.card.key .btn.primary { background: var(--gold); color: var(--gold-ink); border-color: var(--gold) }

/* controls */
button, .btn { font: 700 1rem/1 var(--f-body); border-radius: 12px; min-height: 48px; padding: 13px 18px }
button.primary, .btn.primary { box-shadow: 0 4px 12px rgb(18 121 107 / .22) }
button.primary:hover, .btn.primary:hover { filter: brightness(1.06) }
input, select, textarea { border-radius: 12px; min-height: 48px; padding: 11px 14px; font: 400 1rem var(--f-body) }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent) }
.chip { border-radius: 99px; min-height: 40px; padding: 9px 16px; font-weight: 700 }
.chip[aria-pressed="true"] { background: var(--navy); color: #FFFFFF; border-color: var(--navy) }
:root[data-theme="dark"] .chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent) }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent) } }
.seg { border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; background: var(--surface) }
.seg button { border: 0 !important; border-radius: 9px; min-height: 36px; color: var(--muted) }
.seg button[aria-checked="true"] { background: var(--navy); color: #FFFFFF }
.card.key .seg { background: var(--navy-2); border-color: var(--navy-2) }
.card.key .seg button { color: #C9D3E0 }
.card.key .seg button[aria-checked="true"] { background: var(--gold); color: var(--gold-ink) }
.pill { border-radius: 8px; padding: 4px 8px; font-weight: 800 }
.pill.best { background: var(--accent-soft); color: var(--accent-strong) }
.pill.sale { background: var(--gold); color: var(--gold-ink) }
.pill.muted { background: var(--bg); color: var(--muted); border: 1px solid var(--line) }
.search::before { content: none }
.search { display: flex; align-items: center }
.search input { padding-left: 44px; min-height: 52px; font-size: 1.02rem; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%235A6B7F' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E") no-repeat 14px center }

/* lists: each row a clear tap target */
.li { padding: 14px 16px; gap: 14px }
a.li:hover, button.li:hover { background: var(--bg) }
.list .li strong { font-weight: 700 }

/* price: big, bold, high contrast, no box */
.ptag { min-width: 0; padding: 0; border: 0; background: none; color: var(--ink); justify-items: end; text-align: right }
.ptag-v { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em }
.ptag-u, .ptag-oz { font-weight: 600; color: var(--muted) }
.ptag.big { align-items: end }
.ptag.big .ptag-v { font-size: 2.6rem }
.card.key .ptag, .card.key .ptag-v { color: var(--gold) }
.card.key .ptag-u, .card.key .ptag-oz { color: #C9D3E0 }

/* tabs (phone) */
.tabs { height: auto; box-shadow: 0 -4px 20px rgb(11 25 50 / .06); align-items: end }
.tabs a { gap: 4px; font: 600 .74rem/1 var(--f-body); padding: 10px 0 12px }
.tabs a.on { color: var(--accent) }
.tabs .ti { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round }
.tabs a.add .ti { width: 52px; height: 32px; padding: 5px 15px; margin: -4px 0; border-radius: 12px; background: var(--gold); color: var(--gold-ink);
  stroke-width: 2.6; box-shadow: 0 3px 10px rgb(248 188 46 / .45) }
.tabs a.add, .tabs a.add.on { color: var(--ink); font-weight: 800 }
.tabs b { top: 4px; left: calc(50% + 4px); font-weight: 800 }
.side-brand, .side-add, .side-only { display: none !important }

/* computer: navy sidebar + wide pages */
@media (min-width: 1024px) {
  .tabs { top: 0; bottom: 0; left: 0; right: auto; width: var(--side-w); display: flex; flex-direction: column; gap: 4px;
    padding: 22px 14px; background: var(--navy); border: 0; box-shadow: none; overflow-y: auto }
  .tabs a { display: flex; align-items: center; gap: 12px; justify-items: start; padding: 11px 12px; border-radius: 10px; min-height: 46px;
    color: #C9D3E0; font: 600 15px/1.2 var(--f-body) }
  .tabs a:hover { background: var(--navy-2); color: #FFFFFF }
  .tabs a.on, .tabs a.on:hover { background: #12796B; color: #FFFFFF }
  .tabs a.add { display: none }
  .tabs .ti { width: 20px; height: 20px; flex: none }
  .tabs b { position: static; margin-left: auto; background: var(--gold); color: var(--gold-ink) }
  .side-brand { display: flex !important; color: #FFFFFF !important; font: 800 21px/1 var(--f-display) !important; gap: 10px; margin-bottom: 14px; padding: 4px 8px !important }
  .side-brand:hover { background: none !important }
  .side-brand .logo { width: 36px; height: 36px; border-radius: 10px; background: #12796B; display: grid; place-items: center }
  .side-brand .logo svg { width: 22px; height: 22px; stroke: #FFFFFF }
  .side-add { display: flex !important; background: var(--gold) !important; color: var(--gold-ink) !important; font-weight: 800 !important; margin-bottom: 12px; justify-content: center }
  .side-add .ti { stroke-width: 2.6 }
  .side-only { display: flex !important }
  .side-acct { margin-top: auto; border-top: 1px solid #1E2F4D; padding: 16px 10px 4px; display: grid !important; gap: 2px; color: #FFFFFF; font-size: 14px }
  .side-acct .eyebrow { color: #9AA8BC }
  .side-acct span:last-child { color: #9AA8BC }
  #app { margin-left: var(--side-w); max-width: none; padding: 30px 40px 56px; grid-template-columns: minmax(0, 860px); justify-content: center }
  body.wide #app { grid-template-columns: minmax(0, 1360px) }
  body.no-tabs #app { margin-left: 0 }
  #toast { left: calc(50% + var(--side-w) / 2); bottom: 28px }
  .actionbar { left: var(--side-w); bottom: 0; max-width: none }
  body.has-actionbar #app { padding-bottom: 180px }
  .sticky-actions { bottom: 12px }
  h1 { font-size: 2rem }
  /* item details open as a panel on the right, so the list stays in view */
  .sheet { position: fixed; inset: 0 0 0 auto; margin: 0; height: 100dvh; max-height: none; width: min(520px, 92vw); max-width: none; border-radius: 20px 0 0 20px }
  .sheet[open] { animation: sheet-left .2s ease-out }
  #sheet-body { max-height: 100dvh; padding: 18px 24px 24px }
}
@keyframes sheet-left { from { transform: translateX(40px); opacity: .4 } to { transform: none; opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none } }

/* ---------------- Home ---------------- */
.hero { margin: calc(-16px - env(safe-area-inset-top, 0px)) -16px 0; padding: calc(18px + env(safe-area-inset-top, 0px)) 16px 64px;
  background: var(--navy); color: #FFFFFF; display: grid; gap: 14px }
.hero .brandrow { display: flex; align-items: center; justify-content: space-between; gap: 10px }
.hero .brand-m { display: flex; align-items: center; gap: 9px; font: 800 1.2rem/1 var(--f-display) }
.logo-sq { width: 32px; height: 32px; border-radius: 9px; background: #12796B; display: grid; place-items: center; flex: none }
.logo-sq svg { width: 20px; height: 20px; fill: none; stroke: #FFFFFF; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round }
.hero select { width: auto; min-height: 40px; border-radius: 99px; background: var(--navy-2); color: #FFFFFF; border-color: var(--navy-2); font-weight: 700; padding: 6px 14px }
.hero .search input { border: 0; min-height: 52px }
.hero + * { margin-top: -78px }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center }
.toolbar .search { flex: 1 1 320px }
.toolbar select { width: auto; font-weight: 700 }
.home-grid { display: grid; gap: 20px; min-width: 0 }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; display: grid; gap: 4px; box-shadow: var(--shadow); min-width: 0 }
.kpi .v { font: 800 1.6rem/1.1 var(--f-num); letter-spacing: -0.02em; overflow-wrap: anywhere }
.kpi.bad .v { color: var(--bad) }
.kpi-save { display: none }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px }
.quick .btn { min-height: 56px; font-size: 1.02rem }
.quick svg, .btn svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none }
.cats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px }
.cat { display: grid; justify-items: center; gap: 6px; text-align: center; font: 700 .8rem/1.2 var(--f-body); color: var(--ink); text-decoration: none; background: none; border: 0; padding: 0; min-height: 0 }
.cat .ico { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: var(--c-soft, var(--accent-soft)) }
.cat .ico svg { width: 28px; height: 28px; fill: none; stroke: var(--c, var(--accent-strong)); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round }
.c-teal { --c: var(--accent-strong); --c-soft: var(--accent-soft) } .c-gold { --c: var(--warn); --c-soft: var(--warn-soft) }
.c-blue { --c: var(--blue); --c-soft: var(--blue-soft) } .c-red { --c: var(--bad); --c-soft: var(--bad-soft) }
.carousel { display: grid; grid-auto-flow: column; grid-auto-columns: 176px; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin-inline: -16px; padding: 2px 16px 8px; scrollbar-width: none }
.carousel::-webkit-scrollbar { display: none }
.pcard { scroll-snap-align: start; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; gap: 6px;
  align-content: start; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); min-width: 0 }
.pcard strong { font-size: 1rem; overflow-wrap: anywhere }
.pcard .pv { font: 800 1.6rem/1 var(--f-num); letter-spacing: -0.02em }
.pcard .pv small { font: 600 .8rem var(--f-body); color: var(--muted); letter-spacing: 0 }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px }
.sec-head a { font-weight: 700; font-size: .95rem; text-decoration: none }
.todo-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); background: var(--surface) }
.todo-row:last-child { border-bottom: 0 }
.todo-row .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--c-soft); }
.todo-row .ico svg { width: 20px; height: 20px; fill: none; stroke: var(--c); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round }
.todo-row .grow { display: grid; gap: 2px }
.chev-i { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none }
table.clean { min-width: 640px }
table.clean th { background: var(--bg); padding: 12px 16px; border-bottom: 1px solid var(--line) }
table.clean td { padding: 14px 16px; vertical-align: middle; border-bottom: 1px solid var(--line) }
table.clean tr:last-child td { border-bottom: 0 }
table.clean tbody tr { cursor: pointer }
table.clean tbody tr:hover td { background: var(--bg) }
table.clean .pv { font: 800 1.3rem/1 var(--f-num); letter-spacing: -0.01em }
table.clean .sub { font-size: .85rem; color: var(--muted) }
.badge { display: inline-block; font: 800 .72rem/1 var(--f-body); border-radius: 6px; padding: 4px 7px; margin-left: 6px; white-space: nowrap; vertical-align: 1px }
.badge.gold { background: var(--gold); color: var(--gold-ink) } .badge.red { background: var(--bad); color: #FFFFFF } .badge.teal { background: var(--accent-soft); color: var(--accent-strong) }
@media (min-width: 1024px) {
  .hero { display: none }
  .hero + * { margin-top: 0 }
  .home-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: start }
  .home-grid > * { grid-column: span 12 }
  .home-grid > .span-8 { grid-column: span 8 } .home-grid > .span-4 { grid-column: span 4 } .home-grid > .span-6 { grid-column: span 6 }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px }
  .kpi { padding: 20px 22px }
  .kpi .v { font-size: 2rem }
  .kpi-save { display: grid; background: var(--navy); border-color: var(--navy); color: #FFFFFF }
  .kpi-save .eyebrow, .kpi-save .small { color: #C9D3E0 }
  .kpi-save .v { color: var(--gold); font-size: 2.3rem }
  #savebox .save-total { display: none }
  .only-phone { display: none !important }
}
@media (max-width: 1023px) { .only-desk { display: none !important } }
.save-total { display: grid; gap: 4px }
@media (max-width: 1023px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px }
  .kpi { padding: 12px; border-radius: 14px }
  .kpi .v { font-size: 1.3rem }
  .kpi .small { display: none }
  .kpi .eyebrow { font-size: .66rem }
  .home-grid { gap: 22px }
}
@media (min-width: 1024px) {
  .o1 { order: 1 } .o2 { order: 2 } .o3 { order: 3 } .o4 { order: 4 } .o5 { order: 5 } .o6 { order: 6 } .o7 { order: 7 } .o8 { order: 8 } .o9 { order: 9 }
  .toolbar .btn { min-height: 52px }
  .toolbar .seg { min-height: 52px; align-items: center }
  .toolbar .seg button { min-height: 42px; padding: 0 14px }
  .toolbar select { min-height: 52px }
}
#savebox .save-head { align-items: flex-start }
#savebox .save-head h2 { color: #FFFFFF }
.savechart .tip { background: var(--navy-2); border-color: var(--navy-2) }
th.r, td.r { text-align: right }
.btn svg.i, button svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round }
@media (min-width: 1024px) { .tabs { align-items: stretch } .tabs a { justify-content: flex-start } }
/* Phone: the savings card is white on the navy header, like the design */
@media (max-width: 1023px) {
  #savebox { background: #FFFFFF; border-color: #FFFFFF; color: #0B1932; box-shadow: 0 8px 24px rgb(11 25 50 / .12);
    --ink: #0B1932; --muted: #5A6B7F; --line: #E3E8EE; --surface: #FFFFFF; --accent-soft: #E7F6F3;
    --chart-total: #12796B; --chart-week: #B57A00; --chart-grid: #E3E8EE }
  #savebox .eyebrow, #savebox .muted { color: #5A6B7F }
  #savebox .big { color: #0B1932 }
  #savebox .seg { background: #F4F6F8; border-color: #F4F6F8 }
  #savebox .seg button { color: #5A6B7F }
  #savebox .seg button[aria-checked="true"] { background: #0B1932; color: #FFFFFF }
  #savebox .savechart .tip { background: #F4F6F8; border-color: #E3E8EE }
  #savebox .save-head { flex-wrap: wrap }
}
@media (max-width: 1023px) and (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #savebox {
  background: #10203A; border-color: #22365A; color: #E8EEF6; --ink: #E8EEF6; --muted: #A9B6C8; --line: #22365A; --surface: #10203A;
  --chart-total: #4DC1B4; --chart-week: #F8BC2E; --chart-grid: #22365A }
  :root:not([data-theme="light"]) #savebox .big { color: #F8BC2E } :root:not([data-theme="light"]) #savebox .eyebrow, :root:not([data-theme="light"]) #savebox .muted { color: #A9B6C8 }
  :root:not([data-theme="light"]) #savebox .seg { background: #1A2C4C; border-color: #1A2C4C }
  :root:not([data-theme="light"]) #savebox .savechart .tip { background: #1A2C4C; border-color: #22365A } }
/* Prices */
.chiprow { display: flex; gap: 8px; overflow-x: auto; margin-inline: -16px; padding: 2px 16px 6px; scrollbar-width: none }
.chiprow::-webkit-scrollbar { display: none }
.chiprow .chip { flex: none }
@media (min-width: 1024px) { .chiprow { flex-wrap: wrap; margin-inline: 0; padding: 0 } }
.cards { display: grid; gap: 10px }
.icard { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px;
  text-decoration: none; color: var(--ink); box-shadow: var(--shadow); min-width: 0 }
.icard:hover { border-color: var(--accent) }
.icard .grow { display: grid; gap: 3px }
.icard strong { font-size: 1.04rem; overflow-wrap: anywhere }
.icard .bl { display: flex; flex-wrap: wrap; gap: 6px }
.icard .bl .badge { margin: 0 }
.ink { color: var(--ink) }
table.clean td.r { white-space: nowrap }
table.clean .badge { vertical-align: 2px }
.row.only-desk .btn { min-height: 46px }
@media (min-width: 1024px) { .chiprow { flex-wrap: nowrap; margin-inline: 0; padding: 0 0 6px } }
.icard .small strong { font-size: inherit; font-weight: 700 }
@media (max-width: 1023px) {
  .sortrow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px }
  .sortrow label.inline { display: grid; gap: 4px; font-size: .82rem; font-weight: 700; color: var(--muted) }
  .sortrow label.inline select { width: 100%; min-height: 44px; font-size: .95rem; color: var(--ink) }
  .sortrow .sortby { margin: 0 }
}
/* Checking a receipt: photo on the left, lines on the right (computer) */
.rv { display: grid; gap: 20px; min-width: 0 }
.rv-main { min-width: 0 }
@media (min-width: 1024px) {
  .rv { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start }
  .rv.nophoto { grid-template-columns: minmax(0, 860px) }
  .rv.nophoto .rv-photo { display: none }
  .rv-photo { position: sticky; top: 24px }
  .rv-photo .photo { max-height: calc(100vh - 60px) }
}
.line.check { border: 2px solid var(--warn-line); padding-left: 12px }
.line { border-radius: 16px; box-shadow: var(--shadow) }
.sticky-actions { background: linear-gradient(to top, var(--bg) 70%, transparent) }
/* Sign in */
body:has(#app > .auth) { background: var(--navy) }
.auth { max-width: 460px; margin: 8vh auto 0 }
.auth-card { background: var(--surface); border-radius: 20px; padding: 28px 24px; box-shadow: 0 20px 50px rgb(0 0 0 / .25) }
.auth .brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font: 800 1.3rem/1 var(--f-display) }

/* back button (v0.15.2): same everywhere, goes where you came from */
a.back { align-self: flex-start; justify-self: start; width: fit-content; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px 0 10px;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  color: var(--ink); font: 700 15px/1 var(--f-body); text-decoration: none; margin-bottom: 4px }
a.back:hover { border-color: var(--accent); color: var(--ink) }
a.back:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px }
a.back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; flex: none }

/* "your report is ready" sheet (iPhone app) */
.share-dlg .cd-body { gap: 14px }
.share-dlg .share-prev { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); display: grid; place-items: center; min-height: 120px }
.share-dlg .share-prev img { width: 100%; height: auto; display: block }
.share-dlg .share-prev svg { width: 48px; height: 48px; fill: none; stroke: var(--muted); stroke-width: 1.8 }
.btn.dl.busy { opacity: .6; pointer-events: none }
.share-dlg [data-share] { display: inline-flex; align-items: center; justify-content: center; gap: 8px }
.share-dlg [data-share] svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round }

/* appearance (v0.15.3) */
.appear-row { flex-wrap: wrap; gap: 10px 12px }
.seg.appear { border: 1px solid var(--line); background: var(--bg); padding: 3px; border-radius: 12px; gap: 2px }
.seg.appear button { min-height: 38px; padding: 0 12px; font-weight: 700; color: var(--muted) }
.seg.appear button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink) }
@media (max-width: 420px) { .appear-row .seg.appear { flex: 1 1 100%; } .seg.appear button { flex: 1 } }

/* item popup (v0.16.3): no corner X; the page behind stays still; slide down to close */
body.locked { position: fixed; left: 0; right: 0; overflow: hidden }
.sheet-actions.one { grid-template-columns: 1fr }
.sheet { will-change: transform }
.sheet-head { padding-top: 4px }

/* home search suggestions (v0.16.5) */
.search { position: relative }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 32px rgb(11 25 50 / .18); overflow-y: auto; max-height: min(60vh, 460px); padding: 6px }
.sug { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; min-height: 52px }
.sug .grow { display: flex; flex-direction: column; gap: 2px; min-width: 0 }
.sug strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700 }
.sug:hover, .sug[aria-selected="true"] { background: var(--accent-soft) }
.sug-p { font-weight: 800; font-size: 1.05rem; flex: none }
.sug-none { padding: 12px }
.sug-all { width: 100%; margin-top: 4px; min-height: 44px; border: 0; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; background: none;
  color: var(--accent); font: 700 .95rem var(--f-body); text-align: left; padding: 0 12px }
.hero, .toolbar { overflow: visible }

/* "go to" buttons in section headings (v0.16.6): the back button's look, smaller, on the heading line */
.sec-head { align-items: center }
a.go { position: relative; flex: none; align-self: center; justify-self: start; width: fit-content; display: inline-flex; align-items: center; gap: 2px;
  height: 32px; padding: 0 6px 0 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  color: var(--ink); font: 700 13px/1 var(--f-body); text-decoration: none; white-space: nowrap }
a.go svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round }
a.go::after { content: ""; position: absolute; inset: -6px -4px }          /* a 44px tap area around the small button */
a.go:hover { border-color: var(--accent); color: var(--ink) }
a.go:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px }

/* long names never run into the label on the right (v0.16.7) */
.li .grow { min-width: 0 }
.li .grow strong, .li .grow .small, .todo-row .grow strong { overflow-wrap: anywhere }
.li > .r { flex: none }
.clip { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }

/* plan and billing (v0.18) */
.planbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px;
  background: var(--accent-soft); color: var(--ink); text-decoration: none; font-size: .92rem; margin-bottom: 4px }
.planbar span { font-weight: 800; color: var(--accent); white-space: nowrap }
.planbar.warn { background: var(--warn-soft) }
.planbar.bad { background: var(--bad-soft) }
.planbar.bad span { color: var(--bad) }
.plan-grid { display: grid; gap: 14px }
@media (min-width: 820px) { .plan-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start } }
.plan-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: grid; gap: 10px; box-shadow: var(--shadow) }
.plan-card.mine { border: 2px solid var(--accent) }
.plan-card h3 { font-size: 1.25rem; font-weight: 800 }
.plan-price { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap }
.plan-price .big { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em }
.plan-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: .95rem }
.stepper { display: flex; align-items: center; gap: 12px }
.stepper button { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 12px; font-size: 1.4rem; font-weight: 700 }
.stepper span { min-width: 90px; text-align: center }
.warn-text { color: var(--warn) }

/* the CaseCost logo (v0.18.1): navy cent C on a gold tile */
.logo-sq, .side-brand .logo { background: var(--gold, #F8BC2E) !important }
.logo-sq svg, .side-brand .logo svg { stroke: #0B1932 !important; fill: none }
.logo-sq svg path:first-child, .side-brand .logo svg path:first-child { stroke-width: 9 }
.logo-sq svg path:last-child, .side-brand .logo svg path:last-child { stroke-width: 6.5 }
.logo-sq svg { width: 22px; height: 22px }
.side-brand .logo svg { width: 24px; height: 24px }

/* plan cards: Pro stands out in gold (v0.18.3) */
.plan-card { position: relative }
.plan-card.popular { border: 2px solid var(--gold, #F8BC2E); box-shadow: 0 10px 30px rgb(248 188 46 / .28); padding-top: 26px }
.plan-card.popular.mine { border-color: var(--accent) }
.plan-card .ribbon { position: absolute; top: -13px; left: 50%; transform: translateX(-50%); background: var(--gold, #F8BC2E); color: #0B1932;
  font-weight: 800; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; padding: 5px 14px; border-radius: 99px; white-space: nowrap }
.plan-card.popular [data-start], .plan-card.popular [data-change] { background: var(--gold, #F8BC2E); border-color: var(--gold, #F8BC2E); color: #0B1932 }
@media (min-width: 820px) { .plan-grid { padding-top: 14px } }
.plan-grid { padding-top: 14px }
.side-plan { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: #C9D3E0; font-weight: 700; font-size: 14px; text-decoration: none }
.side-plan:hover { color: #FFFFFF }
.side-plan svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round }

/* no double-tap zoom on phones (quick taps on + and − stay taps); pinch zoom still works (v0.18.5) */
html, body, button, a, input, select, label, .chip, .stepper { touch-action: manipulation }

/* support (v0.19) */
.plan-card .plan-contact { width: auto; max-width: 100%; white-space: normal; height: auto; min-height: 36px; padding: 8px 8px 8px 12px; line-height: 1.3; justify-self: start; align-self: flex-start }
textarea { width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface); color: var(--ink); resize: vertical; min-height: 120px; box-sizing: border-box }

/* sign in, support request, admin portal (v0.20) */
.forgot { justify-self: end; align-self: flex-end; font-weight: 700 }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere }
.svbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #C2362F; color: #FFFFFF; border-radius: 12px; padding: 10px 14px; margin-bottom: 4px; font-size: .92rem }
.svbar > span { display: flex; gap: 10px; align-items: center }
.svbar svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2 }
.svbar button { background: #FFFFFF; color: #C2362F; border: 0; border-radius: 10px; font-weight: 800; min-height: 38px; padding: 0 16px; flex: none }
.admin-actions { gap: 10px }
.admin-actions .primary svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4 }
.admin-grid { display: grid; gap: 14px }
@media (min-width: 900px) { .admin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start } }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: .95rem }
.kv span { color: var(--muted) }
.kv strong { overflow-wrap: anywhere }
tr.clickrow { cursor: pointer }
tr.clickrow:hover td { background: var(--accent-soft) }
/* admin: overview tiles and usage bars */
.ovgrid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)) }
@media (min-width: 900px) { .ovgrid { grid-template-columns: repeat(3, minmax(0, 1fr)) } }
.ovgrid .stat { gap: 4px }
.ovgrid .stat.warn { border-color: var(--gold, #C9971C) }
.ovgrid .stat.bad { border-color: var(--bad) }
.ubar { display: block; height: 5px; border-radius: 3px; background: var(--line); margin-top: 5px; overflow: hidden; max-width: 180px }
.ubar.big { height: 8px; max-width: none; margin: 4px 0 2px }
.ubar i { display: block; height: 100%; background: var(--accent); border-radius: inherit }
.stat.warn .ubar i { background: var(--gold, #C9971C) }
.stat.bad .ubar i { background: var(--bad) }
.admin-filter { gap: 10px; align-items: center }
.admin-filter input[type=search] { min-width: 220px; flex: 1 1 220px }
.admin-accts td { vertical-align: top }
.usage-table td, .usage-table th { white-space: nowrap }
details.card { padding: 12px 16px }
details.card > summary { cursor: pointer; padding: 4px 0 }
details.card[open] > summary { margin-bottom: 6px }
fieldset.plain-fs { border: 0; padding: 0; margin: 0; min-width: 0 } fieldset.plain-fs legend { padding: 0; margin-bottom: 4px }

/* narrow space (phones, tablets, or a narrow window beside the sidebar): wide tables become one card per row,
   each value with its column name */
.table-wrap:has(> table.stack-table) { container-type: inline-size }
@container (max-width: 780px) {
  table.stack-table, table.stack-table tbody, table.stack-table tfoot, table.stack-table tr, table.stack-table td { display: block; width: auto; min-width: 0 !important }
  table.stack-table thead { display: none }
  table.stack-table tr { padding: 12px 14px; border-bottom: 1px solid var(--line) }
  table.stack-table tbody tr:last-child { border-bottom: 0 }
  table.stack-table tfoot tr { border-top: 2px solid var(--line); border-bottom: 0 }
  table.stack-table td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 3px 0 !important;
    border: 0 !important; text-align: right; white-space: normal !important; overflow-wrap: anywhere; min-height: 0 }
  table.stack-table td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 600; text-align: left;
    flex: 0 1 45%; text-transform: none; letter-spacing: 0 }
  table.stack-table td > * { text-align: right }
  table.stack-table td:first-child { display: block; text-align: left; padding-bottom: 6px !important }
  table.stack-table td:first-child::before { content: none }
  table.stack-table td:first-child > * { text-align: left }
  table.stack-table td[data-label=""]::before { content: none }
  table.stack-table td[data-label=""] { justify-content: flex-end }
  table.stack-table td:empty { display: none }
  table.stack-table .ubar { max-width: none }
  table.stack-table .cellv { display: block; text-align: right; min-width: 0 }
  table.stack-table .cellv .sub, table.stack-table .cellv .small { display: block }
}
@media (max-width: 680px) {
  .admin-filter { width: 100% }
  .admin-filter input[type=search] { min-width: 0; flex: 1 1 100% }
  .admin-filter label.inline { flex: 1 1 100%; display: flex; gap: 8px; align-items: center }
  .admin-filter label.inline select { flex: 1 }
  .admin-actions > * { flex: 1 1 calc(50% - 10px) }
  .ovgrid .stat .v { font-size: 1rem }
  .kv { grid-template-columns: minmax(0, auto) minmax(0, 1fr) }
}
@media (max-width: 360px) {
  .ovgrid { grid-template-columns: minmax(0, 1fr) }
  .admin-actions > * { flex-basis: 100% }
}

/* ------------------------------------------------------------------ live view (admin) */
:root { --lv-r1: #2a78d6; --lv-r2: #eb6834; --lv-r3: #1baf7a; --lv-r4: #6250d6; --lv-r5: #e87ba4; --lv-r0: #8a96a3; --lv-ch: #5A6B7F }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --lv-r1: #3987e5; --lv-r2: #d95926; --lv-r3: #199e70; --lv-r4: #9085e9; --lv-r5: #d55181; --lv-r0: #6d7a88; --lv-ch: #A9B6C8 } }
:root[data-theme="dark"] { --lv-r1: #3987e5; --lv-r2: #d95926; --lv-r3: #199e70; --lv-r4: #9085e9; --lv-r5: #d55181; --lv-r0: #6d7a88; --lv-ch: #A9B6C8 }
.r1 { --c: var(--lv-r1) } .r2 { --c: var(--lv-r2) } .r3 { --c: var(--lv-r3) } .r4 { --c: var(--lv-r4) } .r5 { --c: var(--lv-r5) } .r0 { --c: var(--lv-r0) }
.lv-entry { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); border-left: 4px solid var(--accent) }
.lv-entry .grow { display: grid; gap: 2px }
.lv-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none }
.lv-tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 700; border-bottom: 3px solid transparent; white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center }
.lv-tabs a.on { color: var(--ink); border-bottom-color: var(--accent) }
.lv-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start }
@media (min-width: 900px) { .lv-grid { grid-template-columns: minmax(0, 1fr) 300px } .lv-side { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto } .lv-side > summary { pointer-events: none } .lv-side > summary::marker, .lv-side > summary::-webkit-details-marker { display: none; content: "" } }
@media (max-width: 899px) { .lv-side { order: -1 } }
.lv-side > summary { cursor: pointer; padding: 2px 0 8px; list-style-position: inside }
.lv-side input[type=range] { width: 100%; accent-color: var(--accent) }
.lv-side fieldset { border: 0; padding: 0; margin: 0 0 6px }
.lv-side legend { padding: 0; margin-bottom: 6px }
.stack-s { display: grid; gap: 6px }
.seg-wrap { flex-wrap: wrap; display: flex }
.seg-wrap button { flex: 1 0 auto }
.lv-num { display: grid; gap: 4px; font-size: .92rem }
.lv-num .row { gap: 8px; align-items: center }
.lv-num input[type=number] { width: 76px; min-height: 36px; padding: 4px 6px }
.lv-chips { gap: 6px }
.lv-chips .chip { min-height: 36px; padding: 6px 12px; font-size: .88rem }
.row.nowrap { flex-wrap: nowrap; gap: 6px }
.btn.small, button.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink) }
ul.tight { margin: 4px 0 0; padding-left: 18px }
.lv-kpis .stat .v { font-variant-numeric: tabular-nums }
.lv-flow { position: relative; width: 100%; overflow-x: auto }
.lv-flow > div, .lv-flow > svg { min-width: 640px }
.lv-flow svg { display: block; width: 100%; height: auto }
#lvdots { position: absolute; inset: 0; pointer-events: none }
.lv-head { font: 700 12px var(--f-body); fill: var(--muted); text-transform: uppercase; letter-spacing: .06em }
.lv-link { fill: none; stroke: var(--c); stroke-opacity: .35; transition: stroke-opacity .2s }
.lv-link:hover { stroke-opacity: .7 }
.lv-link.dim { stroke-opacity: .08 }
.lv-node rect { fill: var(--c, var(--lv-ch)); stroke: var(--surface); stroke-width: 2 }
.lv-node.ch rect { fill: var(--lv-ch) }
.lv-node.o-good rect { fill: var(--good) } .lv-node.o-warn rect { fill: var(--warn) } .lv-node.o-bad rect { fill: var(--bad) } .lv-node.o-muted rect { fill: var(--lv-r0) }
.lv-node.dim { opacity: .35 }
.lv-node text { font: 700 13px var(--f-body); fill: #fff; paint-order: stroke; stroke: rgb(0 0 0 / .25); stroke-width: 2px }
.lv-dot { fill: var(--c); stroke: var(--surface); stroke-width: 2 }
.lv-two { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start }
@media (min-width: 1100px) { .lv-two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) } .lv-maprow { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) } }
.lv-feed { max-height: 420px; overflow: auto }
.lv-events { list-style: none; margin: 0; padding: 0; display: grid }
.lv-events li { display: flex; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .92rem; animation: lvin .5s ease-out }
.lv-events li:last-child { border-bottom: 0 }
.lv-events .lv-t { width: 64px; flex: none }
.lv-events .grow { min-width: 0; overflow-wrap: anywhere }
@keyframes lvin { from { background: var(--accent-soft) } to { background: transparent } }
@media (prefers-reduced-motion: reduce) { .lv-events li { animation: none } .lv-live i { animation: none !important } }
.lv-sw { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none }
.lv-oc { font-weight: 800; width: 22px; text-align: center; flex: none }
.lv-oc.good { color: var(--good) } .lv-oc.warn { color: var(--warn) } .lv-oc.bad { color: var(--bad) } .lv-oc.muted { color: var(--muted) }
.lv-live i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: 6px; animation: lvpulse 1.6s infinite }
.lv-live i.off { background: var(--muted); animation: none }
@keyframes lvpulse { 50% { opacity: .25 } }
.lv-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px }
.lv-bars li { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 44px; gap: 8px; align-items: center }
.lv-bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden }
.lv-bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px }
.lv-conf { display: grid; gap: 4px; justify-items: end }
.lv-meter { width: 120px; height: 6px; background: var(--line); border-radius: 99px; overflow: hidden }
.lv-meter i { display: block; height: 100%; background: var(--accent) }
.lv-ents .btn { white-space: nowrap }
.lv-map { position: relative; height: 440px; border-radius: 10px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); touch-action: none; cursor: grab; user-select: none }
@media (max-width: 600px) { .lv-map { height: 340px } }
.lv-map.placing { cursor: crosshair; outline: 3px solid var(--warn) }
.lv-map:focus-visible { outline: 3px solid var(--accent) }
.lv-tiles { position: absolute; inset: 0 }
.lv-tiles img { position: absolute; width: 256px; height: 256px; max-width: none; opacity: .9 }
:root[data-theme="dark"] .lv-tiles img { filter: brightness(.7) invert(1) contrast(.9) hue-rotate(180deg) }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lv-tiles img { filter: brightness(.7) invert(1) contrast(.9) hue-rotate(180deg) } }
.lv-map svg { position: absolute; inset: 0 }
.lv-ring { fill: var(--accent); fill-opacity: .1; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4 }
.lv-ring.inner { fill: var(--bg); fill-opacity: .55 }
.lv-st circle { fill: var(--muted); stroke: var(--surface); stroke-width: 2 }
.lv-st circle.hit { fill: transparent; stroke: none; cursor: pointer }
.lv-st.cov circle:first-child { fill: var(--accent) }
.lv-st.unc circle:first-child { fill: var(--surface); stroke: var(--muted); stroke-width: 2.5 }
.lv-st.near circle:first-child { fill: var(--lv-r1) }
.lv-st.foc circle:first-child { fill: var(--ink); stroke: var(--tag); stroke-width: 3 }
.lv-st.you circle:first-child { stroke: var(--tag); stroke-width: 3 }
.lv-scale path { stroke: var(--ink); stroke-width: 3 }
.lv-scale text { font: 700 11px var(--f-body); fill: var(--ink); paint-order: stroke; stroke: var(--surface); stroke-width: 3px }
.lv-attr { position: absolute; right: 4px; bottom: 2px; font-size: 11px; background: rgb(255 255 255 / .8); color: #333; padding: 0 4px; border-radius: 3px }
.lv-attr a { color: #1a4f8a }
.lv-legend { gap: 14px }
.lvl { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; border: 2px solid var(--surface) }
.lvl.cov { background: var(--accent) } .lvl.unc { background: var(--surface); border-color: var(--muted) } .lvl.foc { background: var(--ink); border-color: var(--tag) } .lvl.you { background: var(--muted); border-color: var(--tag) }
.lv-sugs .li { align-items: flex-start }
.lv-chart { margin: 0 }
.lv-chart svg { width: 100%; height: auto; display: block }
.lv-chart .base { stroke: var(--line) }
.lv-sb rect:first-child { fill: var(--chart-total); opacity: .55 }
.lv-sb.on rect:first-child { opacity: 1 }
.lv-sb:hover rect:first-child { opacity: .85 }
.lv-sb rect.hit { fill: transparent }
.lv-sb text { font: 600 11px var(--f-body); fill: var(--muted) }
.lv-sb text.val { fill: var(--ink); font-weight: 700 }
.lv-sb.on text.ax { fill: var(--ink); font-weight: 800 }
.lv-sugs { padding: 0; margin: 0 }
.lv-k4.ovgrid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) }
/* address suggestions */
.addr-wrap { position: relative }
.addr-list { position: absolute; left: 0; right: 0; z-index: 30; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 280px; overflow: auto }
.addr-list li { padding: 10px 12px; border-radius: 8px; cursor: pointer; min-height: 44px; display: flex; align-items: center }
.addr-list li[aria-selected="true"], .addr-list li[data-i]:hover { background: var(--accent-soft) }
.addr-list li.addr-none { cursor: default; color: var(--muted); font-size: .88rem; min-height: 0 }
/* live view drill-downs */
.lv-kpi { text-align: left; cursor: pointer; position: relative; font: inherit; color: inherit; width: 100%; min-height: 0 }
.lv-kpi:hover { border-color: var(--accent) }
.lv-kpi .lv-open { position: absolute; right: 12px; top: 10px; color: var(--muted); font-size: 1.2rem }
.lv-node, .lv-link, tr[data-acct], tr[data-link] { cursor: pointer }
.lv-node:hover rect { filter: brightness(1.1) }
tr[data-acct]:hover, tr[data-link]:hover { background: var(--accent-soft) }
.lv-evb, .lv-barb { all: unset; display: flex; gap: 8px; align-items: center; width: 100%; cursor: pointer; box-sizing: border-box; border-radius: 6px }
.lv-evb:hover, .lv-barb:hover { background: var(--accent-soft) }
.lv-evb:focus-visible, .lv-barb:focus-visible, .lv-frow:focus-visible, .lv-sugb:focus-visible { outline: 3px solid var(--accent) }
.lv-barb { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 44px; gap: 8px }
.lv-events li { padding: 0 }
.lv-events .lv-evb { padding: 7px 2px }
.lv-drawer { margin: 0 0 0 auto; height: 100%; max-height: 100%; width: min(760px, 100%); max-width: 100%; border: 0; padding: 0;
  background: var(--bg); color: var(--ink); box-shadow: -8px 0 30px rgb(0 0 0 / .2) }
.lv-drawer::backdrop { background: rgb(0 0 0 / .4) }
.lv-drawer[open] { display: flex; flex-direction: column; animation: lvslide .2s ease-out }
@keyframes lvslide { from { transform: translateX(30px); opacity: .6 } }
@media (prefers-reduced-motion: reduce) { .lv-drawer[open] { animation: none } }
.lv-dhead { display: flex; gap: 10px; align-items: center; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0 }
.lv-dhead h2 { font-size: 1.15rem; margin: 0; overflow-wrap: anywhere }
.lv-dbody { padding: 16px; overflow: auto; flex: 1 }
.lv-ffil { gap: 8px }
.lv-ffil input[type=search] { flex: 2 1 220px }
.lv-ffil select { flex: 1 1 140px; min-height: 40px }
.lv-flist { padding: 0; margin: 0; list-style: none }
.lv-frow, .lv-sugb { all: unset; box-sizing: border-box; width: 100%; display: flex; gap: 10px; align-items: flex-start; padding: 12px; cursor: pointer; border-bottom: 1px solid var(--line) }
.lv-frow:hover, .lv-sugb:hover { background: var(--accent-soft) }
.lv-frow .grow, .lv-sugb .grow { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere }
.lv-frow .lv-sw { margin-top: 6px }
.lv-sugb .r { display: grid; text-align: right }
.lv-warn { color: var(--warn) } .lv-bad { color: var(--bad) }
.lv-facts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px 16px; margin: 0 }
@media (min-width: 640px) { .lv-facts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) } }
.lv-facts div { display: grid; gap: 1px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px }
.lv-facts dt { font-size: .78rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em }
.lv-facts dd { margin: 0; overflow-wrap: anywhere }
tr.lv-check { background: var(--warn-soft) }
.lv-bars li { display: block }
.lv-kpi { display: grid; justify-items: start; align-content: start; padding-right: 30px }
.lv-evb { flex-wrap: wrap }
.lv-evb .grow { flex: 1 1 150px; min-width: 0 }
.lv-evb .badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
button.stat.lv-kpi { padding: 12px 30px 12px 12px; min-height: 0; border-radius: 10px; background: var(--surface); border: 1px solid var(--line) } button.stat.lv-kpi.warn { border-color: var(--gold, #C9971C) } button.stat.lv-kpi.bad { border-color: var(--bad) }
button.stat.lv-kpi { justify-content: stretch; grid-template-columns: minmax(0, 1fr); text-align: left }
/* admin site (admin.casecost.ai) */
.ahead { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; padding: 10px 16px; background: var(--navy, #0B1932); color: #fff }
.ahead:empty { display: none }
.ahead a { color: #fff }
.ah-brand { display: inline-flex; gap: 8px; align-items: center; text-decoration: none; font-size: 1.05rem }
.ah-brand .logo-sq { width: 30px; height: 30px }
.ah-nav { display: flex; gap: 4px; flex-wrap: wrap }
.ah-nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--on-navy-muted, #C9D3E0); font-weight: 700; min-height: 40px; display: inline-flex; align-items: center }
.ah-nav a[aria-current="page"] { background: rgb(255 255 255 / .14); color: #fff }
.ah-me { margin-left: auto; color: #fff }
.ah-me .muted { color: var(--on-navy-muted, #C9D3E0) }
.ah-me .link { color: #fff; text-decoration: underline; padding: 0; min-height: 0 }
body.admin-site #app { padding-top: 16px }
.qr { display: grid; place-items: center; background: #fff; border-radius: 10px; padding: 8px }
.qr svg { width: 220px; height: 220px }
h2.more-h { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 2px -4px }
