/* Receipt Inventory: plain CSS, no build step. K-State themed: Royal Purple + white, big soft cards */
:root {
  /* K-State purple, refined: tinted canvas so white cards actually lift off the page */
  --bg: #f4effb; --surface: #ffffff; --surface-2: #faf7fe;
  --ink: #241a35; --muted: #6f6385; --line: #e8e0f4;
  --silver: #a7a8aa; --bar: #3c1d6e;
  --accent: #512888; --accent-ink: #ffffff; --accent-soft: #efe4fb;
  --accent-grad: linear-gradient(160deg, #6b3fa8, #512888);
  --hero-grad: linear-gradient(150deg, #6b3fa8 0%, #512888 50%, #35176a 100%);
  --ok: #2c6e3f; --ok-soft: #e4f1e6;
  --warn: #92600a; --warn-soft: #fdf0d4;
  --danger: #a3291c; --danger-soft: #fbe2de;
  --info: #2a5c82; --info-soft: #e2eef7;
  --shadow: 0 1px 2px rgba(53,23,106,.06), 0 10px 28px rgba(53,23,106,.09);
  --radius: 22px;
  --font-head: "Fraunces", Georgia, serif;
  /* Storage-location colors (not food-type colors) */
  --c-front-fridge: #2f6fae; --c-back-fridge: #4a90c2;
  --c-front-freezer: #2e8083; --c-back-freezer: #1f5f6b;
  --c-downstairs-freezer: #39507a; --c-back-pantry: #a67a1f; --c-cabinets: #8a5a2e;
  --c-cats: #a23e6b; --c-utilities: #6b645c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1025; --surface: #241735; --surface-2: #2c1d40;
    --ink: #f1ebfa; --muted: #c3b3dd; --line: #43315c;
    --silver: #a7a8aa; --bar: #351a5c;
    --accent: #b58cf2; --accent-ink: #201530; --accent-soft: #3a2a56;
    --ok: #7fcb94; --ok-soft: #22361f;
    --warn: #f0c177; --warn-soft: #3a2f12;
    --danger: #f29184; --danger-soft: #3c201c;
    --info: #8fbfe6; --info-soft: #1b2e3f;
    --shadow: 0 2px 4px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
    --accent-grad: linear-gradient(160deg, #c4a2f5, #a87ee8);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink);
  background: radial-gradient(1100px 480px at 50% -140px, color-mix(in srgb, var(--bg) 55%, var(--surface)) 0%, var(--bg) 62%) fixed;
  font: 26px/1.6 "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: underline; }
a:hover { text-decoration: underline; }
h1 { font-family: var(--font-head); font-size: 44px; margin: 0 0 8px; letter-spacing: -.02em; font-weight: 700; }
h2 { font-family: var(--font-head); font-size: 27px; margin: 0 0 15px; font-weight: 700; }
.sub { color: var(--muted); margin: 0 0 30px; font-size: 23px; }
.muted { color: var(--muted); }
.small { font-size: 20px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.topbar { background: var(--hero-grad); box-shadow: 0 4px 20px rgba(40,10,80,.2); position: sticky; top: 0; z-index: 20; padding-top: env(safe-area-inset-top, 0px); }
.topbar-inner { max-width: 1340px; margin: 0 auto; padding: 0 26px; height: 92px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 26px; color: #fff; letter-spacing: -.01em; }
.brand, .brand:hover, .bottomnav a { text-decoration: none; }
.brand svg { color: #fff; width: 36px; height: 36px; }
.spacer { flex: 1; }
.mode { font-size: 19px; font-weight: 700; padding: 8px 16px; border-radius: 999px; white-space: nowrap; }
.mode.demo { background: var(--warn-soft); color: var(--warn); }
.mode.live { background: var(--ok-soft); color: var(--ok); }

/* ---------- bottom tab bar (replaces the old top nav links) ---------- */
.bottomnav {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 25;
  display: flex; justify-content: space-around; background: var(--surface);
  border-radius: 28px; box-shadow: 0 14px 36px rgba(53, 23, 106, .24);
  padding: 8px; max-width: 460px; margin: 0 auto;
  backdrop-filter: blur(16px); background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid rgba(255,255,255,.7);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 96px; padding: 9px 10px; border-radius: 22px; flex: 1;
  font-size: 16px; font-weight: 700; color: var(--muted);
}
.bottomnav a:hover { text-decoration: none; background: var(--surface-2); color: var(--ink); }
.bottomnav a.active { color: var(--accent-ink); background: var(--accent-grad); box-shadow: 0 4px 12px rgba(75,36,130,.3); }
.bottomnav svg { width: 26px; height: 26px; }
main { max-width: 1340px; margin: 0 auto; padding: 36px 26px calc(128px + env(safe-area-inset-bottom, 0px)); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 26px; }

/* ---------- buttons & inputs ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 14px; padding: 17px 27px; font: inherit; font-size: 22px; font-weight: 650; cursor: pointer;
  display: inline-flex; align-items: center; gap: 11px; transition: background .12s, border-color .12s, box-shadow .12s;
  min-height: 60px; box-shadow: 0 1px 2px rgba(40,20,80,.04), 0 4px 10px rgba(40,20,80,.05);
}
.btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--ink) 35%, var(--line)); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent-grad); border-color: transparent; color: var(--accent-ink); box-shadow: 0 6px 16px rgba(75,36,130,.3); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: 12px 18px; font-size: 19px; border-radius: 11px; min-height: 50px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

input, select, textarea {
  font: inherit; font-size: 22px; color: var(--ink); background: var(--surface); border: 2px solid var(--line);
  border-radius: 12px; padding: 15px 18px; width: 100%; min-width: 0; min-height: 60px;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 65%, transparent); outline-offset: 1px; border-color: var(--accent);
}
input[type=checkbox] { width: 28px; height: 28px; padding: 0; accent-color: var(--accent); min-height: 0; }
label { font-size: 19px; font-weight: 700; color: var(--muted); display: block; margin-bottom: 8px; }
.check { display: inline-flex; align-items: center; gap: 11px; font-size: 22px; font-weight: 600; color: var(--ink); margin: 0; cursor: pointer; }

/* ---------- pills / chips ---------- */
.pill { display: inline-flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 700; padding: 7px 17px; border-radius: 999px; white-space: nowrap; }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-mute { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
button.pill { border: 0; cursor: pointer; font-family: inherit; }
.cat { --c: var(--c-cabinets); background: color-mix(in srgb, var(--c) 18%, transparent); color: color-mix(in srgb, var(--c) 82%, var(--ink)); }
.cat::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.cat-front-fridge { --c: var(--c-front-fridge); } .cat-back-fridge { --c: var(--c-back-fridge); }
.cat-front-freezer { --c: var(--c-front-freezer); } .cat-back-freezer { --c: var(--c-back-freezer); }
.cat-downstairs-freezer { --c: var(--c-downstairs-freezer); } .cat-back-pantry { --c: var(--c-back-pantry); }
.cat-cabinets { --c: var(--c-cabinets); }
.cat-cats { --c: var(--c-cats); } .cat-utilities { --c: var(--c-utilities); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px;
  padding: 12px 24px; font: inherit; font-size: 21px; font-weight: 650; cursor: pointer;
  box-shadow: 0 1px 2px rgba(40,20,80,.04), 0 4px 10px rgba(40,20,80,.05);
}
.chip:hover { color: var(--ink); }
.chip.on { background: var(--accent-grad); border-color: transparent; color: var(--accent-ink); box-shadow: 0 4px 12px rgba(75,36,130,.28); }

.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 13px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 14px 22px; font: inherit; font-size: 21px; font-weight: 650; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--accent-soft); color: var(--accent); }

/* ---------- money: always saved, hidden unless "Show prices" is ticked ---------- */
html:not(.show-prices) .money { display: none !important; }
.foot { max-width: 1340px; margin: -50px auto 0; padding: 0 26px 42px; display: flex; justify-content: flex-end; }
.foot .check { font-size: 20px; font-weight: 600; color: var(--muted); }

/* ---------- hero (inventory/home page only, replaces the shared topbar there) ---------- */
.hero {
  margin: -36px -26px 0; padding: 20px 26px 92px; background: var(--hero-grad); color: #fff;
  border-radius: 0 0 36px 36px; position: relative; overflow: hidden;
}
.hero-glow { position: absolute; border-radius: 50%; pointer-events: none; }
.hero-glow-a { top: -160px; right: -100px; width: 420px; height: 420px; background: radial-gradient(circle, rgba(255,255,255,.2), transparent 68%); }
.hero-glow-b { bottom: -140px; left: -80px; width: 340px; height: 340px; background: radial-gradient(circle, rgba(255,211,110,.16), transparent 70%); }
.hero-top { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 2; padding-top: env(safe-area-inset-top, 0px); }
.hero-top .brand { color: #fff; font-size: 22px; font-weight: 700; gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 15px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.24); }
.hero-top .brand .brand-mark svg { width: 28px; height: 28px; }
.hero-top .mode { background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28); display: inline-flex; align-items: center; gap: 8px; }
.hero-top .mode.demo { color: #ffe9b3; } .hero-top .mode.live { color: #fff; }
.hero-top .mode i { width: 9px; height: 9px; border-radius: 50%; background: #7df0ae; box-shadow: 0 0 0 4px rgba(125,240,174,.25); }
.hero-body { position: relative; z-index: 2; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-top: 30px; }
.greet h1 { margin: 0 0 6px; font-size: 52px; line-height: 1.02; letter-spacing: -.02em; font-weight: 700; color: #fff; }
.greet p { margin: 0; font-size: 22px; color: #e6dbf7; font-weight: 500; }
.illus { flex: none; width: clamp(150px, 26vw, 280px); margin-bottom: -6px; }
.illus svg { width: 100%; height: auto; display: block; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.qa {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 60px; padding: 0 26px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.3); border-radius: 18px;
  color: #fff; font: inherit; font-weight: 700; font-size: 21px; cursor: pointer; transition: transform .15s, background .15s;
}
.qa svg { width: 24px; height: 24px; }
.qa:hover { background: rgba(255,255,255,.24); }
.qa:active { transform: scale(.97); }
.qa-primary { background: #fff; color: #512888; border-color: #fff; box-shadow: 0 8px 20px rgba(30,8,70,.25); }
.qa-primary:hover { background: #fff; transform: translateY(-1px); }
@media (max-width: 760px) {
  .hero { margin: -20px -14px 0; padding: 16px 14px 72px; border-radius: 0 0 30px 30px; }
  .hero-body { margin-top: 22px; gap: 8px; }
  .greet h1 { font-size: 36px; white-space: nowrap; } .greet p { font-size: 19px; }
  .illus { width: 112px; }
  .hero-actions { gap: 10px; margin-top: 20px; }
  .qa { flex: 1 1 auto; min-height: 56px; padding: 0 16px; font-size: 19px; border-radius: 16px; }
  .hero-body { flex-direction: column; align-items: flex-start; }
  .illus { position: absolute; right: 0; top: -4px; width: 104px; }
}

/* ---------- inventory ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.summary { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; color: var(--muted); font-size: 22px; }
.summary b { color: var(--ink); }
.sum-btn { border: 0; font: inherit; font-size: 20px; font-weight: 700; border-radius: 999px; padding: 8px 19px; cursor: pointer; background: var(--warn-soft); color: var(--warn); }
.sum-btn:hover { filter: brightness(.96); }

/* ---------- big search bar ---------- */
.search-wrap { position: relative; margin-bottom: 18px; }
.search-wrap svg { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-wrap svg { color: var(--accent); }
.search-hero {
  width: 100%; min-height: 72px; font-size: 24px; border-radius: 20px;
  padding: 0 20px 0 58px; border: 2px solid transparent; background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.search-hero::placeholder { color: var(--muted); opacity: .8; }
.search-hero:focus { border-color: var(--accent); outline: none; }

/* ---------- stat tiles: a single floating card that overlaps the hero on the inventory page ---------- */
.stats {
  display: flex; align-items: stretch; margin: -62px 0 20px; position: relative; z-index: 3;
  background: var(--surface); border-radius: 26px; box-shadow: var(--shadow); padding: 12px 8px;
}
.stat-tile {
  flex: 1; text-align: center; border: 0; border-radius: 0; padding: 8px 14px; background: transparent; font: inherit; cursor: default;
  position: relative; color: var(--ink);
}
.stat-tile + .stat-tile::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 1px; background: var(--line); }
.stat-tile .ico { display: grid; place-items: center; width: 46px; height: 46px; margin: 0 auto 6px; border-radius: 15px; background: var(--accent-soft); font-size: 24px; line-height: 1; }
.stat-tile.warn .ico { background: var(--warn-soft); }
.stat-tile .n { display: block; font-family: var(--font-head); font-size: 40px; font-weight: 700; line-height: 1.1; }
.stat-tile .lbl { display: block; font-size: 17px; font-weight: 700; color: var(--muted); margin-top: 2px; }
button.stat-tile { cursor: pointer; }
button.stat-tile:hover .n, button.stat-tile:hover .lbl { opacity: .75; }
.stat-tile.warn .n, .stat-tile.warn .lbl { color: var(--warn); }
.stat-tile.accent:not(.off) .n, .stat-tile.accent:not(.off) .lbl { color: var(--accent); }
.stat-tile.accent.off .n, .stat-tile.accent.off .lbl { color: var(--ink); }
.stat-tile.accent.off .lbl { color: var(--muted); }

.toolbar { display: flex; gap: 15px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .search { flex: 1 1 auto; max-width: 520px; }
.filters { display: flex; align-items: center; gap: 17px; margin-bottom: 22px; flex-wrap: wrap; }
.filters .chips { flex: 1 1 auto; }
.opts { position: relative; flex: none; }
.opts summary { list-style: none; cursor: pointer; color: var(--muted); font-weight: 700; font-size: 21px; padding: 12px 18px; border: 2px solid var(--line); border-radius: 12px; user-select: none; }
.opts summary::-webkit-details-marker { display: none; }
.opts summary::after { content: " \25BE"; }
.opts summary:hover, .opts[open] summary { background: var(--surface); color: var(--ink); }
.opts-body { position: absolute; right: 0; top: calc(100% + 10px); z-index: 15; width: 380px; padding: 23px; display: grid; gap: 20px; background: var(--surface); border: 2px solid var(--line); border-radius: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }

.filter-banner { display: flex; align-items: center; gap: 15px; background: var(--accent-soft); color: var(--accent); border-radius: 14px; padding: 15px 20px; margin-bottom: 18px; font-weight: 700; font-size: 22px; }

.list { display: grid; gap: 14px; background: none; border: 0; box-shadow: none; overflow: visible; }
.list > .empty { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.grp-wrap { display: block; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; animation: rise .3s ease both; }
.grp { display: flex; align-items: center; gap: 16px; padding: 18px 22px; font-size: 26px; font-weight: 700; color: var(--ink);
  cursor: pointer; user-select: none; list-style: none; min-height: 96px; }
.grp::-webkit-details-marker { display: none; }
.grp:hover { background: var(--surface-2); }
.grp:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 65%, transparent); outline-offset: -3px; }
.loc-tile { display: grid; place-items: center; flex: none; width: 62px; height: 62px; border-radius: 20px; font-size: 32px; line-height: 1;
  background: color-mix(in srgb, var(--c, var(--c-cabinets)) 16%, var(--surface)); }
.loc-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.loc-name .cnt { font-size: 19px; font-weight: 500; color: var(--muted); letter-spacing: 0; opacity: 1; margin-top: 2px; }
.soon-badge { margin-left: auto; padding: 6px 15px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-size: 18px; font-weight: 700; white-space: nowrap; }
.grp .arrow { flex: none; margin-left: auto; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); transition: transform .15s ease; }
.soon-badge + .arrow { margin-left: 0; }
.grp-wrap[open] > .grp .arrow { transform: rotate(90deg); }
.grp-rows { margin: 0 16px 16px; padding: 4px 6px; border-radius: 18px; background: var(--surface-2); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.row { display: grid; grid-template-columns: minmax(0, 1fr) 285px 195px 380px; gap: 22px; align-items: center; padding: 22px 18px; min-height: 104px; border-top: 1px solid var(--line); }
html.show-prices .row { grid-template-columns: minmax(0, 1fr) 285px 195px 125px 380px; }
.grp-rows > .row:first-child { border-top: 0; }
.row.needs-review { box-shadow: inset 4px 0 0 var(--warn); border-radius: 4px; }
.row.used { opacity: .6; }
.row.is-out .nm-text { opacity: .65; }

.c-nm { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; min-width: 0; font-weight: 700; font-size: 25px; }
.c-nm .nm-text { flex: 1 1 120px; min-width: 0; }
.c-nm .raw { flex-basis: 100%; font-weight: 400; color: var(--muted); font-size: 19px; }
.food { display: grid; place-items: center; flex: none; width: 52px; height: 52px; border-radius: 17px; background: var(--surface); font-size: 28px; line-height: 1; box-shadow: 0 1px 3px rgba(53,23,106,.12); }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c, var(--c-cabinets)); flex: none; }
.c-exp { line-height: 1.3; font-size: 22px; font-weight: 600; }
.c-exp small { display: block; font-size: 19px; color: var(--muted); font-weight: 600; }
.c-exp.soon, .c-exp.soon small { color: var(--warn); }
.c-exp.gone, .c-exp.gone small { color: var(--danger); }
.c-exp.gone small { font-weight: 700; }
/* always visible — no hover-reveal for an older user */
.c-acts { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; opacity: 1; }
.c-acts .btn { border-color: var(--line); background: var(--surface); color: var(--ink); min-height: 58px; font-size: 20px; }
.c-acts .btn:hover { background: var(--surface-2); border-color: var(--ink); color: var(--ink); }
.c-acts .btn-danger { color: var(--danger); }
.c-acts .btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-icon { padding: 12px 15px; }
.btn-icon svg { width: 24px; height: 24px; }

.stepper { display: inline-flex; align-items: center; border: 2px solid var(--line); border-radius: 13px; overflow: hidden; background: var(--surface); }
.stepper button { border: 0; background: var(--surface-2); width: 64px; height: 64px; font-size: 32px; line-height: 1; cursor: pointer; color: var(--ink); font-weight: 800; }
.stepper button:hover { background: var(--surface-2); color: var(--ink); }
.stepper input { width: 80px; border: 0; border-radius: 0; background: transparent; text-align: right; font-weight: 750; font-size: 22px; padding: 0 4px 0 6px; height: 64px; -moz-appearance: textfield; appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: none; background: var(--accent-soft); }
.stepper .unit { color: var(--muted); font-size: 19px; font-weight: 600; padding: 0 7px 0 3px; min-width: 34px; }

.empty { text-align: center; padding: 70px 24px; color: var(--muted); }
.empty h2 { color: var(--ink); }

/* ---------- dialog ---------- */
dialog { border: 2px solid var(--line); border-radius: 18px; padding: 0; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.28); width: min(720px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(15, 22, 18, .55); }
.dlg-head { padding: 25px 28px 0; }
.dlg-body { padding: 20px 28px; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.dlg-body .full { grid-column: 1 / -1; }
.dlg-foot { padding: 18px 28px 25px; display: flex; gap: 13px; align-items: center; flex-wrap: wrap; }
.dlg-foot .grow { flex: 1; }

/* ---------- toast ---------- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; }
.toast { background: var(--ink); color: var(--bg); padding: 16px 25px; border-radius: 14px; box-shadow: var(--shadow); font-weight: 650; font-size: 22px; max-width: min(90vw, 620px); }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- add receipt ---------- */
.add-wrap { max-width: 860px; }
.hint { display: flex; gap: 16px; align-items: flex-start; color: var(--muted); font-size: 20px; margin: 22px 0 0; padding: 18px 22px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.hint-ico { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 16px; background: var(--warn-soft); font-size: 24px; }
.drop { border: 2.5px dashed color-mix(in srgb, var(--accent) 38%, var(--line)); border-radius: 28px; padding: 54px 30px; text-align: center; background: var(--surface); box-shadow: var(--shadow); cursor: pointer; transition: background .15s, border-color .15s, transform .15s; }
.drop:hover { border-color: var(--accent); }
.drop.over { background: var(--accent-soft); border-color: var(--accent); transform: scale(1.01); }
.drop-ico { display: grid; place-items: center; width: 104px; height: 104px; margin: 0 auto; border-radius: 34px; background: var(--accent-soft); color: var(--accent); }
.drop-ico svg { width: 52px; height: 52px; }
.drop h2 { margin: 22px 0 8px; font-size: 32px; }
.drop img { max-width: 100%; max-height: 380px; border-radius: 16px; box-shadow: var(--shadow); }
.actions { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 20px; }
.cam-body { padding: 20px 28px 5px; }
#camVideo { width: 100%; max-height: 60vh; background: #000; border-radius: 10px; display: block; }
#camErr { margin: 10px 0 0; color: var(--danger); }
.tips { margin: 0; padding-left: 20px; color: var(--muted); }
.tips li { margin-bottom: 11px; }
.scanning { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 88%, transparent); display: grid; place-items: center; z-index: 60; backdrop-filter: blur(3px); }
.scanning .box { text-align: center; padding: 42px 54px; }
.spin { width: 54px; height: 54px; border: 6px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 20px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- review ---------- */
.banner { border-radius: 14px; padding: 16px 20px; margin-bottom: 20px; font-weight: 600; font-size: 22px; }
.banner.demo { background: var(--warn-soft); color: var(--warn); }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner.bad { background: var(--danger-soft); color: var(--danger); }
.review-grid { display: grid; grid-template-columns: 380px 1fr; gap: 24px; align-items: start; }
.paper-wrap { position: sticky; top: 24px; }
.paper { background: #fffef9; color: #26302b; border: 1px solid #e4dfcf; border-radius: 4px; padding: 22px 20px; font-size: 15px; line-height: 1.6; box-shadow: var(--shadow); -webkit-mask: radial-gradient(circle 6px at 8px 100%, #0000 98%, #000) bottom/16px 51% repeat-x, linear-gradient(#000 0 0) top/100% 50% no-repeat; mask: radial-gradient(circle 6px at 8px 100%, #0000 98%, #000) bottom/16px 51% repeat-x, linear-gradient(#000 0 0) top/100% 50% no-repeat; }
.paper .ctr { text-align: center; }
.paper .r { display: flex; justify-content: space-between; gap: 10px; }
.paper .neg { color: #a33; }
.paper hr { border: 0; border-top: 1px dashed #c9c3b0; margin: 9px 0; }
.paper-img { width: 100%; border-radius: 8px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.hdr-grid { display: grid; grid-template-columns: 2fr 1.3fr 1fr 1fr 1fr; gap: 15px; padding: 22px; }
html:not(.show-prices) .hdr-grid { grid-template-columns: 2fr 1fr; }
html:not(.show-prices) table.lines-t { min-width: 644px; }
.totals-check { margin: 0 18px 18px; }
.totals-check:empty { display: none; }
.lines { margin-top: 20px; overflow-x: auto; }
table.lines-t { width: 100%; border-collapse: collapse; min-width: 1064px; table-layout: fixed; font-size: 21px; }
.lines-t input[type=number] { padding: 8px; -moz-appearance: textfield; appearance: textfield; }
.lines-t input[type=number]::-webkit-inner-spin-button,
.lines-t input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.lines-t th { text-align: left; font-size: 18px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 15px 12px; background: var(--surface-2); border-bottom: 2px solid var(--line); font-weight: 700; }
.lines-t td { padding: 15px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.lines-t tr:first-child td { border-top: 0; }
.lines-t tr.flagged td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
.lines-t tr.is-return { background: color-mix(in srgb, var(--info-soft) 55%, transparent); }
.lines-t tr.skipped { opacity: .45; }
.lines-t input, .lines-t select { padding: 8px 10px; min-height: 42px; }
.lines-t select { padding-left: 7px; padding-right: 4px; }
.lines-t .num { text-align: right; }
.review-grid > * { min-width: 0; }
.lines-t .rawline { display: block; margin-top: 6px; font-size: 19px; color: var(--muted); }
.flags { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 10px; }
.stickybar { position: sticky; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); margin-top: 22px; display: flex; gap: 15px; align-items: center; padding: 20px 23px; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); box-shadow: 0 -6px 24px rgba(0,0,0,.08); flex-wrap: wrap; }

/* ---------- receipts list ---------- */
.rc { display: grid; grid-template-columns: 1.8fr 1fr 1fr 1fr auto; gap: 17px; align-items: center; padding: 18px 22px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); font-size: 22px; animation: rise .3s ease both; }
.rc-main { display: flex; align-items: center; gap: 16px; min-width: 0; }
.rc-ico { display: grid; place-items: center; flex: none; width: 58px; height: 58px; border-radius: 19px; background: var(--accent-soft); font-size: 28px; line-height: 1; }
html:not(.show-prices) .rc { grid-template-columns: 1.8fr 1fr 1fr auto; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .add-grid, .review-grid { grid-template-columns: 1fr; }
  .paper-wrap { position: static; order: 2; }
  .hdr-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .topbar-inner { gap: 6px; padding: 0 12px; min-width: 0; }
  .brand { flex: none; }
  .topbar .brand span { display: none; }
  .mode { flex: none; }
  .mode { font-size: 13px; padding: 4px 10px; }
  main { padding: 20px 14px calc(140px + env(safe-area-inset-bottom, 0px)); }
  .bottomnav a { min-width: 0; flex: 1 1 0; font-size: 13px; }
  .bottomnav svg { width: 24px; height: 24px; }
  .search-hero { min-height: 64px; font-size: 22px; }
  .stats { padding: 14px 4px; margin-top: -32px; }
  .stat-tile { padding: 0 6px; }
  .stat-tile .n { font-size: 24px; }
  .stat-tile .lbl { font-size: 12px; }
  .row, html.show-prices .row { grid-template-columns: minmax(0, 1fr); grid-template-areas: "nm" "acts" "qty" "exp"; row-gap: 14px; padding: 22px 20px; }
  .row > .c-nm { grid-area: nm; }
  .row > .c-acts { grid-area: acts; justify-content: stretch; min-width: 0; }
  .row > .c-acts .btn { flex: 1 1 0; justify-content: center; min-width: 0; }
  .row > .c-qty { grid-area: qty; }
  .row > .c-qty .stepper { width: 100%; }
  .row > .c-qty .stepper input { flex: 1; width: auto; text-align: center; }
  .row > .c-exp { grid-area: exp; text-align: left; }
  .row > .c-exp:empty { display: none; }
  .row > .c-price { display: none !important; }

  /* Phone is the primary device for this app -- make the on-screen type and
     touch targets bigger here than on desktop, not just re-stacked. */
  body { font-size: 29px; }
  h1 { font-size: 34px; }
  .page-head { margin-bottom: 18px; }
  .summary { font-size: 20px; }
  .toolbar .search { max-width: none; }
  input, select, textarea { font-size: 24px; min-height: 64px; }
  .grp { padding: 14px 14px; font-size: 23px; min-height: 84px; gap: 12px; }
  .loc-tile { width: 54px; height: 54px; font-size: 28px; border-radius: 17px; }
  .grp-rows { margin: 0 8px 10px; }
  .food { width: 46px; height: 46px; font-size: 25px; }
  .row { padding: 24px 18px; row-gap: 16px; }
  .c-nm { font-size: 28px; gap: 10px; }
  .c-nm .nm-text { flex: 1 1 120px; min-width: 0; }
.c-nm .raw { font-size: 18px; }
  .c-exp { font-size: 23px; }
  .c-exp small { font-size: 18px; }
  .c-acts .btn { min-height: 64px; font-size: 21px; padding: 14px 16px; flex-basis: 0; }
  .stepper button { width: 72px; height: 72px; font-size: 36px; }
  .stepper input { height: 72px; font-size: 24px; }
  .stepper .unit { font-size: 18px; }
  .rc, html:not(.show-prices) .rc { grid-template-columns: 1fr auto auto; }
  .rc .hide-sm { display: none !important; }
  .opts-body { right: auto; left: 0; }
  .filters .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px; padding: 4px 14px 8px; scrollbar-width: none; }
  .filters .chips::-webkit-scrollbar { display: none; }
  .filters .chip { flex: none; }
  .dlg-body { grid-template-columns: 1fr 1fr; }
}

/* ---------- shared page hero (Scan, Receipts, Review) ---------- */
.page-hero { position: relative; overflow: hidden; padding: 20px 26px 96px; color: #fff; background: var(--hero-grad); border-radius: 0 0 36px 36px; }
.page-hero-inner { position: relative; z-index: 2; max-width: 1340px; margin: 0 auto; }
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-top: 30px; }
.page-title h1 { margin: 0 0 6px; font-size: 52px; line-height: 1.02; letter-spacing: -.02em; color: #fff; }
.page-title p { margin: 0; font-size: 21px; color: #e6dbf7; font-weight: 500; max-width: 640px; }
main.has-hero { position: relative; z-index: 3; margin-top: -56px; padding-top: 0; }
main.has-hero > .banner { box-shadow: var(--shadow); }
@media (max-width: 760px) {
  .page-hero { padding: 16px 14px 76px; border-radius: 0 0 30px 30px; }
  .page-title { margin-top: 22px; flex-wrap: wrap; }
  .page-title > div { flex: 1 1 240px; }
  .page-title h1 { font-size: 38px; } .page-title p { font-size: 18px; }
  .page-title .qa { flex: none; min-height: 52px; padding: 0 18px; }
  main.has-hero { margin-top: -44px; }
  .drop { padding: 36px 18px; }
  .actions .btn { flex: 1 1 auto; justify-content: center; }
  .actions .spacer { display: none; }
}

a.btn, a.qa { text-decoration: none; }
.drop p { font-size: 20px; line-height: 1.5; }
@media (max-width: 760px) { .drop p { font-size: 18px; } .drop h2 { font-size: 28px; } .drop-ico { width: 88px; height: 88px; border-radius: 28px; } }

/* ---------- shopping list ---------- */
.shop-add { display: flex; gap: 12px; margin-bottom: 22px; padding: 10px; background: var(--surface); border-radius: 24px; box-shadow: var(--shadow); }
.shop-add input { border: 0; background: transparent; min-height: 64px; font-size: 24px; padding: 0 16px; }
.shop-add input:focus { outline: none; }
.shop-add .btn { min-height: 64px; padding: 0 34px; border-radius: 18px; }
.shop-h { font-family: var(--font-head); font-size: 24px; margin: 26px 4px 12px; display: flex; align-items: center; gap: 10px; }
.shop-h span { font-family: inherit; font-size: 17px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 2px 14px; }
.shop-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 12px; }
.shop-row { display: flex; align-items: center; gap: 16px; padding: 14px 6px; min-height: 92px; }
.shop-row + .shop-row { border-top: 1px solid var(--line); }
.tick { flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; border: 2.5px solid color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--surface); color: transparent; cursor: pointer; transition: all .15s; padding: 0; }
.tick svg { width: 26px; height: 26px; }
.tick:hover { border-color: var(--accent); }
.shop-row.done .tick { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.shop-name { flex: 1; min-width: 0; font-size: 26px; font-weight: 700; line-height: 1.25; display: flex; flex-direction: column; }
.shop-name small { font-size: 17px; font-weight: 600; color: var(--warn); }
.shop-row.done .shop-name { text-decoration: line-through; color: var(--muted); }
.shop-row.done .food { opacity: .55; }
.empty-ico { display: grid; place-items: center; width: 88px; height: 88px; margin: 0 auto 14px; border-radius: 28px; background: var(--accent-soft); font-size: 44px; }
.empty p { max-width: 460px; margin: 0 auto; }
@media (max-width: 760px) {
  .shop-add input { font-size: 22px; min-height: 60px; }
  .shop-add .btn { padding: 0 24px; min-height: 60px; }
  .shop-name { font-size: 24px; }
}

#confirmDlg .dlg-foot { flex-wrap: nowrap; }
#confirmDlg .dlg-foot .btn { flex: 1 1 0; justify-content: center; }
#confirmDlg .dlg-foot .grow { display: none; }

/* ---------- footer: log out ---------- */
.foot { gap: 18px; align-items: center; position: relative; z-index: 4; padding-bottom: calc(124px + env(safe-area-inset-bottom, 0px)); }   /* above the page, clear of the floating tab bar */
.logout-form { margin: 0; }

/* ---------- phone fixes: dialogs fit the screen, toasts clear the tab bar ---------- */
.dlg-body > * { min-width: 0; }
dialog { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; }
.addmode-seg { margin: 16px 28px 0; }
#toasts { bottom: calc(118px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 760px) {
  .dlg-body { grid-template-columns: 1fr; }
  .dlg-foot .btn { flex: 1 1 auto; justify-content: center; }
}

/* ---------- dark mode touch-ups ---------- */
@media (prefers-color-scheme: dark) {
  .bottomnav { border-color: var(--line); }
  .toast.err { color: #2a0f0b; }
}

/* ---------- review on a phone: each line is a card, not a table row ---------- */
@media (max-width: 760px) {
  .hdr-grid, html:not(.show-prices) .hdr-grid { grid-template-columns: 1fr; }
  .hdr-grid > * { min-width: 0; }
  .lines { overflow-x: visible; background: none; border: 0; box-shadow: none; }
  table.lines-t, html:not(.show-prices) table.lines-t { display: block; min-width: 0; }
  .lines-t thead { display: none; }
  .lines-t tbody { display: grid; gap: 14px; }
  .lines-t tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px 12px; padding: 18px 16px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
  .lines-t tr.flagged { box-shadow: inset 5px 0 0 var(--warn), var(--shadow); }
  .lines-t tr.flagged td:first-child { box-shadow: none; }
  .lines-t td { display: block; padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; }
  .lines-t td::before { content: attr(data-label); display: block; margin-bottom: 6px; font-size: 17px; font-weight: 700; color: var(--muted); }
  .lines-t td[data-label="Item"] { grid-column: 1 / -1; order: -2; }
  .lines-t td[data-label="Item"]::before { content: none; }
  .lines-t td[data-label="Category"] { grid-column: 1 / -1; order: -1; }
  .lines-t td[data-label="Include"] { grid-column: 1 / -1; order: 9; display: flex; align-items: center; gap: 12px; }
  .lines-t td[data-label="Include"]::before { content: "Add this one"; order: 2; margin: 0; font-size: 20px; color: var(--ink); }
  .lines-t input, .lines-t select { min-height: 60px; padding: 10px 14px; font-size: 22px; }
  .lines-t input[type=checkbox] { min-height: 0; width: 32px; height: 32px; }
  .lines-t .num { text-align: left; }
  .lines-t .pill { white-space: normal; text-align: left; border-radius: 16px; }
  .stickybar { position: static; flex-direction: column; align-items: stretch; }
  .stickybar .spacer { display: none; }
  .stickybar .btn { justify-content: center; }
}
