/* Kitchen ledger: warm paper surfaces, herb-green accent, editorial headings. */

:root {
  color-scheme: light;
  --paper: #f6f3ec;
  --card: #fffdf8;
  --sunken: #efeae0;
  --ink: #1d1f1a;
  --muted: #6a6b62;
  --line: #e4ddcf;
  --accent: #2f5d3a;
  --accent-strong: #234a2c;
  --accent-soft: #e2ecdf;
  --accent-ink: #ffffff;
  --expired: #b3341f;
  --expired-soft: #f8e1da;
  --soon: #b7791f;
  --soon-soft: #f9ecd3;
  --low: #3d6a8a;
  --low-soft: #dfe9f0;
  --danger: #a72a1c;
  --shadow: 0 1px 2px rgb(40 34 20 / 6%), 0 6px 20px -8px rgb(40 34 20 / 14%);
  --shadow-lift: 0 10px 30px -10px rgb(40 34 20 / 30%);
  --radius: 18px;
  --radius-sm: 12px;
  --content: 40rem;
  --tabbar: 4.25rem;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Charter, Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #151612;
    --card: #1e201b;
    --sunken: #262821;
    --ink: #eeeadf;
    --muted: #a3a295;
    --line: #34362d;
    --accent: #8cc49a;
    --accent-strong: #a5d6b0;
    --accent-soft: #24362a;
    --accent-ink: #10180f;
    --expired: #f08c76;
    --expired-soft: #3a211b;
    --soon: #e6b35f;
    --soon-soft: #372c19;
    --low: #8fbadb;
    --low-soft: #1d2b36;
    --danger: #f08c76;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px -10px rgb(0 0 0 / 50%);
    --shadow-lift: 0 12px 32px -10px rgb(0 0 0 / 60%);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body.with-nav { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 1rem); }

a { color: var(--accent); }

.icon { flex: none; display: block; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

[hidden] { display: none !important; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: calc(0.7rem + env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px)) 0.7rem max(1rem, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1.05rem;
  transform: rotate(-6deg);
}

.topbar .topnav, .topbar .scan-cta, .topbar .logout { display: none; }
.logout { margin: 0; }

/* ---------- Bottom tab bar (phones) ---------- */

.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  height: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px));
  padding: 0 0.25rem env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(16px);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--line);
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: 44px;
  height: var(--tabbar);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.tabbar a[aria-current="page"] { color: var(--accent); }

.tab-scan { position: relative; }

.tab-scan-disc {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  margin-top: -1.6rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-lift), 0 0 0 5px var(--paper);
  transition: transform 0.15s ease;
}

.tab-scan:active .tab-scan-disc { transform: scale(0.94); }
.tabbar .tab-scan[aria-current="page"] { color: var(--accent); }

/* ---------- Layout ---------- */

main {
  max-width: var(--content);
  margin: 0 auto;
  padding: 1.25rem max(1rem, env(safe-area-inset-left, 0px)) 2rem;
  animation: rise 0.35s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  main { animation: none; }
}

.page-head { margin-bottom: 1.1rem; }
.page-head.split { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }

h1, h2 { font-family: var(--font-display); letter-spacing: -0.015em; }
h1 { font-size: clamp(1.7rem, 6vw, 2.2rem); line-height: 1.1; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 0.6rem; }

.eyebrow {
  margin: 0 0 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.lede { margin: 0.5rem 0 0; color: var(--muted); }

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}
.back::before { content: "‹"; font-size: 1.3rem; line-height: 1; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin: 0 0 1rem;
}

form { margin: 0; }
form.plain { display: contents; }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0 0 1.25rem; }

/* ---------- Tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.9rem 0.85rem;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.tile strong { font-family: var(--font-display); font-size: 2rem; line-height: 1; }
.tile span { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.tile-expired { background: var(--expired-soft); border-color: transparent; }
.tile-expired strong { color: var(--expired); }
.tile-soon { background: var(--soon-soft); border-color: transparent; }
.tile-soon strong { color: var(--soon); }
.tile-low { background: var(--low-soft); border-color: transparent; }
.tile-low strong { color: var(--low); }

/* ---------- Rows ---------- */

.group-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.2rem; }
.group-head h2 { margin: 0; }
.dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; }
.dot-expired { background: var(--expired); }
.dot-soon { background: var(--soon); }
.dot-low { background: var(--low); }

.rows { list-style: none; margin: 0; padding: 0; }
.rows > li + li { border-top: 1px solid var(--line); }
.card > .rows:only-child { margin: -0.35rem 0; }

.row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 44px;
  padding: 0.6rem 0;
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
a.row:active { opacity: 0.7; }
.row > .icon:last-child { color: var(--muted); opacity: 0.6; }
.menu .row > .icon:first-child { color: var(--accent); }

.row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 0.85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 0.2rem; flex: none; }

.rows.compact li { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.55rem 0; }
.rows.compact a { font-weight: 600; text-decoration: none; }

.qty { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.qty small { font-weight: 500; color: var(--muted); }

.big-number { font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; margin: 0.25rem 0 0.5rem; }

.thumb {
  --hue: 120;
  display: grid;
  place-items: center;
  flex: none;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: hsl(var(--hue) 38% 88%);
  color: hsl(var(--hue) 40% 28%);
  font-family: var(--font-display);
  font-weight: 700;
}
.thumb-md { width: 2.9rem; height: 2.9rem; font-size: 1.2rem; }
.thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }

@media (prefers-color-scheme: dark) {
  .thumb { background: hsl(var(--hue) 22% 24%); color: hsl(var(--hue) 45% 80%); }
}

.pill {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.pill-expired { background: var(--expired-soft); color: var(--expired); }
.pill-soon { background: var(--soon-soft); color: var(--soon); }
.pill-low { background: var(--low-soft); color: var(--low); }

.empty { margin: 0.4rem 0 0; color: var(--muted); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.empty-state p { margin: 0; }

.footer-link { text-align: center; }
.footer-link a { display: inline-flex; align-items: center; gap: 0.2rem; font-weight: 600; text-decoration: none; }

/* ---------- Forms ---------- */

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.85rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}
label:last-child { margin-bottom: 0; }

input, select, textarea, button, .button {
  font: inherit;
  min-height: 44px;
}

input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--sunken);
  color: var(--ink);
  font-weight: 400;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--card);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea { min-height: 6rem; resize: vertical; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.75rem; }
.grid-2 label { margin-bottom: 0.85rem; }

.input-row { display: flex; gap: 0.5rem; margin-bottom: 0.85rem; }
.input-row input { flex: 1; }
.input-row + .lookup-actions { margin-top: -0.25rem; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1.05rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
button:hover, .button:hover { background: var(--accent-strong); }
button:active, .button:active { transform: scale(0.97); }
button:focus-visible, .button:focus-visible, a:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }

.secondary { background: var(--accent-soft); color: var(--accent); }
.secondary:hover { background: color-mix(in srgb, var(--accent-soft) 80%, var(--accent)); }
.ghost { background: transparent; color: var(--muted); }
.ghost:hover { background: var(--sunken); }
.danger { color: var(--danger); background: var(--expired-soft); }
.danger:hover { background: color-mix(in srgb, var(--expired-soft) 80%, var(--danger)); }
.wide { width: 100%; }
.icon-button { padding: 0; width: 44px; flex: none; }

.chip {
  min-height: 36px;
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
  background: var(--sunken);
  color: var(--ink);
  border-color: var(--line);
}
.chip:hover { background: var(--line); }

.lookup-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.5rem; }

.savebar {
  position: sticky;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 0.6rem);
  z-index: 10;
  margin: 0 0 1rem;
}
.savebar button { box-shadow: var(--shadow-lift); min-height: 50px; }

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 0.4rem; font-size: 0.88rem; font-weight: 600; color: var(--muted); }

.segmented { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--sunken);
  color: var(--ink);
  font-weight: 600;
  text-transform: capitalize;
  cursor: pointer;
}
.segmented input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.segmented input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }

.error, .notice, .saved {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  margin: 0 0 1rem;
}
.error { color: var(--danger); background: var(--expired-soft); }
.notice { color: var(--soon); background: var(--soon-soft); }
.saved { color: var(--accent); background: var(--accent-soft); }
.hint { margin: 0.25rem 0 0.4rem; font-size: 0.85rem; color: var(--muted); }

/* Product form */

.product-hero { display: flex; gap: 0.9rem; align-items: flex-start; }
.product-hero-fields { flex: 1; min-width: 0; }
.product-photo {
  flex: none;
  width: 6.5rem;
  height: 6.5rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
}
.product-photo img { width: 100%; height: 100%; object-fit: contain; }

.lookup-results { list-style: none; margin: 0 0 0.5rem; padding: 0; display: grid; gap: 0.5rem; }
.hit {
  width: 100%;
  justify-content: flex-start;
  gap: 0.8rem;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--sunken);
  color: var(--ink);
  text-align: left;
  font-weight: 400;
}
.hit:hover { background: var(--accent-soft); border-color: var(--accent); }

/* Stock filters */

.filters { display: grid; gap: 0.5rem; margin-bottom: 1rem; }
.filters label { margin: 0; }
.search { position: relative; }
.search .icon { position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 2.5rem; border-radius: 999px; background: var(--card); }
.filter-row { display: flex; gap: 0.5rem; }
.filter-row label { flex: 1; min-width: 0; }
.filter-row select { border-radius: 999px; background: var(--card); text-transform: capitalize; }

/* Shopping */

.quick-add { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.quick-add label { margin: 0; }
.quick-add .grow { flex: 1 1 12rem; }
.quick-add .small { flex: 0 0 5.5rem; }
.quick-add button { flex: 1 1 100%; }

.shopping li { display: flex; align-items: center; gap: 0.75rem; padding: 0.35rem 0; }
.checkbox {
  width: 28px;
  min-height: 28px;
  height: 28px;
  padding: 0;
  border-radius: 9px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--accent-ink);
  flex: none;
  position: relative;
}
.checkbox::after { content: ""; position: absolute; inset: -9px; }
.checkbox:hover { background: var(--accent-soft); }
.is-checked .checkbox { background: var(--accent); border-color: var(--accent); }
.is-checked .row-title, .is-checked .row-sub { color: var(--muted); }

/* Scan */

.scan-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 2.2rem 1rem;
  margin-bottom: 1rem;
  border-radius: 28px;
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--accent) 88%, #fff) 0%, var(--accent) 60%, var(--accent-strong) 100%);
  color: var(--accent-ink);
  box-shadow: var(--shadow-lift);
}
.scan-hero:hover { background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--accent) 80%, #fff) 0%, var(--accent) 60%, var(--accent-strong) 100%); }
.scan-hero strong { font-family: var(--font-display); font-size: 1.5rem; }
.scan-mode { font-size: 0.85rem; opacity: 0.85; font-weight: 500; }
.scan-hero-frame {
  display: grid;
  place-items: center;
  width: 7rem;
  height: 7rem;
  border-radius: 24px;
  background: rgb(255 255 255 / 14%);
  animation: breathe 2.4s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: scale(1.05); background: rgb(255 255 255 / 22%); } }
@media (prefers-reduced-motion: reduce) { .scan-hero-frame { animation: none; } }

.manual-code label { margin-bottom: 0.4rem; }
.manual-code .input-row { margin: 0; }

.scanner-sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: #000;
  color: #fff;
}
.scanner-sheet video { flex: 1; width: 100%; min-height: 0; object-fit: cover; }
.scanner-reticle {
  position: absolute;
  left: 50%;
  top: 45%;
  width: min(78vw, 22rem);
  aspect-ratio: 16 / 10;
  transform: translate(-50%, -50%);
  border-radius: 18px;
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / 45%);
  border: 3px solid rgb(255 255 255 / 90%);
}
.scanner-reticle::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 2px;
  background: #ff5a3c;
  box-shadow: 0 0 12px #ff5a3c;
  animation: sweep 1.8s ease-in-out infinite;
}
@keyframes sweep { 0%, 100% { transform: translateY(-36px); } 50% { transform: translateY(36px); } }
.scanner-bar {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
  text-align: center;
  background: linear-gradient(transparent, rgb(0 0 0 / 70%));
}
.scanner-bar p { margin: 0; }
.scanner-close { background: rgb(255 255 255 / 18%); color: #fff; }
.scanner-close:hover { background: rgb(255 255 255 / 28%); }

.scan-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 1rem);
  z-index: 110;
  transform: translateX(-50%);
  width: min(92vw, 26rem);
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  box-shadow: var(--shadow-lift);
}

/* Auth */

.auth { max-width: 24rem; margin: 8vh auto 0; }
.auth .card label { margin-bottom: 1rem; }

/* ---------- Wider screens: top nav instead of tab bar ---------- */

@media (min-width: 760px) {
  :root { --content: 46rem; }
  body.with-nav { padding-bottom: 2rem; }
  .tabbar { display: none; }
  .topbar { padding-left: max(1.5rem, calc((100vw - 64rem) / 2)); padding-right: max(1.5rem, calc((100vw - 64rem) / 2)); }
  .topbar .topnav { display: flex; gap: 0.25rem; }
  .topnav a {
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
  }
  .topnav a:hover { color: var(--ink); background: var(--sunken); }
  .topnav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
  .topbar .scan-cta { display: inline-flex; min-height: 40px; }
  .topbar .logout { display: block; }
  .logout button { min-height: 40px; padding: 0 0.7rem; }
  .logout span { display: none; }
  .savebar { position: static; }
  .savebar button { width: auto; min-width: 12rem; box-shadow: none; }
  .quick-add button { flex: 0 0 auto; }
  .tile strong { font-size: 2.4rem; }
  .product-photo { width: 8rem; height: 8rem; }
}

@media (min-width: 760px) and (max-width: 980px) {
  .topnav a { padding: 0.45rem 0.55rem; }
  .scan-cta span { display: none; }
}

@media (max-width: 420px) {
  main { padding-top: 1rem; }
  .tiles { gap: 0.45rem; }
  .tile { padding: 0.75rem 0.7rem; }
  .tile strong { font-size: 1.7rem; }
  .product-photo { width: 5rem; height: 5rem; }
}

/* ---------- Messages ---------- */

.maint-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  max-width: var(--content);
  margin: 1rem auto 0;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--soon-soft);
  border: 1px solid color-mix(in srgb, var(--soon) 35%, transparent);
}
@media (max-width: 42rem) { .maint-banner { margin: 0.75rem 1rem 0; } }
.maint-banner .icon { color: var(--soon); margin-top: 0.1rem; }
.maint-active { background: var(--expired-soft); border-color: color-mix(in srgb, var(--expired) 35%, transparent); }
.maint-active .icon { color: var(--expired); }
.maint-text { min-width: 0; overflow-wrap: anywhere; }
.maint-message { display: block; margin-top: 0.2rem; color: var(--muted); }
.maint-text a { font-weight: 600; }
[data-countdown] { font-variant-numeric: tabular-nums; }

.apk-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  max-width: var(--content);
  margin: 1rem auto 0;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
@media (max-width: 42rem) { .apk-banner { margin: 0.75rem 1rem 0; } }
.apk-banner .icon { color: var(--accent); }
.apk-text { flex: 1 1 12rem; min-width: 0; }
.apk-actions { display: flex; gap: 0.5rem; }


.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 0.75rem);
  z-index: 120;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(92vw, 28rem);
  pointer-events: none;
}
body:not(.with-nav) .toasts { bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem); }

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 0.5rem 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  box-shadow: var(--shadow-lift);
  pointer-events: auto;
  animation: toast-in 0.2s ease both;
  border-left: 5px solid var(--accent);
}
.toast span { flex: 1; padding-top: 0.1rem; }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--soon); }
.toast-info { border-left-color: var(--low); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: 0.2s ease; }
.toast-close {
  min-height: 32px;
  width: 32px;
  padding: 0;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  font-size: 1.2rem;
}
.toast-close:hover { background: rgb(255 255 255 / 12%); opacity: 1; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}

.field-error {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--danger);
}
[aria-invalid="true"] { border-color: var(--danger) !important; box-shadow: 0 0 0 3px var(--expired-soft); }

label.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  font-weight: 600;
}
label.check input { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--accent); }

.hint.center, .center { text-align: center; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 0.6rem; }
.grid-3 label { margin-bottom: 0.85rem; }
.plain-fieldset { border: 1px solid var(--line); }
.split, .split-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.small-button { min-height: 36px; padding: 0.25rem 0.7rem; font-size: 0.85rem; }
.warn-text { color: var(--soon); font-weight: 600; }
.empty-state h1 { font-size: 1.5rem; margin: 0.5rem 0; }
form[aria-busy="true"] button[type="submit"] { opacity: 0.6; }

.account-link { display: none; }

/* ---------- Shopping lists ---------- */

.list-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
}
.shopping .thumb { flex: none; }
.list-settings summary { cursor: pointer; font-weight: 650; min-height: 32px; }
.list-settings[open] summary { margin-bottom: 0.75rem; }
.list-settings form.plain button { margin-top: 0.75rem; }
.store-rows li { display: flex; align-items: center; gap: 0.35rem; padding: 0.3rem 0; }
.inline-edit { display: flex; flex: 1; gap: 0.35rem; align-items: center; }
.inline-edit label, .add-store label { margin: 0; flex: 1; }
.add-store { margin: 0.75rem 0 0; }

/* ---------- Shop mode ---------- */

.store-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.6rem 0.75rem; }
.store-picker > label { display: flex; flex-direction: row; align-items: center; gap: 0.5rem; margin: 0; flex: 1 1 12rem; color: var(--accent); }
.store-picker select { flex: 1; }
.add-store-inline summary { list-style: none; display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer; }
.add-store-inline summary::-webkit-details-marker { display: none; }
.add-store-inline[open] { flex-basis: 100%; }
.add-store-inline form { margin: 0.6rem 0 0; }

.scan-dock { margin: 0 0 1rem; }
.scan-big {
  width: 100%;
  min-height: 64px;
  border-radius: var(--radius);
  font-size: 1.15rem;
  box-shadow: var(--shadow-lift);
}
.scan-dock .manual-code { margin-top: 0.6rem; }
.scan-dock .input-row { margin: 0; }

.basket-bar {
  position: sticky;
  top: calc(3.6rem + env(safe-area-inset-top, 0px));
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 1rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.basket-total { display: flex; flex-direction: column; line-height: 1.2; }
.basket-total strong { font-family: var(--font-display); font-size: 1.6rem; }
.basket-label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.basket-warn { font-size: 0.8rem; font-weight: 600; color: var(--soon); }

.shop-group h2 { display: flex; align-items: center; gap: 0.5rem; }
.shop-group .count {
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: var(--sunken);
  color: var(--muted);
}
.shop-rows { padding: 0.25rem 0.75rem; }
.shop-rows li { display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0; min-height: 56px; }
.shop-rows .row-main { flex: 1; min-width: 0; }
.shop-rows .checkbox { width: 32px; height: 32px; min-height: 32px; }
.is-skipped .row-title { color: var(--muted); text-decoration: line-through; }

.price-button {
  min-height: 40px;
  padding: 0.3rem 0.8rem;
  background: var(--sunken);
  color: var(--ink);
  border-color: var(--line);
  font-variant-numeric: tabular-nums;
}
.price-button.is-missing { color: var(--soon); background: var(--soon-soft); border-color: transparent; }

/* ---------- Bottom sheet ---------- */

body.sheet-open { overflow: hidden; }
/* Messages move to the top so they never cover the sheet's buttons. */
body.sheet-open .toasts { top: calc(env(safe-area-inset-top, 0px) + 0.75rem); bottom: auto; }
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgb(0 0 0 / 45%);
  animation: fade-in 0.15s ease both;
}
.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 95;
  transform: translateX(-50%);
  width: min(100%, 34rem);
  max-height: 92vh;
  overflow-y: auto;
  padding: 0.5rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  border-radius: 22px 22px 0 0;
  background: var(--card);
  box-shadow: 0 -10px 40px rgb(0 0 0 / 25%);
  animation: sheet-up 0.22s ease both;
}
.sheet-handle { width: 42px; height: 5px; margin: 0.2rem auto 0.6rem; border-radius: 999px; background: var(--line); }
.sheet-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.9rem; }
.sheet-head h2 { margin: 0; font-size: 1.25rem; }
.sheet-head .row-main { flex: 1; min-width: 0; }
.sheet-actions { display: flex; gap: 0.6rem; margin-top: 1rem; }
.sheet-actions button { flex: 1; min-height: 50px; }
.sheet-more summary { cursor: pointer; font-weight: 600; color: var(--muted); min-height: 36px; }

@keyframes sheet-up {
  from { transform: translate(-50%, 30%); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-backdrop { animation: none; }
}

.stepper { display: flex; align-items: center; gap: 0.35rem; margin-top: 0.3rem; }
.stepper input { text-align: center; min-width: 0; }
.stepper .icon-button { width: 40px; min-height: 40px; }

.price-field { margin-bottom: 0.6rem; }
.money-input {
  display: flex;
  align-items: center;
  margin-top: 0.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--sunken);
  padding-left: 0.9rem;
}
.money-input:focus-within { border-color: var(--accent); }
.money-symbol { font-size: 1.6rem; font-weight: 700; color: var(--muted); }
.money-input input {
  border: 0;
  background: transparent;
  font-size: 1.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: none;
  margin: 0;
}
.money-input input:focus { box-shadow: none; }
.price-tools, .ocr-results { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 0.6rem; }
.ocr-results .hint { flex-basis: 100%; margin: 0; }

/* ---------- Finish shop ---------- */

.finish-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.finish-head .row-main { flex: 1; min-width: 8rem; }
.finish-head label.check { margin: 0; font-size: 0.9rem; }
.finish-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lift);
}
.finish-bar button { min-height: 50px; }

@media (min-width: 760px) {
  .toasts { bottom: 1.25rem; }
  .account-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
  }
  .account-link:hover { color: var(--ink); }
  .basket-bar { top: 4.2rem; }
  .sheet { bottom: auto; top: 50%; transform: translate(-50%, -50%); border-radius: var(--radius); animation: none; }
  .sheet-handle { display: none; }
  .finish-bar { position: static; box-shadow: none; }
}

@media (max-width: 420px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 label:last-child { grid-column: span 2; }
}
