:root {
  color-scheme: light;
  --ink: #172033;
  --ink-muted: #667087;
  --navy: #17233e;
  --navy-soft: #253b73;
  --accent: #ff7043;
  --accent-dark: #d9481e;
  --aqua: #28b8ae;
  --surface: #ffffff;
  --surface-muted: #f4f6fb;
  --line: #dfe4ef;
  --focus: #1967d2;
  --danger: #b42318;
  --success: #087a63;
  --shadow: 0 18px 45px rgb(24 35 62 / 12%);
  --radius-lg: 1.5rem;
  --radius-md: 1rem;
  --radius-sm: 0.75rem;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--surface-muted);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% 0%, rgb(40 184 174 / 10%), transparent 30rem),
    var(--surface-muted);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

html[data-background-theme="fox_orbit"] body {
  background:
    radial-gradient(circle at 90% 12%, rgb(255 112 67 / 18%), transparent 22rem),
    radial-gradient(circle at 8% 70%, rgb(37 59 115 / 12%), transparent 28rem),
    var(--surface-muted);
}

html[data-background-theme="fox_forest"] body {
  background:
    radial-gradient(circle at 80% 0%, rgb(40 184 174 / 15%), transparent 24rem),
    linear-gradient(180deg, #eef3f8, var(--surface-muted));
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.7rem 1rem;
  color: #fff;
  background: var(--navy);
  border-radius: 0.6rem;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 1.35rem;
  height: 1.35rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  width: 100%;
  max-width: 78rem;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  overflow-x: clip;
  padding-bottom: calc(5.75rem + env(safe-area-inset-bottom));
  background:
    linear-gradient(rgb(244 246 251 / 95%), rgb(244 246 251 / 97%)),
    var(--theme-background-image, none) center top / cover;
}

html[data-background-theme="fox_orbit"] .app-shell {
  --theme-background-image: url("../assets/backgrounds/fox-orbit.webp");
}

html[data-background-theme="fox_forest"] .app-shell {
  --theme-background-image: url("../assets/backgrounds/fox-forest.webp");
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(4.5rem + env(safe-area-inset-top));
  padding: calc(0.75rem + env(safe-area-inset-top)) 1rem 0.75rem;
  background: rgb(244 246 251 / 90%);
  border-bottom: 1px solid rgb(223 228 239 / 80%);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  gap: 0.7rem;
  align-items: center;
  color: var(--navy);
  font-size: 1.2rem;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.025em;
}

.brand-mark {
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, var(--navy-soft), var(--navy));
  border-radius: 0.75rem 0.75rem 0.75rem 0.2rem;
  box-shadow: 0 8px 20px rgb(23 35 62 / 20%);
}

.connection-pill {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  max-width: 12rem;
  padding: 0.5rem 0.7rem;
  overflow: hidden;
  color: var(--ink-muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  flex: 0 0 auto;
  width: 0.55rem;
  height: 0.55rem;
  background: #98a2b3;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgb(152 162 179 / 14%);
}

.connection-pill[data-status="ready"] .status-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px rgb(8 122 99 / 14%);
}

.connection-pill[data-status="attention"] .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgb(255 112 67 / 16%);
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  min-width: 0;
  padding: 0 1rem 2rem;
}

.overview {
  position: relative;
  display: grid;
  gap: 1.25rem;
  padding: 1.5rem;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 100% 0%, rgb(81 209 199 / 32%), transparent 15rem),
    linear-gradient(145deg, #263f7b 0%, var(--navy) 70%);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow);
}

html[data-background-theme="fox_orbit"] .overview {
  background:
    linear-gradient(120deg, rgb(8 24 53 / 42%), rgb(8 24 53 / 6%)),
    url("../assets/backgrounds/fox-orbit-hero-v2.webp") center / cover;
}

html[data-background-theme="fox_forest"] .overview {
  background:
    linear-gradient(120deg, rgb(8 24 53 / 28%), rgb(8 24 53 / 4%)),
    url("../assets/backgrounds/fox-forest-hero-v2.webp") center / cover;
}

html[data-background-theme] .overview::after {
  display: none;
}

.overview::after {
  position: absolute;
  right: -2.5rem;
  bottom: -4.5rem;
  width: 10rem;
  height: 10rem;
  content: "";
  border: 1.5rem solid rgb(255 112 67 / 75%);
  border-radius: 50%;
}

.overview-copy,
.search-field,
.quick-actions {
  position: relative;
  z-index: 1;
}

.eyebrow,
.section-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.eyebrow {
  color: #aeece7;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 9vw, 3.8rem);
  line-height: 1;
  letter-spacing: -0.055em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.5rem;
  line-height: 1.15;
  letter-spacing: -0.035em;
}

h3 {
  margin-bottom: 0.45rem;
  font-size: 1.05rem;
}

.search-field {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  min-height: 3.35rem;
  padding: 0 1rem;
  color: var(--ink-muted);
  background: #fff;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 30px rgb(0 0 0 / 12%);
}

.search-field:focus-within {
  border-color: #79dcd5;
}

.search-field input {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.search-field input::-webkit-search-cancel-button {
  display: none;
}

.search-field input::placeholder {
  color: #7d879b;
}

.search-clear-button {
  display: grid;
  flex: 0 0 2.75rem;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  place-items: center;
  color: var(--ink-muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
}

.search-clear-button:hover,
.search-clear-button:active {
  color: var(--ink);
  background: var(--surface-muted);
}

.quick-actions {
  display: grid;
  gap: 0.75rem;
}

.action-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.8rem;
  align-items: center;
  min-width: 0;
  padding: 0.9rem;
  text-align: left;
  color: var(--navy);
  background: #fff;
  border: 0;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 20px rgb(0 0 0 / 10%);
}

.action-card-accent {
  background: #fff4ef;
}

.action-card strong,
.action-card small {
  display: block;
}

.action-card strong {
  font-size: 0.95rem;
}

.action-card small {
  margin-top: 0.08rem;
  color: var(--ink-muted);
  font-size: 0.76rem;
}

.action-icon {
  display: grid;
  width: 2.6rem;
  height: 2.6rem;
  place-items: center;
  color: #fff;
  background: var(--navy);
  border-radius: 0.8rem;
}

.action-card-accent .action-icon {
  background: var(--accent);
}

.action-arrow {
  width: 1.1rem;
  color: #8a93a5;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.summary-card {
  position: relative;
  width: 100%;
  min-width: 0;
  padding: 0.85rem 0.55rem 0.75rem;
  overflow: hidden;
  font: inherit;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.summary-card.is-active {
  border-color: var(--navy);
  box-shadow: 0 0 0 2px rgb(23 35 62 / 14%);
}

.summary-card::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 0.25rem;
  content: "";
  background: var(--navy-soft);
}

.summary-household::before {
  background: var(--aqua);
}

.summary-expiry::before {
  background: var(--accent);
}

.summary-expired::before {
  background: var(--danger);
}

.summary-card span,
.summary-card small {
  display: block;
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 0.66rem;
  line-height: 1.2;
  text-overflow: ellipsis;
}

.summary-card strong {
  display: block;
  margin: 0.35rem 0 0.15rem;
  font-size: clamp(1.45rem, 7vw, 2.3rem);
  line-height: 1;
}

.inventory-section {
  min-width: 0;
  max-width: 100%;
  padding: 0.35rem 0 calc(1rem + var(--inventory-scroll-fill, 0px));
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}

.section-kicker {
  color: var(--accent-dark);
}

.result-count {
  color: var(--ink-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.inventory-view-switcher {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  margin-bottom: 0.8rem;
}

.inventory-view-label {
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.inventory-view-options {
  display: grid;
  grid-auto-flow: column;
  gap: 0.2rem;
  padding: 0.2rem;
  background: #e4e9f2;
  border-radius: 999px;
}

.inventory-view-button {
  min-height: 2.25rem;
  padding: 0.4rem 0.85rem;
  color: var(--ink-muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  background: transparent;
  border: 0;
  border-radius: 999px;
}

.inventory-view-button.is-active {
  color: var(--navy);
  background: var(--surface);
  box-shadow: 0 1px 5px rgb(23 32 51 / 12%);
}

.inventory-view-button:focus-visible {
  outline: 3px solid rgb(37 59 115 / 24%);
  outline-offset: 1px;
}

.filter-row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding-bottom: 0.85rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.category-filter-row {
  margin-top: -0.35rem;
}

.category-filter-row[hidden] {
  display: none;
}

.filter-chip-category {
  min-height: 2.25rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
}

.filter-chip {
  flex: 0 0 auto;
  min-height: 2.55rem;
  padding: 0.55rem 0.9rem;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid #cfd5e2;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 750;
}

.filter-chip.is-active {
  color: #fff;
  background: var(--navy);
  border-color: var(--navy);
}

.inventory-list {
  display: grid;
  gap: 0.65rem;
}

.inventory-list.is-grouped {
  grid-template-columns: minmax(0, 1fr);
  gap: 0.85rem;
}

.catalog-item {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-width: 0;
  padding: 0.9rem 3.25rem 0.9rem 1rem;
  color: var(--ink);
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.catalog-item > span:first-child { min-width: 0; }
.catalog-item strong, .catalog-item small { display: block; }
.catalog-item small, .catalog-stock { color: var(--ink-muted); font-size: 0.78rem; }
.catalog-stock { flex: 0 0 auto; text-align: right; }
.catalog-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.inventory-purchase-group {
  display: grid;
  min-width: 0;
  gap: 0.55rem;
  padding: 0.7rem;
  background: rgb(255 255 255 / 45%);
  border: 1px solid #d4dbe8;
  border-radius: var(--radius-lg);
}

.inventory-purchase-heading {
  display: flex;
  gap: 0.75rem;
  align-items: end;
  justify-content: space-between;
  min-width: 0;
  padding: 0 0.15rem;
}

.inventory-purchase-heading > div {
  min-width: 0;
}

.inventory-purchase-heading h3,
.inventory-purchase-heading small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-purchase-heading h3 {
  margin: 0;
  font-size: 0.98rem;
}

.inventory-purchase-heading small,
.inventory-purchase-count {
  color: var(--ink-muted);
  font-size: 0.72rem;
}

.inventory-purchase-heading small {
  margin-top: 0.1rem;
}

.inventory-purchase-count {
  flex: 0 0 auto;
  padding-bottom: 0.1rem;
  font-weight: 750;
  white-space: nowrap;
}

.inventory-purchase-items {
  display: grid;
  min-width: 0;
  gap: 0.55rem;
}

.swipe-row {
  --swipe-action-width: min(13.2rem, 58%);
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius-md);
}

.swipe-row.has-single-action {
  --swipe-action-width: min(7.5rem, 38%);
}

.swipe-actions {
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: var(--swipe-action-width);
  overflow: hidden;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  pointer-events: none;
}

.swipe-actions.has-quantity-editor {
  grid-template-columns: 2fr 1fr;
}

.swipe-actions.has-single-action {
  grid-template-columns: minmax(0, 1fr);
}

.swipe-row.is-open .swipe-actions {
  pointer-events: auto;
}

.swipe-action {
  min-width: 0;
  padding: 0.4rem;
  color: #fff;
  border: 0;
  font-size: 0.7rem;
  font-weight: 850;
  line-height: 1.15;
}

.swipe-action-decrease {
  background: #667085;
}

.swipe-action-increase {
  background: #168a78;
}

.swipe-action-quantity {
  background: #168a78;
}

.swipe-action-empty {
  background: #c3472c;
}

.swipe-action-shopping {
  background: #168a78;
}

.swipe-action-delete {
  background: #c3472c;
}

.inventory-item-surface {
  position: relative;
  z-index: 2;
  min-width: 0;
  transform: translateX(var(--swipe-offset, 0));
  transition: transform 220ms cubic-bezier(0.22, 0.8, 0.24, 1), opacity 160ms ease;
  touch-action: pan-y;
}

.swipe-row.is-open .inventory-item-surface {
  transform: translateX(calc(0px - var(--swipe-action-width)));
}

.swipe-row.is-dragging .inventory-item-surface {
  transform: translateX(var(--swipe-offset, 0));
  transition: none;
}

.swipe-row.is-updating .inventory-item-surface {
  opacity: 0.58;
}

.inventory-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  width: 100%;
  gap: 0.8rem;
  align-items: center;
  padding: 0.9rem 3.25rem 0.9rem 0.9rem;
  color: var(--ink);
  font: inherit;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.swipe-toggle {
  position: absolute;
  z-index: 3;
  top: 50%;
  right: 0.45rem;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  transform: translateY(-50%);
  color: var(--ink-muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: -0.08em;
}

.swipe-toggle:focus-visible {
  outline: 3px solid rgb(37 59 115 / 24%);
  outline-offset: 1px;
}

.inventory-item:hover {
  border-color: #aeb8cb;
  box-shadow: 0 8px 20px rgb(23 32 51 / 8%);
}

.inventory-item:active {
  transform: scale(0.992);
}

.inventory-item:focus-visible {
  outline: 3px solid rgb(37 59 115 / 24%);
  outline-offset: 2px;
}

.item-kind {
  display: grid;
  width: 2.7rem;
  height: 2.7rem;
  place-items: center;
  color: var(--navy);
  background: #eaf0ff;
  border-radius: 0.85rem;
  font-weight: 850;
}

.inventory-item[data-kind="household"] .item-kind {
  color: #086b64;
  background: #e3f8f5;
}

.item-copy {
  min-width: 0;
}

.item-copy strong,
.item-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-copy small {
  margin-top: 0.12rem;
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.item-quantity {
  text-align: right;
  white-space: nowrap;
}

.item-quantity strong,
.item-quantity small {
  display: block;
}

.quantity-product-name {
  margin: 0 0 0.3rem;
  overflow-wrap: anywhere;
  font-weight: 850;
}

.quantity-current {
  margin: 0 0 1rem;
  color: var(--ink-muted);
  font-size: 0.86rem;
}

.quantity-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
}

.quantity-input-row strong {
  min-width: 3rem;
  color: var(--ink-muted);
}

.item-quantity small {
  color: var(--ink-muted);
  font-size: 0.72rem;
}

.empty-state {
  display: grid;
  justify-items: center;
  padding: 2.1rem 1.25rem;
  text-align: center;
  background: var(--surface);
  border: 1px dashed #c7cedd;
  border-radius: var(--radius-lg);
}

.empty-icon {
  display: grid;
  width: 3.5rem;
  height: 3.5rem;
  margin-bottom: 0.8rem;
  place-items: center;
  color: var(--navy-soft);
  background: #eaf0ff;
  border-radius: 1rem;
}

.empty-state h3 {
  margin-bottom: 0.25rem;
}

.empty-state p {
  max-width: 25rem;
  margin-bottom: 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.bottom-nav {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 100%;
  max-width: 78rem;
  min-height: calc(4.8rem + env(safe-area-inset-bottom));
  margin: 0 auto;
  padding: 0.45rem 0.3rem calc(0.45rem + env(safe-area-inset-bottom));
  background: rgb(255 255 255 / 94%);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px rgb(23 32 51 / 8%);
  backdrop-filter: blur(18px);
}

.nav-item {
  display: grid;
  gap: 0.15rem;
  justify-items: center;
  align-content: center;
  min-height: 3.65rem;
  min-width: 0;
  color: #747e91;
  background: transparent;
  border: 0;
  font-size: clamp(0.59rem, 2.65vw, 0.72rem);
  font-weight: 750;
}

.nav-item.is-active {
  color: var(--accent-dark);
}

.capture-circle {
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  margin-top: -1.25rem;
  place-items: center;
  color: inherit;
  background: transparent;
  border: 4px solid transparent;
  border-radius: 50%;
}

.nav-item.is-active .capture-circle {
  color: #fff;
  background: var(--accent);
  border-color: #fff;
  box-shadow: 0 8px 22px rgb(217 72 30 / 28%);
}

.visually-hidden-input {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.dialog {
  width: min(calc(100% - 1.5rem), 35rem);
  max-width: calc(100% - 1.5rem);
  max-height: min(90vh, 48rem);
  max-height: min(90dvh, 48rem);
  padding: 1.25rem;
  overflow-x: hidden;
  overflow-y: auto;
  color: var(--ink);
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 90px rgb(15 23 42 / 35%);
}

.dialog > form {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.dialog::backdrop {
  background: rgb(15 23 42 / 58%);
  backdrop-filter: blur(4px);
}

.dialog-heading {
  display: flex;
  gap: 1rem;
  align-items: start;
  justify-content: space-between;
  min-width: 0;
  max-width: 100%;
  margin-bottom: 1.25rem;
}

.dialog-heading > :first-child {
  min-width: 0;
}

.dialog-heading-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.5rem;
}

.icon-button {
  display: grid;
  flex: 0 0 auto;
  width: 2.7rem;
  height: 2.7rem;
  place-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 50%;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 0.9rem;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.form-grid > *,
.autocomplete-field {
  min-width: 0;
  max-width: 100%;
}

.form-wide {
  grid-column: 1 / -1;
}

.form-grid label,
.setup-panel label {
  display: grid;
  align-content: start;
  gap: 0.35rem;
  color: #3d4658;
  font-size: 0.84rem;
  font-weight: 750;
}

.form-grid > label:not(.form-wide) > span:first-child {
  display: block;
  min-height: 2.4em;
  line-height: 1.2;
}

.form-grid label small {
  color: var(--ink-muted);
  font-weight: 500;
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.setup-panel input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 3rem;
  padding: 0.65rem 0.75rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid #c8cfdd;
  border-radius: var(--radius-sm);
}

.form-grid textarea {
  min-height: 5.5rem;
  resize: vertical;
  font: inherit;
}

.form-grid input,
.form-grid select {
  align-self: start;
  height: 3rem;
  min-block-size: 3rem;
  max-block-size: 3rem;
  block-size: 3rem;
}

.date-input-shell {
  position: relative;
  display: block;
  width: 100%;
  height: 3rem;
  min-height: 3rem;
  max-height: 3rem;
  overflow: hidden;
  background: #fff;
  border: 1px solid #c8cfdd;
  border-radius: var(--radius-sm);
}

.date-input-shell input[type="date"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 3rem !important;
  min-height: 3rem !important;
  max-height: 3rem !important;
  margin: 0;
  padding: 0.65rem 0.75rem;
  line-height: 1.2;
  background: transparent;
  border: 0;
  border-radius: inherit;
  appearance: none;
  -webkit-appearance: none;
}

.date-input-shell:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.date-input-shell input[type="date"]:focus-visible {
  outline: none;
}

.autocomplete-field {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.3rem);
  right: 0;
  left: 0;
  display: grid;
  max-height: 15rem;
  padding: 0.3rem;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #aeb8ca;
  border-radius: var(--radius-sm);
  box-shadow: 0 14px 35px rgb(15 23 42 / 20%);
}

.autocomplete-list[hidden] {
  display: none;
}

.autocomplete-option {
  display: grid;
  gap: 0.15rem;
  width: 100%;
  padding: 0.7rem;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 0.55rem;
}

.autocomplete-option:hover,
.autocomplete-option:focus-visible {
  background: var(--surface-muted);
  outline: none;
}

.autocomplete-option strong {
  font-size: 0.9rem;
}

.autocomplete-option small,
.selection-hint {
  color: var(--ink-muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.form-field-note {
  display: block;
  min-height: 1.2em;
  line-height: 1.2;
}

.form-field-note:empty,
.form-field-note[hidden] {
  visibility: hidden;
}

.form-field-note-peer::after {
  display: block;
  min-height: 1.2em;
  content: "";
}

#category-selection-hint {
  white-space: nowrap;
}

.product-form[data-mode="view"] input:disabled,
.product-form[data-mode="view"] select:disabled,
#product-form[data-mode="view"] textarea:disabled,
#product-form[data-mode="view"] input:disabled,
#product-form[data-mode="view"] select:disabled {
  color: var(--ink);
  background: var(--surface-muted);
  border-color: transparent;
  opacity: 1;
  -webkit-text-fill-color: var(--ink);
}

#product-form[data-mode="view"] .date-input-shell {
  background: var(--surface-muted);
  border-color: transparent;
}

.purchase-history {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.subsection-heading {
  margin-bottom: 0.75rem;
}

.purchase-history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 0;
  max-width: 100%;
  margin-bottom: 0.75rem;
}

.purchase-history-filter {
  min-height: 2.25rem;
  padding: 0.45rem 0.8rem;
  font-size: 0.8rem;
}

.purchase-history-list {
  display: grid;
  gap: 0.6rem;
  min-width: 0;
  max-width: 100%;
}

.purchase-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  padding: 0.8rem;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.purchase-entry-copy,
.purchase-entry-price {
  min-width: 0;
}

.purchase-entry-copy strong,
.purchase-entry-copy small,
.purchase-entry-price strong,
.purchase-entry-price small {
  display: block;
}

.purchase-entry-copy strong,
.purchase-entry-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchase-entry-copy small,
.purchase-entry-price small,
.purchase-history-empty {
  color: var(--ink-muted);
  font-size: 0.76rem;
}

.purchase-entry-price {
  text-align: right;
  white-space: nowrap;
}

.receipt-dialog {
  max-height: min(94vh, 54rem);
  max-height: min(94dvh, 54rem);
}

.cleanup-dialog {
  max-height: min(94vh, 54rem);
  max-height: min(94dvh, 54rem);
}

.cleanup-intro,
.cleanup-summary {
  color: var(--ink-muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.cleanup-loading {
  display: grid;
  gap: 0.65rem;
  padding: 1rem;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.cleanup-loading progress {
  width: 100%;
  accent-color: var(--accent);
}

.cleanup-loading small {
  color: var(--ink-muted);
}

.cleanup-groups {
  display: grid;
  gap: 1rem;
}

.cleanup-group {
  min-width: 0;
  padding: 1rem;
  background: #f8f9fc;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.cleanup-group h3 {
  margin: 0;
  font-size: 1rem;
}

.cleanup-reason {
  margin: 0.25rem 0 0.8rem;
  color: var(--ink-muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.cleanup-products {
  display: grid;
  gap: 0.5rem;
}

.cleanup-product {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
  padding: 0.7rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.cleanup-product input {
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 0.1rem;
  accent-color: var(--navy);
}

.cleanup-product strong,
.cleanup-product small {
  display: block;
  overflow-wrap: anywhere;
}

.cleanup-product small {
  margin-top: 0.12rem;
  color: var(--ink-muted);
  font-size: 0.75rem;
}

.cleanup-name-fieldset {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
  padding: 0;
  margin: 1rem 0 0;
  border: 0;
}

.cleanup-name-fieldset legend {
  margin-bottom: 0.4rem;
  font-weight: 800;
}

.cleanup-name-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.55rem;
  align-items: center;
  min-width: 0;
  font-size: 0.82rem;
}

.cleanup-name-option span {
  overflow-wrap: anywhere;
}

.cleanup-name-option input[type="radio"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--navy);
}

.cleanup-manual-name {
  width: 100%;
  min-width: 0;
  margin-top: 0.2rem;
}

.cleanup-group-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.8rem;
}

.receipt-processing {
  display: grid;
  gap: 1rem;
}

.receipt-processing img {
  width: 100%;
  max-height: 16rem;
  object-fit: contain;
  background: #eef1f7;
  border-radius: var(--radius-md);
}

.processing-copy {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem 0.75rem;
  align-items: center;
}

.processing-copy strong {
  grid-column: 1 / -1;
}

.processing-copy small {
  grid-column: 1 / -1;
  color: var(--ink-muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.processing-copy progress {
  width: 100%;
  height: 0.7rem;
  accent-color: var(--accent);
}

.receipt-analysis-summary {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  color: var(--ink-muted);
  background: #eef4ff;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  line-height: 1.45;
}

.processing-copy span {
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.processing-actions {
  display: flex;
  gap: 0.65rem;
  justify-content: flex-end;
}

.receipt-meta,
.receipt-line-card {
  min-width: 0;
  padding: 1rem;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.receipt-meta legend,
.receipt-line-card legend {
  padding: 0 0.4rem;
  color: var(--navy);
  font-size: 0.9rem;
  font-weight: 850;
}

.receipt-line-card[data-status="approved"] {
  border-color: #65c6b4;
  box-shadow: 0 0 0 3px rgb(8 122 99 / 9%);
}

.receipt-line-card[data-status="skipped"] {
  border-color: #d5a58f;
  opacity: 0.72;
}

.review-progress-row {
  display: flex;
  justify-content: space-between;
  margin: 1rem 0 0.55rem;
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.raw-receipt-line {
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.9rem;
  overflow-wrap: anywhere;
  color: #4d586d;
  background: #f2f4f8;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
}

.line-review-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.line-review-actions .button {
  min-width: 0;
  padding-right: 0.45rem;
  padding-left: 0.45rem;
  font-size: 0.8rem;
}

.button-secondary.button-danger {
  color: #a33d24;
  border-color: #e5b4a6;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: flex-end;
  min-width: 0;
  max-width: 100%;
  margin-top: 1rem;
}

.product-out-of-stock-button {
  margin-right: auto;
}

.button {
  min-height: 3rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 800;
}

.button-primary {
  color: #fff;
  background: var(--navy);
  border: 1px solid var(--navy);
}

.button-primary:hover {
  background: var(--navy-soft);
}

.button-secondary {
  color: var(--navy);
  background: #fff;
  border: 1px solid #bdc5d5;
}

.button-full {
  width: 100%;
  margin-top: 0.8rem;
}

.form-message {
  min-height: 1.4rem;
  margin: 0.8rem 0 0;
  color: var(--danger);
  font-size: 0.84rem;
  font-weight: 650;
}

.form-message[data-tone="success"] {
  color: var(--success);
}

.setup-panel {
  padding: 1rem;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.setup-panel p {
  margin-bottom: 0.8rem;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.setup-panel .setup-hint {
  margin-top: 0.85rem;
  margin-bottom: 0;
  font-size: 0.8rem;
}

.password-settings {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.password-settings summary {
  color: var(--navy);
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
}

.password-settings[open] summary {
  margin-bottom: 0.65rem;
}

.password-settings form {
  display: grid;
  gap: 0.65rem;
}

.password-settings .form-message {
  margin-bottom: 0;
}

.setup-panel code {
  padding: 0.12rem 0.3rem;
  color: var(--navy);
  background: #e5eaf5;
  border-radius: 0.3rem;
}

.theme-settings {
  min-width: 0;
  padding: 0;
  margin: 1rem 0 0;
  border: 0;
}

.theme-settings legend {
  margin-bottom: 0.15rem;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
}

.theme-settings > p {
  margin-bottom: 0.65rem;
}

.backup-settings {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.backup-heading h3 {
  margin: 0 0 0.2rem;
  color: var(--ink);
  font-size: 0.92rem;
}

.backup-heading p {
  margin: 0;
}

.backup-status {
  display: grid;
  gap: 0.55rem;
  margin: 0.8rem 0 0;
}

.backup-status div {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.65rem 0.75rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
}

.backup-status dt {
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.backup-status dd {
  margin: 0;
  color: var(--navy);
  font-size: 0.78rem;
  font-weight: 750;
  text-align: right;
}

.theme-options {
  display: grid;
  gap: 0.65rem;
}

.theme-option {
  position: relative;
  display: grid;
  grid-template-columns: auto 4.5rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  min-height: 5rem;
  padding: 0.55rem;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.theme-option:has(input:checked) {
  border-color: var(--navy-soft);
  box-shadow: 0 0 0 3px rgb(37 59 115 / 12%);
}

.theme-option input {
  width: 1.15rem;
  min-height: auto;
  margin: 0;
  accent-color: var(--navy-soft);
}

.theme-preview {
  width: 4.5rem;
  height: 3.75rem;
  background-position: center;
  background-size: cover;
  border-radius: 0.65rem;
}

.theme-preview-orbit {
  background-image: url("../assets/backgrounds/fox-orbit-hero-v2.webp");
}

.theme-preview-forest {
  background-image: url("../assets/backgrounds/fox-forest-hero-v2.webp");
}

.theme-option strong,
.theme-option small {
  display: block;
}

.theme-option small {
  margin-top: 0.1rem;
  color: var(--ink-muted);
  font-size: 0.76rem;
  font-weight: 500;
}

.theme-message {
  margin-bottom: 0 !important;
}

.toast {
  position: fixed;
  z-index: 60;
  right: 1rem;
  bottom: calc(6rem + env(safe-area-inset-bottom));
  left: 1rem;
  max-width: 32rem;
  margin: 0 auto;
  padding: 0.85rem 1rem;
  color: #fff;
  background: var(--navy);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 650;
}

@media (min-width: 42rem) {
  .topbar,
  main {
    padding-right: 2rem;
    padding-left: 2rem;
  }

  .overview {
    grid-template-columns: minmax(0, 1fr) minmax(20rem, 1.1fr);
    padding: 2rem;
    border-radius: var(--radius-lg);
  }

  .overview-copy {
    align-self: center;
    grid-row: span 2;
  }

  .quick-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-card {
    padding: 1.25rem;
  }

  .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .inventory-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inventory-purchase-items {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bottom-nav {
    right: 2rem;
    bottom: 1rem;
    left: auto;
    width: 21rem;
    min-height: 4.5rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 1.4rem;
  }
}

@media (min-width: 64rem) {
  main {
    grid-template-columns: minmax(0, 1.55fr) minmax(18rem, 0.7fr);
    align-items: start;
  }

  .overview {
    grid-column: 1 / -1;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .inventory-section {
    grid-row: 2;
  }

  .summary-grid {
    grid-column: 2;
  }
}

@media (max-width: 23rem) {
  .summary-card {
    padding-right: 0.4rem;
    padding-left: 0.4rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-wide {
    grid-column: auto;
  }

  .form-grid > label:not(.form-wide) > span:first-child {
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Kamra 1.0 – Receptek */
.recipes-section {
  padding: 1rem 1rem calc(2rem + env(safe-area-inset-bottom));
  min-width: 0;
}
.recipes-section .section-heading { align-items: center; gap: 0.5rem; }
.recipes-section .section-heading .button { padding: 0.55rem 0.8rem; font-size: 0.85rem; white-space: nowrap; }
.recipe-search {
  display: block;
  width: 100%;
  min-height: 3rem;
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.9rem;
  border: 1px solid #ccd4e0;
  border-radius: var(--radius-md);
  background: #fff;
  font: inherit;
}
#recipe-count { display: block; margin-bottom: 0.65rem; }
.recipe-list { display: grid; gap: 0.7rem; }
.recipe-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 1rem;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
}
.recipe-card span:first-child { min-width: 0; }
.recipe-card strong, .recipe-card small { display: block; overflow-wrap: anywhere; }
.recipe-card small { margin-top: 0.2rem; font-size: 0.78rem; color: var(--ink-muted); }
.recipe-chevron { font-size: 1.8rem; color: var(--ink-muted); }
.recipe-empty {
  padding: 2rem 1rem;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--ink-muted);
}
.recipe-fields, .recipe-ingredients { display: grid; gap: 0.8rem; }
.recipe-fields label, .recipe-product-label { display: grid; gap: 0.3rem; font-size: 0.85rem; font-weight: 700; color: #3d4658; }
.recipe-fields input, .recipe-ingredient-name, .recipe-product-select {
  width: 100%;
  min-width: 0;
  min-height: 2.85rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid #c8cfdd;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.recipe-ingredients-heading { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin: 1.4rem 0 0.25rem; }
.recipe-ingredients-heading h3 { margin: 0; }
.recipe-ingredients-heading button { padding: 0.45rem 0.55rem; font-size: 0.8rem; }
.recipe-hint { font-size: 0.8rem; color: var(--ink-muted); }
.recipe-ingredient-row { display: grid; gap: 0.4rem; padding: 0.7rem; border-radius: var(--radius-sm); background: var(--surface-muted); }
.recipe-ingredient-line { display: flex; gap: 0.55rem; align-items: center; }
.recipe-ingredient-name { flex: 1; }
.recipe-product-label { font-size: 0.75rem; }
.recipe-product-select { min-height: 2.5rem; font-size: 0.84rem; }
.recipe-dialog .dialog-actions .button-danger { margin-right: auto; }
