/* ShopCheck - shelf-label look: cool paper, ink, shelf-tag yellow for the main action, red/green only for results. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #1b2230;
  --muted: #5b6476;
  --line: #d9dee7;
  --tag: #ffd43b;
  --tag-ink: #1b2230;
  --ok: #1f7a46;
  --ok-bg: #e6f4ec;
  --flag: #b3261e;
  --flag-bg: #fbe9e7;
  --warn: #8a5300;
  --warn-bg: #fdf1dc;
  --focus: #2457c5;
  --radius: 14px;
  --radius-s: 9px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141b;
    --surface: #181e28;
    --ink: #e8ecf2;
    --muted: #9aa4b5;
    --line: #2a3342;
    --tag: #ffd43b;
    --tag-ink: #141821;
    --ok: #5cc98b;
    --ok-bg: #15301f;
    --flag: #ff8a80;
    --flag-bg: #3a1916;
    --warn: #f0b445;
    --warn-bg: #352812;
    --focus: #8fb0ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
#app { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.boot { color: var(--muted); padding: 40px 0; text-align: center; }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.25rem; font-weight: 700; }
h2 { font-size: 1.05rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.num { font-variant-numeric: tabular-nums; }
.big { font-size: 1.6rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* top bar */
.bar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; min-height: 56px; position: sticky; top: env(safe-area-inset-top, 0px); background: var(--bg); z-index: 5; }
.bar h1 { text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back, .icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: var(--ink); font-size: 1.6rem; text-decoration: none; border-radius: 50%; cursor: pointer; }
.brand-mark { width: 26px; height: 26px; margin-left: 9px; border-radius: 6px; background: var(--tag); box-shadow: inset 0 0 0 2px var(--tag-ink); }

/* buttons */
.btn { appearance: none; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); border-radius: var(--radius-s); min-height: 48px; padding: 0 16px; font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; cursor: pointer; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--tag); color: var(--tag-ink); border-color: var(--tag-ink); }
.btn.danger { color: var(--flag); border-color: currentColor; }
.btn.big { min-height: 64px; font-size: 1.1rem; border-radius: var(--radius); }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 0.9rem; }
.hero { display: grid; gap: 10px; }
.hero.two { grid-template-columns: 1fr 1fr; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.actions .btn { flex: 1 1 auto; }
.stack { display: grid; gap: 10px; }

/* lists */
.label { font-size: 0.8rem; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; margin: 4px 2px 8px; }
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.row { display: flex; gap: 12px; align-items: center; padding: 12px 14px; text-decoration: none; min-height: 64px; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main .muted { font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.thumb { width: 48px; height: 48px; flex: none; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chip { font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.chip.ok { color: var(--ok); background: var(--ok-bg); }
.chip.flag { color: var(--flag); background: var(--flag-bg); }
.chip.warn { color: var(--warn); background: var(--warn-bg); }
.empty { text-align: center; padding: 18px 8px; display: grid; gap: 8px; }

/* trip totals: the register comparison */
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.totals div { display: flex; flex-direction: column; }
.totals .muted { font-size: 0.8rem; }
.totals .grand { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: baseline; border-top: 1px dashed var(--line); padding-top: 8px; }
.totals .grand strong { font-size: 1.7rem; }
.banner { padding: 10px 14px; border-radius: var(--radius-s); font-weight: 600; }
.banner.flag { background: var(--flag-bg); color: var(--flag); }
.install { display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius-s); padding: 10px 12px; font-size: 0.9rem; }
.update { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--radius); display: flex; gap: 10px; align-items: center; z-index: 30; width: max-content; max-width: calc(100% - 32px); }

/* panels + form */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 12px; }
.form { gap: 14px; }
.field { display: grid; gap: 6px; }
.field > label { font-weight: 600; font-size: 0.95rem; display: flex; gap: 8px; align-items: center; }
.field[data-src="read"] > label::after { content: "read from photo"; font-size: 0.72rem; font-weight: 600; color: var(--warn); background: var(--warn-bg); padding: 1px 7px; border-radius: 99px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline .pre, .inline .mid { color: var(--muted); font-weight: 600; }
input, select { font: inherit; font-size: 1.1rem; color: var(--ink); background: var(--bg); border: 1.5px solid var(--line); border-radius: var(--radius-s); min-height: 48px; padding: 0 12px; min-width: 0; }
input { flex: 1 1 7em; }
input.per { flex: 0 1 4.2em; width: 4.2em; }
input.qty { flex: 0 1 4em; width: 4em; text-align: center; }
select { flex: 0 1 auto; padding-right: 8px; }
.more summary { cursor: pointer; color: var(--muted); font-weight: 600; min-height: 32px; }
.more[open] summary { margin-bottom: 8px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 6px 0; }
.choice input { flex: none; width: 22px; height: 22px; min-height: 0; margin-top: 2px; accent-color: var(--ink); }
.choice span { display: flex; flex-direction: column; }
.meter { height: 10px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--ink); }

/* photo */
.photo { display: grid; gap: 8px; }
.cam { width: 100%; }
.photo-img { padding: 0; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; background: var(--bg); cursor: zoom-in; }
.photo-img img { display: block; width: 100%; max-height: 260px; object-fit: contain; }
.photo-actions { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.hidden-file { display: none; }
.status:empty { display: none; }

/* the tag-check result: styled as a shelf label, the one bold element */
.result { border-radius: var(--radius); padding: 14px 16px 14px 22px; background: var(--surface); border: 1px solid var(--line); display: grid; gap: 8px; position: relative; overflow: hidden; }
.result::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 8px; background: var(--line); }
.result.ok::before { background: var(--ok); }
.result.ok h3 { color: var(--ok); }
.result.flag { background: var(--flag-bg); border-color: var(--flag); }
.result.flag::before { background: var(--flag); }
.result.flag h3 { color: var(--flag); }
.result.warn { background: var(--warn-bg); }
.result.warn::before { background: var(--warn); }
.result .calc { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.result .calc strong { background: var(--tag); color: var(--tag-ink); padding: 2px 10px; border-radius: 6px; }

/* dialogs */
dialog { border: 0; padding: 0; background: transparent; color: var(--ink); max-width: 100vw; }
dialog::backdrop { background: rgba(10, 14, 20, 0.55); }
.sheet { width: min(560px, 100vw); margin: auto auto 0; }
.sheet > form, .sheet:not(:has(form)) { background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); display: grid; gap: 10px; }
.sheet input { width: 100%; }
.crop { width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; background: #000; color: #fff; padding: calc(10px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); }
.crop[open] { display: flex; flex-direction: column; gap: 10px; }
.crop-help { font-size: 0.9rem; opacity: 0.85; }
.crop-help, .crop .actions { position: relative; z-index: 1; } /* above the frame's dimming shadow */
.crop-view { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; touch-action: none; }
.crop-view canvas { max-width: 100%; max-height: 100%; display: block; }
.crop-frame { position: absolute; border: 3px solid var(--tag); box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45); border-radius: 4px; touch-action: none; cursor: move; }
.handle { position: absolute; width: 34px; height: 34px; background: var(--tag); border-radius: 50%; border: 3px solid #000; }
.handle.nw { left: -17px; top: -17px; } .handle.ne { right: -17px; top: -17px; }
.handle.sw { left: -17px; bottom: -17px; } .handle.se { right: -17px; bottom: -17px; }
.crop .btn { background: #1b2230; color: #fff; border-color: #3a4456; }
.crop .btn.primary { background: var(--tag); color: #141821; border-color: var(--tag); }
.full { width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; background: #000; display: none; }
.full[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 12px; }
.full img { max-width: 100%; max-height: 92%; object-fit: contain; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--radius-s); max-width: calc(100% - 32px); z-index: 40; transition: opacity 0.4s; }
.toast.flag { background: var(--flag); color: #fff; }
.toast.gone { opacity: 0; }

@media (max-width: 380px) {
  .hero.two { grid-template-columns: 1fr; }
  .totals { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* reading-accuracy list */
.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-variant-numeric: tabular-nums; }
