:root {
  --bg:        #f4f6fb;
  --bg2:       #ffffff;
  --bg3:       #f0f2f8;
  --bg4:       #e8ecf5;
  --border:    #e2e6f0;
  --border2:   #d0d6e8;
  --text:      #14192e;
  --text-mid:  #3d4463;
  --text-muted:#7a84a8;
  --accent:    #4f62d9;
  --accent-bg: #eef0fd;
  --green:     #1a9e5c;
  --green-bg:  #eafaf2;
  --yellow:    #b87d00;
  --yellow-bg: #fdf7e3;
  --orange:    #c45c00;
  --orange-bg: #fdf1e8;
  --red:       #c82b2b;
  --red-bg:    #fdeaea;
  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 1px 4px rgba(20,25,46,.06), 0 4px 16px rgba(20,25,46,.07);
  --shadow-sm: 0 1px 3px rgba(20,25,46,.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.container { max-width: 980px; margin: 0 auto; padding: 0 24px; }

/* ── Header ── */
header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 0 var(--border), 0 2px 8px rgba(20,25,46,.05);
}
header .inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px;
}
.logo { font-size: 1.05rem; font-weight: 800; color: var(--text); letter-spacing: -.02em; }
.logo span { color: var(--accent); }

/* ── Index hero ── */
.hero { padding: 48px 0 36px; }
.hero h1 {
  font-size: 2rem; font-weight: 800; letter-spacing: -.03em;
  margin-bottom: 10px; color: var(--text);
}
.hero p { color: var(--text-muted); font-size: 15px; max-width: 500px; line-height: 1.7; }

/* ── Stats ── */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin: 32px 0 24px; }
.stat-box {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 22px;
  flex: 1; min-width: 110px; box-shadow: var(--shadow-sm);
}
.stat-num { font-size: 1.9rem; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 5px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }

/* ── Search ── */
.search-wrap { position: relative; margin-bottom: 14px; }
.search-wrap::before {
  content: "🔍"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 14px; pointer-events: none;
}
#search-input {
  width: 100%; padding: 11px 16px 11px 40px;
  border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--bg2); color: var(--text); font-size: 14px;
  box-shadow: var(--shadow-sm); transition: border-color .15s;
  outline: none;
}
#search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,98,217,.12); }

/* ── Filters ── */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 28px; }
.filter-btn {
  padding: 6px 14px; border-radius: 20px;
  border: 1.5px solid var(--border2);
  background: var(--bg2); color: var(--text-mid);
  cursor: pointer; font-size: 13px; font-weight: 500;
  transition: all .15s; white-space: nowrap;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Product Grid ── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 18px;
}

.product-card {
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.product-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}
.product-card a { display: block; color: inherit; text-decoration: none; }

.card-image {
  width: 100%; height: 176px; object-fit: contain;
  background: var(--bg3); padding: 20px;
  border-bottom: 1px solid var(--border);
}
.card-body { padding: 16px 18px 18px; }
.card-brand {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--accent); margin-bottom: 5px;
}
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 13px; line-height: 1.45; color: var(--text); }

/* ── Score badge ── */
.score-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 20px; font-size: 13px; font-weight: 700;
}
.score-green  { background: var(--green-bg);  color: var(--green); }
.score-yellow { background: var(--yellow-bg); color: var(--yellow); }
.score-orange { background: var(--orange-bg); color: var(--orange); }
.score-red    { background: var(--red-bg);    color: var(--red); }

.card-meta { margin-top: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-price { font-size: 13px; color: var(--text-muted); }
.card-price .amount { font-size: 15px; font-weight: 700; color: var(--text); }
.card-category {
  font-size: 11px; color: var(--text-muted);
  background: var(--bg3); padding: 3px 9px;
  border-radius: 6px; border: 1px solid var(--border); font-weight: 500;
}

/* ── Product detail header ── */
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-muted); margin: 28px 0 24px;
  padding: 7px 14px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--bg2); transition: all .15s;
}
.back-link:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }

.product-header {
  display: flex; gap: 36px; margin-bottom: 40px;
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  box-shadow: var(--shadow-sm); flex-wrap: wrap;
}
.product-image-wrap {
  flex: 0 0 180px; height: 180px;
  background: var(--bg3); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.product-image-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; padding: 16px; }

.product-info { flex: 1; min-width: 240px; }
.product-brand {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--accent); margin-bottom: 7px;
}
.product-title { font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: 18px; line-height: 1.3; }

.summary-table { width: 100%; border-collapse: collapse; }
.summary-table td {
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  font-size: 13.5px; vertical-align: middle;
}
.summary-table td:first-child { color: var(--text-muted); white-space: nowrap; width: 170px; font-weight: 500; }
.summary-table td:last-child { font-weight: 600; }
.summary-table tr:last-child td { border-bottom: none; }

.buy-btn {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 18px;
  padding: 11px 22px; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: 0 2px 8px rgba(79,98,217,.25); transition: opacity .15s, transform .15s;
}
.buy-btn:hover { opacity: .9; transform: translateY(-1px); text-decoration: none; }
.buy-btn .price-tag { opacity: .85; font-weight: 500; }

/* ── Sections ── */
.section { margin-bottom: 40px; }
.section-title {
  font-size: .9rem; font-weight: 800; color: var(--text);
  text-transform: uppercase; letter-spacing: .07em;
  border-left: 3px solid var(--accent); padding-left: 12px;
  margin-bottom: 20px;
}

/* ── Ingredient list ── */
.ingredient-list { display: flex; flex-direction: column; gap: 10px; }

.ingredient-item {
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  border-left-width: 3px;
}
.ingredient-item.risk-high   { border-left-color: var(--red); }
.ingredient-item.risk-med    { border-left-color: var(--orange); }
.ingredient-item.risk-low    { border-left-color: var(--yellow); }
.ingredient-item.risk-safe   { border-left-color: var(--green); }
.ingredient-item.risk-unknown{ border-left-color: var(--border2); }

.ingredient-name { font-weight: 700; font-size: 14px; margin-bottom: 3px; color: var(--text); }
.ingredient-func {
  font-size: 12px; font-weight: 600; color: var(--accent);
  background: var(--accent-bg); display: inline-block;
  padding: 2px 9px; border-radius: 4px; margin-bottom: 10px;
}
.ingredient-meta {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px 16px;
}
.meta-item { font-size: 13px; }
.meta-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 2px; }
.ingredient-source { margin-top: 10px; font-size: 12px; color: var(--text-muted); }
.ingredient-source a { color: var(--accent); font-weight: 500; }

/* ── Warning boxes ── */
.warning-box {
  background: var(--yellow-bg); border: 1.5px solid #e8c840;
  border-radius: var(--radius-sm); padding: 16px 18px; margin-bottom: 12px;
}
.warning-box.danger { background: var(--red-bg); border-color: #e08080; }
.warning-box.info   { background: var(--accent-bg); border-color: #b0bbf0; }
.warning-title { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.warning-body { font-size: 13px; color: var(--text-mid); }
.warning-body p { margin-bottom: 4px; }
.warning-body p:last-child { margin-bottom: 0; }

/* ── Market alert ── */
.market-alert {
  background: var(--accent-bg); border: 1.5px solid #c0c8f5;
  border-radius: var(--radius-sm); padding: 14px 18px;
  margin-bottom: 32px; font-size: 13.5px; color: var(--text-mid);
  line-height: 1.6;
}

/* ── Score table ── */
.score-table { width: 100%; border-collapse: collapse; background: var(--bg2); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); border: 1.5px solid var(--border); }
.score-table th, .score-table td { padding: 12px 18px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.score-table th { background: var(--bg3); color: var(--text-muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.score-table tr:last-child td { border-bottom: none; background: var(--bg3); font-weight: 800; font-size: 15px; }
.score-table td:nth-child(2) { font-weight: 700; font-size: 15px; }
.score-note { font-size: 12px; color: var(--text-muted); font-weight: 400; margin-top: 2px; }

.score-bar-wrap {
  background: var(--bg4); border-radius: 6px; height: 8px;
  width: 120px; display: inline-block; vertical-align: middle;
  overflow: hidden;
}
.score-bar { height: 100%; border-radius: 6px; transition: width .4s ease; }

/* ── Sources ── */
.source-list { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.source-list li {
  font-size: 13px; color: var(--text-muted);
  padding: 9px 14px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.source-list a { color: var(--accent); font-weight: 500; }

/* ── No results ── */
.no-results { color: var(--text-muted); text-align: center; padding: 60px 0; display: none; font-size: 14px; }

/* ── Footer ── */
footer {
  border-top: 1px solid var(--border);
  padding: 28px 0; margin-top: 64px;
  background: var(--bg2);
}
footer p { text-align: center; color: var(--text-muted); font-size: 12.5px; line-height: 1.7; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .hero h1 { font-size: 1.5rem; }
  .product-header { flex-direction: column; padding: 20px; }
  .product-image-wrap { flex: none; width: 100%; height: 160px; }
  .score-bar-wrap { width: 80px; }
  .stats { gap: 8px; }
  .stat-box { padding: 14px 16px; }
}
