:root {
  --ink: #15181c;
  --muted: #5d666f;
  --paper: #ffffff;
  --bg: #f4f6f8;
  --line: #e1e5ea;
  --accent: #0f766e;
  --accent-dark: #0b544e;
  --saving: #067647;
  --old: #b42318;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

a { color: inherit; }

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.logo {
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}
.logo span { color: var(--accent); }

.search {
  flex: 1;
  max-width: 560px;
}

.search input {
  width: 100%;
  padding: 10px 14px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.search input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  background: var(--paper);
}

.result-count {
  margin-left: auto;
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 236px 1fr;
  gap: 28px;
  align-items: start;
}

/* ---- filters ---- */

.filters {
  position: sticky;
  top: 76px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 16px 16px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.filter-group { padding: 14px 0; border-bottom: 1px solid var(--line); }
.filter-group:last-child { border-bottom: 0; }

.filter-group h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 14px;
  cursor: pointer;
}
.option input { accent-color: var(--accent); margin: 0; flex-shrink: 0; }
.option-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.option-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.link-button {
  background: none;
  border: 0;
  padding: 4px 0;
  font: inherit;
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

.price-fields { display: flex; gap: 8px; align-items: center; }
.price-fields input {
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  font: inherit;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ---- results ---- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar select {
  padding: 7px 10px;
  font: inherit;
  font-size: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 10px;
  font-size: 13px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 100px;
}
.chip button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 15px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.chip button:hover { color: var(--old); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-decoration: none;
}
.card:hover { border-color: var(--accent); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- image with skeleton ---- */

.thumb {
  margin: -14px -14px 12px;
  height: 170px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  border-radius: var(--radius) var(--radius) 0 0;
  position: relative;
  overflow: hidden;
}

.thumb:not(.loaded)::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, var(--bg) 30%, #e9edf1 50%, var(--bg) 70%);
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.thumb.empty { background: var(--bg); }
.thumb.empty::after { animation: none; }

@keyframes shimmer {
  from { background-position: 150% 0; }
  to { background-position: -50% 0; }
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 1;
  opacity: 0;
}
.thumb.loaded img { opacity: 1; }

.brand {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.35;
  margin: 0 0 10px;
  height: calc(2 * 1.35 * 14px);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.subtitle { font-size: 12px; color: var(--muted); margin-bottom: 10px; }

.price-block { margin-top: auto; }

.price {
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.price small { font-size: 13px; font-weight: 400; color: var(--muted); }

.unit-price { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.saving {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--saving);
  border: 1px solid #b8e3cc;
  background: #e7f6ee;
  border-radius: 3px;
  white-space: nowrap;
}

.store-count { margin-top: 8px; font-size: 12px; color: var(--muted); }
.out-of-stock { color: var(--old); }

/* ---- pagination ---- */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 28px 0 8px;
}
.pagination button {
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination span { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

.message {
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
}
.message strong { display: block; color: var(--ink); margin-bottom: 4px; font-size: 16px; }

/* ---- product page ---- */

.product {
  max-width: 940px;
  margin: 0 auto;
  padding: 24px;
}

.back { font-size: 14px; color: var(--accent); text-decoration: none; }

.product-head {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 32px;
  margin: 18px 0 32px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

.product-head .thumb { 
    height: 240px; 
    margin: 0; 
    padding: 0; 
    border-radius: var(--radius); 
    border: 1px solid var(--line); 
}

.product h1 {
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 4px 0 6px;
}

.meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.tag {
  padding: 3px 9px;
  font-size: 13px;
  background: var(--bg);
  border-radius: 100px;
}

.best-price {
  margin: 20px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.best-price .saving {
  position: static;
  display: inline-block;
  margin-top: 8px;
  color: var(--saving);
  background: #e7f6ee;
}
.best-price .price { font-size: 32px; }

table { width: 100%; border-collapse: collapse; background: var(--paper); }
caption {
  text-align: left;
  font-size: 15px;
  font-weight: 600;
  padding: 16px 14px 12px;
}
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
th { font-size: 12px; font-weight: 600; color: var(--muted); }
th.money, td.money { text-align: right; }
td.money { font-variant-numeric: tabular-nums; font-weight: 600; }
td.money .old {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--old);
  text-decoration: line-through;
}
tbody tr:last-child td { border-bottom: 0; }
tr.cheapest td { background: #f0faf5; }

.visit-store {
  display: inline-block;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--paper);
  background: var(--accent);
  border-radius: var(--radius);
  text-decoration: none;
  white-space: nowrap;
}
.visit-store:hover { background: var(--accent-dark); }

.table-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

@media (max-width: 880px) {
  .page { grid-template-columns: 1fr; }
  .filters { position: static; max-height: none; }
  .product-head { grid-template-columns: 1fr; }
  .product-head .thumb { max-width: 260px; }
  .header-inner { flex-wrap: wrap; gap: 12px; }
  .result-count { order: 3; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .thumb:not(.loaded)::after { animation: none; }
}