/* Mobile-first UI (keeps the original vibe, but easier to extend) */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

/* ===========================================================================
   iOS standalone chrome seam — DO NOT "TIDY" ANY OF THE FOUR RULES BELOW
   ===========================================================================
   On a Home-Screen (standalone) install, iOS does NOT give the page the whole
   screen. Measured on an iPhone X-class device: screen 375x812, web view
   375x762. Where those missing 50pt go is decided by the status-bar meta, and
   whichever strip the web view doesn't get is painted by iOS itself with the
   theme-color meta — no element, and no canvas background, can reach it.

   The app currently puts that strip at the TOP (see index.html), so a flat
   band of theme-color sits directly above the page. Making the join invisible
   needs FOUR things to agree. All four have been broken at least once; each
   one alone reintroduces a visible line across the top of the screen.

   1. index.html: apple-mobile-web-app-status-bar-style = "default".
      "black-translucent" moves the strip to the BOTTOM instead, where it
      leaves the tab bar floating ~50pt above the screen edge.
   2. settings.js applyTheme(): meta[theme-color] = the theme's bgA.
      That is the colour iOS paints the strip with.
   3. The page gradient must start at exactly --bg-a across its ENTIRE top
      edge, so it meets that flat band seamlessly. Hence `to bottom` and not
      `135deg`: a diagonal is already ~a third of the way to --bg-b by the
      top-RIGHT corner, which reads as a step on the right-hand side. Only the
      10px side gutters really show the gradient, so the look barely changes.
      Keep html and body in sync.
   4. .container's box-shadow must not extend above its own top edge — see the
      note on that rule. This was the actual cause of the "sharp line" that
      survived 1-3.

   The root background is the canvas background: painted across the whole
   canvas but *positioned* using this element's box, so with the default
   `repeat` the gradient tiles and visibly restarts in any area outside that
   box. `no-repeat` leaves the flat background colour there instead. (The old
   env(safe-area-inset-bottom)-keyed surface layer was dead code: 0px tall when
   the viewport misses the safe area, hidden behind body when it doesn't.)
   =========================================================================== */
html {
  background: var(--surface) linear-gradient(to bottom, var(--bg-a) 0%, var(--bg-b) 100%) no-repeat;
  overscroll-behavior: none;
}

:root {
  --bg-a: #667eea;
  --bg-b: #764ba2;
  --accent-a: #667eea;
  --accent-b: #764ba2;
  --accent-solid: #667eea;

  /* Surface palette — overridden wholesale by .theme-dark */
  --surface: #ffffff;        /* the app "sheet" */
  --card: #fafafa;           /* cards on the sheet */
  --card-solid: #ffffff;     /* floating menus/dialogs */
  --border: #eeeeee;         /* card borders */
  --border-strong: #dddddd;  /* input borders */
  --divider: #ececf2;        /* row separators */
  --text: #333333;
  --text-muted: #666666;
  --text-faint: #8a8a95;
  --text-ghost: #bbbbbb;
  --btn-2: #f0f0f0;          /* secondary buttons */
  --btn-2-active: #e6e6e6;
  --qbtn: #efeff4;           /* small square action buttons */
  --qbtn-active: #e2e2e8;
  --chip-bg: #ffffff;
  --chip-border: #e2e2ea;
  --input-bg: #ffffff;
}

.theme-dark {
  --surface: #171a21;
  --card: #1e222b;
  --card-solid: #232834;
  --border: #2a2f3a;
  --border-strong: #353b48;
  --divider: #2a2f3a;
  --text: #e7e9ee;
  --text-muted: #9aa1ad;
  --text-faint: #7c8391;
  --text-ghost: #5a6170;
  --btn-2: #2a2f3a;
  --btn-2-active: #343a47;
  --qbtn: #2a2f3a;
  --qbtn-active: #343a47;
  --chip-bg: #1e222b;
  --chip-border: #353b48;
  --input-bg: #14171d;
}

/* position:fixed pins the app shell — on iOS the document itself can
   otherwise rubber-band ("outer frame scrolls") and steal touch scrolling
   from #viewRoot. Only #viewRoot scrolls. inset:0 spans the full viewport;
   the bottom nav is pinned separately (see .bottom-nav) so it always reaches
   the true screen bottom regardless of how iOS reports viewport height in a
   Home-Screen (standalone) install. */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  /* `to bottom`, never a diagonal — see the iOS standalone chrome seam
     contract at the top of this file (point 3). */
  background: var(--bg-a) linear-gradient(to bottom, var(--bg-a) 0%, var(--bg-b) 100%);
  position: fixed;
  inset: 0;
  overflow: hidden; /* prevent page-level scrolling (avoid double scroll) */
  overscroll-behavior: none;
  touch-action: pan-y;
  padding: calc(4px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 0 calc(10px + env(safe-area-inset-left));
  -webkit-tap-highlight-color: transparent;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  color: var(--text);
}

/* Horizontal padding lives on #viewRoot (not the container) so the iOS
   overlay scrollbar — drawn at the scroll container's right edge — sits in
   the blank padding gutter instead of on top of buttons. */
.container {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border-radius: 18px 18px 0 0; /* bottom is flush with the screen edge */
  padding: 14px 8px 0;
  /* CONTRACT — see "iOS standalone chrome seam" at the top of this file.
     The negative spread is load-bearing: it keeps the shadow from reaching
     ABOVE the container's top edge. body{overflow:hidden} hard-clips anything
     that does, and that clip line lands exactly on the boundary with the iOS
     status-bar chrome. `0 20px 60px` (no spread) bled ~40px up and drew a
     crisp dark line across the top of the screen. Raise the blur or drop the
     spread and it comes straight back. */
  box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.35);
  position: relative;
  height: 100%;
  max-height: none;
  overflow: hidden; /* scrolling is handled by #viewRoot */
  display: flex;
  flex-direction: column;
}

/* Bottom navigation — labeled tabs in the thumb zone, scan front and center.
   Kept in normal flow as the LAST flex child of the full-height .container
   (body is position:fixed; inset:0, so the container spans the real screen
   height and its last child sits flush at the physical bottom). A fixed
   `bottom:0` was tried and reverted: in a Home-Screen (standalone) install the
   fixed element positions against the layout viewport, not the visual one, so
   it floated up and left an ugly gap below the bar. In-flow avoids that.
   `margin: 0 -8px` bleeds the bar to the container's edges. The bottom padding
   hugs the very bottom: rather than reserving the full home-indicator safe
   area (~34px) below the icons — which read as an ugly empty strip in a
   standalone install — we let the home indicator overlap the bar's small
   gutter. The home indicator pill is ~5pt tall sitting ~8pt off the bottom, so
   `env(safe-area-inset-bottom) - 16px` (18px on a 34pt inset) clears it with a
   few points to spare without donating the whole 34pt safe area to empty
   space. The max() floor keeps 6px on desktop, where the inset is 0.
   position:relative + z-index keep the popped-up scan button painting above
   the scrolling content. */
.bottom-nav {
  position: relative;
  z-index: 30;
  margin: 0 -8px;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  gap: 2px;
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  padding: 5px calc(6px + env(safe-area-inset-right)) max(6px, calc(env(safe-area-inset-bottom) - 16px)) calc(6px + env(safe-area-inset-left));
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.06);
}

.nav-btn {
  flex: 1;
  min-height: 46px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn svg { width: 23px; height: 23px; }
.nav-btn.active { color: var(--accent-solid); }
.nav-btn:active { background: rgba(102, 126, 234, 0.10); }

.nav-scan {
  width: 62px;
  min-height: 52px;
  align-self: center;
  height: 62px;
  margin-top: -26px; /* pops above the bar */
  border: 4px solid var(--surface);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-a) 0%, var(--accent-b) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  flex: 0 0 auto;
}
.nav-scan svg { width: 28px; height: 28px; }
.nav-scan:active { transform: scale(0.96); }
.nav-scan.active { box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22), 0 0 0 3px rgba(102, 126, 234, 0.35); }

h1 {
  color: var(--text);
  margin-bottom: 18px;
  font-size: 22px;
  font-weight: 700;
  text-align: left;
}

#viewRoot {
  flex: 1;
  min-height: 0; /* required for flex children to scroll */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; /* don't chain the bounce to the page */
  /* The nav is an in-flow sibling below, so no space needs reserving for it —
     just a little breathing room under the last content row. */
  padding: 0 8px 16px;
}

.muted { color: var(--text-muted); font-size: 13px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  text-align: left;
  margin-top: 12px;
}

.section-title {
  margin-top: 18px;
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  text-align: left;
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.item-name {
  font-weight: 800;
  color: var(--text);
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.2;
}

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.button {
  width: 100%;
  padding: 16px 18px;
  font-size: 16px;
  font-weight: 800;
  color: white;
  background: linear-gradient(135deg, var(--accent-a) 0%, var(--accent-b) 100%);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.button:active { transform: scale(0.99); }
.button:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.button-secondary {
  background: var(--btn-2);
  color: var(--text);
  font-weight: 800;
}
.button-secondary:active { background: var(--btn-2-active); }

.button-row { display: flex; gap: 10px; margin-top: 12px; }
.button-row .button { flex: 1; }
.button-row .button-secondary { flex: 1; }

.pill {
  background: #f0f0ff;
  color: #3a3a9f;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
  border: 1px solid rgba(102, 126, 234, 0.25);
  white-space: nowrap;
}
.pill-warn {
  background: #fff3e0;
  color: #a05a00;
  border-color: rgba(255, 152, 0, 0.35);
}

.status { margin-top: 12px; font-size: 13px; color: var(--text-muted); text-align: left; }

.result:empty { display: none; }

.result {
  margin-top: 14px;
  padding: 12px;
  background: var(--btn-2);
  border-radius: 10px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--text);
  word-break: break-all;
}
.result.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.result.error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* Camera preview shell — always visible at the top of the scan view.
   Fixed aspect ratio + max-height so the preview always fits on screen;
   the video is cropped with object-fit (decoding still uses the full frame). */
.video-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 46dvh;
  border-radius: 16px;
  overflow: hidden; /* clips the aim overlay's dimming shadow */
  background: linear-gradient(160deg, #23232e 0%, #15151d 100%);
}
.video-shell video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.video-shell video.active { display: block; }

/* Placeholder shown while the camera is off (Scan button lives here) */
.cam-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.cam-placeholder-icon svg {
  width: 46px;
  height: 46px;
  color: rgba(255, 255, 255, 0.45);
}

/* Floating controls over the live preview (torch / stop) */
.cam-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
  z-index: 3;
}
.cam-icon {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.45);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.cam-icon svg { width: 20px; height: 20px; }
.cam-icon:active { background: rgba(0, 0, 0, 0.65); }
.cam-icon.on { background: var(--accent-solid); }

/* Aiming frame overlaid on the camera preview */
.scan-aim {
  position: absolute;
  left: 12%;
  right: 12%;
  top: 30%;
  bottom: 30%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 14px;
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.18);
  pointer-events: none;
}
.scan-aim::before {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  height: 2px;
  background: rgba(255, 80, 80, 0.85);
}

.hidden { display: none !important; }

.field { margin-top: 10px; }
.label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; font-weight: 700; }
.input, .select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
  background: var(--input-bg);
  color: var(--text);
}
.input:focus, .select:focus {
  border-color: rgba(102, 126, 234, 0.8);
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

/* Date fields — an iOS-only overflow that desktop browsers never show.
   WebKit sizes input[type=date] to the content of its own shadow field and
   treats the CSS width as a MINIMUM, so with the Hungarian format
   ("éééé. hh. nn.") the control rendered wider than its card and spilled past
   the right edge of the screen. `appearance: none` is what makes WebKit treat
   it as an ordinary text field that honours width and padding; the width /
   max-width / min-width trio removes any intrinsic-size floor (including the
   flex min-content floor in the variation row), and `overflow: hidden` is the
   belt-and-braces guarantee that nothing can paint outside the border box.
   min-height keeps the 44pt tap target that the native chrome was providing.
   Font stays 16px: anything smaller makes iOS zoom the page on focus. */
.input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  min-height: 46px;
  padding-left: 12px;
  padding-right: 8px;
}
.input[type="date"]::-webkit-datetime-edit { padding: 0; min-width: 0; }
.input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
  width: 100%;
  margin: 0;
}
.input[type="date"]::-webkit-calendar-picker-indicator {
  flex: 0 0 auto;
  margin-left: 4px;
  padding: 0;
}

.inventory-list { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }

.thumb {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--input-bg);
}

.exp-badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 12px;
  color: #111;
  border: 1px solid rgba(0,0,0,0.08);
  white-space: nowrap;
}
.exp-expired { background: #ff5b5b; color: white; }
.exp-14 { background: #ff2d2d; color: white; }
.exp-30 { background: #ffb37a; }
.exp-60 { background: #ffc28f; }
.exp-90 { background: #ffe27a; }
.exp-ok { background: #8be28b; }
.exp-none { background: #f0f0f0; color: #444; }

.images {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.img-large {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  object-fit: cover;
}
.img-small {
  width: 80px;
  height: 80px;
  border-radius: 14px;
  border: 1px solid var(--border);
  object-fit: cover;
  background: var(--input-bg);
}

/* Filter chips — one-tap filters (faster than dropdowns) */
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1.5px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.chip:active { transform: scale(0.97); }
.chip.active {
  background: linear-gradient(135deg, var(--accent-a) 0%, var(--accent-b) 100%);
  border-color: transparent;
  color: white;
}
/* Small category/store photo inside a filter chip */
.chip-img {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  object-fit: cover;
  margin-left: -6px;
  flex: 0 0 auto;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Collapsible advanced filter panel */
details.more-filters { margin-top: 4px; }
details.more-filters > summary {
  list-style: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-solid);
  padding: 8px 2px;
  -webkit-tap-highlight-color: transparent;
}
details.more-filters > summary::-webkit-details-marker { display: none; }
details.more-filters > summary::after { content: ' ▾'; }
details.more-filters[open] > summary::after { content: ' ▴'; }

/* Shared create-a-product form (productForm.js). Everything past price lives
   in the disclosure, so the common case is "type a name, tap Save" while the
   rarer fields are one tap away instead of missing from this entry point. */
details.pf-more { margin-top: 14px; }
details.pf-more > summary {
  list-style: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-solid);
  padding: 8px 2px;
  -webkit-tap-highlight-color: transparent;
}
details.pf-more > summary::-webkit-details-marker { display: none; }
details.pf-more > summary::after { content: ' ▾'; }
details.pf-more[open] > summary::after { content: ' ▴'; }

/* Search field with voice + clear buttons */
.search-wrap { position: relative; }
.search-wrap .input { padding-right: 88px; }
.search-wrap.no-mic .input { padding-right: 42px; }
.search-clear {
  position: absolute;
  right: 46px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: var(--btn-2);
  color: var(--text-muted);
  font-weight: 900;
  cursor: pointer;
  display: none;
  touch-action: manipulation;
}
.search-wrap.no-mic .search-clear { right: 6px; }
.search-wrap.has-value .search-clear { display: block; }
.mic-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 999px;
  background: var(--qbtn);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.mic-btn svg { width: 18px; height: 18px; }
.mic-btn:active { background: var(--qbtn-active); }
.mic-btn.listening {
  background: #e5484d;
  color: white;
  animation: micPulse 1.2s ease-out infinite;
}
@keyframes micPulse {
  0% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.45); }
  100% { box-shadow: 0 0 0 12px rgba(229, 72, 77, 0); }
}

/* Inventory top bar: search + add on one line */
/* Quantity stepper (product page) — stretches to the full card width */
.qty-stepper {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.qty-stepper .qty-btn {
  flex: 0 0 64px;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: var(--btn-2);
  color: var(--text);
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}
.qty-stepper .qty-btn:active { background: var(--btn-2-active); }
/* Zero stock: the − (and its reason caret) is dimmed and inert rather than
   silently doing nothing — the server refuses a decrease at 0. */
.qty-stepper .qty-btn[disabled] {
  opacity: 0.35;
  cursor: default;
}
.qty-stepper .qty-btn[disabled]:active { background: var(--btn-2); }
.qty-stepper input {
  flex: 1;
  width: auto;
  min-width: 0;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px 6px;
  background: var(--input-bg);
  color: var(--text);
}

/* Toasts */
/* Global connection-status bar (offline / reconnecting). Fixed to the top so
   it's visible on any screen; hidden via the global .hidden rule when idle. */
.conn-status {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2000;
  padding: 7px 14px;
  padding-top: calc(7px + env(safe-area-inset-top, 0px));
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.conn-offline { background: #e5484d; color: #fff; }
.conn-reconnecting { background: var(--btn-2); color: var(--text-muted); }
.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: connPulse 1s ease-in-out infinite;
}
@keyframes connPulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 0.9; } }

.toast-container {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 1200;
  width: min(92vw, 420px);
  display: flex;
  justify-content: center;
  pointer-events: none;
}
/* Toasts follow the selected theme via the accent variables */
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--accent-solid);
  color: white;
  border-radius: 14px;
  padding: 13px 16px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
  font-size: 14px;
  font-weight: 600;
  max-width: 100%;
  opacity: 0;
  translate: 0 8px;
  transition: opacity 0.18s ease, translate 0.18s ease;
}
.toast.toast-in { opacity: 1; translate: 0 0; }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-error { background: #a52a3a; }
.toast-success { background: var(--accent-solid); }
.toast-action {
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: white;
  font-weight: 900;
  font-size: 14px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  touch-action: manipulation;
  white-space: nowrap;
}
.toast-action:active { background: rgba(255, 255, 255, 0.12); }

/* Low-contrast metadata (e.g. product ID) */
.meta-faint {
  margin-top: 22px;
  text-align: center;
  font-size: 11px;
  color: var(--text-ghost);
  user-select: all;
  overflow-wrap: anywhere;
}

/* Small inline badges next to names */
.badge-line { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.opened-badge {
  padding: 5px 9px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 11.5px;
  background: #e8f1ff;
  color: #1f4f9f;
  border: 1px solid rgba(31, 79, 159, 0.2);
  white-space: nowrap;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-muted);
}
.empty-state .emoji { font-size: 40px; margin-bottom: 10px; }

/* Onboarding tips inside empty states */
.tips-list {
  text-align: left;
  margin: 12px auto 0;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tips-list .tip {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13.5px;
  color: var(--text-muted);
}
.tips-list .tip .t-emoji { flex: 0 0 22px; text-align: center; }
.tips-list .tip b { color: var(--text); }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: none;
  background: var(--btn-2);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 900;
  touch-action: manipulation;
}
.icon-btn:active { background: var(--btn-2-active); }

.shop-item.shop-done .item-name {
  text-decoration: line-through;
  opacity: 0.65;
}
.shop-item.shop-done {
  opacity: 0.85;
}

/* Bigger, themed checkboxes (toggles) */
input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent-solid);
  flex: 0 0 auto;
}

/* Label + toggle on one line */
.switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.add-btn {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--accent-a) 0%, var(--accent-b) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  flex: 0 0 auto;
}
.add-btn svg { width: 22px; height: 22px; }
.add-btn:active { transform: scale(0.95); }

/* Photo capture/pick buttons (product images) */
.photo-btn-row { display: flex; gap: 10px; margin-top: 4px; }
.photo-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 1.5px dashed var(--border-strong);
  background: var(--chip-bg);
  border-radius: 14px;
  padding: 16px 10px;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.photo-btn:active { background: var(--btn-2); }
.photo-btn .emoji { font-size: 26px; }

/* Floating delete button over the large product image */
.img-wrap { position: relative; }
.img-del {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  font-size: 16px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}
.img-del:active { background: rgba(0, 0, 0, 0.75); }
.img-small.selected {
  border-color: var(--accent-solid);
  box-shadow: 0 0 0 2px var(--accent-solid);
}

/* Inventory list cards: content left, tall image right, qty badge on image */
.inv-card {
  display: flex;
  gap: 12px;
  align-items: stretch;
  padding: 12px;
  cursor: pointer;
}
.inv-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.inv-title { display: flex; align-items: flex-start; gap: 8px; }
.inv-name { flex: 1; min-width: 0; font-size: 15px; }
.inv-meta { font-size: 12.5px; }
.inv-card .badge-line { gap: 6px; }
.inv-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}
.inv-qbtn {
  flex: 0 0 56px;
  padding: 9px 0;
  border: none;
  border-radius: 10px;
  background: var(--qbtn);
  color: var(--text);
  font-weight: 800;
  font-size: 14px;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.inv-qbtn:active { background: var(--qbtn-active); }
.inv-qbtn[disabled] {
  opacity: 0.35;
  cursor: default;
}
.inv-qbtn[disabled]:active { background: var(--qbtn); }
.inv-media {
  position: relative;
  flex: 0 0 82px;
  min-height: 96px;
}
.inv-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--input-bg);
}
.inv-img-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: var(--qbtn);
  opacity: 0.6;
}
.inv-qty {
  position: absolute;
  right: 6px;
  bottom: 6px;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent-solid);
  color: white;
  font-size: 12.5px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.inv-qty-warn { background: #e8590c; }

/* Scan history rows */
/* Product-history search + type-filter controls */
.hist-controls { margin-bottom: 4px; }
.hist-controls .hist-search { margin-bottom: 8px; }
.hist-type-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.hist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--divider);
}
.hist-item:first-child { padding-top: 2px; }
.hist-item:last-child { border-bottom: none; padding-bottom: 2px; }
.hist-main { flex: 1; min-width: 0; }
.hist-name {
  font-weight: 800;
  color: var(--text);
  font-size: 14.5px;
  overflow-wrap: anywhere;
}
.hist-sub {
  color: var(--text-faint);
  font-size: 12.5px;
  margin-top: 3px;
  overflow-wrap: anywhere;
}
.hist-actions { display: flex; gap: 6px; }
.hist-btn {
  min-width: 42px;
  height: 38px;
  padding: 0 10px;
  border: none;
  border-radius: 10px;
  background: var(--qbtn);
  color: var(--text);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.hist-btn:active { background: var(--qbtn-active); }
.hist-btn-primary { background: var(--accent-solid); color: white; }

/* --- Bug reports (Settings -> Report a problem, sent list) --- */
.bug-report {
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
}
.bug-report:first-child { padding-top: 2px; }
.bug-report:last-child { border-bottom: none; padding-bottom: 2px; }
.bug-report .hist-name { font-weight: 700; }
.bug-fixnote {
  margin-top: 8px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--btn-2);
  font-size: 14px;
}
.bug-thread { margin-top: 8px; }
.bug-note {
  margin-top: 8px;
  padding-left: 10px;
  border-left: 2px solid var(--divider);
  font-size: 14px;
}
/* Only the text itself keeps the reporter's line breaks — pre-wrap on the
   wrapper would also render the template literal's own indentation. */
.bug-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* --- Multi-select token input (categories / stores) --- */
.ms-box {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 8px 10px;
  background: var(--input-bg);
  cursor: text;
}
.ms-box:focus-within {
  border-color: rgba(102, 126, 234, 0.8);
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}
.ms-input {
  flex: 1;
  min-width: 110px;
  border: none;
  outline: none;
  font-size: 16px;
  padding: 6px 2px;
  background: transparent;
  color: var(--text);
}
.ms-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f0f0ff;
  color: #3a3a9f;
  border: 1px solid rgba(102, 126, 234, 0.25);
  border-radius: 999px;
  padding: 6px 6px 6px 12px;
  font-size: 13.5px;
  font-weight: 700;
  max-width: 100%;
}
.ms-chip > span { overflow-wrap: anywhere; }
.ms-chip-x {
  border: none;
  background: rgba(102, 126, 234, 0.15);
  color: #3a3a9f;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  flex: 0 0 auto;
  touch-action: manipulation;
}
.ms-sugg {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.ms-sugg-btn {
  border: 1.5px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.ms-sugg-btn:active { background: var(--btn-2); }
.ms-sugg-new { border-style: dashed; color: var(--accent-solid); }

/* --- Inventory filters --- */
.filter-chiprow { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-clear {
  border-color: #e5484d;
  color: #e5484d;
  background: #fff5f5;
}
.theme-dark .chip-clear { background: rgba(229, 72, 77, 0.12); }
.pill-dates {
  background: #eef7ff;
  color: #155e9f;
  border-color: rgba(21, 94, 159, 0.25);
}
/* Autocomplete search under the top-6 chips (large collections) */
.filter-search { margin-top: 10px; }
.filter-search .input { padding-top: 10px; padding-bottom: 10px; font-size: 14px; }
.filter-results { margin-top: 8px; }

/* --- Collapsible sections (variations, product history) --- */
.var-section { margin-top: 14px; }
.var-section > summary {
  list-style: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  padding: 6px 2px;
  -webkit-tap-highlight-color: transparent;
}
.var-section > summary::-webkit-details-marker { display: none; }
.var-section > summary::after { content: ' ▾'; color: var(--accent-solid); }
.var-section[open] > summary::after { content: ' ▴'; color: var(--accent-solid); }

/* Variation (batch) rows */
.var-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.var-row:first-child { padding-top: 0; }
.var-line { display: flex; align-items: center; gap: 10px; }
.var-date { flex: 1; min-width: 0; padding: 10px 12px; }
.var-qty {
  display: flex;
  align-items: center;
  gap: 8px;
}
.var-btn {
  min-width: 44px;
  height: 40px;
  padding: 0 12px;
  border: none;
  border-radius: 10px;
  background: var(--qbtn);
  color: var(--text);
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.var-btn:active { background: var(--qbtn-active); }
.var-count { min-width: 28px; text-align: center; font-weight: 900; font-size: 16px; }
.var-trash {
  margin-left: auto;
  background: #fdecec;
  color: #a33;
  font-size: 13.5px;
}
.var-trash:active { background: #f8dcdc; }
/* Quantity + date + Add. The date needs room for a full localized date
   ("2026. 08. 15." is far wider than "8/15/26"), so the row wraps instead of
   squeezing it: on a narrow phone the button drops to its own line rather
   than clipping the date to "yyyy.". */
.var-add {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.var-add input[type="number"] { flex: 0 0 76px; text-align: center; }
.var-add input[type="date"] { flex: 1 1 160px; min-width: 160px; }
.var-add .button { flex: 1 1 auto; }

/* Quantity − with a reason dropdown (use / expired / lost / broken) */
.qty-dec-wrap {
  position: relative;
  display: flex;
  gap: 3px;
  flex: 0 0 auto;
}
.qty-dec-wrap .qty-btn { flex: 0 0 52px; }
.qty-dec-wrap .qty-caret {
  flex: 0 0 32px;
  font-size: 14px;
  border-radius: 12px;
}
.reason-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  min-width: 230px;
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  padding: 6px;
}
.reason-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 12px;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}
.reason-menu button:active { background: var(--btn-2); }

.button-danger {
  background: #fdecec;
  color: #a33;
  font-weight: 800;
}
.button-danger:active { background: #f8dcdc; }

/* --- Product images: default marker / pending photo thumbs --- */
.img-star {
  position: absolute;
  top: 10px;
  left: 10px;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #ffd76a;
  font-size: 13.5px;
  font-weight: 800;
  padding: 9px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  touch-action: manipulation;
}
.img-star:active { background: rgba(0, 0, 0, 0.75); }
.img-star-on { cursor: default; padding: 9px 11px; }
.thumb-wrap { position: relative; flex: 0 0 auto; }
.thumb-star {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 13px;
  color: #ffd76a;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.thumb-x {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: white;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

/* --- Scan view: camera overlays --- */
.cam-actions-left {
  left: 10px;
  right: auto;
}
.paused-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.28);
}
.paused-overlay .button { box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35); }
.paused-stop {
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  font-weight: 700;
  padding: 9px 16px;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  touch-action: manipulation;
}
.paused-stop:active { background: rgba(0, 0, 0, 0.65); }
.scan-toast {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(20, 20, 28, 0.78);
  color: white;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 13.5px;
  font-weight: 600;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.scan-toast.success { background: rgba(21, 87, 36, 0.82); }
.scan-toast.error { background: rgba(114, 28, 36, 0.85); }
.scan-toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.scan-toast-x {
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 12px;
  cursor: pointer;
  flex: 0 0 auto;
  touch-action: manipulation;
}

/* Zoom control on the camera preview — a text pill rather than an icon, so
   the current level is readable at a glance. */
.cam-zoom {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.2px;
}

/* Live decode telemetry over the preview (Settings → Scanner diagnostics) */
.scan-diag {
  position: absolute;
  left: 10px;
  /* Clears the row of camera buttons at the top of the preview. */
  top: 60px;
  z-index: 3;
  max-width: calc(100% - 20px);
  padding: 5px 9px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: rgba(255, 255, 255, 0.92);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

/* Per-field save state on the product edit form (there is no Save button —
   every field commits on its own). Sits inside the field's <label>. */
.fld-state {
  font-weight: 700;
  font-size: 11.5px;
  margin-left: 6px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.fld-state.fs-saving { color: var(--text-faint); }
.fld-state.fs-saved { color: #2f9e44; }
.fld-state.fs-error { color: #d64545; }

/* Online prefill strip on the new-product form (scan view). One row, one
   contextual action, colour-coded by state so it reads at a glance. */
.lookup-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--input-bg);
}
.lookup-strip.lk-found {
  border-color: rgba(34, 197, 94, 0.5);
  background: rgba(34, 197, 94, 0.10);
}
.lookup-strip.lk-warn {
  border-color: rgba(234, 179, 8, 0.5);
  background: rgba(234, 179, 8, 0.10);
}
.lk-icon { font-size: 18px; flex: 0 0 auto; }
.lookup-strip.lk-loading .lk-icon {
  animation: lk-pulse 1.1s ease-in-out infinite;
}
@keyframes lk-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}
.lk-main { flex: 1; min-width: 0; }
.lk-title { font-size: 13.5px; font-weight: 800; overflow-wrap: anywhere; }
.lk-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; overflow-wrap: anywhere; }
.lk-btn {
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  background: var(--card-solid);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}
.lk-btn:active { background: var(--input-bg); }

/* Proposed photo from the lookup, pending the user's ✕ */
.lk-photo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px;
  border-radius: 12px;
  border: 1px dashed var(--border-strong);
}
.lk-photo-img {
  width: 54px;
  height: 54px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--input-bg);
  flex: 0 0 auto;
}
.lk-photo-main { flex: 1; min-width: 0; }
.lk-photo-title { font-size: 13px; font-weight: 800; }
.lk-photo-x {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: none;
  background: var(--input-bg);
  color: var(--text-muted);
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

/* Link-mode banner on the scan view */
.link-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-a) 0%, var(--accent-b) 100%);
  color: white;
}
.link-banner .lb-main { flex: 1; min-width: 0; }
.link-banner .lb-title { font-weight: 800; font-size: 14.5px; overflow-wrap: anywhere; }
.link-banner .lb-sub { font-size: 12.5px; opacity: 0.9; margin-top: 2px; }
.link-banner button {
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-weight: 800;
  font-size: 13px;
  padding: 9px 14px;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}
.link-banner button:active { background: rgba(255, 255, 255, 0.14); }

/* --- Auth screens (login / signup / household setup) --- */
body.nav-hidden .bottom-nav { display: none; }
body.nav-hidden .container { padding-bottom: 18px; }
/* No fixed nav on auth screens → #viewRoot needn't reserve room for it. */
body.nav-hidden #viewRoot { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

.auth-wrap {
  max-width: 400px;
  margin: 0 auto;
  padding: 0 8px;
  padding-top: 6vh;
}
.auth-hero { text-align: center; margin-bottom: 20px; }
.auth-hero-small { padding-top: 0; margin-bottom: 14px; }
.auth-logo {
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--accent-a) 0%, var(--accent-b) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}
.auth-logo svg { width: 40px; height: 40px; }
.auth-title {
  margin-bottom: 6px;
  font-size: 24px;
  text-align: center;
}
.auth-tagline { color: var(--text-muted); font-size: 14px; }
.auth-card { margin-top: 0; }

/* Language switcher on the auth screens — a flat flag row (no bulky chips): the
   active flag is full-colour with an accent underline, the rest desaturated. */
.lang-seg { display: inline-flex; align-items: center; gap: 4px; }
.lang-seg-btn {
  position: relative;
  border: 0;
  background: none;
  padding: 5px 7px 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.4;
  filter: grayscale(0.6);
  transition: opacity 0.16s ease, filter 0.16s ease, transform 0.1s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.lang-seg-btn:hover { opacity: 0.72; }
.lang-seg-btn:active { transform: scale(0.86); }
.lang-seg-btn.active { opacity: 1; filter: none; }
.lang-seg-btn.active::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 1px;
  width: 16px;
  height: 2.5px;
  border-radius: 999px;
  background: var(--accent-solid);
  transform: translateX(-50%);
}
.auth-alt {
  text-align: center;
  margin-top: 18px;
  color: var(--text-muted);
  font-size: 14px;
}
.auth-link {
  color: var(--accent-solid);
  font-weight: 800;
  text-decoration: none;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 700;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-strong);
}

/* Password field with show/hide toggle */
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 48px; }
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.pw-toggle svg { width: 20px; height: 20px; }
.pw-toggle:active { background: var(--btn-2); }

/* Household choice rows on signup */
.hh-option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
}
.hh-option input[type="radio"] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent-solid);
  flex: 0 0 auto;
  margin-top: 2px;
}
.hh-sub { margin-left: 34px; }

/* Platform admin: household invite links (settings) */
.pill-muted {
  background: var(--btn-2);
  color: var(--text-muted);
  border-color: var(--border-strong);
}
.invite-new { flex-direction: column; align-items: stretch; gap: 8px; margin-top: 12px; }
.invite-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}

/* Which server the login screen talks to (anything but prod) */
.env-tag {
  text-align: center;
  margin-top: 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

/* Pending invitation banner */
.pending-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: #fff8e6;
  border: 1px solid rgba(255, 170, 0, 0.3);
  border-radius: 12px;
  padding: 12px;
}
.theme-dark .pending-banner { background: rgba(245, 166, 35, 0.12); }
.pending-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: #f5a623;
  flex: 0 0 auto;
  animation: pendingPulse 1.6s ease-out infinite;
}
@keyframes pendingPulse {
  0% { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0.5); }
  100% { box-shadow: 0 0 0 10px rgba(245, 166, 35, 0); }
}

/* Avatars */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--qbtn);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  overflow: hidden;
  flex: 0 0 auto;
  border: 1px solid var(--border);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 64px; height: 64px; font-size: 30px; margin: 0 auto; }
.avatar-row { display: flex; align-items: center; gap: 14px; }
.avatar-row .avatar-lg { margin: 0; }
.auth-hero .avatar-lg { margin: 0 auto 12px; }
/* Tappable avatar (set category/store photo) */
button.avatar { cursor: pointer; padding: 0; }

/* Household member rows */
.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
}
.member-row:last-of-type { border-bottom: none; }
.icon-btn-accent {
  background: var(--accent-solid);
  color: white;
}

/* Favorite stars */
.star-btn {
  border: none;
  background: transparent;
  color: var(--text-ghost);
  font-size: 21px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  flex: 0 0 auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.star-btn.on { color: #f5b301; }
.star-btn:active { transform: scale(1.15); }

/* Categories toolbar (favorites filter + sort) */
.cat-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}
/* A <select> is a flex item with min-width:auto, so it refuses to shrink below
   its longest option and ran off the right edge on a 390pt phone. min-width:0
   lets it shrink; `flex: 0 1 auto` keeps it only as wide as its options need
   (stretching it to fill the row is what made it look absurdly long once it
   wrapped); and the row still wraps as a last resort on very narrow screens. */
.cat-toolbar .select {
  padding: 10px 12px;
  font-size: 14px;
  flex: 0 1 auto;
  width: auto;
  min-width: 0;
  max-width: 100%;
  text-overflow: ellipsis;
}
.cat-toolbar .chip { flex: 0 0 auto; max-width: 100%; }

/* --- Settings hub: tappable navigation rows --- */
.nav-rows { padding: 4px 6px; }
.nav-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 8px;
  border: none;
  border-bottom: 1px solid var(--divider);
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.nav-row:last-child { border-bottom: none; }
.nav-row:active { background: var(--btn-2); }
.nav-row .nr-emoji { flex: 0 0 26px; font-size: 19px; text-align: center; }
.nav-row .nr-main { flex: 1; min-width: 0; }
.nav-row .nr-sub { display: block; font-size: 12px; font-weight: 500; color: var(--text-faint); margin-top: 2px; }
.nav-row .nr-chevron { color: var(--text-ghost); font-size: 17px; font-weight: 800; }

/* --- Theme picker grid --- */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.theme-swatch {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 2px;
  border-radius: 12px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.theme-swatch .sw-dot {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.08);
}
.theme-swatch .sw-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}
.theme-swatch.active .sw-dot {
  border-color: var(--accent-solid);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}
.theme-swatch.active .sw-name { color: var(--text); }

/* --- Price dialog / modals --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-card {
  width: 100%;
  max-width: 360px;
  background: var(--card-solid);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
.modal-sub { margin-top: 4px; }
.price-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.price-input-row .input {
  flex: 1;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
}
.price-cur {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-muted);
  flex: 0 0 auto;
}

/* --- Spending report bars --- */
.bar-row { margin-top: 10px; }
.bar-row .bar-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.bar-row .bar-head .bar-val { color: var(--text-muted); white-space: nowrap; }
.bar-track {
  margin-top: 5px;
  height: 8px;
  border-radius: 999px;
  background: var(--btn-2);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  min-width: 2px;
}

/* --- Shopping rework --- */
.list-chips { margin-bottom: 4px; }
.list-chips .chip.default::before { content: '⭐ '; }
.shop-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.shop-toolbar .item-name { flex: 1; min-width: 0; font-size: 16px; }

/* Quick-add typeahead: existing products matching what's being typed. Plain
   flow content under the input (not a floating popover) so it can never end
   up clipped or covering the list on a small phone. */
.qa-suggest {
  margin-top: 8px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  overflow: hidden;
  background: var(--input-bg);
}
.qa-hint {
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--divider);
}
.qa-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border: none;
  border-bottom: 1px solid var(--divider);
  background: transparent;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.qa-row:last-child { border-bottom: none; }
.qa-row:active { background: var(--btn-2); }
.qa-row[disabled] { opacity: 0.5; }
.qa-name { display: block; font-weight: 700; overflow-wrap: anywhere; }
.qa-meta {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-faint);
  overflow-wrap: anywhere;
}
.qa-create .qa-name { font-weight: 800; color: var(--accent-solid); }

/* Category rename/delete outcome. Persistent on purpose: the products that
   could not be rewritten are only findable from here, so it must survive
   longer than a toast. */
.rewrite-result { margin-top: 10px; }
.rewrite-result-warn { border-left: 3px solid var(--warn, #d98324); }
.rewrite-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.rewrite-head .item-name { overflow-wrap: anywhere; }
.shop-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px;
}
.shop-check {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid var(--border-strong);
  background: var(--input-bg);
  color: white;
  font-size: 14px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.shop-item.shop-done .shop-check {
  background: var(--accent-solid);
  border-color: var(--accent-solid);
}
.shop-main { flex: 1; min-width: 0; }
.shop-qty {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
.shop-qty button {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: var(--qbtn);
  color: var(--text);
  font-weight: 900;
  font-size: 14px;
  cursor: pointer;
  touch-action: manipulation;
}
.shop-qty button:active { background: var(--qbtn-active); }
.shop-qty .q { min-width: 22px; text-align: center; font-weight: 800; font-size: 14px; }
.shop-x {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-ghost);
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}
.shop-x:active { background: var(--btn-2); }
.shop-group {
  margin-top: 16px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.checkout-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  padding: 10px 0 4px;
  background: linear-gradient(to top, var(--surface) 70%, transparent);
}

/* --- Barcode rows on the product page --- */
.bc-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* --- Inventory sticky header ---
   Only the search/add/filter BAR sticks; the quick-filter chips below it are
   ordinary flow content that scrolls away underneath it. Nothing here ever
   changes size or leaves the flow while scrolling, which is the whole point:
   an earlier version shrank the stuck header into a "compact" bar, and because
   a stuck element's height is still flow height, every collapse yanked the
   list up by ~78px. Do not reintroduce a scroll-driven size change here —
   put anything that needs to appear on demand in .filter-drop instead.

   .inv-header is display:contents, i.e. no box at all: a sticky child can only
   stick within its parent's box, so a ~105px wrapper would let the bar scroll
   away after 105px. This makes #viewRoot the bar's containing block. */
.inv-header { display: contents; }
.inv-topbar {
  display: flex;
  gap: 10px;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 25;
  margin: 0 -8px;
  padding: 4px 8px 8px;
  background: var(--surface);
}
/* Paint-only — a box-shadow costs no layout, so toggling it on scroll can't
   reintroduce the jump that killed the old compact header. */
.inv-topbar.stuck { box-shadow: 0 8px 18px rgba(0, 0, 0, 0.09); }

/* Home of the quick-filter chips. While the row is lifted into .filter-drop
   the slot keeps the height JS froze on it, so the list never shifts. */
.chip-slot { min-height: 48px; }
.chip-slot .chip-row { padding-top: 0; }

/* The one filter panel — absolutely positioned inside the sticky bar, so it
   overlays the list instead of reflowing it, in every scroll position.
   --filter-drop-max is set by the view to the room left above the nav. */
.filter-drop {
  position: absolute;
  top: 100%;
  left: 8px;
  right: 8px;
  z-index: 40;
  max-height: var(--filter-drop-max, 70vh);
  overflow-y: auto;
  /* Without this, flicking the panel past its end chains the scroll to
     #viewRoot behind it — which is how scrolling the filters used to close
     them. */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border-radius: 0 0 16px 16px;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.18);
  padding: 0 0 10px;
}
.filter-drop .chip-row { padding: 10px 10px 4px; }

/* Funnel button (right of the search bar) — the only filter toggle there is. */
.filter-btn {
  display: inline-flex;
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1.5px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--text-muted);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.filter-btn svg { width: 17px; height: 17px; }
.filter-btn.on {
  background: linear-gradient(135deg, var(--accent-a) 0%, var(--accent-b) 100%);
  border-color: transparent;
  color: white;
}
/* The chips scroll away, so the funnel is the only always-visible hint that
   the list is filtered at all. */
.filter-btn.has-active:not(.on) {
  border-color: var(--accent-solid);
  color: var(--accent-solid);
}

/* Active category/store filter count badge on the funnel button. */
.filter-count {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent-solid);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
  pointer-events: none;
}

/* --- Bulk action bar ---
   Sticky above the nav; bottom padding keeps the buttons clear of the scan
   button's overhang (its circle pops into the scroll area and used to eat
   taps meant for the middle bulk buttons). */
.bulk-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  padding: 10px 0 36px;
  background: linear-gradient(to top, var(--surface) 75%, transparent);
}
.bulk-bar .card { margin-top: 0; }

/* --- Compact category/store rows: name gets the space, actions fold
   behind the ⋯ toggle --- */
.icon-btn-sm { width: 30px; height: 30px; border-radius: 10px; font-size: 15px; }
.star-sm { font-size: 19px; padding: 2px; }
.ent-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--divider);
}
.ent-actions .hist-btn { font-size: 13px; }
