/*
 * Маркетплейс — стили.
 *
 * Раскладка: страница ровно в высоту экрана. Шапка и подвал закреплены,
 * прокручиваются только список категорий в фильтрах и сетка товаров.
 * На узких экранах закрепление снимается — там привычнее обычный скролл.
 */

:root {
  /* Палитра снята с макета заказчика */
  --c-bg:        #fbf6f3; /* фон страницы */
  --c-surface:   #f7efeb; /* панель фильтров и подвал */
  --c-card:      var(--c-bg); /* карточка, строка корзины, поле ввода — в тон странице */
  --c-line:      #e6dcd5; /* рамки внутри карточек, разделители таблиц */
  --c-line-strong: #cbbcb2; /* рамки самостоятельных элементов: корзина, сортировка */
  --c-line-soft: #f0e8e3; /* разделители */
  --c-ink:       #000000; /* основной текст — везде чёрный */
  --c-ink-strong: var(--c-ink); /* синоним, оставлен для обратной совместимости */
  --c-muted:     #8b817b; /* артикул, подписи */
  --c-green:     #5fa23e; /* кнопки, активный фильтр */
  --c-green-dk:  #4e8a31; /* наведение */
  --c-red:       #e1252f; /* цена */
  --c-white:     #ffffff;

  --radius-s: 3px;
  --radius-m: 5px;
  --radius-l: 7px;

  --shop-max: 100%;       /* фильтры и товары во всю ширину экрана */
  --shop-pad: 18px;

  /* Отступ сверху, который съедают админ-бар WP и прочая обвязка темы.
     Значение проставляет market.js замером, здесь только запасное. */
  --shop-offset: 0px;
}

/* ------------------------------------------------------------------ */
/* Базовое                                                             */
/* ------------------------------------------------------------------ */

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--c-bg);
  font-family: 'Avanti', sans-serif;
  color: var(--c-ink);
}

.shop *,
.shop *::before,
.shop *::after {
  box-sizing: border-box;
}

/* Тема задаёт всем button фон, рамку и padding 10px 20px — это ломает
   кружки, степперы и иконки. Гасим один раз здесь, дальше стилизуем сами.
   :where() обнуляет специфичность до 0,0,1: сброс перекрывает правило темы
   для button, но не мешает нашим же правилам по классам. */
:where(.shop) button {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;              /* тянет и line-height от родителя */
  vertical-align: middle;
}

.shop {
  display: flex;
  flex-direction: column;
  /* Тёмная вспышка браузера по касанию — своя подсветка уже есть */
  -webkit-tap-highlight-color: transparent;
  /* Тема красит body в серый с той же специфичностью, что и наше правило,
     и выигрывает при более позднем подключении. Задаём цвет на контейнере. */
  color: var(--c-ink);
  height: calc(100vh - var(--shop-offset));
  height: calc(100dvh - var(--shop-offset));
  overflow: hidden;
  background: var(--c-bg);
}

.shop img {
  max-width: 100%;
}

/* Атрибут hidden сильнее любых display из медиазапросов */
.shop [hidden] {
  display: none !important;
}

/* Заголовки и параграфы наследуют цвет контейнера, а не переменные темы */
.shop h1,
.shop h2,
.shop h3,
.shop h4,
.shop p,
.shop span,
.shop label,
.shop td,
.shop th {
  color: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.shop :focus-visible {
  outline: 2px solid var(--c-green);
  outline-offset: 2px;
}

/* Скроллбары внутренних областей — потоньше и в тон фону */
.filters,
.catalog__scroll,
.cart__scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--c-line) transparent;
}

.filters::-webkit-scrollbar,
.catalog__scroll::-webkit-scrollbar,
.cart__scroll::-webkit-scrollbar {
  width: 8px;
}

.filters::-webkit-scrollbar-thumb,
.catalog__scroll::-webkit-scrollbar-thumb,
.cart__scroll::-webkit-scrollbar-thumb {
  background: var(--c-line);
  border-radius: 4px;
}

/* ------------------------------------------------------------------ */
/* Шапка — закреплена                                                  */
/* ------------------------------------------------------------------ */

.shop-header {
  flex: 0 0 auto;
  background: var(--c-bg);
}

.shop-header__inner {
  max-width: var(--shop-max);
  margin: 0 auto;
  padding: 12px var(--shop-pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.shop-header__brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.shop-header__logo {
  height: 92px;
  width: auto;
  flex: 0 0 auto;
  display: block;
  object-fit: contain;
}

.shop-header__heading {
  min-width: 0;
}

/* Элементы мобильной шапки: включаются только в медиазапросе.
   Фон и рамку гасим здесь: сброс :where(.shop) button слабее правила темы,
   если main.css подключается позже. */
.shop-header__back,
.shop-header__mobile-title {
  display: none;
}

.shop-header__back {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--c-ink);
}

.breadcrumbs {
  margin-top: 2px;
  font-size: 13px;
  color: var(--c-muted);
}

.breadcrumbs a {
  color: var(--c-muted);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--c-ink);
  text-decoration: underline;
}

.breadcrumbs__sep {
  margin: 0 5px;
}

.shop-header__title {
  margin: 0;
  font-family: inherit;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  margin-top: 15px;
  color: var(--c-ink);
}

.shop-header__aside {
  display: flex;
  align-items: center;
  gap: 22px;
}

.shop-contact {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.shop-contact__phone {
  font-size: 19px;
  font-weight: 700;
  color: var(--c-ink);
  text-decoration: none;
  line-height: 1.2;
}

.shop-contact__hours {
  font-size: 13px;
  color: var(--c-muted);
}

.cart-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  background: transparent;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--radius-m);
  background: var(--c-card);
  cursor: pointer;
  font-family: inherit;
  color: var(--c-ink);
  transition: background .2s ease;
}

@media (hover: hover) {
  .cart-button:hover {
    background: rgba(0, 0, 0, .05);
  }
}


.cart-button__icon svg,
.cart-button__icon img {
  width: 28px;
  height: 28px;
  display: block;
  max-width: none;            /* тема ограничивает img шириной родителя */
  object-fit: contain;
  color: var(--c-green);
}

.cart-button__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.cart-button__caption {
  font-size: 14px;
}

.cart-button__sum {
  font-size: 18px;
  font-weight: 700;
}

.cart-button__badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--c-green);
  color: var(--c-white);
  font-size: 11px;
  font-weight: 700;
  line-height: 19px;
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* Тело — единственная растягивающаяся область                         */
/* ------------------------------------------------------------------ */

.shop__body {
  flex: 1 1 auto;
  min-height: 0;          /* без этого flex-ребёнок не даст детям скроллиться */
  width: 100%;
  max-width: var(--shop-max);
  margin: 0 auto;
  padding: 14px var(--shop-pad);
  overflow: hidden;
}

.shop__view {
  display: grid;
  gap: 20px;
  height: 100%;
  min-height: 0;
}

.shop__view--catalog {
  grid-template-columns: 290px minmax(0, 1fr);
}

.shop__view--cart {
  grid-template-columns: minmax(0, 1fr) 340px;
}

/* ------------------------------------------------------------------ */
/* Кнопки                                                              */
/* ------------------------------------------------------------------ */

.btn {
  display: block;
  width: 100%;
  padding: 12px 18px;
  border: none;
  border-radius: var(--radius-m);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}

.btn--green {
  background: var(--c-green);
  color: var(--c-white);
}

.btn--green:hover:not(:disabled) {
  background: var(--c-green-dk);
}

.btn--green:disabled {
  background: var(--c-line-soft);
  color: var(--c-muted);
  cursor: not-allowed;
}

.btn--link {
  background: transparent;
  color: var(--c-muted);
  font-size: 15px;
  font-weight: 400;
  text-decoration: underline;
  padding: 8px 0;
}

.btn--link:hover {
  color: var(--c-ink);
}

.btn--outline {
  background: transparent;
  border: 1px solid var(--c-line-strong);
  color: var(--c-ink-strong);
}

.btn--outline:hover {
  background: rgba(0, 0, 0, .05);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 44px;
  flex: 0 0 52px;
  padding: 0;                 /* тема иначе вдавливает иконку своим padding */
  border: none;
  border-radius: var(--radius-s);
  cursor: pointer;
  background: transparent;
  color: var(--c-ink);
  transition: background .2s ease;
}

.icon-btn svg,
.icon-btn img {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  max-width: none;
  object-fit: contain;
}

.icon-btn--green {
  background: var(--c-green);
  color: var(--c-white);
}

/*
 * Кнопка в карточке идёт без фона, поэтому в покое сливается с карточкой.
 * Подложка появляется по наведению — она же подсказывает, что элемент кликабельный.
 * Внутри (hover: hover), иначе на тач-экранах состояние залипает после касания.
 */
@media (hover: hover) {
  .icon-btn--green:hover {
    background: var(--c-green-dk);
  }

  .card__actions .icon-btn:hover {
    background: rgba(0, 0, 0, .08);
  }
}

/* Нажатие — чуть глубже, чтобы отклик читался и без смены фона на тач-экране */
.card__actions .icon-btn:active {
  background: rgba(0, 0, 0, .14);
}

/* В карточке иконка крупнее общей: кнопка идёт без фона,
   и мелкий значок на ней теряется */
.card__actions .icon-btn {
  width: 54px;
  height: 50px;
  flex-basis: 54px;
}

.card__actions .icon-btn svg,
.card__actions .icon-btn img {
  width: 48px;
  height: 48px;
  /* Оптическая посадка: значок корзины визуально тяжелее снизу */
  transform: translateY(-1px);
}

.icon-btn--framed {
  border: 1px solid var(--c-line-strong);
  width: 36px;
  height: 36px;
  flex-basis: 36px;
}

@media (hover: hover) {
  .icon-btn--framed:hover {
    background: rgba(224, 43, 32, .12);
    border-color: var(--c-red);
    color: var(--c-red);
  }
}

/* PNG нельзя перекрасить через currentColor, поэтому вместо смены цвета
   иконки слегка гасим её прозрачностью — эффект читается одинаково */
.icon-btn--framed img {
  opacity: .75;
  transition: opacity .2s ease;
}

@media (hover: hover) {
  .icon-btn--framed:hover img {
    opacity: 1;
  }
}

/* ------------------------------------------------------------------ */
/* Панель фильтров — со своей прокруткой                               */
/* ------------------------------------------------------------------ */

.filters {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--c-line-soft);
  border-radius: var(--radius-l);
  background: var(--c-surface);
}

.filters__title {
  margin: 0 0 8px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  color: var(--c-ink);
}

.filters__divider {
  height: 0;
  margin: 0;
  border: none;
  border-top: 1px solid var(--c-line);
}

.cat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cat-list li {
  margin: 0;
}

.cat {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 9px 14px;
  border: none;
  border-radius: var(--radius-m);
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.5;           /* сброс .shop button снял межстрочный интервал */
  color: var(--c-ink);
  cursor: pointer;
  text-align: left;
  transition: background .15s ease, color .15s ease;
}

/* Место под иконку резервируется всегда: без этого категории без картинки
   съезжают влево и список выглядит рваным */
.cat__icon {
  flex: 0 0 22px;
  width: 22px;
  height: 24px;               /* по высоте строки, чтобы иконка не съезжала */
  display: flex;
  align-items: center;
  justify-content: center;
}

/*
 * Размер задан в пикселях, а не через max-width: 100%: так иконка не зависит
 * от того, получил ли контейнер вычисляемую ширину, и не разворачивается
 * до натуральных 198px, если правило контейнера почему-то не применилось.
 * max-width: none — потому что тема объявляет img { max-width: 100% }.
 */
.cat__icon img {
  width: 22px;
  height: 22px;
  max-width: none;
  object-fit: contain;
  display: block;
}

.cat__name {
  flex: 1 1 auto;
  min-width: 0;
  /* Перенос вместо многоточия: «Гребни для волос и бороды» и подобные
     длинные названия иначе теряют смысл в обрезке */
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (hover: hover) {
  .cat:hover {
    background: rgba(0, 0, 0, .06);
  }
}

.cat.is-active {
  background: var(--c-green);
  color: var(--c-white);
  font-weight: 700;
}

/* Цены с чекбоксами */
.price-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.price-list__hint {
  margin: 0;
  font-size: 14px;
  color: var(--c-muted);
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--radius-m);
  cursor: pointer;
  font-size: 16px;
  line-height: 1.5;
  transition: background .15s ease;
}

@media (hover: hover) {
  .check:hover {
    background: rgba(0, 0, 0, .05);
  }
}

.check input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.check__box {
  position: relative;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border: 2px solid var(--c-line);
  border-radius: 4px;
  background: transparent;
  transition: background .15s ease, border-color .15s ease;
}

.check__box::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid var(--c-white);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform .15s ease;
}

.check input:checked + .check__box {
  background: var(--c-green);
  border-color: var(--c-green);
}

.check input:checked + .check__box::after {
  transform: rotate(45deg) scale(1);
}

.filters .btn--green {
  margin-top: auto;
}

/* ------------------------------------------------------------------ */
/* Каталог: шапка списка закреплена, прокрутка только у сетки          */
/* ------------------------------------------------------------------ */

.catalog {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.sortbar {
  flex: 0 0 auto;
  align-self: flex-start;
  max-width: 100%;
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* Подпись и кнопки визуально одинаковы: своя рамка у каждой, без зазоров */
.sortbar__label,
.sortbar__btn {
  min-width: 128px;
  padding: 12px 20px;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--radius-s);
  background: var(--c-bg);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.3;
  color: var(--c-ink);
  text-align: center;
  white-space: nowrap;
}

/* Соседние рамки накладываются друг на друга, а не удваиваются в линию */
.sortbar > * + * {
  margin-left: -1px;
}

.sortbar__label {
  cursor: default;
  user-select: none;
}

.sortbar__arrow {
  margin-left: 6px;
  font-size: 14px;
}

.sortbar__btn {
  position: relative;         /* активная кнопка поверх соседних рамок */
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

@media (hover: hover) {
  .sortbar__btn:hover {
    background: var(--c-surface);
  }
}

.sortbar__btn.is-active {
  z-index: 1;
  background: var(--c-green);
  border-color: var(--c-green);
  color: var(--c-white);
  font-weight: 700;
}

/* Панель сортировки и фильтров для узких экранов. По умолчанию скрыта,
   включается только в мобильном медиазапросе. */
.mobile-bar {
  display: none;
}

.catalog__found {
  flex: 0 0 auto;
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--c-ink);
}

.catalog__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  /* запас сверху и слева: приподнятая при наведении плашка не срезается о край */
  padding: 6px 8px 6px 6px;
  margin: -6px 0 0 -6px;
  -webkit-overflow-scrolling: touch;
}

.catalog__empty {
  margin: 24px 0;
  font-size: 17px;
  color: var(--c-muted);
}

/* ------------------------------------------------------------------ */
/* Сетка, плашки категорий, карточки товара                            */
/* ------------------------------------------------------------------ */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 14px;
  align-content: start;
  padding-bottom: 4px;
}

.tile,
.card {
  display: flex;
  flex-direction: column;
  padding: 10px;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-m);
  background: var(--c-card);
}

/* Плашка категории */
.tile {
  cursor: pointer;
  transition: box-shadow .2s ease, transform .2s ease;
}

@media (hover: hover) {
  .tile:hover {
    box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
    transform: translateY(-2px);
  }
}

.tile__name {
  margin: 0 0 4px;
  font-family: inherit;
  font-size: 19px;
  font-weight: 700;
  color: var(--c-ink-strong);
  text-align: left;
}

.tile__count {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--c-muted);
  text-align: left;
}

.tile__media {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: var(--radius-s);
  background: var(--c-card);
  margin-top: auto;
}

.tile__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Карточка товара */
.card__media {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: var(--radius-s);
  background: var(--c-card);
  margin-bottom: 8px;
}

/*
 * :not(.card__badge) обязателен: лейбл новинки — тоже <img> внутри .card__media,
 * и без исключения он получал inset: 0 с растяжением на весь квадрат.
 */
.card__media img:not(.card__badge) {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* Вытянутые фото режем до квадрата от верхнего края — так у сувениров
     остаётся видна значимая часть, а не середина шнурка */
  object-fit: cover;
  object-position: top;
}

.card__badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  padding: 5px 12px;
  border-radius: var(--radius-s);
  background: var(--c-green);
  color: var(--c-white);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .04em;
}

/* Готовая картинка: подложку и отступы снимаем, они уже в самом файле.
   Селектор с .card__media — чтобы перебить правило фото товара. */
.card__media img.card__badge--img,
.card__badge--img {
  position: absolute;
  inset: auto;
  top: -6px;
  left: 8px;
  width: auto;
  /* Высота по скетчу: около 9% ширины карточки. Ширину не задаём —
     тянется по пропорции файла */
  height: 48px;
  max-width: none;
  padding: 0;
  border-radius: 0;
  background: none;
  object-fit: contain;
  display: block;
}

.card__sku {
  margin: 0 0 2px;
  font-size: 13px;
  color: var(--c-muted);
}

.card__name {
  margin: 0 0 4px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.2;
}

.card__price {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 700;
  color: var(--c-red);
}

.card__actions {
  display: flex;
  /* center, а не stretch: кнопка выше степпера, при stretch они
     выравнивались бы по верхнему краю */
  align-items: center;
  gap: 8px;
  margin-top: auto;
}

/* Поле количества: кнопки и поле одним блоком */
.stepper {
  display: flex;
  align-items: stretch;
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-s);
  overflow: hidden;
  background: var(--c-card);
}

.stepper__btn {
  width: 36px;
  flex: 0 0 36px;
  padding: 0;                 /* без этого padding темы сдвигает + и − */
  border: none;
  background: var(--c-surface);
  font-family: inherit;
  font-size: 20px;
  line-height: 1;
  color: var(--c-ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s ease;
}

@media (hover: hover) {
  .stepper__btn:hover {
    background: var(--c-line);
  }
}

.stepper__input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  border: none;
  background: var(--c-bg);
  text-align: center;
  font-family: inherit;
  font-size: 17px;
  color: var(--c-ink);
  padding: 0;
}

.stepper__input:focus {
  outline: none;
}

/*
 * main.css темы задаёт input[type="text"] фон #fff и padding 0.375rem 0.75rem.
 * Это 0,1,1 и перебивает наши классы: боковые отступы в 12px съедали ширину
 * поля количества, из-за чего цифры обрезались. Префикс .shop даёт 0,2,0.
 */
.shop .stepper__input,
.shop .stepper__input:focus,
.shop .cf-input,
.shop .cf-input:focus {
  background-color: var(--c-bg);
}

.shop .stepper__input {
  width: 100%;
  min-width: 0;
  padding: 0 2px;
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* Корзина                                                             */
/* ------------------------------------------------------------------ */

.cart {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 16px;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--radius-l);
  background: var(--c-bg);
}

.cart__title {
  flex: 0 0 auto;
  margin: 0 0 12px;
  color: var(--c-ink-strong);
  font-family: inherit;
  font-size: 20px;
  font-weight: 700;
}

.cart__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
}

.cart-table {
  width: 100%;
  /* separate нужен ради скруглений и sticky-шапки, spacing нулевой:
     строки идут вплотную друг к другу и к шапке */
  border-collapse: separate;
  border-spacing: 0;
}

.cart-table th {
  position: sticky;
  top: -1px;                  /* прячем шов над рамкой при прокрутке */
  z-index: 2;
  padding: 11px 12px;
  background: var(--c-surface);
  border-top: 1px solid var(--c-line-strong);
  border-bottom: 1px solid var(--c-line-strong);
  font-size: 15px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
  color: var(--c-ink);
}

.cart-table th:first-child {
  border-left: 1px solid var(--c-line-strong);
  border-top-left-radius: var(--radius-s);
}

.cart-table th:last-child {
  border-right: 1px solid var(--c-line-strong);
  border-top-right-radius: var(--radius-s);
}

/*
 * Верхнюю границу строке даёт нижняя граница предыдущей строки или шапки,
 * поэтому у ячеек только border-bottom — иначе на стыках выйдет линия в 2px.
 */
.cart-table td {
  padding: 10px 12px;
  background: var(--c-card);
  border-bottom: 1px solid var(--c-line-strong);
  font-size: 16px;
  color: var(--c-ink-strong);
  vertical-align: middle;
}

.cart-table td:first-child {
  border-left: 1px solid var(--c-line-strong);
}

.cart-table td:last-child {
  border-right: 1px solid var(--c-line-strong);
}

.cart-table tr:last-child td:first-child {
  border-bottom-left-radius: var(--radius-s);
}

.cart-table tr:last-child td:last-child {
  border-bottom-right-radius: var(--radius-s);
}

.cart-table__col-category {
  font-size: 15px;
}

/* Явные ширины: с width:1% браузер схлопывал колонку фото до минимума,
   а картинку следом ужимал тема-правило img { max-width: 100% } */
.cart-table__col-sku      { width: 96px; }
.cart-table__col-photo    { width: 96px; }
.cart-table__col-category { width: 150px; }
.cart-table__col-price    { width: 96px; }
.cart-table__col-qty      { width: 148px; }
.cart-table__col-sum      { width: 110px; }
.cart-table__col-remove   { width: 68px; }
/* «Товар» ширины не имеет — забирает всё оставшееся место */

.cart-table th.cart-table__col-price,
.cart-table th.cart-table__col-sum,
.cart-table td.cart-table__col-price,
.cart-table td.cart-table__col-sum {
  text-align: right;
  white-space: nowrap;
}

.cart-table td.cart-table__col-price {
  color: var(--c-red);
  font-weight: 700;
}

.cart-table td.cart-table__col-sum {
  font-weight: 700;
}

.cart-table__col-sku {
  font-size: 15px;
  white-space: nowrap;
}

.cart-table__thumb {
  width: 80px;
  height: 80px;
  max-width: none;            /* тема ограничивает img шириной ячейки */
  object-fit: cover;
  object-position: top;
  background: var(--c-card);
  border-radius: var(--radius-s);
  display: block;
}

.cart-table .stepper {
  height: 36px;
  width: 124px;
}

/* Количество строкой — только для узких экранов, там степпер скрыт */
.cart-row__qty {
  display: none;
}

.cart-table .stepper__btn {
  width: 32px;
  flex-basis: 32px;
  padding: 0;
  font-size: 18px;
}

.cart__empty {
  margin: 20px 0;
  font-size: 17px;
  color: var(--c-muted);
}

.cart > .btn {
  flex: 0 0 auto;
  width: auto;
  min-width: 200px;
  align-self: flex-start;
  margin-top: 14px;
}

/* Правая панель «Ваш заказ» */
.summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  border-radius: var(--radius-l);
  background: var(--c-surface);
  color: var(--c-ink-strong);
}

.summary__title {
  margin: 0 0 4px;
  font-family: inherit;
  font-size: 20px;
  font-weight: 700;
}

.summary__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 16px;
}

.summary__divider {
  height: 0;
  margin: 4px 0;
  border: none;
  border-top: 1px solid var(--c-line);
}

.summary__total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 19px;
  font-weight: 700;
}

.summary__total b {
  font-size: 25px;
}

.summary__status {
  min-height: 20px;
  font-size: 15px;
}

.summary__status.is-error {
  color: var(--c-red);
}

.summary__status.is-success {
  color: #1b5e20;
}

.promo {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--c-line);
}

/*
 * Все строки блока отбиты слева на ширину иконки, даже если иконки нет, —
 * тогда «Бесплатная доставка» и «Мы свяжемся с вами» стоят строго в колонку.
 */
.promo__item {
  position: relative;
  min-height: 32px;
  padding-left: 44px;
}

.promo__icon {
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.promo__icon svg {
  width: 30px;
  height: 30px;
  display: block;
  color: var(--c-green);
}

.promo__text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.promo__text b {
  font-size: 15px;
}

.promo__text span {
  font-size: 14px;
  color: inherit;
}

/* ------------------------------------------------------------------ */
/* Подвал — закреплён, во всю ширину                                   */
/* ------------------------------------------------------------------ */

.shop-footer {
  flex: 0 0 auto;
  background: var(--c-surface);
  border-top: 1px solid var(--c-line);
}

.shop-footer__inner {
  max-width: var(--shop-max);
  margin: 0 auto;
  padding: 12px var(--shop-pad);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
}

.shop-footer__copy {
  font-size: 14px;
  color: var(--c-ink-strong);
}

.shop-footer__action .btn {
  width: auto;
  min-width: 220px;
  padding: 12px 28px;
}

.shop-footer__stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  padding-right: 24px;        /* сводка не липнет к правому краю экрана */
  font-size: 14px;
  line-height: 1.3;
  color: var(--c-ink);
}

.shop-footer__stats b {
  font-weight: 700;
}

/* ------------------------------------------------------------------ */
/* Модалка контактов                                                   */
/* ------------------------------------------------------------------ */

.cf-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .5);
  padding: 16px;
}

.cf-modal {
  position: relative;
  width: 100%;
  max-width: 440px;
  padding: 28px;
  border-radius: var(--radius-l);
  background: var(--c-bg);
}

.cf-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--c-ink);
}

.cf-title {
  margin: 0 0 20px;
  font-family: inherit;
  font-size: 20px;
  font-weight: 700;
}

.cf-field {
  margin-bottom: 12px;
}

.cf-label {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.cf-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-s);
  background: var(--c-card);
  font-family: inherit;
  font-size: 16px;
  color: var(--c-ink);
}

.cf-input:focus {
  outline: none;
  border-color: var(--c-green);
}

.cf-input.is-invalid {
  border-color: var(--c-red);
}

.cf-textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.4;
}

.cf-error {
  min-height: 18px;
  font-size: 13px;
  color: var(--c-red);
}

.cf-hint {
  font-size: 13px;
  color: var(--c-muted);
}

/* ------------------------------------------------------------------ */
/* Уведомления                                                         */
/* ------------------------------------------------------------------ */

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 90px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius-m);
  background: rgba(0, 0, 0, .82);
  color: var(--c-white);
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .3);
}

/* ------------------------------------------------------------------ */
/* Адаптив                                                             */
/* ------------------------------------------------------------------ */

@media (max-width: 1200px) {
  .shop__view--cart {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
}

@media (max-width: 1000px) {
  .shop__view--catalog {
    grid-template-columns: 240px minmax(0, 1fr);
  }
}

/* ==================================================================== */
/* МОБИЛЬНАЯ ВЕРСИЯ                                                     */
/*                                                                      */
/* Разметка та же, что и на десктопе. Экран определяется атрибутом      */
/* data-screen на .shop: categories | products | filters | cart.        */
/* Его проставляет market.js, десктопные правила его игнорируют.        */
/* ==================================================================== */

@media (max-width: 820px) {

  html,
  body {
    height: auto;
    /* Именно visible, не auto: при overflow: auto и высоте auto body
       становится контейнером прокрутки, который сам не прокручивается,
       и sticky-шапка внутри него не срабатывает */
    overflow: visible;
  }

  .shop {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .shop__body {
    overflow: visible;
    padding: 0 12px 24px;
  }

  .shop__view,
  .shop__view--catalog,
  .shop__view--cart {
    display: block;
    height: auto;
  }

  .filters,
  .catalog,
  .cart,
  .summary {
    height: auto;
    overflow: visible;
  }

  .catalog__scroll,
  .cart__scroll {
    overflow: visible;
    padding: 0;
    margin: 0;
  }

  /* Подвал на мобильных не нужен: действия живут в корзине */
  .shop-footer {
    display: none;
  }

  /* ---------------------------------------------------------------- */
  /* Шапка: назад — лого/заголовок — корзина                          */
  /* ---------------------------------------------------------------- */

  /* Шапка закреплена: корзина и кнопка «назад» доступны при любой прокрутке */
  .shop-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--c-bg);
    box-shadow: 0 1px 8px rgba(0, 0, 0, .08);
  }

  .shop-header__inner {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
  }

  .shop-header__back {
    grid-column: 1;
    justify-self: start;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--c-ink);
  }

  .shop-header__back svg {
    width: 24px;
    height: 24px;
  }

  .shop-header__brand {
    grid-column: 2;
    justify-content: center;
    gap: 0;
  }

  .shop-header__logo {
    height: 72px;
  }

  /* Заголовок и крошки десктопа на мобильных не показываем */
  .shop-header__heading {
    display: none;
  }

  .shop-header__mobile-title {
    display: block;
    grid-column: 2;
    justify-self: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
    font-weight: 700;
    color: var(--c-ink);
  }

  .shop-header__aside {
    grid-column: 3;
    justify-self: end;
    gap: 0;
  }

  /* Телефон менеджера прячем — он есть в подвале десктопа и в контактах */
  .shop-contact {
    display: none;
  }

  /* Корзина сжимается до иконки со счётчиком */
  .cart-button,
  .cart-button:hover,
  .cart-button:focus,
  .cart-button:active {
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background: transparent;
    justify-content: center;
  }

  .cart-button__text {
    display: none;
  }

  .cart-button__badge {
    top: -2px;
    right: -2px;
  }

  /* На стартовом экране — лого по центру, кнопки «назад» нет */
  .shop[data-screen="categories"] .shop-header__mobile-title {
    display: none;
  }

  /* На остальных экранах вместо лого — название раздела */
  .shop:not([data-screen="categories"]) .shop-header__brand {
    display: none;
  }

  /* ---------------------------------------------------------------- */
  /* Переключение экранов                                              */
  /* ---------------------------------------------------------------- */

  .shop[data-screen="categories"] .catalog,
  .shop[data-screen="filters"] .catalog,
  .shop[data-screen="products"] .filters {
    display: none;
  }

  /* Стартовый экран: только список категорий */
  .shop[data-screen="categories"] .filters__block--price,
  .shop[data-screen="categories"] .filters__divider,
  .shop[data-screen="categories"] .filters .btn {
    display: none;
  }

  /* Экран фильтров: только цены и кнопки */
  .shop[data-screen="filters"] .filters__block--categories,
  .shop[data-screen="filters"] .filters__divider {
    display: none;
  }

  /* ---------------------------------------------------------------- */
  /* Список категорий вместо плашек                                    */
  /* ---------------------------------------------------------------- */

  .filters {
    padding: 12px 0;
    border: none;
    border-radius: 0;
    background: transparent;
    gap: 16px;
  }

  .filters__title {
    padding: 0 2px;
  }

  /* Категории — сплошным списком, границы соседей накладываются */
  .cat-list {
    gap: 0;
  }

  .cat-list li + li .cat {
    margin-top: -1px;
  }

  .cat {
    padding: 13px 14px;
    border: 1px solid var(--c-line-strong);
    border-radius: 0;
    background: var(--c-card);
    font-size: 16px;
  }

  .cat__icon {
    flex-basis: 26px;
    width: 26px;
    height: 26px;
  }

  .cat__icon img {
    width: 26px;
    height: 26px;
  }

  .cat-list li:first-child .cat {
    border-top-left-radius: var(--radius-s);
    border-top-right-radius: var(--radius-s);
  }

  .cat-list li:last-child .cat {
    border-bottom-left-radius: var(--radius-s);
    border-bottom-right-radius: var(--radius-s);
  }

  .cat.is-active {
    position: relative;
    z-index: 1;
    border-color: var(--c-green);
  }

  .price-list {
    gap: 0;
  }

  .check {
    padding: 13px 14px;
    border: 1px solid var(--c-line-strong);
    border-radius: 0;
    background: var(--c-card);
  }

  .price-list .check + .check {
    margin-top: -1px;
  }

  /* ---------------------------------------------------------------- */
  /* Товары: сортировка списком, кнопка фильтров, две карточки в ряд   */
  /* ---------------------------------------------------------------- */

  .sortbar {
    display: none;             /* переключатель заменяет выпадающий список */
  }

  .mobile-bar {
    display: flex;
    gap: 8px;
    margin: 0 0 12px;
    padding: 12px 0;
    /* Высоту шапки замеряет market.js: она зависит от логотипа и от того,
       уходит ли название категории в две строки */
    position: sticky;
    top: var(--header-h, 60px);
    z-index: 60;
    background: var(--c-bg);
  }

  /* Счётчик едет вместе с панелью, иначе выглядывает из-под неё */
  .catalog__found {
    position: sticky;
    top: calc(var(--header-h, 60px) + 68px);
    z-index: 59;
    margin: 0 0 10px;
    padding-bottom: 8px;
    background: var(--c-bg);
  }

  .mobile-sort {
    flex: 1 1 auto;
    min-width: 0;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--c-line-strong);
    border-radius: var(--radius-s);
    background: var(--c-bg);
    font-family: inherit;
    font-size: 15px;
    color: var(--c-ink);
  }

  .mobile-filters-btn {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--c-line-strong);
    border-radius: var(--radius-s);
    background: var(--c-bg);
    color: var(--c-ink);
    cursor: pointer;
  }

  .mobile-filters-btn svg {
    width: 22px;
    height: 22px;
  }

  /* Фильтры по цене применены — подсвечиваем кнопку */
  .mobile-filters-btn.is-active {
    background: var(--c-green);
    border-color: var(--c-green);
    color: var(--c-white);
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .card__name {
    font-size: 14px;
  }

  .card__sku {
    font-size: 12px;
  }

  .card__price {
    font-size: 17px;
  }

  .card__actions {
    gap: 6px;
  }

  /* В карточке шириной ~160px каждый пиксель на счету */
  .card__actions .stepper {
    height: 40px;
  }

  .card__actions .stepper__btn {
    width: 28px;
    flex-basis: 28px;
    font-size: 18px;
  }

  .card__actions .stepper__input {
    font-size: 15px;
  }

  .icon-btn {
    width: 42px;
    height: 40px;
    flex-basis: 42px;
  }

  .icon-btn svg,
  .icon-btn img {
    width: 22px;
    height: 22px;
  }

  /* Идёт следом за общим правилом: выигрывает и по специфичности (0,2,1),
     и по порядку — чтобы при отладке не гадать, что кого перебивает */
  .card__actions .icon-btn {
    width: 50px;
    height: 46px;
    flex-basis: 50px;
  }

  .card__actions .icon-btn svg,
  .card__actions .icon-btn img {
    width: 44px;
    height: 44px;
    transform: translateY(-2px);
  }

  .card__media img.card__badge--img,
  .card__badge--img {
    top: 6px;
    left: 6px;
    height: 26px;
  }

  /* ---------------------------------------------------------------- */
  /* Корзина: фото, артикул, название, «X шт.», сумма, удалить        */
  /* ---------------------------------------------------------------- */

  .cart {
    padding: 0;
    border: none;
    background: transparent;
  }

  .cart__title {
    font-size: 17px;
    margin: 12px 0;
  }

  .cart-table,
  .cart-table tbody {
    display: block;
    border-spacing: 0;
  }

  .cart-table thead {
    display: none;
  }

  .cart-table tr {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--c-line);
  }

  .cart-table td,
  .cart-table td:first-child,
  .cart-table td:last-child {
    display: block;
    width: auto;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
  }

  /* Порядок ячеек задаём order, а не разметкой: на десктопе он другой */
  /*
   * Ширины фиксированные, тянется только название. Иначе длина артикула,
   * количества и суммы разъезжается от строки к строке и колонки прыгают.
   */
  .cart-table td.cart-table__col-photo {
    order: 1;
    flex: 0 0 40px;
    width: 40px;
  }

  .cart-table td.cart-table__col-sku {
    order: 2;
    flex: 0 0 52px;
    width: 52px;
    font-size: 13px;
    color: var(--c-ink);
  }

  .cart-table td.cart-table__col-name {
    order: 3;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14px;
    overflow-wrap: anywhere;
  }

  .cart-table td.cart-table__col-qty {
    order: 4;
    flex: 0 0 56px;
    width: 56px;
    font-size: 14px;
    text-align: right;
    white-space: nowrap;
  }

  .cart-table td.cart-table__col-sum {
    order: 5;
    flex: 0 0 72px;
    width: 72px;
    font-size: 15px;
    text-align: right;
    white-space: nowrap;
  }

  .cart-table td.cart-table__col-remove {
    order: 6;
    flex: 0 0 32px;
    width: 32px;
  }

  /* Ниже .cart-table td, иначе display: block оттуда перебивает скрытие */
  .cart-table td.cart-table__col-category,
  .cart-table td.cart-table__col-price {
    display: none;
  }

  .cart-table__thumb {
    width: 40px;
    height: 40px;
  }

  /* Количество показываем текстом, степпер убираем */
  .cart-table .stepper {
    display: none;
  }

  .cart-row__qty {
    display: inline;
    color: var(--c-red);
    font-weight: 700;
  }

  .cart-table td[data-label]::before {
    content: none;
  }

  .icon-btn--framed {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
    border: none;
    background: transparent;
    color: var(--c-ink);
  }

  .icon-btn--framed svg,
  .icon-btn--framed img {
    width: 20px;
    height: 20px;
  }

  /* Очистку корзины на мобильных не показываем */
  .cart > .btn {
    display: none;
  }

  /* ---------------------------------------------------------------- */
  /* Итого и кнопки под списком                                        */
  /* ---------------------------------------------------------------- */

  .summary {
    padding: 0;
    background: transparent;
    gap: 12px;
    margin-top: 16px;
  }

  .summary__title,
  .summary__row,
  .summary__divider,
  .promo {
    display: none;
  }

  .summary__total {
    padding: 14px 0;
    border-top: 1px solid var(--c-line-strong);
    font-size: 18px;
  }

  .summary__total b {
    font-size: 22px;
  }

  .toast-stack {
    right: 12px;
    left: 12px;
    bottom: 16px;
  }
}

@media (max-width: 420px) {
  /* Специфичность как у правил ширины выше, иначе скрытие не сработает */
  .cart-table td.cart-table__col-sku {
    display: none;             /* на самых узких экранах уступает названию */
  }
}

@media (prefers-reduced-motion: reduce) {
  .shop *,
  .shop *::before,
  .shop *::after {
    transition: none !important;
  }
}