/* ===== Мобильный UI (полная версия) ===== */

:root { --mobile-nav-h: 60px; } /* фактическая высота нижней панели */
/* Контейнер */
.m-container{max-width:1140px;margin:0 auto;padding:0 12px;}

/* Шапка */
.m-header__top{
  background:#00467f;               /* бренд-цвет */
  border-bottom:1px solid rgba(0,0,0,.06);
}
.m-header__search{
  background:#fff;
  border-bottom:1px solid rgba(0,0,0,.06);
}
.m-header__top .m-container,
.m-header__search .m-container{padding:8px 12px}

/* Логотип по центру */
.m-logo{display:flex;align-items:center;justify-content:center;padding:4px 0;text-decoration:none;}
.m-logo img{height:60px;display:block}

/* Поиск */
.m-search{display:flex;gap:8px}
.m-search__input{flex:1 1 auto;border:1px solid #e5e7eb;border-radius:8px;padding:10px 12px;font-size:16px}
.m-search__btn{border:1px solid #e5e7eb;background:#fff;border-radius:8px;padding:0 12px}
.m-header__search { box-shadow: 0 1px 0 rgba(0,0,0,.06); }

/* Нижняя навигация (фиксированная) */
.m-bottom-nav{
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1030;

  height: var(--mobile-nav-h);            /* ← фиксируем высоту */
  background: #fff;
  border-top: 1px solid rgba(0,0,0,.08);

  display: flex;
  justify-content: space-around;
  align-items: center;

  /* для iOS-выреза */
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.m-bottom-nav__item{
  position:relative;display:flex;flex-direction:column;align-items:center;gap:4px;
  font-size:13px;color:#444;text-decoration:none
}
.m-bottom-nav__item i{font-size:20px}
.m-bottom-nav__item.is-active{color:#00467f}

/* Бейджи количества (верх/низ) */
.m-badge{
  position:absolute;top:-7px;right:4px;
  min-width:15px;height:12px;border-radius:5px;
  background:#dc3545;color:#fff;font-size:9px;
  display:inline-flex;align-items:center;justify-content:center
}


/* Категории */
.m-section-title{font-size:16px;margin:12px 0}
.m-cats .m-section-title{margin-top:8px;margin-bottom:18px}
.m-cats .m-section-title + .m-cats-grid{margin-top:4px}

.m-cats-grid{
  display:grid;grid-template-columns:repeat(4,1fr);
  gap:12px;margin:12px 0
}
@media (max-width:480px){ .m-cats-grid{grid-template-columns:repeat(3,1fr);} }

.m-cat{
  display:flex;flex-direction:column;align-items:center;gap:6px;
  text-align:center;color:#222;text-decoration:none
}
.m-cat__thumb{
  width:72px;height:72px;border-radius:16px;
  background:#fff;                         /* белый фон под изображения */
  display:flex;align-items:center;justify-content:center;overflow:hidden
}
.m-cat__thumb img{max-width:80%;max-height:80%;object-fit:contain}
.m-cat__title{font-size:12px;line-height:1.2}

/* Рекомендуемые товары — сетка */
.m-products .m-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}
@supports (align-items: stretch) {
  .m-products .m-grid{align-items:stretch;}
}

/* Карточка товара (строгое вертикальное построение) */
.m-product{
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  background:#fff;border-radius:12px;padding:8px;
  height:100%;
}

/* 1) Изображение — фиксированная область */
.m-product__img{
  width:100%;aspect-ratio:1/1;border-radius:8px;
  background:#fff;
  display:flex;align-items:center;justify-content:center;overflow:hidden
}
.m-product__img img:not(.sale-badge-mobile) {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  padding: 5px;
}

/* 2) Наименование — РОВНО 3 строки с многоточием */
.m-product__name{
  font-size:13px;font-weight:500;line-height:1.3;
  margin-top:8px;

  display:-webkit-box;
  -webkit-line-clamp:3;
  -webkit-box-orient:vertical;
  overflow:hidden;
  /* резерв под 3 строки, чтобы высота всегда одинаковая */
  min-height:calc(1.3em * 3);
  max-height:calc(1.3em * 3);
}

/* 3) Код */
.m-product__meta{
  font-size:11px;color:#777;margin-top:6px;
  /* одна строка, обрезаем при необходимости */
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}

/* 4) Цена слева — единица справа */
.m-product__price-row{
  display:flex;justify-content:space-between;align-items:center;margin-top:6px
}
.m-product__price{font-weight:600;color:#0078be;font-size:14px}
.m-product__unit{font-size:12px;color:#777;white-space:nowrap}

/* 5) Кнопка корзины — всегда у нижнего края */
.m-product__footer{
  margin-top:10px; /* прижимает кнопку вниз, выравнивая высоту карточек */
  height: 32px;
}
.product-item .cart-add.btn{
  width:100%;
  border:1px solid #0078be;
  background:#0078be;color:#fff;
  border-radius:8px;padding:10px 12px;
  font-size:14px;line-height:0.7;
}

/* После добавления — контролы количества */
.product-item .quantity-controls{
  display:flex;align-items:center;gap:8px;width:100%
}
.product-item .btn-minus,
.product-item .btn-plus{
  min-width:40px;padding:0 10px;
  background:#fff;color:#0078be
}
.product-item .quantity{
  width:64px;text-align:center;height: 32px;;
  border:1px solid #e5e7eb;border-radius:8px;font-size:15px
}

/* Мелочи */
img{max-width:100%;height:auto}
.table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
.table-wrap table{min-width:680px}

/* Чтобы контент и футер не перекрывались фикс-панелью */
@media (max-width: 991.98px) {
  body {
    padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0));
  }
}

/* высота строки поиска будет подставляться из JS */
:root { --search-h: 56px; }

/* Поиск «липнет» к верху экрана (основной режим) */
@media (max-width: 991.98px) {
  .m-header__search {
    position: sticky;
    top: 0; /* либо: top: env(safe-area-inset-top, 0); */
    z-index: 1040;
    box-shadow: 0 1px 0 rgba(0,0,0,.06);
    backdrop-filter: saturate(180%) blur(4px);
  }


  /* Сам поиск в fixed-режиме */
  body.js-fixed-search .m-header__search {
    position: fixed;
    top: env(safe-area-inset-top, 0); left: 0; right: 0;
  }

  /* Спейсер, компенсирующий высоту fixed-поиска (вставлен в шаблоне) */
  .m-header__search-spacer { display: none; height: var(--search-h); }
  body.js-fixed-search .m-header__search-spacer { display: block; }
 }


.sale-badge-mobile {
  position: absolute;
  top: 0px;
  right: 0px;
  width: 40px;      /* немного меньше, чем на десктопе */
  height: auto;
  z-index: 10;
  pointer-events: none;

  /* сбрасываем стили изображений товаров */
  object-fit: unset !important;
  aspect-ratio: unset !important;
  width: 36px !important;
  height: auto !important;
  padding: 0 !important;
}