:root {
  --color-bg: #f7f5f0;
  --color-surface: #ffffff;
  --color-border: #e2ddd2;
  --color-text: #2b2621;
  --color-text-muted: #756e63;
  --color-primary: #d9782f;
  --color-primary-dark: #b85f1f;
  --color-accent: #4c7a4c;
  --color-badge-bg: #f0ece2;
  --color-badge-text: #5c5548;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(43, 38, 33, 0.08), 0 1px 2px rgba(43, 38, 33, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
.hidden { display: none !important; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.4;
}

a { color: inherit; }

/* ---------- Topbar ---------- */

.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.3rem;
  white-space: nowrap;
}
.brand-mark { font-size: 1.4rem; }

.topbar-search { flex: 1; }
.topbar-search input {
  width: 100%;
  max-width: 480px;
  padding: 9px 14px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 0.95rem;
  background: var(--color-bg);
}
.topbar-search input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.lang-toggle { display: flex; border: 1px solid var(--color-border); border-radius: 999px; overflow: hidden; }
.lang-btn {
  border: none;
  background: var(--color-surface);
  padding: 7px 14px;
  cursor: pointer;
  font-weight: 600;
  color: var(--color-text-muted);
}
.lang-btn.active { background: var(--color-primary); color: white; }

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

.layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}

.filters-toggle {
  display: none;
  grid-column: 1 / -1;
}

/* ---------- Sidebar ---------- */

.sidebar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px;
  position: sticky;
  top: 78px;
  max-height: calc(100vh - 98px);
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.sidebar-header h2 { margin: 0; font-size: 1.1rem; }

.link-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  text-decoration: underline;
}

.filter-group {
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border);
}
.filter-group:last-child { border-bottom: none; }
.filter-group h3 {
  margin: 0 0 10px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.pill-group { display: flex; gap: 8px; }
.pill {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text);
}
.pill.active { background: var(--color-primary); border-color: var(--color-primary); color: white; }

.checkbox-list { display: flex; flex-direction: column; gap: 6px; }
.checkbox-list.scrollable { max-height: 180px; overflow-y: auto; padding-right: 4px; }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  cursor: pointer;
}
.checkbox-row.hidden { display: none; }
.checkbox-row input { accent-color: var(--color-primary); cursor: pointer; }

.select-input {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  font-size: 0.88rem;
}

.text-input-sm {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.ingredient-filter { margin-bottom: 12px; }
.ingredient-filter label { display: block; font-size: 0.82rem; margin-bottom: 4px; color: var(--color-text-muted); }
.hint { font-size: 0.75rem; color: var(--color-text-muted); margin: 4px 0 0; }

/* ---------- Ingredient shuttle (dual list-box with transfer buttons) ---------- */

.shuttle-group { padding-bottom: 20px; }
.shuttle-heading { font-size: 0.85rem; text-transform: none; letter-spacing: normal; margin: 0 0 10px; }
.shuttle-heading.exclude { color: #b3261e; }
.shuttle-heading.include { color: var(--color-accent); }

.shuttle {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: start;
}
.shuttle-col label { display: block; font-size: 0.75rem; color: var(--color-text-muted); margin-bottom: 4px; }
.shuttle-col .text-input-sm { margin-bottom: 6px; }

.shuttle-list {
  width: 100%;
  height: 150px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.82rem;
  padding: 2px;
}
.shuttle-list option { padding: 3px 6px; border-radius: 4px; }

.shuttle-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
  padding-top: 30px;
}
.shuttle-btn {
  width: 34px;
  height: 30px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}
.shuttle-btn:hover { background: var(--color-bg); color: var(--color-primary-dark); }

.range-inputs { display: flex; align-items: center; gap: 8px; }
.range-inputs input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.85rem;
}
.range-inputs span { color: var(--color-text-muted); }

.nutrient-filter { margin-top: 10px; }
.nutrient-filter label { display: block; font-size: 0.82rem; margin-bottom: 4px; color: var(--color-text-muted); }

/* ---------- Tabs ---------- */

.filter-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}
.tab-btn {
  flex: 1;
  padding: 8px 4px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--color-primary-dark); border-bottom-color: var(--color-primary); }
.tab-panel.hidden { display: none; }

/* ---------- Sliders ---------- */

.slider {
  width: 100%;
  accent-color: var(--color-primary);
  cursor: pointer;
}
.slider-readout {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin-top: 4px;
  font-weight: 600;
}

/* ---------- Big search button ---------- */

.search-btn-big {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 18px;
  font-size: 1.15rem;
  font-weight: 700;
  color: white;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}
.search-btn-big:hover { background: var(--color-primary-dark); }

details.advanced summary {
  cursor: pointer;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  font-weight: 600;
}

/* ---------- Results ---------- */

.results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.results-count { font-weight: 600; color: var(--color-text-muted); }
.sort-control { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; }
.sort-control select {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

.product-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-image {
  aspect-ratio: 4 / 3;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.card-image img { width: 100%; height: 100%; object-fit: cover; }
.card-image.no-image { background: var(--color-badge-bg); }
.no-image-icon { font-size: 2.2rem; opacity: 0.4; }

.lock-badge {
  display: none;
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(43, 38, 33, 0.75);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
}

.product-card.locked .card-image img { filter: blur(14px); transform: scale(1.1); }
.product-card.locked .lock-badge { display: block; }
.product-card.locked .card-brand,
.product-card.locked .card-name,
.product-card.locked .card-ingredients { filter: blur(5px); user-select: none; }
.product-card.locked .card-offers { display: none; }

.card-body { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-brand { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-primary-dark); font-weight: 700; }
.card-name { margin: 0; font-size: 1rem; line-height: 1.3; min-height: 2.6em; }

.card-badges { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0; }
.badge {
  background: var(--color-badge-bg);
  color: var(--color-badge-text);
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.card-rating { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; }
.stars { color: var(--color-primary); letter-spacing: 1px; }
.score-num { color: var(--color-text-muted); }

.card-ingredients { font-size: 0.8rem; color: var(--color-text-muted); }

.card-price { font-size: 0.92rem; margin-top: auto; padding-top: 6px; }

.card-offers { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.buy-btn {
  display: block;
  text-align: center;
  background: var(--color-accent);
  color: white;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}
.buy-btn:hover { opacity: 0.9; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--color-text-muted); }
.empty-state.hidden { display: none; }

.error { color: #b3261e; }

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 28px;
}
.pagination button {
  padding: 8px 16px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination span { color: var(--color-text-muted); font-size: 0.88rem; }

/* ---------- Unlock banner + paywall modal ---------- */

.unlock-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: #fbeee0;
  border: 1px solid #eecfa8;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.unlock-banner strong { display: block; font-size: 1rem; margin-bottom: 2px; }
.unlock-banner p { margin: 0; font-size: 0.85rem; color: var(--color-text-muted); }

.unlock-btn {
  background: var(--color-primary);
  color: white;
  border: none;
  padding: 12px 18px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.92rem;
}
.unlock-btn:hover { background: var(--color-primary-dark); }
.unlock-btn.full-width { display: block; width: 100%; white-space: normal; margin-top: 14px; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 38, 33, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 420px;
  width: 100%;
  position: relative;
  box-shadow: 0 10px 40px rgba(43, 38, 33, 0.25);
}
.modal h2 { margin: 0 0 10px; font-size: 1.2rem; }
.modal p { font-size: 0.88rem; color: var(--color-text-muted); margin: 0 0 16px; }
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
}
#unlock-form label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; }
#unlock-form input[type="email"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.92rem;
  margin-bottom: 14px;
}
.consent-row { display: flex; align-items: flex-start; gap: 8px; font-weight: 400 !important; margin-bottom: 6px; }
.consent-row input { margin-top: 3px; accent-color: var(--color-primary); }
.modal-demo-note { text-align: center; margin-top: 10px; }

/* ---------- Footer ---------- */

.footer-legal-links {
  margin-top: 8px;
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.footer-legal-links a { color: var(--color-text-muted); font-size: 0.78rem; text-decoration: underline; }
.footer-legal-links a:hover { color: var(--color-primary-dark); }

.legal-page {
  max-width: 780px;
  margin: 40px auto;
  padding: 0 20px 60px;
  line-height: 1.6;
}
.legal-page h1 { font-size: 1.6rem; margin-bottom: 6px; }
.legal-page h2 { font-size: 1.15rem; margin-top: 28px; }
.legal-page .placeholder-notice {
  background: #fbeee0;
  border: 1px solid #eecfa8;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 0.88rem;
  margin: 16px 0 28px;
}
.legal-page .placeholder-notice strong { display: block; margin-bottom: 4px; }
.legal-page .fill-in { background: #fff3cd; padding: 1px 4px; border-radius: 3px; }
.legal-page a.back-link { display: inline-block; margin-bottom: 20px; font-size: 0.85rem; }

.site-footer {
  max-width: 1400px;
  margin: 20px auto;
  padding: 16px 20px;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  text-align: center;
}

/* ---------- Responsive ---------- */

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .filters-toggle {
    display: block;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 10px;
    font-weight: 700;
    cursor: pointer;
  }
  .sidebar {
    display: none;
    position: static;
    max-height: none;
  }
  .sidebar.open { display: block; }
  .topbar-inner { flex-wrap: wrap; }
  .topbar-search { order: 3; flex-basis: 100%; }
}
