/* ============================================================
   PKmotors — Мобильная адаптация
   ============================================================
   Все правила здесь — внутри @media (max-width: 768px) или уже,
   чтобы НЕ затрагивать десктопную вёрстку.

   Структура (контролируется Dev'ом каждой секции):
     [Dev 1] Foundation — viewport, drawer, hamburger, dock-hide, touch-targets
     [Dev 2] Catalog — filters sheet, toolbar, lrow, map
     [Dev 3] Detail / Reports / Compare — gallery, bottom-bar, sticky-label
     [Dev 4] Home / Profile / Chat / Create — hero, profile-stats, chat list⇄thread, stepper
     [Dev 5] B2B / B2B-onboarding — kpi, orders, tiers, hero
   ============================================================ */


/* ============================================================
   [Dev 1] FOUNDATION
   ============================================================ */

/* По умолчанию (десктоп) hamburger и mobile-only элементы скрыты */
.hamburger-btn,
.topbar-search-btn { display: none; }
.mobile-bottom-bar { display: none; }
.mobile-bottom-nav { display: none; }
.mobile-only { display: none; }
.detail-bottom-bar { display: none; }
.thread-back-btn { display: none; }
/* Drawer — НЕ display:none, чтобы анимация transform работала.
   Используем visibility+delay (transition delay только при close) для
   полной блокировки pointer-events во время и после анимации. */
.mobile-drawer-root {
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s linear 0.3s;
}
.mobile-drawer-root.is-open {
  visibility: visible;
  pointer-events: auto;
  transition: visibility 0s linear 0s;
}
.mobile-drawer-root * { pointer-events: inherit; } /* блокировать все клики на скрытом дереве */
@media (min-width: 769px) {
  /* На десктопе drawer вообще убираем из tab-order */
  .mobile-drawer-root { display: none !important; }
}

/* Кнопка «Фильтры» — на десктопе скрыта (sidebar виден всегда) */
.filters-btn { display: none; }
.filters-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: var(--r-pill);
  background: var(--brand-500);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 768px) {
  /* ── App shell ─────────────────────────────────────────── */
  .app {
    height: 100dvh;
    height: 100vh;
    grid-template-rows: 56px 1fr;
  }
  .main-scroll {
    padding: 16px 14px calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .main-scroll::-webkit-scrollbar { width: 0; }

  /* ── TopBar — компактный мобильный режим ───────────────── */
  .topbar { padding: 8px 10px 0; }
  .topbar-inner {
    height: 52px;
    padding: 0 6px;
    gap: 6px;
  }
  .menubar { display: none; }
  .topbar-search {
    /* большой search скрыт; вместо него — иконка-кнопка */
    display: none;
  }
  .hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: var(--r-pill);
  }
  .topbar-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: var(--r-pill);
    margin-left: auto;
  }
  .brand-name { display: none; }
  .topbar-tools { gap: 4px; margin-left: 0; }
  .topbar-theme-btn,
  .topbar-bell-btn { width: 40px; height: 40px; }
  .topbar-cta {
    height: 40px;
    padding: 0 12px;
  }
  .topbar-cta-label { display: none; }
  .avatar { width: 36px; height: 36px; font-size: 12px; }

  /* ── Dock — скрыть, навигация переезжает в drawer ──────── */
  .dock-wrap { display: none; }

  /* ── TweaksPanel — скрыть на мобиле (это инструмент) ──── */
  .twk-panel,
  .twk-fab { display: none !important; }

  /* ── Touch-targets ─────────────────────────────────────── */
  .icon-btn {
    min-width: var(--touch-min);
    min-height: var(--touch-min);
  }
  .chip {
    min-height: 32px;        /* чуть больше для тача, но не 44 (визуально слишком грубо) */
    padding: 0 12px;
    font-size: 13px;
  }
  .card-fav {
    width: 40px; height: 40px;
    top: 8px; right: 8px;
  }
  .btn-sm {
    min-height: 36px;
    padding: 0 14px;
    font-size: 13px;
  }

  /* ── Section spacing ───────────────────────────────────── */
  .section { margin-top: 32px; }
  .section-head {
    margin-bottom: 14px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .section-head .h-title { font-size: 22px !important; }
  /* Filter-chips в section-head — горизонтальный scroll */
  .section-head .row {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin: 0 -14px;
    padding: 4px 14px;
  }
  .section-head .row::-webkit-scrollbar { display: none; }
  .section-head .chip { flex-shrink: 0; scroll-snap-align: start; }
}

/* ── Глобальные fix-ы для мобильного контента ──────────── */
@media (max-width: 768px) {
  /* Запрещаем горизонтальный overflow в принципе — никаких "обрезаний по краям" */
  html, body { overflow-x: hidden; }
  /* Заголовки — нормальный wrap по пробелам, длинные слова — ломать */
  h1, h2, h3, .h-display, .h-title, .h-section {
    overflow-wrap: break-word;
    word-break: normal;
    white-space: normal;
    /* Критично: min-width:0 чтобы flex/grid не расширялись под контент */
    min-width: 0;
  }
  /* card-title в карточках товаров — длинные модели */
  .card-title { overflow-wrap: anywhere; }
  /* Контейнеры grid/flex/block — запрещаем расширяться под детей */
  .screen, .screen > div, .hero, .hero-text, .b2b-hero, .b2b-hero-content,
  .detail-grid, .detail-main, .detail-side, .catalog, .create-body,
  .chat-grid, .chat-list, .chat-thread, .compare-table,
  .b2b-header, .b2b-id, .b2b-mgr,
  .profile-head, .profile-head .flex-1 {
    min-width: 0;
  }
  /* Кнопки на мобиле должны нормально переносить или сжиматься */
  .btn { white-space: normal; line-height: 1.2; }
  .btn-lg { padding: 0 16px; }
  /* Защита от длинных непереносимых строк */
  .screen { max-width: 100%; min-width: 0; }
  /* Контент растягивается под viewport. 56px topbar + 16px padding-top = 72px. */
  .screen.home,
  .screen.catalog,
  .screen.detail,
  .screen.create,
  .screen.profile,
  .screen.chat,
  .screen.compare,
  .screen.b2b,
  .screen.b2b-onboarding {
    min-height: calc(100dvh - 96px);
    min-height: calc(100vh - 96px);
  }

  /* Inline fontSize в JSX — задавлены через !important на мобиле.
     Это позволяет не править все экраны вручную, а централизованно
     ужимать заголовки. */
  .hero h1.h-display { font-size: 32px !important; line-height: 1.05 !important; }
  .b2b-hero h1.h-display,
  .b2b-onboarding .b2b-hero h1.h-display { font-size: 28px !important; line-height: 1.1 !important; }
  .screen.create .h-display,
  .create-head .h-display { font-size: 26px !important; }
  .screen.profile .profile-head h1.h-display { font-size: 24px !important; }
  .screen.compare h1.h-display,
  .compare-head h1.h-display { font-size: 26px !important; }
  .screen.b2b .b2b-header h1.h-display,
  .screen.b2b .b2b-id h1.h-display { font-size: 22px !important; }
}

@media (max-width: 380px) {
  .hero h1.h-display { font-size: 28px !important; }
  .b2b-hero h1.h-display { font-size: 24px !important; }
}

/* ── Mobile Drawer (slide-in слева) ────────────────────────
   Стили существуют всегда (не в media), чтобы анимация
   transform работала. visibility/pointer-events управляются
   из foundation-блока выше. */
.mobile-drawer-root {
  position: fixed; inset: 0;
  z-index: 100;
}
.mobile-drawer-overlay {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.mobile-drawer-root.is-open .mobile-drawer-overlay { opacity: 1; }
.mobile-drawer {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: min(82vw, 340px);
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  border-radius: 0 var(--r-2xl) var(--r-2xl) 0;
  display: flex; flex-direction: column; gap: 14px;
  transform: translateX(-110%);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.mobile-drawer-root.is-open .mobile-drawer { transform: translateX(0); }

.mobile-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 0.5px solid var(--stroke-1);
}
.mobile-drawer-nav {
  display: flex; flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  margin: 4px -6px;
  padding: 0 6px;
}
.mobile-drawer-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 14px 12px;
  border: 0; background: transparent;
  border-radius: var(--r-md);
  font-size: 15px; font-weight: 500;
  color: var(--fg);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.mobile-drawer-item:hover { background: var(--glass-1); }
.mobile-drawer-item.is-active { background: var(--glass-2); color: var(--brand-500); }
.mobile-drawer-item.is-active .mobile-drawer-chev { opacity: 0; }
.mobile-drawer-item > svg:first-child { color: var(--fg-muted); flex-shrink: 0; }
.mobile-drawer-item.is-active > svg:first-child { color: var(--brand-500); }
.mobile-drawer-item > span:nth-child(2) { flex: 1; }
.mobile-drawer-chev { transition: opacity 0.12s; }
.mobile-drawer-cta { width: 100%; height: 48px; font-size: 14px; }
.mobile-drawer-foot {
  display: flex; flex-direction: column; gap: 12px;
  padding-top: 12px;
  border-top: 0.5px solid var(--stroke-1);
}
.mobile-drawer-theme {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: 0.5px solid var(--stroke-1);
  background: var(--glass-1);
  color: var(--fg);
  border-radius: var(--r-md);
  font-size: 13px;
  cursor: pointer;
}
.mobile-drawer-theme:hover { background: var(--glass-2); }
.mobile-drawer-contacts {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px;
  padding-left: 4px;
}


/* ============================================================
   [Dev 2] CATALOG — bottom-sheet, toolbar, lrow, map
   ============================================================ */

@media (max-width: 768px) {
  /* Главный grid → 1 колонка, sidebar убираем (фильтры в sheet) */
  .catalog { grid-template-columns: 1fr; gap: 12px; }
  .catalog .sidebar { display: none; }

  .catalog-toolbar {
    position: sticky; top: 8px;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 12px;
  }
  .catalog-toolbar .toolbar-count { flex: 1 1 100%; font-size: 13px; }
  .catalog-toolbar .toolbar-actions {
    display: flex; gap: 8px; width: 100%; align-items: center;
  }
  .catalog-toolbar .filters-btn {
    display: inline-flex !important;
    flex: 1;
    height: 40px;
    align-items: center; justify-content: center; gap: 8px;
  }
  .catalog-toolbar .select { width: auto; flex: 1; min-width: 0; height: 40px; }
  .catalog-toolbar .seg-toggle { display: none; } /* layout всегда grid на мобиле */

  /* Grid карточек — на мобиле одна колонка */
  .grid-cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* ── Listing card: 2 блока ────────────────────────────────
     Block 1 (top): photo (left) + info (right, title/price/meta)
     Block 2 (bottom): локация + действия + tags
  */
  .grid-cards .card {
    display: grid;
    grid-template-columns: 132px 1fr;
    grid-template-areas:
      "photo info"
      "bottom bottom";
    gap: 0;
    overflow: hidden;
  }
  .grid-cards .card-photo {
    grid-area: photo;
    aspect-ratio: 4 / 3;
    height: auto;
    border-radius: 0;
  }
  .grid-cards .card-body {
    display: contents;
  }
  .grid-cards .card-info {
    grid-area: info;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    align-self: stretch;
  }
  .grid-cards .card-bottom {
    grid-area: bottom;
    padding: 10px 14px 12px;
    border-top: 0.5px solid var(--stroke-1);
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .grid-cards .card-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .grid-cards .card-title {
    font-size: 14px;
    line-height: 1.2;
    margin: 0;
  }
  .grid-cards .card-price {
    font-size: 15px;
    line-height: 1.1;
    white-space: nowrap;
  }
  .grid-cards .card-meta {
    font-size: 11px;
    gap: 3px;
  }
  .grid-cards .card-foot {
    font-size: 12px;
  }
  .grid-cards .card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 6px;
  }
  .grid-cards .card-tag-chip {
    font-size: 11px;
    height: 24px;
    padding: 0 8px;
    background: var(--glass-2);
    border: 0.5px solid var(--stroke-1);
    color: var(--fg-muted);
  }
  .grid-cards .card-actions {
    padding-top: 8px;
    border-top: 0.5px solid var(--stroke-1);
    margin-top: 0;
  }
  .grid-cards .card-fav {
    width: 32px; height: 32px;
    top: 6px; right: 6px;
  }
  .grid-cards .card-tag {
    top: 6px; left: 6px;
    font-size: 10px;
    padding: 3px 8px;
  }
  .grid-cards .card-pager { display: none; } /* пагинатор не помещается на маленькой фотке */

  /* List view */
  .lrow {
    grid-template-columns: 110px 1fr;
    gap: 12px;
    padding: 10px;
  }
  .lrow-photo { min-height: 90px; }
  .lrow-side { display: none; } /* действия переезжают в lrow-foot */
  .lrow-head { gap: 6px; }
  .lrow-head .card-title { font-size: 14px; }
  .lrow-head .card-price { font-size: 14px; }
  .lrow-foot { font-size: 11px; gap: 8px; }

  /* Map view → переключатель list/map (skip — карта в десктоп-варианте) */
  .map-wrap {
    grid-template-columns: 1fr;
    height: auto;
    gap: 12px;
  }
  .map-canvas { height: 60dvh; min-height: 360px; }
  .map-side { max-height: none; }
}

@media (max-width: 480px) {
  .catalog-toolbar { padding: 8px 10px; }
  .catalog-toolbar .toolbar-actions { flex-wrap: wrap; }
  .catalog-toolbar .select { flex: 1 1 100%; }
}

/* ── Filters fullscreen-sheet (Velocity Liquid Glass) ───── */
.filters-sheet-root {
  position: fixed; inset: 0;
  z-index: 95;
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s linear 0.32s;
}
.filters-sheet-root.is-open {
  visibility: visible;
  pointer-events: auto;
  transition: visibility 0s linear 0s;
}
.filters-sheet-root * { pointer-events: inherit; }
.filters-sheet-overlay {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.42);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.filters-sheet-root.is-open .filters-sheet-overlay { opacity: 1; }
.filters-sheet {
  position: absolute;
  /* Fullscreen sheet с верхними скруглениями (как в drawer) */
  left: 0; right: 0; top: 14px; bottom: 0;
  display: flex; flex-direction: column;
  padding: 0;
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  overflow: hidden;
  /* Liquid Glass: непрозрачный mesh-фон + sheen + blur */
  background:
    radial-gradient(80% 60% at 50% -10%, var(--mesh-a) 0%, transparent 65%),
    radial-gradient(70% 60% at 100% 50%, var(--mesh-d) 0%, transparent 70%),
    radial-gradient(70% 60% at 0% 100%, var(--mesh-c) 0%, transparent 70%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--mesh-e) 100%);
  border: 0;
  box-shadow: inset 0 0.5px 0 var(--sheen);
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  overscroll-behavior: contain;
}
.filters-sheet-root.is-open .filters-sheet { transform: translateY(0); }
.filters-sheet-grip {
  display: block;
  align-self: center;
  width: 36px; height: 4px;
  margin: 8px 0 0;
  border-radius: 2px;
  background: var(--fg-ghost);
  flex-shrink: 0;
}
.filters-sheet-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px 14px;
  border-bottom: 0.5px solid var(--stroke-1);
  flex-shrink: 0;
  background: var(--glass-1);
  -webkit-backdrop-filter: blur(var(--blur-2)) saturate(180%);
  backdrop-filter: blur(var(--blur-2)) saturate(180%);
}
.filters-sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 24px;
  display: flex; flex-direction: column; gap: 20px;
  -webkit-overflow-scrolling: touch;
}
/* Внутри sheet'а sidebar-head лишний (есть собственный head'ер) */
.filters-sheet-body .sidebar-head { display: none; }
/* Filter-group в sheet'е — оборачиваем в стеклянную карточку для Velocity-стиля */
.filters-sheet-body .filter-group {
  padding: 14px;
  border-radius: var(--r-lg);
  background: var(--glass-1);
  -webkit-backdrop-filter: blur(var(--blur-1)) saturate(160%);
  backdrop-filter: blur(var(--blur-1)) saturate(160%);
  border: 0.5px solid var(--stroke-1);
  gap: 10px;
}
.filters-sheet-body .filter-label { font-size: 11px; }
.filters-sheet-foot {
  display: flex; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 0.5px solid var(--stroke-1);
  flex-shrink: 0;
  background: var(--glass-2);
  -webkit-backdrop-filter: blur(var(--blur-3)) saturate(200%);
  backdrop-filter: blur(var(--blur-3)) saturate(200%);
}
.filters-sheet-foot .btn { flex: 1; height: 48px; }
.filters-sheet-foot .btn-primary { flex: 2; }

@media (min-width: 769px) {
  .filters-sheet-root { display: none !important; }
}


/* ============================================================
   [Dev 3] DETAIL / REPORTS / COMPARE
   ============================================================ */

@media (max-width: 768px) {
  /* ── Detail layout ─────────────────────────────────────── */
  .detail-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .detail-side {
    position: static;
    gap: 12px;
  }

  /* Gallery */
  .gallery { padding: 6px; border-radius: var(--r-lg); }
  .gal-main { aspect-ratio: 4 / 3; border-radius: var(--r-md); }
  .gal-nav { width: 44px; height: 44px; font-size: 18px; }
  .gal-prev { left: 8px; } .gal-next { right: 8px; }
  .gal-counter { bottom: 10px; right: 10px; font-size: 11px; padding: 4px 10px; }
  .gal-badge { font-size: 11px; padding: 4px 10px; }
  .gal-thumbs {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  /* Tabs — скролл по горизонтали с padding под последний таб */
  .d-tabs {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding: 4px;
    scrollbar-width: none;
  }
  .d-tabs::-webkit-scrollbar { display: none; }
  .d-tab {
    flex-shrink: 0;
    scroll-snap-align: start;
    padding: 8px 14px;
    font-size: 13px;
    white-space: nowrap;
  }

  /* Tab content */
  .d-card { padding: 14px; }
  .specs-grid { grid-template-columns: 1fr; gap: 4px 0; }
  .credit-grid { grid-template-columns: 1fr; gap: 14px; }
  .credit-result { padding: 14px; flex-direction: column; align-items: flex-start; gap: 6px; }
  .seller-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px; }
  .vin-box { flex-direction: column; align-items: flex-start; gap: 6px; }

  /* Detail bottom-bar — sticky CTA снизу.
     Не используем position: fixed: предок .screen.detail имеет
     transform от .fade-up, что создаёт containing block для fixed.
     Sticky + явный negative margin даёт fullbleed на всю ширину. */
  .detail-bottom-bar {
    display: flex !important;
    align-items: center;
    gap: 10px;
    position: sticky;
    bottom: 0;
    margin: 16px -14px calc(-1 * (96px + env(safe-area-inset-bottom, 0px)));
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-1);
    border-top: 0.5px solid var(--stroke-2);
    z-index: 30;
  }
  .detail-bottom-bar .dbb-price {
    display: flex; flex-direction: column;
    line-height: 1.05;
    flex-shrink: 0;
    min-width: 0;
    max-width: 38%;
  }
  .detail-bottom-bar .dbb-price-num {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.02em;
    white-space: nowrap;
  }
  .detail-bottom-bar .dbb-price-byn {
    font-size: 10px;
    color: var(--fg-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .detail-bottom-bar .dbb-cta {
    flex: 1;
    min-width: 0;
    height: 46px;
    padding: 0 12px;
    font-size: 14px;
    white-space: nowrap;
  }
  .detail-bottom-bar .dbb-icon {
    width: 44px; height: 44px;
    flex-shrink: 0;
    border-radius: var(--r-pill);
    display: flex; align-items: center; justify-content: center;
    background: var(--glass-1);
    border: 0.5px solid var(--stroke-2);
    color: var(--fg);
  }
  /* нижний padding для экрана detail, чтобы bottom-bar не перекрывал контент */
  .screen.detail {
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  }

  /* ── Compare — улучшенная мобильная раскладка ─────────── */
  .compare-head { flex-direction: column; align-items: flex-start; gap: 4px; margin-bottom: 16px; }
  .compare-table {
    --comp-label-w: 110px;
    padding: 12px 0;
    border-radius: var(--r-lg);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* красивый кастомный scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--fg-ghost) transparent;
  }
  .comp-grid {
    min-width: 100%;
    gap: 0 12px;
  }
  /* Sticky label-колонка слева */
  .comp-row-label,
  .comp-h:first-child,
  .comp-h-cell:first-child {
    position: sticky; left: 0;
    background: var(--bg-1);
    padding: 10px 10px 10px 14px !important;
    z-index: 2;
    box-shadow: 1px 0 0 var(--stroke-1);
    font-size: 10px !important;
    letter-spacing: 0.04em;
  }
  /* Карточка авто в header */
  .comp-h-cell {
    padding: 0 4px 14px;
  }
  .comp-h-cell .comp-photo {
    aspect-ratio: 4/3;
    border-radius: var(--r-sm);
    margin-bottom: 8px;
  }
  .comp-h-cell .comp-remove {
    width: 22px; height: 22px;
    top: 6px; right: 6px;
  }
  .comp-h-cell .card-title { font-size: 12px !important; line-height: 1.2; margin-top: 6px !important; }
  .comp-h-cell .h-display { font-size: 15px !important; line-height: 1.05; white-space: nowrap; margin-top: 4px !important; }
  /* Ячейки — компактные */
  .comp-row-cell {
    padding: 10px 6px !important;
    font-size: 12px;
    line-height: 1.3;
    word-break: break-word;
    overflow-wrap: anywhere;
    align-items: flex-start;
  }
  .comp-row-cell.is-best { font-size: 12px; }
  .best-badge { font-size: 10px; }
}

@media (max-width: 480px) {
  .gal-thumbs { grid-template-columns: repeat(3, 1fr); }
  .seller-stats { grid-template-columns: 1fr; gap: 6px; }
}


/* ============================================================
   [Dev 4] HOME / PROFILE / CHAT / CREATE
   ============================================================ */

@media (max-width: 768px) {
  /* ── Home: hero ────────────────────────────────────────── */
  .hero {
    grid-template-columns: 1fr;
    gap: 20px;
    min-height: auto;
    padding-top: 4px;
  }
  .hero-deck { display: none; }
  .hero-text { max-width: 100%; }
  .hero h1.h-display { font-size: clamp(28px, 8.5vw, 44px); line-height: 1.05; letter-spacing: -0.025em; }
  .hero p { font-size: 14px; line-height: 1.5; }
  .hero-search { padding: 12px; margin-top: 16px; border-radius: var(--r-xl); }

  .hsearch-tabs {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .hsearch-tabs::-webkit-scrollbar { display: none; }
  .hsearch-tab { flex-shrink: 0; scroll-snap-align: start; padding: 8px 14px; }
  .hsearch-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .hsearch-field { min-width: 0; }
  .hsearch-field label { font-size: 10px; }
  .hsearch-field .input,
  .hsearch-field .select { width: 100%; min-width: 0; height: 40px; font-size: 13px; }
  .hsearch-go {
    grid-column: 1 / -1;
    height: 46px;
    width: 100%;
  }

  /* Categories — 2col на мобиле, чтобы текст помещался */
  .cat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cat-card {
    min-width: 0;
    min-height: 96px;
    padding: 12px;
  }
  .cat-icon { font-size: 24px; }
  .cat-name { font-size: 13px; word-break: break-word; }
  .cat-count { font-size: 11px; }

  /* Trust */
  .trust { grid-template-columns: 1fr; gap: 12px; margin-top: 32px; }
  .trust-card { padding: 14px; gap: 12px; }

  /* Footer — компактная мобильная версия */
  .footer { margin-top: 32px; padding-bottom: 16px; }
  .footer-top {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 16px;
    margin-bottom: 20px;
    border-radius: var(--r-xl);
  }
  .footer-cta .h-title { font-size: 18px !important; }
  .footer-cta .t-mute { font-size: 13px !important; }
  .footer-cta-actions { flex-direction: column; align-items: stretch; gap: 8px; }
  .footer-cta-actions .btn { width: 100%; height: 42px; }
  .footer-phone { width: 100%; padding: 8px 14px; }
  .footer-phone .h-title { font-size: 18px !important; letter-spacing: -0.01em; }
  /* Грид колонок: 2col на мобиле для экономии места */
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 18px 16px;
    padding: 0 4px 18px;
  }
  /* Brand-col — на всю ширину */
  .footer-brand-col {
    grid-column: 1 / -1;
    padding-bottom: 12px;
    border-bottom: 0.5px solid var(--stroke-1);
    margin-bottom: 4px;
  }
  .footer-brand-col p {
    font-size: 12px !important;
    margin-top: 10px !important;
    max-width: 100% !important;
  }
  .footer-social { margin-top: 12px; gap: 6px; }
  .footer-soc-btn { width: 32px; height: 32px; }
  .footer-col-title { font-size: 10px; margin-bottom: 8px; }
  .footer-col ul { gap: 6px; }
  .footer-col a { font-size: 12px; }
  .footer-bottom {
    padding: 14px 4px 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .footer-bottom > .t-faint { font-size: 11px !important; }
  .footer-bottom-links {
    flex-wrap: wrap;
    gap: 8px 14px;
    width: 100%;
  }
  .footer-bottom-links a { font-size: 11px; }
  .footer-lang { align-self: flex-start; }
}

@media (max-width: 380px) {
  .footer-grid { grid-template-columns: 1fr; gap: 14px; }
  .footer-brand-col { padding-bottom: 8px; }
}

@media (max-width: 768px) {
  /* ── Profile ───────────────────────────────────────────── */
  .profile-head {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px 16px;
    gap: 12px;
  }
  .profile-head .flex-1 {
    text-align: center; width: 100%;
    display: flex; flex-direction: column; align-items: center;
    gap: 6px;
  }
  .profile-head .row {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 10px;
  }
  .profile-head h1, .profile-head .h-display {
    font-size: 22px; line-height: 1.15;
  }
  .profile-avatar { width: 76px; height: 76px; font-size: 28px; }
  .profile-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
  .pstat { padding: 14px; }
  .pstat-num { font-size: 24px; }
  .pstat-label { font-size: 11px; word-break: break-word; }
  .my-stats { grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 10px; font-size: 11px; }
  .search-row { flex-wrap: wrap; gap: 8px; padding: 12px; }
  .d-tabs { width: 100%; }

  /* ── Chat — list⇄thread на мобиле ──────────────────────── */
  .chat-grid {
    grid-template-columns: 1fr;
    height: calc(100dvh - 140px);
    border-radius: var(--r-lg);
  }
  .chat-grid.show-thread .chat-list { display: none; }
  .chat-grid.show-list .chat-thread { display: none; }
  .chat-list { border-right: 0; }
  .thread-back-btn {
    display: inline-flex !important;
    align-items: center; justify-content: center;
    width: 36px; height: 36px;
    border-radius: var(--r-pill);
    background: transparent;
    border: 0;
    color: var(--fg);
    margin-right: 4px;
  }
  .thread-back-btn:hover { background: var(--glass-1); }
  .thread-listing-pin { margin: 8px 12px; padding: 8px; }
  .pin-photo { width: 56px; height: 44px; }
  .thread-msgs { padding: 12px; gap: 10px; }
  .msg { max-width: 85%; }
  .thread-input {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    gap: 6px;
  }

  /* ── Create ────────────────────────────────────────────── */
  .screen.create { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .create-body {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .create-form { padding: 18px 18px 24px; border-radius: var(--r-lg); }
  .create-preview { display: none; } /* preview не нужен на мобиле */
  .create-head { flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 14px; }
  .create-head .h-display { font-size: 28px; line-height: 1.1; }

  /* Stepper — компактная версия */
  .stepper {
    padding: 10px 12px;
    margin-bottom: 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .stepper::-webkit-scrollbar { display: none; }
  .step { flex: 0 0 auto; gap: 6px; padding-right: 6px; }
  .step + .step::before { display: none; }
  .step .step-label { font-size: 12px; }
  .step:not(.is-on) .step-label { display: none; }
  .step-dot { width: 24px; height: 24px; font-size: 11px; }

  .cat-pick { grid-template-columns: 1fr; gap: 8px; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .photo-up,
  .photo-slot { min-width: 0; }

  /* form-nav sticky-bottom — fixed не работает из-за transform на предке.
     Sticky bottom внутри .create-form контейнера прилипает к низу viewport
     при скролле, и обычно отображается в потоке внизу. */
  .form-nav {
    position: sticky;
    bottom: 0;
    margin: 24px -18px -24px;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-1);
    border-top: 0.5px solid var(--stroke-2);
    z-index: 25;
    gap: 10px;
  }
  .form-nav .btn {
    flex: 1;
    min-width: 0;
    height: 46px;
    font-size: 14px;
  }
  .form-nav .btn.btn-primary { flex: 1.5; }
  .form-nav .btn-lg { padding: 0 14px; }
}

@media (max-width: 480px) {
  .photo-grid { grid-template-columns: 1fr; }
  .my-stats { grid-template-columns: 1fr; gap: 4px; }
}


/* ============================================================
   [Dev 5] B2B / B2B-ONBOARDING
   ============================================================ */

@media (max-width: 768px) {
  /* ── B2B Cabinet ───────────────────────────────────────── */
  .screen.b2b { padding: 14px 14px 80px; gap: 12px; }
  .b2b-header {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 18px 16px;
  }
  .b2b-id { gap: 8px; }
  .b2b-id h1, .b2b-id .h-display, .b2b-id h2 {
    font-size: 22px; line-height: 1.15; letter-spacing: -0.015em;
  }
  .b2b-id .row, .b2b-tier-row { flex-wrap: wrap; gap: 8px; }
  .b2b-mgr { text-align: left; }
  .b2b-mgr .row { flex-wrap: wrap; gap: 8px; }
  .b2b-mgr .btn { flex: 1; min-width: 100px; height: 42px; }
  .b2b-kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .b2b-kpi { padding: 14px; }

  .b2b-credit {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px;
  }
  .b2b-credit-bar { width: 100%; }

  .b2b-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scroll-snap-type: x proximity;
    width: 100%;
    scrollbar-width: none;
  }
  .b2b-tabs::-webkit-scrollbar { display: none; }
  .b2b-tabs .b2b-tab { flex-shrink: 0; scroll-snap-align: start; }

  .b2b-filter { flex-wrap: wrap; gap: 8px; }
  .b2b-filter .b2b-spacer { display: none; }

  /* Order row → стек на мобиле */
  .b2b-order-main {
    grid-template-columns: 80px 1fr;
    gap: 10px;
    padding: 10px;
  }
  .b2b-order-photo { width: 80px; height: 60px; }
  .b2b-order-info { min-width: 0; }
  .b2b-order-status { grid-column: 2; justify-self: start; font-size: 11px; }
  .b2b-order-total { grid-column: 1 / -1; font-size: 14px; padding-top: 8px; border-top: 0.5px solid var(--stroke-1); }
  .b2b-order-toggle { position: absolute; top: 10px; right: 10px; }
  .b2b-order { position: relative; }
  .b2b-order-detail { padding: 12px; }
  .b2b-detail-grid { grid-template-columns: 1fr; gap: 12px; }
  .b2b-pricerow { font-size: 12px; gap: 8px; }
  .b2b-tracker { gap: 8px; }
  .b2b-tracker-stages { font-size: 11px; }

  /* Pricing & rates tables → горизонтальный scroll-обёртка */
  .b2b-pricing-tiers { grid-template-columns: 1fr; gap: 10px; }
  .b2b-vat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .b2b-new-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .b2b-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--r-md);
  }
  .b2b-table { min-width: 560px; }
  .b2b-rates { min-width: 560px; }

  /* Analytics */
  .b2b-analytics { grid-template-columns: 1fr; gap: 14px; }
  .b2b-bars { gap: 6px; }
  .b2b-bar-col { min-width: 28px; }

  /* ── B2B Onboarding ────────────────────────────────────── */
  .screen.b2b-onboarding { padding: 14px 14px 80px; }
  .b2b-hero {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 22px 16px;
  }
  .b2b-hero-content h1,
  .b2b-hero h1 {
    font-size: clamp(24px, 7vw, 36px);
    line-height: 1.1;
    letter-spacing: -0.02em;
  }
  .b2b-hero-content p,
  .b2b-hero p { font-size: 13px; line-height: 1.5; }
  .b2b-hero-art { display: none; }
  .b2b-hero-stats {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px 18px;
    align-items: flex-start;
  }
  .b2b-hero-stats > * + *::before { display: none; }
  .b2b-hero-cta,
  .b2b-hero-actions,
  .b2b-hero-content .row {
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }
  .b2b-hero .btn,
  .b2b-hero-cta .btn,
  .b2b-hero-actions .btn {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    font-size: 14px;
    white-space: normal;
  }

  .b2b-benefits { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .b2b-benefit { padding: 14px; }

  .b2b-onb-tiers { padding: 14px; overflow: hidden; }
  .b2b-tiers-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -14px;
    padding: 0 14px;
  }
  .b2b-tiers-table { min-width: 720px; }

  .b2b-form { padding: 18px; }
  .b2b-stepper {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .b2b-stepper .b2b-step + .b2b-step { margin-top: 4px; }
  .b2b-form-grid { grid-template-columns: 1fr; gap: 12px; }
  .b2b-radios { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .b2b-radios-3 { grid-template-columns: 1fr; gap: 8px; }
  .b2b-form-nav { flex-direction: column-reverse; gap: 10px; }
  .b2b-form-nav .btn { width: 100%; height: 46px; }

  .b2b-faq { padding: 14px; }
  .b2b-faq-item { padding: 12px; }

  .b2b-submitted-card { padding: 24px 18px; }
}

@media (max-width: 480px) {
  .b2b-kpis { grid-template-columns: 1fr; }
  .b2b-benefits { grid-template-columns: 1fr; }
  .b2b-vat-grid,
  .b2b-new-grid { grid-template-columns: 1fr; }
}
