:root{
  --bg:#f6f7f9;
  --surface:#fff;
  --text:#1d1f23;
  --muted:#6b7280;
  --accent:#e4572e;
  --accent-soft:#fde8e1;
  --border:#e5e7eb;
  --good:#1a7f37;
  --radius:12px;
}
@media (prefers-color-scheme:dark){
  :root{
    --bg:#15171a;
    --surface:#1f2226;
    --text:#e8e9eb;
    --muted:#9aa0a6;
    --border:#2c3036;
    --accent-soft:#3a2520;
  }
}
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  line-height:1.45;
  font-family:system-ui,sans-serif;
}
.site-header{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  align-items:center;
  justify-content:space-between;
  padding:12px 16px;
  background:var(--surface);
  border-bottom:1px solid var(--border);
}
.brand{
  display:flex;
  gap:10px;
  align-items:center;
  font-weight:700;
  font-size:1.15rem;
  text-decoration:none;
  color:inherit;
}
.logo{
  width:40px;
  height:40px;
  border-radius:50%;
  object-fit:cover;
}
.header-controls{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  align-items:center;
  font-size:.9rem;
  color:var(--muted);
}
select{
  padding:6px 10px;
  border:1px solid var(--border);
  border-radius:8px;
  background:var(--surface);
  color:var(--text);
}
.tabs{
  display:flex;
  gap:4px;
  padding:0 16px;
  background:var(--surface);
  border-bottom:1px solid var(--border);
  overflow-x:auto;
}
.tab{
  padding:12px 14px;
  color:var(--muted);
  text-decoration:none;
  border-bottom:3px solid transparent;
}
.tab.active{
  color:var(--text);
  border-bottom-color:var(--accent);
  font-weight:600;
}
.container{
  max-width:1100px;
  margin:0 auto;
  padding:16px;
}
h1{
  font-size:1.4rem;
}
.chips{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}
.chip{
  border:1px solid var(--border);
  background:var(--surface);
  color:var(--text);
  padding:6px 14px;
  border-radius:999px;
  cursor:pointer;
}
.chip.active{
  background:var(--accent);
  color:#fff;
  border-color:var(--accent);
}
.chip.no-match:not(.active){
  opacity:.5;
}
.card-store{
  color:var(--accent);
  font-size:.8rem;
  font-weight:700;
}
.meta,.empty{
  color:var(--muted);
  font-size:.9rem;
}
.cards{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(220px,1fr));
  gap:12px;
}
.card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.card-name a{
  color:inherit;
}
.card-prices{
  display:flex;
  gap:8px;
  align-items:baseline;
  flex-wrap:wrap;
}
.price{
  font-weight:700;
  font-size:1.15rem;
}
.old{
  text-decoration:line-through;
  color:var(--muted);
}
.badge{
  background:var(--accent-soft);
  color:var(--accent);
  font-weight:700;
  padding:2px 8px;
  border-radius:6px;
  font-size:.85rem;
}
.card-until{
  color:var(--muted);
  font-size:.85rem;
}
.search{
  width:100%;
  box-sizing:border-box;
  padding:10px 14px;
  font-size:1rem;
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:var(--surface);
  color:var(--text);
  margin-bottom:12px;
}
.table-wrap{
  overflow-x:auto;
}
.hint{
  color:var(--muted);
  font-size:.85rem;
  margin:-4px 0 12px;
}
.cat-group{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  margin-bottom:8px;
  overflow:hidden;
}
.cat-group summary{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:12px 16px;
  cursor:pointer;
  font-weight:600;
  list-style:none;
}
.cat-group summary::-webkit-details-marker{display:none}
.cat-group summary::before{
  content:"▸";
  color:var(--muted);
  transition:transform .15s;
}
.cat-group[open] summary::before{transform:rotate(90deg)}
.cat-name{flex:1}
.cat-count{
  color:var(--muted);
  font-weight:400;
  font-size:.85rem;
}
.cat-group table.best{border-radius:0}
table.best{
  width:100%;
  border-collapse:collapse;
  background:var(--surface);
  border-radius:var(--radius);
  overflow:hidden;
}
th,td{
  padding:10px 12px;
  text-align:left;
  border-bottom:1px solid var(--border);
}
th{
  font-size:.85rem;
  color:var(--muted);
  font-weight:600;
}
.cat{
  display:block;
  color:var(--muted);
  font-size:.8rem;
}
.dossier{
  max-width:720px;
  margin:0 auto;
  background:var(--surface);
  border:2px solid var(--text);
  border-radius:4px;
  padding:24px;
  font-family:"Courier New",monospace;
}
.dossier-head{
  border-bottom:2px solid var(--text);
  margin-bottom:16px;
}
.stamp{
  display:inline-block;
  color:var(--accent);
  border:3px solid var(--accent);
  padding:4px 10px;
  transform:rotate(-4deg);
  font-weight:700;
  letter-spacing:1px;
}
.dossier-body{
  display:grid;
  grid-template-columns:220px 1fr;
  gap:24px;
}
.photo img{
  width:100%;
  aspect-ratio:1/1;
  object-fit:cover;
  border:1px solid var(--text);
}
.photo figcaption{
  text-align:center;
  font-size:.8rem;
  color:var(--muted);
}
.fields dt{
  font-weight:700;
  margin-top:10px;
}
.fields dd{
  margin:0;
  border-bottom:1px dotted var(--muted);
}
.dossier-foot{
  display:flex;
  justify-content:space-between;
  margin-top:24px;
}
.site-footer{
  text-align:center;
  color:var(--muted);
  font-size:.8rem;
  padding:24px 16px;
}
@media (max-width:600px){
  .dossier-body{
    grid-template-columns:1fr;
  }
  .photo{
    max-width:220px;
    margin:0 auto;
  }
  .site-header{
    flex-direction:column;
    align-items:flex-start;
  }
}

/* Пагинация скидок */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
  margin: 20px 0 8px;
}
.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.page-btn:disabled {
  opacity: .4;
  cursor: default;
}
.page-gap {
  color: var(--muted);
  padding: 0 4px;
}

/* Подозрительно большая скидка */
.card-warn {
  font-size: .8rem;
  color: var(--muted);
}

/* «Выгода»: какой именно товар */
table.best td b {
  display: block;
}
table.best .product {
  display: block;
  font-size: .82rem;
  color: var(--muted);
}
.old-price{
  display:block;
  font-size:.8rem;
}
.avg-store{
  display:block;
  color:var(--muted);
  font-size:.8rem;
}
