/* ================================================================
   PRICETRACKER — Warm Market Design System
   Fonts: Fraunces (display/logo) · Figtree (UI)
   Palette: Warm linen · Sage green · Amber
   ================================================================ */

:root {
  /* ── Surfaces ──────────────────────────────────── */
  --bg:        #F3EEE6;
  --surface:   #FDFBF7;
  --surface-2: #EAE5DB;
  --border:    #D9D4CA;

  /* ── Text ──────────────────────────────────────── */
  --text:        #28241F;
  --text-muted:  #877F72;
  --text-subtle: #ADA59B;

  /* ── Accent (sage green) ───────────────────────── */
  --accent:        #4A7B5A;
  --accent-hover:  #3C6449;
  --accent-light:  #EBF2ED;
  --accent-border: #BAD4C2;

  /* ── Semantic ──────────────────────────────────── */
  --positive:        #1C6B3A;
  --positive-bg:     #EAF4EE;
  --positive-border: #B0D9BF;
  --warn:            #9A6020;
  --warn-bg:         #FEF3E4;
  --negative:        #A5362C;

  /* ── Shadows (warm-tinted) ─────────────────────── */
  --shadow-sm: 0 1px 3px rgba(40, 36, 31, 0.07);
  --shadow-md: 0 4px 14px rgba(40, 36, 31, 0.09);
  --shadow-lg: 0 12px 40px rgba(40, 36, 31, 0.16);

  /* ── Border radii ──────────────────────────────── */
  --r-xs:   4px;
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   18px;
  --r-pill: 999px;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Figtree', -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5 {
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}
a { text-decoration: none; color: inherit; }

/* ── Utilities ──────────────────────────────────────────────────── */
.hidden        { display: none !important; }
.text-muted    { color: var(--text-muted); }
.text-positive { color: var(--positive); }
.text-warn     { color: var(--warn); }
.font-bold     { font-weight: 700; }
.tabular       { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }

/* ── Labels ─────────────────────────────────────────────────────── */
.label-small {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.65px;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Badges / Chips (pill-shaped) ───────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.badge--active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 600;
}
.badge--primary { border-color: var(--accent); color: var(--accent); }
button.badge   { cursor: pointer; }
button.badge:hover:not(.badge--active) {
  border-color: var(--text-muted);
  color: var(--text);
  background: var(--surface-2);
}

.subcat-chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Inputs ─────────────────────────────────────────────────────── */
.input-base {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 0 16px;
  font-family: 'Figtree', sans-serif;
  font-size: 14px;
  transition: border-color 0.18s, box-shadow 0.18s;
  outline: none;
  width: 100%;
  box-shadow: var(--shadow-sm);
}
.input-base::placeholder { color: var(--text-subtle); }
.input-base:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74, 123, 90, 0.14);
}
.input-lg {
  height: 52px;
  font-size: 16px;
  border-radius: var(--r-md);
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--r-sm);
  padding: 0 16px;
  height: 38px;
  font-family: 'Figtree', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-muted); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(74, 123, 90, 0.28);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 4px 14px rgba(74, 123, 90, 0.32);
}
.btn-lg {
  height: 52px;
  font-size: 15px;
  padding: 0 28px;
  border-radius: var(--r-md);
}
.btn-sm {
  height: 32px;
  font-size: 12px;
  padding: 0 12px;
}

/* ── Header / Nav ───────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(40, 36, 31, 0.06);
}
.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  height: 56px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.back-link {
  font-size: 12px;
  color: var(--text-subtle);
  letter-spacing: 0.02em;
  flex-shrink: 0;
  transition: color 0.15s;
}
.back-link:hover { color: var(--text-muted); }

.logo {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.6px;
}

.main-nav {
  display: flex;
  gap: 2px;
  align-items: center;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover  { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--accent); background: var(--accent-light); font-weight: 600; }

/* ── Page Content ───────────────────────────────────────────────── */
.page-content {
  max-width: 1120px;
  margin: 0 auto;
  padding: 36px 28px 80px;
}
.page-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
  letter-spacing: -0.5px;
  font-family: 'Fraunces', Georgia, serif;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
}

/* ── Table Card ─────────────────────────────────────────────────── */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* ── Tables ─────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--accent-light); }
tfoot tr td {
  background: var(--surface-2);
  font-weight: 700;
  border-top: 1px solid var(--border);
  border-bottom: none;
}

/* ── Loader ─────────────────────────────────────────────────────── */
.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 0;
  gap: 14px;
  color: var(--text-muted);
  font-size: 14px;
}

.empty-box {
  text-align: center;
  padding: 56px 32px;
  color: var(--text-muted);
  font-size: 15px;
  border: 1.5px dashed var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  line-height: 1.65;
}

/* ── Search Hero ────────────────────────────────────────────────── */
.search-hero {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.search-input-wrap { flex: 1; }

/* ── Baskets Row ────────────────────────────────────────────────── */
.baskets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 32px;
}

/* ── Product cells ──────────────────────────────────────────────── */
.product-row-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}
.product-thumb {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  object-fit: contain;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px;
}
.product-labels {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.product-name-found {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 190px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Price cells ────────────────────────────────────────────────── */
.price-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.price-link {
  color: var(--text);
  font-weight: 500;
  transition: color 0.12s;
}
.price-link:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.price-best {
  color: var(--positive);
  font-weight: 700;
  font-size: 15px;
}
.price-best:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.alt-toggle {
  font-size: 10px;
  color: var(--text-subtle);
  cursor: pointer;
  user-select: none;
  margin-top: 5px;
  display: block;
  transition: color 0.12s;
  letter-spacing: 0.3px;
}
.alt-toggle:hover { color: var(--text-muted); }
.alt-dropdown {
  margin-top: 6px;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-left: 2px solid var(--border);
  padding-left: 8px;
}

/* ── Warning badge ──────────────────────────────────────────────── */
.warning-ico {
  color: var(--warn);
  font-size: 11px;
  margin-left: 4px;
  cursor: help;
}

/* ── Tech Page ──────────────────────────────────────────────────── */
.tech-filters-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
}
.range-slider { accent-color: var(--accent); }

.tech-list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.tech-row {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.tech-row:last-child { border-bottom: none; }
.tech-row:hover { background: var(--accent-light); }

.tech-row-img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: var(--r-sm);
  background: #fff;
  border: 1px solid var(--border);
  padding: 3px;
  flex-shrink: 0;
}
.tech-row-info { flex: 1; min-width: 0; }
.tech-row-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tech-row-prices {
  display: flex;
  gap: 16px;
  margin-left: auto;
  align-items: center;
}
.tech-store-col {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.tech-store-name {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-subtle);
}
.tech-row-action {
  margin-left: 12px;
  font-weight: 600;
  font-size: 12px;
  color: var(--accent);
  white-space: nowrap;
  padding: 6px 14px;
  border: 1px solid var(--accent-border);
  border-radius: var(--r-pill);
  background: var(--accent-light);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.tech-row-action:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── AI Drawer ──────────────────────────────────────────────────── */
.ai-drawer {
  margin-top: 10px;
  margin-bottom: 28px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.ai-trigger {
  width: 100%;
  padding: 13px 18px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Figtree', sans-serif;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.12s, color 0.12s;
}
.ai-trigger:hover { background: var(--surface-2); color: var(--text); }
.ai-content { border-top: 1px solid var(--border); padding: 18px; }
.ai-input-wrap { display: flex; gap: 8px; margin-bottom: 14px; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ai-chip {
  cursor: pointer;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 6px 14px;
  font-size: 13px;
  font-family: 'Figtree', sans-serif;
  transition: background 0.15s, border-color 0.15s;
}
.ai-chip:hover { border-color: var(--accent); background: var(--accent-light); }
.ai-chip-name  { font-weight: 600; color: var(--text); }
.ai-chip-price { color: var(--text-muted); margin-left: 4px; }

/* ── Catalog Page ───────────────────────────────────────────────── */
.catalog-controls {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.catalog-toolbar { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.catalog-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 24px; }
.catalog-grid {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* Sort dropdown */
.sort-wrap { position: relative; }
.sort-btn { font-size: 12px; padding: 0 12px; }
.sort-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-width: 190px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.sort-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Figtree', sans-serif;
  transition: background 0.1s, color 0.1s;
}
.sort-option:hover  { background: var(--surface-2); color: var(--text); }
.sort-option.active { color: var(--text); font-weight: 600; }

/* Layout toggle */
.layout-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface);
}
.layout-btn {
  padding: 5px 10px;
  font-size: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.layout-btn.active { background: var(--surface-2); color: var(--text); }
.layout-btn:hover:not(.active) { background: var(--surface-2); }

/* Grocery grid cards */
.grocery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 12px;
}
.grocery-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}
.grocery-card:hover { border-color: var(--accent-border); box-shadow: var(--shadow-md); }
.grocery-card-img {
  width: 100%;
  height: 140px;
  object-fit: contain;
  background: var(--surface-2);
  padding: 14px;
}
.grocery-card-img--empty { background: var(--surface-2); height: 140px; }
.grocery-card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.grocery-card-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.grocery-card-meta { font-size: 11px; color: var(--text-muted); }
.grocery-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 8px;
}
.grocery-card-price { font-size: 15px; font-weight: 700; }
.grocery-card-store { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.grocery-card-ppu   { font-size: 11px; color: var(--text-muted); }

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 36, 31, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.2s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 700; font-size: 16px; font-family: 'Fraunces', Georgia, serif; }
.modal-close {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 10px;
  line-height: 1.4;
  transition: color 0.1s, background 0.1s;
}
.modal-close:hover { color: var(--text); background: var(--border); }
.modal-body {
  overflow-y: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Basket edit rows */
.basket-edit-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.basket-edit-row:last-of-type { border-bottom: none; padding-bottom: 0; }
.basket-edit-fields { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.basket-edit-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.basket-new-form {
  border-top: 1px solid var(--border);
  padding-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Recipe modal */
.recipe-cat-header {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-subtle);
  user-select: none;
}
.recipe-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  font-family: 'Figtree', sans-serif;
  cursor: pointer;
  transition: background 0.1s;
  border-left: 2px solid transparent;
}
.recipe-item:hover { background: var(--surface-2); }
.recipe-item.active {
  background: var(--accent-light);
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Ingredient chips */
.ingredient-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 12px;
  color: var(--text);
}
.chip-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.1s;
}
.chip-remove:hover { color: var(--negative); }

/* Tech tabs (kept for compatibility) */
.tech-tabs { border-bottom: 1px solid var(--border); display: flex; gap: 24px; margin-bottom: 24px; }
.tech-tab { padding: 10px 0; color: var(--text-muted); font-weight: 500; font-size: 14px; position: relative; cursor: pointer; }
.tech-tab:hover { color: var(--text); }
.tech-tab.active { color: var(--text); }
.tech-tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }

/* ── Mobile ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    height: auto;
    padding: 12px 16px 0;
  }
  .header-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding-bottom: 10px;
  }
  .main-nav {
    gap: 0;
    width: 100%;
    border-top: 1px solid var(--border);
    padding: 6px 0;
  }
  .nav-link {
    padding: 8px 12px;
    flex: 1;
    justify-content: center;
    font-size: 13px;
    border-radius: var(--r-sm);
  }

  .page-content { padding: 20px 16px 56px; }
  .page-title   { font-size: 22px; }

  .search-hero  { flex-direction: column; }
  .grocery-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }

  .table-card   { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table         { min-width: 520px; }

  .baskets-row  { gap: 6px; }

  .tech-row            { flex-wrap: wrap; gap: 8px; }
  .tech-row-prices     { flex-direction: row; flex-wrap: wrap; gap: 10px; margin-left: 0; margin-top: 4px; width: 100%; }
  .tech-row-action     { margin-left: 0; margin-top: 6px; }
  .tech-row-img        { width: 44px; height: 44px; }
  .tech-row-name       { font-size: 13px; }
  .tech-filters-bar    { flex-wrap: wrap; gap: 8px; }
  .ai-input-wrap       { flex-direction: column; }
  .catalog-controls    { flex-direction: column; gap: 10px; }
  .catalog-toolbar     { flex-wrap: wrap; }
  .catalog-grid        { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .modal-overlay { padding: 12px; align-items: flex-end; }
  .modal-box     { max-height: 92vh; border-radius: var(--r-lg) var(--r-lg) 0 0; }

  /* Structural section mobile fixes */
  .baskets-section  { padding: 14px; }
  .search-section-card { padding: 14px; }
  .ai-section-header { padding: 10px 14px; }
  .ai-section-body  { padding: 14px; }
  .tech-grid { grid-template-columns: 1fr; gap: 12px; }
}

/* ================================================================
   STRUCTURAL COMPONENTS — Page layout, new sections
   ================================================================ */

/* ── Page load animations ───────────────────────────────────── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-title          { animation: fade-up 0.35s ease both; }
.page-subtitle       { animation: fade-up 0.35s ease 0.06s both; }
.baskets-section     { animation: fade-up 0.35s ease 0.10s both; }
.search-section-card { animation: fade-up 0.35s ease 0.18s both; }
.ai-section          { animation: fade-up 0.35s ease 0.10s both; }

/* ── Quick Baskets section (groceries) ──────────────────────── */
.baskets-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.baskets-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.baskets-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-family: 'Fraunces', Georgia, serif;
  letter-spacing: -0.2px;
}
.baskets-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.basket-chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 5px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.badge--active .basket-chip-count {
  background: var(--accent);
  color: #fff;
}

/* ── Search section card (groceries) ────────────────────────── */
.search-section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 20px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-sm);
}
.search-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.65px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Savings bar (groceries results) ────────────────────────── */
.savings-bar {
  background: var(--positive-bg);
  border: 1px solid var(--positive-border);
  border-radius: var(--r-sm);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fade-up 0.25s ease both;
}
.savings-bar-icon {
  font-size: 16px;
  flex-shrink: 0;
}

/* ── Enhanced empty state ────────────────────────────────────── */
.empty-icon  { font-size: 34px; margin-bottom: 10px; }
.empty-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  font-family: 'Fraunces', Georgia, serif;
}
.empty-desc {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 380px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ── AI section (tech) — always-visible card ────────────────── */
.ai-section {
  background: var(--surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--r-md);
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.ai-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 18px;
  background: var(--accent-light);
  border-bottom: 1px solid var(--accent-border);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.ai-collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'Figtree', sans-serif;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  transition: background 0.1s, color 0.1s;
}
.ai-collapse-btn:hover { background: var(--surface); color: var(--text); }
.ai-section-body { padding: 16px 18px; }

/* ── Tech result CARD GRID ──────────────────────────────────── */
/* Override the old flex-column layout */
.tech-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 14px;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  overflow: visible;
}

.tech-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.2s, transform 0.15s;
  box-shadow: var(--shadow-sm);
}
.tech-card:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.tech-card-img-wrap {
  width: 100%;
  height: 130px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tech-card-img-el {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.tech-card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 10px;
}
.tech-card-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--text);
}
.tech-card-stores {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.tech-card-store-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tech-card-store-lbl {
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 10px;
  font-weight: 600;
}
.tech-card-store-price {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  font-size: 12px;
}
.tech-card-store-price.best {
  color: var(--positive);
  font-weight: 700;
  font-size: 14px;
}
.tech-card-cta {
  display: block;
  text-align: center;
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  margin-top: auto;
}
.tech-card-cta:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Canonical grocery match metadata ───────────────────────── */
.product-name-lt {
  font-size: 10px;
  color: var(--text-subtle);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
}

.no-match {
  color: var(--text-subtle);
  font-size: 18px;
  line-height: 1;
}

/* Store cell for canonical matches */
.match-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pack-price-note {
  font-size: 10px;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  white-space: nowrap;
}

.price-type-badge {
  display: inline-flex;
  align-items: center;
  min-height: 16px;
  padding: 1px 5px;
  border: 1px solid var(--accent-border);
  border-radius: var(--r-sm);
  background: var(--accent-light);
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}

.match-empty-reason {
  max-width: 160px;
  margin-top: 3px;
  color: var(--text-subtle);
  font-size: 10px;
  line-height: 1.25;
}

.match-product-name {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
  cursor: help;
  display: block;
}

.match-qty {
  font-size: 10px;
  color: var(--text-subtle);
  margin-top: 1px;
  display: block;
}

/* ── Mobile grocery cards (< 640 px) ────────────────────────── */
.mobile-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mobile-product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.mobile-product-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.mobile-store-list {
  display: flex;
  flex-direction: column;
}

.mobile-store-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
}
.mobile-store-row:last-child { border-bottom: none; }

.mobile-store-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-subtle);
  width: 54px;
  flex-shrink: 0;
}

.mobile-store-product {
  flex: 1;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.mobile-store-detail {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 1px;
}
