:root {
  --bg: #f4f3ee; --panel: #ffffff; --ink: #1d211c; --muted: #6b7068; --line: #e2e1da;
  --accent: #4b6b3c; --accent-ink: #ffffff; --good: #2f7d3b; --bad: #b5452f; --chip: #ebeae3;
  --best: #eef6ea;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151814; --panel: #1e221d; --ink: #e8eae4; --muted: #9aa094; --line: #30362e;
    --accent: #8db36d; --accent-ink: #12150f; --good: #7cc477; --bad: #ef8a71; --chip: #262b24;
    --best: #1f2d1c;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
code { background: var(--chip); padding: 1px 5px; border-radius: 4px; }

.top { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-inner { display: flex; gap: 16px; align-items: center; height: 60px; }
.logo { font-weight: 800; font-size: 19px; text-decoration: none; white-space: nowrap; }
.logo span { color: var(--accent); }
.search { flex: 1; display: flex; }
.search input { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px 0 0 8px; background: var(--bg); color: var(--ink); font-size: 15px; }
.search button, .filters button { padding: 9px 16px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; }
.search button { border-radius: 0 8px 8px 0; }
nav a { text-decoration: none; font-weight: 600; }

.cats { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0; }
.chip { background: var(--chip); padding: 6px 12px; border-radius: 99px; text-decoration: none; font-size: 14px; white-space: nowrap; }
.chip b { color: var(--muted); font-weight: 500; margin-left: 4px; }
.chip.on { background: var(--accent); color: var(--accent-ink); } .chip.on b { color: inherit; opacity: .8; }

.layout { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: start; }
.filters { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; position: sticky; top: 76px; }
.filters form { display: grid; gap: 12px; }
.filters label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.filters select, .filters input[type=number] { padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); font-size: 14px; width: 100%; }
.filters .range { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters .check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 14px; }
.filters button { border-radius: 8px; }
.stats { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: grid; gap: 4px; }
.stats b { color: var(--ink); }

.results-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.results-head h1 { margin: 0; font-size: 22px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; text-decoration: none; display: flex; flex-direction: column; transition: transform .12s, box-shadow .12s; }
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.thumb { aspect-ratio: 4/3; background: #fff; display: grid; place-items: center; position: relative; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: contain; position: absolute; inset: 0; background: #fff; }
.thumb .ph { font-size: 44px; opacity: .5; }
.card-body { padding: 10px 12px 12px; display: grid; gap: 4px; }
.cat { font-size: 12px; color: var(--muted); }
.name { font-weight: 600; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.price-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 4px; }
.price { font-weight: 800; font-size: 17px; white-space: nowrap; } .price small { font-weight: 500; color: var(--muted); font-size: 12px; }
.shops-badge { font-size: 12px; background: var(--chip); padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.shops-badge.multi { background: var(--accent); color: var(--accent-ink); }
.save { font-size: 12px; color: var(--good); font-weight: 600; }
.oos { font-size: 12px; color: var(--bad); }
.empty { background: var(--panel); border: 1px dashed var(--line); padding: 32px; border-radius: 12px; text-align: center; }
.pager { display: flex; gap: 16px; justify-content: center; align-items: center; margin: 24px 0; }
.pager a { background: var(--panel); border: 1px solid var(--line); padding: 6px 14px; border-radius: 8px; text-decoration: none; }

.crumbs { color: var(--muted); font-size: 14px; } .crumbs a { color: var(--muted); }
.product-head { display: grid; grid-template-columns: 280px 1fr; gap: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.product-head h1 { margin: 0 0 6px; font-size: 24px; }
.thumb.big { border-radius: 8px; } .thumb.big .ph { font-size: 72px; }
.headline-price { font-size: 30px; font-weight: 800; margin: 14px 0 4px; }
.headline-price .muted { font-size: 18px; font-weight: 500; }
h2 { margin: 28px 0 12px; font-size: 19px; }

.offers { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.offers th, .offers td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.offers th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.offers .r { text-align: right; }
.offers .shop { font-weight: 700; white-space: nowrap; }
.offers .title { color: var(--muted); font-size: 14px; }
.offers .price { font-weight: 800; font-size: 16px; white-space: nowrap; }
.offers tr.best { background: var(--best); }
.offers tr.gone { opacity: .5; }
.offers td.err { color: var(--bad); }
.tag { display: inline-block; margin-left: 8px; font-size: 11px; background: var(--good); color: #fff; padding: 1px 7px; border-radius: 99px; vertical-align: middle; }
.st { font-size: 13px; white-space: nowrap; } .st.yes { color: var(--good); } .st.no { color: var(--bad); }
.go { background: var(--accent); color: var(--accent-ink); padding: 6px 12px; border-radius: 8px; text-decoration: none; font-weight: 600; white-space: nowrap; font-size: 14px; }

.chart { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--line); }
.chart .axis { fill: var(--muted); font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; padding: 6px 4px 0; }
.legend i { display: inline-block; width: 12px; height: 3px; margin-right: 6px; vertical-align: middle; border-radius: 2px; }
.foot { color: var(--muted); font-size: 12px; padding: 32px 16px; }

@media (max-width: 820px) {
  .cats { flex-wrap: nowrap; overflow-x: auto; margin: 12px -16px; padding: 0 16px 6px; scrollbar-width: none; }
  .layout { grid-template-columns: 1fr; }
  .filters { position: static; }
  .product-head { grid-template-columns: 1fr; }
  .top-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; }
  .search { order: 3; flex-basis: 100%; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .offers .title { display: none; }
  .offers th, .offers td { padding: 8px; }
}
