.dense-products {
  --dense-rows: 2;
  display: grid;
  grid-template-rows: repeat(var(--dense-rows), minmax(0, 1fr));
  grid-auto-columns: minmax(178px, 1fr);
  grid-auto-flow: column;
  gap: 12px;
  overflow-x: auto;
  padding: 5px 5px 14px;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.dense-products::-webkit-scrollbar { display: none; }

.dense-product-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 310px;
  overflow: hidden;
  flex-direction: column;
  border: 1px solid #e4e5e8;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 6px 18px rgb(26 29 34 / 6%);
  scroll-snap-align: start;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.dense-product-card:hover,
.dense-product-card:focus-within {
  border-color: color-mix(in srgb, var(--brand-red) 42%, #e4e5e8);
  box-shadow: 0 13px 30px rgb(86 28 34 / 12%);
  transform: translateY(-2px);
}

.dense-product-card__media {
  position: relative;
  display: grid;
  height: 128px;
  flex: 0 0 128px;
  place-items: center;
  margin: 7px 7px 0;
  overflow: hidden;
  border-radius: 10px;
  background: linear-gradient(145deg, #fafafa, #f4f5f7);
}

.dense-product-card__rank,
.dense-product-card__badge {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 8px;
  display: grid;
  min-height: 22px;
  place-items: center;
  padding: 3px 7px;
  border-radius: 6px;
  background: #fff0f2;
  color: var(--brand-red);
  font-size: 9px;
  font-weight: 900;
}

.dense-product-card__rank {
  min-width: 24px;
  padding: 3px;
  background: #202228;
  color: #fff;
}

.dense-product-card__rank + .dense-product-card__badge { left: 38px; }

.dense-product-card__favorite {
  position: absolute;
  z-index: 3;
  top: 7px;
  right: 7px;
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  padding: 0;
  border: 1px solid rgb(20 22 26 / 7%);
  border-radius: 50%;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 3px 9px rgb(0 0 0 / 8%);
  cursor: pointer;
}

.dense-product-card__favorite img { width: 16px; }
.dense-product-card__favorite.is-active { background: #fff0f2; }
.dense-product-card__favorite.is-active img { filter: invert(14%) sepia(99%) saturate(6300%) hue-rotate(349deg); }

.dense-product-card__image {
  width: calc(100% - 22px);
  height: calc(100% - 18px);
  object-fit: contain;
  transition: transform .25s ease;
}

.dense-product-card:hover .dense-product-card__image { transform: scale(1.035); }
.dense-product-card.is-cover .dense-product-card__image { width: 100%; height: 100%; object-fit: cover; }

.dense-product-card__body {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  padding: 11px 12px 12px;
}

.dense-product-card__eyebrow {
  overflow: hidden;
  margin-bottom: 2px;
  color: var(--brand-red);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .2px;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.dense-product-card__brand {
  color: #8b8d92;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .4px;
  text-transform: uppercase;
}

.dense-product-card h3 {
  display: -webkit-box;
  min-height: 38px;
  margin: 4px 0 3px;
  overflow: hidden;
  color: #292b30;
  font-size: 12.5px;
  line-height: 1.42;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.dense-product-card__rating {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 5px;
  font-size: 10px;
}

.dense-product-card__rating b { color: #ed9f00; }
.dense-product-card__rating small { color: #94969b; }

.dense-product-card__benefit {
  display: block;
  margin: 1px 0 5px;
  overflow: hidden;
  color: #7b3fa0;
  font-size: 9px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dense-product-card__benefit--express { color: #16834c; }

.dense-product-card__stock { margin: 1px 0 6px; }
.dense-product-card__stock span { display: block; margin-bottom: 3px; color: #d66b08; font-size: 9px; font-weight: 800; }
.dense-product-card__stock i { display: block; height: 4px; overflow: hidden; border-radius: 99px; background: #f2dfcd; }
.dense-product-card__stock b { display: block; height: 100%; border-radius: inherit; background: #ed7b10; }

.dense-product-card__purchase {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  justify-content: flex-end;
  gap: 7px;
  margin-top: auto;
}

.dense-product-card__price { display: flex; min-width: 0; min-height: 32px; flex-direction: column; justify-content: flex-end; }
.dense-product-card__price del { color: #96989d; font-size: 9.5px; line-height: 1.1; }
.dense-product-card__price strong { color: var(--brand-red); font-size: 16px; line-height: 1.2; white-space: nowrap; }

.dense-product-card__cart {
  display: flex;
  width: 100%;
  min-width: 31px;
  height: 38px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 8px;
  border: 1px solid #dfe0e3;
  border-radius: 8px;
  background: #fff;
  color: #36383d;
  font: 800 10.5px Roboto, sans-serif;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}

.dense-product-card__cart img { width: 16px; }
.dense-product-card__cart span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dense-product-card__cart:hover,
.dense-product-card__cart.is-added { border-color: var(--brand-red); background: var(--brand-red); color: #fff; }
.dense-product-card__cart:hover img,
.dense-product-card__cart.is-added img { filter: brightness(0) invert(1); }

.dense-product-card--mini .dense-product-card__cart { width: 100%; padding: 0 8px; border-radius: 8px; }
.dense-product-card--mini .dense-product-card__cart span { position: static; width: auto; height: auto; overflow: visible; clip: auto; }

.dense-product-card--full .dense-product-card__purchase,
.dense-product-card--discount .dense-product-card__purchase,
.dense-product-card--dark .dense-product-card__purchase { gap: 6px; }

.dense-product-card--discount .dense-product-card__badge { background: var(--brand-red); color: #fff; }
.dense-product-card--discount .dense-product-card__price { align-items: flex-start; gap: 0; }

.dense-product-card--dark {
  border-color: #292b31;
  background: #17191e;
  box-shadow: 0 10px 25px rgb(0 0 0 / 20%);
}

.dense-product-card--dark .dense-product-card__media { background: linear-gradient(145deg, #30333a, #22242a); }
.dense-product-card--dark .dense-product-card__badge { background: #f1ca68; color: #17191e; }
.dense-product-card--dark .dense-product-card__eyebrow,
.dense-product-card--dark .dense-product-card__price strong { color: #f1ca68; }
.dense-product-card--dark .dense-product-card__brand,
.dense-product-card--dark .dense-product-card__rating small { color: #aeb0b6; }
.dense-product-card--dark h3 { color: #fff; }
.dense-product-card--dark .dense-product-card__cart { border-color: #f1ca68; background: #f1ca68; color: #17191e; }

.dense-product-card--express { border-top: 3px solid #25a666; }
.dense-product-card--coupon { background: linear-gradient(180deg, #fff 0 70%, #fbf5ff 100%); }

.dense-grid-shell { position: relative; }
.dense-grid-arrow { position: absolute; z-index: 8; top: 50%; display: grid; width: 39px; height: 39px; place-items: center; padding: 0; border: 1px solid #ddd; border-radius: 50%; background: #fff; box-shadow: 0 6px 17px rgb(0 0 0 / 14%); cursor: pointer; transform: translateY(-50%); }
.dense-grid-arrow img { width: 18px; }
.dense-grid-arrow--prev { left: -18px; }
.dense-grid-arrow--prev img { transform: rotate(180deg); }
.dense-grid-arrow--next { right: -18px; }
.dense-grid-arrow:disabled { visibility: hidden; }
.dense-density-toggle { display: inline-flex; padding: 3px; border: 1px solid #e1e1e3; border-radius: 8px; background: #f5f5f6; }
.dense-density-toggle button { height: 30px; padding: 0 11px; border: 0; border-radius: 6px; background: transparent; color: #72747a; font: 700 10px Roboto, sans-serif; cursor: pointer; }
.dense-density-toggle button.is-active { background: #fff; box-shadow: 0 2px 7px rgb(0 0 0 / 8%); color: #222; }
.dense-showcase-notice { min-height: 14px; margin: 5px 0 -5px; color: #229542; font-size: 9px; text-align: right; }

body[data-card-density="compact"] .dense-products { grid-auto-columns: minmax(160px, 1fr); gap: 8px; }
body[data-card-density="compact"] .dense-product-card { min-height: 276px; border-radius: 11px; }
body[data-card-density="compact"] .dense-product-card__media { height: 96px; flex-basis: 96px; margin: 5px 5px 0; }
body[data-card-density="compact"] .dense-product-card__body { padding: 8px 9px 9px; }
body[data-card-density="compact"] .dense-product-card__brand { display: none; }
body[data-card-density="compact"] .dense-product-card__eyebrow { font-size: 8.5px; }
body[data-card-density="compact"] .dense-product-card h3 { min-height: 33px; margin-top: 2px; font-size: 11px; }
body[data-card-density="compact"] .dense-product-card__rating { margin-bottom: 3px; font-size: 9px; }
body[data-card-density="compact"] .dense-product-card__benefit { margin-bottom: 3px; font-size: 8.5px; }
body[data-card-density="compact"] .dense-product-card__stock { margin-bottom: 4px; }
body[data-card-density="compact"] .dense-product-card__price del { font-size: 8.5px; }
body[data-card-density="compact"] .dense-product-card__price strong { font-size: 14px; }
body[data-card-density="compact"] .dense-product-card__cart { height: 34px; min-width: 34px; padding: 0 7px; font-size: 9.5px; }
body[data-card-density="compact"] .dense-product-card--mini .dense-product-card__cart { width: 100%; }
body[data-card-density="compact"] .dense-product-card--full .dense-product-card__purchase,
body[data-card-density="compact"] .dense-product-card--discount .dense-product-card__purchase,
body[data-card-density="compact"] .dense-product-card--dark .dense-product-card__purchase { gap: 4px; }

@media (max-width: 767.98px) {
  .dense-products { --dense-rows: 2 !important; grid-auto-columns: minmax(156px, 64vw); gap: 9px; }
  .dense-grid-arrow { display: none; }
  body[data-card-density="compact"] .dense-products { grid-auto-columns: minmax(156px, 62vw); }
}

@media (prefers-reduced-motion: reduce) {
  .dense-products { scroll-behavior: auto; }
  .dense-product-card,
  .dense-product-card__image { transition: none; }
}
