/* АвтоКамДеталь — панель. Общие стили. */

:root {
  /* Явно говорим браузеру, что страница светлая — иначе Android/Chrome
     на телефоне сам «затемняет» (force dark / «тёмная тема для сайтов»)
     и инвертирует наши собственные цвета вперемешку, из-за чего текст на
     некоторых фонах сливается (так и было с артикулом на подложке). */
  color-scheme: light;
  --bg: #F5F3EE;
  --surface: #FFFFFF;
  --border: #E4E1D8;
  --border-soft: #EFEDE6;
  --dark: #1B1D21;
  --dark-2: #2A2C31;
  --dark-3: #33353A;

  --text: #1B1D21;
  /* Серые тона сделаны заметно темнее для читаемости (были #8A8375/#9A9484/#B7B0A0) */
  --text-secondary: #635D4E;
  --text-muted: #726C5C;
  --text-faint: #8B8474;
  --text-on-dark: #FFFFFF;
  --text-on-dark-muted: #C9C4B8;

  --accent: #E1483F;
  --accent-tint: #FBE0DD;
  --green: #2F8F5B;
  --green-tint: #DCEEE3;
  --blue: #3B4FA0;
  --blue-tint: #E3E7F5;
  --amber: #B7791F;
  --amber-tint: #FCEFD6;
  --purple: #7B4FA0;
  --purple-tint: #EDE3F5;
  --neutral: #4A453B;
  --neutral-tint: #E9E7E3;
  --telegram: #229ED9;

  --radius-lg: 16px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --font-head: 'Manrope', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;

  --header-h: 56px;
  --tabbar-h: 64px;
  --desktop-breakpoint: 900px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

h1, h2, h3, .font-head { font-family: var(--font-head); }

/* ---------- App shell ---------- */

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* pages that are not the dual-layout Home get a centered phone-width
   column on wide screens so the mockup does not stretch full-bleed */
@media (min-width: 560px) {
  .app.centered {
    margin-top: 24px;
    margin-bottom: 24px;
    min-height: calc(100vh - 48px);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 12px 32px rgba(27, 29, 33, 0.06);
  }
}

.topbar {
  height: var(--header-h);
  flex: 0 0 auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}
.topbar .back-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  border-radius: 8px;
}
.topbar .back-btn:hover { background: var(--border-soft); }
.topbar .title {
  font-weight: 700; font-size: 16px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .crumb {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-muted);
}

.brand-bar {
  height: 64px;
  flex: 0 0 auto;
  background: var(--dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.brand-bar .brand {
  display: flex; align-items: center; gap: 9px;
}
.brand-bar .brand img { width: 26px; height: 26px; object-fit: contain; }
.brand-bar .brand span {
  font-family: var(--font-head); font-weight: 700; font-size: 15px; color: #fff;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 700; font-size: 12px; color: #fff;
  flex: 0 0 auto;
}

.content {
  flex: 1 1 auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}
.content.tight { padding: 20px; gap: 18px; }

.section-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-muted);
}

/* ---------- Поиск товара по названию/артикулу (все страницы Корзины) ----------
   ВАЖНО: на страницах-списках (Корзина, подкатегории) .content сам ничего не
   скроллит (ему некуда — он всегда ровно по размеру своего содержимого,
   реально скроллится вся страница), но у него `overflow-y:auto` в базовом
   классе — а для position:sticky это ВСЁ РАВНО делает его «ближайшим
   скролл-контейнером», даже без фактического скролла внутри. Поэтому если
   положить поиск ВНУТРЬ .content, sticky будет считать отступы от границ
   .content, а не от окна — и при реальной прокрутке страницы поиск просто
   уедет вместе со списком (проверено). Поэтому в разметке (cart.html,
   cart-subcategory.html) поиск — СОСЕД .content внутри #main-content, не
   его потомок: тогда ближайший настоящий скролл-контейнер — окно браузера,
   как и у .topbar. */
.cart-search-wrap {
  position: sticky;
  top: var(--header-h);
  z-index: 25;
  background: var(--bg);
  padding: 12px 20px 10px;
}
@media (min-width: 900px) {
  /* Десктопная шапка этих двух страниц (.d-topbar) НЕ липкая (в отличие от
     мобильной .topbar) — она просто уедет при скролле, конкурировать не с
     чем, поэтому поиск может прилипать сразу к верху окна. */
  .cart-search-wrap { top: 0; }
}
/* На странице товаров подкатегории (.cart-page) структура другая: поиск —
   не часть скроллящегося .content, а отдельная нескроллящаяся полоса между
   шапкой и хлебной крошкой (как и сама крошка) — там липкость не нужна, он
   и так всегда виден. */
.cart-page [data-cart-search] {
  /* position:relative (а не static) — чтобы оставаться в обычном потоке
     (не sticky, он тут не нужен — полоса и так всегда видна), но при этом
     быть "ближайшим позиционированным родителем" для выпадающего списка
     результатов (.cart-search-results, position:absolute) — без этого он
     отсчитывает позицию от всего документа и улетает далеко за пределы
     экрана (баг: на этой странице выпадающий список не был виден вообще). */
  position: relative;
  /* top:0 — обязательно переопределить: без этого остаётся унаследованный
     "top: var(--header-h)" (56px) из общего правила .cart-search-wrap выше
     (оно писалось под position:sticky, когда отступ сверху был нужен).
     При position:relative "top" всё равно сдвигает блок визуально вниз на
     56px, но место в потоке остаётся зарезервировано на исходной позиции —
     поэтому между крошкой и строкой поиска появлялась пустая полоса высотой
     ровно 56px (баг, обнаружен пользователем на мобильном). */
  top: 0;
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.cart-search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.cart-search-box svg { flex: 0 0 auto; color: var(--text-faint); }
.cart-search-box input {
  border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 14.5px; color: var(--text); width: 100%;
}
.cart-search-box input::placeholder { color: var(--text-faint); }
.cart-search-clear { display: none; border: 0; background: none; color: var(--text-faint); padding: 2px; cursor: pointer; }
.cart-search-wrap.has-text .cart-search-clear { display: flex; }

.cart-search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: 0 12px 30px rgba(0, 0, 0, .18);
  max-height: 340px; overflow-y: auto; z-index: 20; display: none;
}
.cart-search-results.open { display: block; }
.cart-search-result { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--border-soft); }
.cart-search-result:last-child { border-bottom: 0; }
.cart-search-result:hover { background: var(--accent-tint); }
.cart-search-result .r-name { font-size: 13.5px; font-weight: 700; color: var(--text); }
.cart-search-result .r-art { font-size: 12px; color: var(--accent); font-weight: 600; }
.cart-search-result .r-path { font-size: 11px; color: var(--text-faint); }
.cart-search-empty { padding: 14px 12px; font-size: 12.5px; color: var(--text-faint); }

/* ---------- Bottom tab bar (mobile) ---------- */

.tabbar {
  height: var(--tabbar-h);
  flex: 0 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 12px;
}
.tabbar .tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-faint);
  font-size: 10.5px;
  background: none; border: none;
}
.tabbar .tab.active { color: var(--accent); font-weight: 600; }
.tabbar .tab svg { width: 21px; height: 21px; }

/* ---------- Rows / cards ---------- */

.row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.row-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.row-icon.lg { width: 44px; height: 44px; border-radius: 10px; }
.row-body { flex: 1 1 auto; min-width: 0; }
.row-title { font-size: 14.5px; font-weight: 600; }
.row-title.lg { font-size: 15px; }
.row-sub { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }
.row-sub.lg { font-size: 12.5px; }
.chevron { flex: 0 0 auto; color: var(--text-faint); }

.tint-red { background: var(--accent-tint); color: var(--accent); }
.tint-blue { background: var(--blue-tint); color: var(--blue); }
.tint-green { background: var(--green-tint); color: var(--green); }
.tint-amber { background: var(--amber-tint); color: var(--amber); }
.tint-purple { background: var(--purple-tint); color: var(--purple); }
.tint-neutral { background: var(--neutral-tint); color: var(--neutral); }

.doc-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.doc-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.doc-title { font-size: 13px; font-weight: 600; }
.doc-date { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
.badge {
  background: var(--green-tint); color: var(--k2f855a, #2F855A);
  font-size: 10.5px; font-weight: 600;
  padding: 3px 8px; border-radius: 20px;
  white-space: nowrap;
}
.badge.amber { background: var(--amber-tint); color: var(--k9a6a00, #9A6A00); }

/* ---------- Buttons / forms ---------- */

.btn {
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: 15px;
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { opacity: 0.9; }
.btn-outline {
  height: 44px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; color: var(--text-secondary); font-weight: 500; }
.field input {
  height: 46px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
}
.field input:focus { outline: none; border-color: var(--accent); }
.field textarea {
  min-height: 84px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  resize: vertical;
}
.field textarea:focus { outline: none; border-color: var(--accent); }
.field input[type="file"] {
  height: auto;
  padding: 10px 14px;
  font-size: 13.5px;
}
.field-hint { font-size: 11.5px; color: var(--text-faint); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-secondary); }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--accent); }

.option-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center;
  /* .option-card теперь <button>: гасим кнопочные умолчания */
  width: 100%;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color .15s;
}
.option-card:hover { border-color: var(--green); }
.option-icon {
  width: 60px; height: 60px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.option-title { font-family: var(--font-head); font-weight: 700; font-size: 17px; }
.option-sub { font-size: 13px; color: var(--text-secondary); }
.option-card.disabled { opacity: 0.55; cursor: default; }

.sub-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 15px 14px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14.5px; font-weight: 500;
}

/* ---------- Status / notices ---------- */

.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.status-row { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--text-secondary); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.status-note { font-size: 11.5px; color: var(--text-muted); }

.empty-state {
  flex: 1 1 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 0 40px; text-align: center;
}
.empty-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--neutral-tint);
  display: flex; align-items: center; justify-content: center;
}
.empty-title { font-family: var(--font-head); font-weight: 700; font-size: 16px; }
.empty-sub { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* ---------- Cart ---------- */

.item-row { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; }
.item-top { display: flex; align-items: center; gap: 8px; }
.item-name { flex: 1 1 auto; min-width: 0; font-size: 15.5px; font-weight: 700; line-height: 1.3; }
.stepper { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.stepper button {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.stepper .qty { min-width: 16px; text-align: center; font-size: 13.5px; font-weight: 700; }
.item-photo-btn {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent-tint); border: none;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
/* Подложка под названием + артикулом (чтобы в списке товаров сразу
   бросалось в глаза, что именно добавляю в корзину). */
.item-highlight {
  background: var(--accent-tint);
  border-radius: 9px;
  padding: 7px 9px;
  margin-bottom: 2px;
}
.item-highlight .item-top { margin: 0; }
.item-highlight .item-article { color: #6B332C; }

/* Подсветка товара, к которому перешли по клику из поиска (Корзина) —
   прокручиваем к нему и даём короткую пульсацию рамкой в акцентном цвете. */
@keyframes item-row-found-pulse {
  0% { box-shadow: 0 0 0 0 rgba(225, 72, 63, .55); }
  70% { box-shadow: 0 0 0 9px rgba(225, 72, 63, 0); }
  100% { box-shadow: 0 0 0 0 rgba(225, 72, 63, 0); }
}
.item-row-found { animation: item-row-found-pulse 1.1s ease-out 2; border-color: var(--accent); }

.price-table { margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--border-soft); overflow-x: auto; }
.price-table table { width: 100%; font-size: 13.5px; border-collapse: collapse; white-space: nowrap; }
/* Нал/Безнал — по центру своих колонок (заголовок и число выровнены одинаково) */
.price-table th { font-weight: 700; color: var(--text-secondary); padding: 4px 8px; text-align: center; font-size: 13px; }
.price-table td { padding: 4px 8px; text-align: center; font-weight: 700; }
.price-table th:first-child, .price-table td:first-child { text-align: left; padding-left: 0; font-weight: 600; }
.price-table thead .group-title { text-align: center; font-weight: 700; color: var(--neutral); padding-bottom: 4px; }

.cart-bar {
  flex: 0 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.cart-summary { display: flex; align-items: center; gap: 8px; }
.cart-summary [data-cart-count] { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* «Сброс» — полноценная заметная кнопка, а не бледный текст */
.cart-summary .clear-link {
  font-size: 13px; font-weight: 700;
  color: var(--accent);
  background: var(--accent-tint);
  border: 1px solid var(--kf0c4c0, #F0C4C0);
  border-radius: 9px;
  padding: 6px 14px;
  flex: 0 0 auto;
}
.cart-summary .clear-link:hover { background: var(--kf7d2ce, #F7D2CE); }
.cart-bar table { width: 100%; font-size: 13px; border-collapse: collapse; }
.cart-bar table th { text-align: center; font-weight: 600; color: var(--text-muted); padding: 2px 6px; }
.cart-bar table th:first-child, .cart-bar table td:first-child { text-align: left; }
.cart-bar table td { text-align: center; padding: 3px 6px; font-weight: 700; }
.cart-weight { font-size: 12.5px; color: var(--text-muted); }

/* ===== Липкая шапка на всех страницах ===== */
.topbar { position: sticky; top: 0; z-index: 30; }

/* ===== Страница позиций корзины: фикс-высота, чтобы шапка была всегда
   сверху, корзина — снизу (телефон) или сбоку справа (ПК), а прокручивался
   только список товаров ===== */
.app.cart-page { height: 100vh; }
@media (min-width: 560px) {
  .app.centered.cart-page { height: calc(100vh - 48px); }
}
.cart-page .cart-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.cart-page .cart-main > .content { flex: 1 1 auto; min-height: 0; }

/* Телефон: корзина закреплена внизу полосой */
.cart-page .cart-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  max-height: 42vh;
  overflow-y: auto;
}

/* ПК (широкий экран): корзина «плавает» справа отдельной колонкой */
@media (min-width: 900px) {
  .app.centered.cart-page { max-width: 900px; }
  .cart-page .cart-main { flex-direction: row; }
  .cart-page .cart-main > .content { border-right: 1px solid var(--border); }
  .cart-page .cart-bar {
    flex: 0 0 320px;
    width: 320px;
    border-top: none;
    position: sticky;
    top: 0;
    bottom: auto;
    align-self: flex-start;
    max-height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }
  .cart-page .cart-bar > .cart-summary,
  .cart-page .cart-bar > [data-cart-totals],
  .cart-page .cart-bar > .cart-weight,
  .cart-page .cart-bar > .cart-send { flex-shrink: 0; }
}

/* Телефон/планшет: верхнюю полосу (категория + «Домой») и нижнюю корзину
   выделяем отдельным тёплым тоном, чтобы они явно отличались от белых
   карточек товаров и было видно, где список, а где закреплённые полосы. */
@media (max-width: 899.98px) {
  .cart-page .topbar {
    background: var(--keae3d3, #EAE3D3);
    border-bottom: 1px solid var(--kd6cfbe, #D6CFBE);
  }
  .cart-page .cart-bar {
    background: var(--keae3d3, #EAE3D3);
    border-top: 1px solid var(--kd6cfbe, #D6CFBE);
    box-shadow: 0 -3px 10px rgba(60, 50, 25, 0.07);
  }
  /* «шапка-крошки» между полосой и списком — чуть темнее фона, но светлее
     полос, чтобы переход был плавным. */
  .cart-page [data-breadcrumb] {
    background: var(--kf1ece0, #F1ECE0) !important;
    border-bottom-color: var(--kd6cfbe, #D6CFBE) !important;
  }
}

/* ---------- Desktop home (dual layout) ---------- */

.mobile-shell { display: block; }
.desktop-shell { display: none; }

@media (min-width: 900px) {
  body.home-page .app { max-width: none; }
  .mobile-shell { display: none; }
  .desktop-shell { display: flex; }
}

.desktop-shell { width: 100%; min-height: 100vh; background: var(--bg); }
.d-sidebar {
  width: 240px; flex: 0 0 auto;
  background: var(--dark); color: #fff;
  display: flex; flex-direction: column; padding: 24px 18px; gap: 24px;
}
.d-sidebar .brand { display: flex; align-items: center; gap: 10px; }
.d-sidebar .brand img { width: 30px; height: 30px; object-fit: contain; }
.d-sidebar .brand span { font-family: var(--font-head); font-weight: 700; font-size: 15px; }
.d-sidebar .brand-sub { font-size: 11px; color: #948E80; margin-top: 4px; margin-left: 40px; }
.d-nav { display: flex; flex-direction: column; gap: 2px; }
.d-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  font-size: 13.5px; color: var(--text-on-dark-muted);
}
.d-nav a.active { background: var(--dark-2); color: #fff; font-weight: 600; }
.d-nav a.active svg { stroke: var(--accent); }

.d-nav-group { display: flex; flex-direction: column; }
.d-nav-toggle {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  font-size: 13.5px; color: var(--text-on-dark-muted);
  background: none; border: none; width: 100%; text-align: left;
  cursor: pointer; font-family: inherit;
}
.d-nav-toggle:hover { background: var(--dark-2); }
.d-nav-toggle span { flex: 1 1 auto; }
.d-nav-chevron { flex: 0 0 auto; transition: transform 0.15s ease; }
.d-nav-group.open .d-nav-toggle { color: #fff; }
.d-nav-group.open .d-nav-chevron { transform: rotate(90deg); }
.d-nav-sub {
  display: none; flex-direction: column; gap: 1px;
  padding-left: 30px; margin-top: 1px;
}
.d-nav-group.open .d-nav-sub { display: flex; }
.d-nav-sub a {
  padding: 8px 12px; border-radius: 7px;
  font-size: 12.5px; color: var(--text-on-dark-muted);
}
.d-nav-sub a:hover { background: var(--dark-2); color: #fff; }
.d-user {
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding-top: 16px; border-top: 1px solid var(--dark-3);
}
.d-user-name { font-size: 12.5px; font-weight: 600; }
.d-user-role { font-size: 11px; color: #948E80; }

.d-main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.d-topbar {
  height: 64px; flex: 0 0 auto;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 32px;
}
.d-search {
  display: flex; align-items: center; gap: 10px;
  width: 380px; height: 38px; border: 1px solid var(--border); border-radius: 10px;
  padding: 0 12px; background: var(--kfbfaf7, #FBFAF7); color: var(--text-muted); font-size: 13.5px;
}
.d-actions { display: flex; align-items: center; gap: 18px; }
.d-new-btn {
  height: 40px; padding: 0 18px; border-radius: 9px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; font-size: 13.5px; font-weight: 600; border: none;
}
.d-body { flex: 1 1 auto; padding: 28px 32px; display: flex; flex-direction: column; gap: 22px; overflow: auto; }
.d-quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.d-quick-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
}
.d-quick-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.d-table-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; flex: 1 1 auto; display: flex; flex-direction: column; overflow: hidden; }
.d-table-head { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.d-table-head .see-all { font-size: 13px; color: var(--accent); font-weight: 600; }
.d-table { width: 100%; border-collapse: collapse; }
.d-table th {
  text-align: left; padding: 10px 20px; background: var(--kfbfaf7, #FBFAF7);
  font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.d-table td { padding: 13px 20px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; vertical-align: middle; }
.d-table tr:last-child td { border-bottom: none; }
.muted-cell { color: var(--text-faint); }

/* ===== Корзина: выбор поставщика + кнопки отправки в CRM ===== */
.cart-supplier-table { width: 100%; border-collapse: collapse; }
.cart-supplier-table th { text-align: center; font-weight: 600; color: var(--text-muted); padding: 2px 6px; font-size: 12.5px; }
.cart-supplier-table th:nth-child(2), .cart-supplier-table td:nth-child(2) { text-align: left; }
.cart-supplier-table td { text-align: center; padding: 4px 6px; font-weight: 700; font-size: 13px; }
.cart-supplier-radio { width: 26px; }
.cart-supplier-row { cursor: pointer; border-radius: 8px; }
.cart-supplier-row.is-selected { background: var(--keef4ee, #EEF4EE); }
.cart-supplier-row input[type="radio"] { width: 16px; height: 16px; accent-color: #2F8F5B; cursor: pointer; }
/* Строка выбирается тапом целиком — гасим выделение текста, иначе на телефоне
   промах по радио превращался в выделение цены вместо выбора поставщика. */
.cart-supplier-table { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
@media (max-width: 899.98px) {
  .cart-supplier-table td { padding: 9px 6px; }
  .cart-supplier-row input[type="radio"] { width: 20px; height: 20px; }
}

.cart-send { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }

/* Единая кнопка «Отправить» — основной акцентный цвет (var(--accent)), как и
   остальные первичные действия в панели (.btn, «Сброс», выбранный поставщик) —
   чтобы главное действие в корзине не терялось на фоне яркой подложки товаров. */
.cart-send-overview-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border-radius: 12px; border: none;
  background: var(--accent); color: #fff; cursor: pointer;
  font-family: var(--font-head); font-weight: 700; font-size: 14px;
  transition: filter .15s, transform .05s;
}
.cart-send-overview-btn:hover { filter: brightness(0.92); }
.cart-send-overview-btn:active { transform: translateY(1px); }
.cart-send-overview-btn:disabled { opacity: 0.45; cursor: default; }
.cart-send-overview-btn svg { flex-shrink: 0; }
@media (max-width: 899.98px) {
  .cart-send { margin-top: 8px; padding-top: 8px; }
  .cart-send-overview-btn { padding: 9px 14px; font-size: 13px; }
}

/* Старые стили CRM-кнопок — оставлены для модалки */
.cart-send-btns { display: flex; gap: 10px; }
.cart-send-btn {
  flex: 1; display: flex; align-items: center; gap: 9px; justify-content: center;
  padding: 10px 8px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface); cursor: pointer; transition: transform .05s, box-shadow .15s, border-color .15s;
}
.cart-send-btn:hover { box-shadow: 0 3px 10px rgba(60,50,25,.10); }
.cart-send-btn:active { transform: translateY(1px); }
.cart-send-btn.onec { border-color: #E7C200; }
.cart-send-btn.onec:hover { border-color: #C9A800; }
.cart-send-btn.ms { border-color: #7FB2E6; }
.cart-send-btn.ms:hover { border-color: #4C8FD1; }
.cart-send-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px; font-weight: 800; font-size: 13px; color: #fff; flex: 0 0 auto;
}
.cart-send-btn.onec .cart-send-badge { background: #E1B700; color: #7A1F1F; }
.cart-send-btn.ms .cart-send-badge { background: #1F63B8; }
.cart-send-txt { display: flex; flex-direction: column; line-height: 1.1; text-align: left; font-weight: 800; font-size: 14px; color: var(--text); }
.cart-send-txt small { font-weight: 600; font-size: 11px; color: var(--text-muted); }

/* ===== Живой список позиций ===== */
/* Встроенный список убран: весь перечень теперь показывает модалка «Отправить»
   (на ПК) и попап «Список» (на телефоне). Стили .cart-list-* ниже нужны
   для содержимого этих попапов. */
.cart-list { display: none; }
.cart-list-title { font-size: 12px; font-weight: 800; color: var(--text-secondary); margin-bottom: 8px; }
.cart-list-head,
.cart-list-row { display: grid; grid-template-columns: 1fr 56px 56px; gap: 6px; align-items: center; }
.cart-list-head {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  padding-bottom: 5px; border-bottom: 1px solid var(--border);
}
.cart-list-head .cart-list-nal,
.cart-list-head .cart-list-bnal { text-align: right; }
.cart-list-body { display: flex; flex-direction: column; }
@media (max-width: 899.98px) {
  .cart-list-body { max-height: 42vh; overflow-y: auto; }
}
.cart-list-row { padding: 6px 0; border-bottom: 1px solid var(--kefeadd, #EFEADD); font-size: 12.5px; }
.cart-list-name {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600; color: var(--text);
}
.cart-list-qty { color: var(--text-muted); font-weight: 700; margin-left: 4px; }
.cart-list-nal,
.cart-list-bnal { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.cart-list-empty { font-size: 12.5px; color: var(--text-muted); padding: 8px 0; }

/* Телефон: вместо списка — маленькая кнопка в строке «Итого», открывающая
   тот же список в попапе. */
.cart-list-mobile-btn {
  display: inline-flex; align-items: center; gap: 2px; flex: 0 0 auto; white-space: nowrap;
  font-family: inherit; font-size: 13px; font-weight: 700; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 6px 10px 6px 12px; cursor: pointer;
}
.cart-list-mobile-btn:active { background: var(--kf1ece0, #F1ECE0); }
.cart-list-mobile-btn-arrow { color: var(--text-muted); font-size: 15px; }
@media (min-width: 900px) {
  .cart-list-mobile-btn { display: none; }
}

/* ===== Модалка отправки в CRM ===== */
.send-modal-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(30,26,18,.42);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.send-modal {
  width: 100%; max-width: 420px; background: var(--surface); border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,.30); overflow: hidden; display: flex; flex-direction: column; max-height: 92vh;
}
.send-modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.send-modal-icon { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; font-weight: 800; font-size: 12px; color: #fff; }
.send-modal-icon.onec { background: #E1B700; color: #7A1F1F; }
.send-modal-icon.ms { background: #1F63B8; }
.send-modal-title { font-weight: 800; font-size: 15px; flex: 1; }
.send-modal-close { border: none; background: none; font-size: 24px; line-height: 1; color: var(--text-muted); cursor: pointer; padding: 0 4px; }
.tk-icon-btn {
  border: 1px solid var(--border); background: none; border-radius: 8px;
  font-size: 15px; line-height: 1; color: var(--text-secondary);
  cursor: pointer; padding: 6px 8px; flex: 0 0 auto;
}
.tk-icon-btn:hover { background: var(--bg); }
.tk-icon-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
/* min-height:0 обязателен: без него тело не сжимается и выталкивает подвал
   с кнопками за экран — на телефоне «Создать заказ» становился недоступен. */
.send-modal-body { padding: 14px 16px; flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 12px; }
.send-modal-summary { font-size: 13px; color: var(--text-secondary); }
.send-modal-warn { font-size: 12px; color: var(--k8a5a22, #8A5A22); background: var(--kfbefe4, #FBEFE4); border-radius: 8px; padding: 7px 10px; }
.send-modal-field { display: flex; flex-direction: column; gap: 5px; }
.send-modal-field span { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.send-modal-field input, .send-modal-field textarea, .send-modal-field select {
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; font: inherit; font-size: 14px; background: var(--bg);
}
.send-modal-field textarea { resize: vertical; }
.send-modal-error { font-size: 12.5px; color: var(--kb23b3b, #B23B3B); }
.send-modal-confirm { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; color: var(--k8a5a22, #8A5A22); background: var(--kfbefe4, #FBEFE4); border-radius: 8px; padding: 10px 12px; }
.send-modal-confirm[hidden] { display: none; }
.send-modal-confirm-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.send-modal-confirm-btns .btn, .send-modal-confirm-btns .btn-outline { flex: 1 1 auto; white-space: normal; }
.send-modal-foot { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); flex: 0 0 auto; }
.send-modal-foot .btn, .send-modal-foot .btn-outline { flex: 1; }
/* Телефон: модалка почти во весь экран — форме МС нужно место под список
   найденных контрагентов, а подвал с кнопками остаётся закреплённым. */
@media (max-width: 560px) {
  .send-modal-overlay { padding: 10px; align-items: flex-end; }
  .send-modal { max-height: 94vh; border-radius: 16px; }
  .send-modal-foot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .send-modal-foot .btn, .send-modal-foot .btn-outline { padding: 12px 10px; }
}
.send-result-title { font-weight: 800; font-size: 16px; }
.send-result-sub { font-size: 13px; color: var(--text-secondary); margin-top: -4px; }
.send-result-row { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; }
.send-result-row.ok > span:first-child { color: #2F8F5B; font-weight: 800; }
.send-result-row.fail > span:first-child { color: var(--kb23b3b, #B23B3B); font-weight: 800; }
.send-result-row.fail { color: var(--kb23b3b, #B23B3B); }

@media (max-width: 899.98px) {
  .cart-send { border-top-color: var(--kd6cfbe, #D6CFBE); }
}
.send-channels-row { display: flex; gap: 16px; flex-wrap: wrap; padding: 4px 0 2px; }
.send-channels-row .checkbox-row { font-size: 13px; color: var(--text-secondary); }

.cart-list-modal { max-width: 380px; }
.cart-list-modal .send-modal-body { padding-top: 14px; }

/* ── Модал расчёта ТК ─────────────────────────────────────────────────── */
.tk-modal { max-width: 560px; }
.tk-modal-body { display: flex; flex-direction: column; gap: 0; padding-bottom: 0; }
.tk-form { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.tk-form-row { display: grid; gap: 12px; }
.tk-form-row.three { grid-template-columns: repeat(3, 1fr); }
.tk-form-row.two   { grid-template-columns: repeat(2, 1fr); }
/* дать колонкам сжиматься, иначе поля вылезают вправо (гориз. скролл) */
.tk-form-row > * { min-width: 0; }
.tk-modal-body { overflow-x: hidden; }
.tk-form .send-modal-field input,
.tk-form .send-modal-field select,
.tk-form .send-modal-field textarea { width: 100%; box-sizing: border-box; }
@media (max-width: 420px) {
  .tk-form-row.three { grid-template-columns: repeat(2, 1fr); }
  .tk-form-row.two   { grid-template-columns: 1fr; }
}

/* ── Автоподсказки городов ─────────────────────────────────────────────── */
.tk-city-wrap { position: relative; }
.tk-suggest {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0,0,0,.16); margin-top: 4px; max-height: 220px;
  overflow-y: auto; padding: 4px;
}
.tk-suggest[hidden] { display: none; }
.tk-suggest-item {
  padding: 8px 10px; border-radius: 7px; font-size: 13.5px; cursor: pointer;
  color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tk-suggest-item:hover, .tk-suggest-item.active { background: var(--bg); }
.tk-suggest-empty { padding: 8px 10px; font-size: 13px; color: var(--text-muted); }

/* Результаты */
.tk-results { border-top: 1px solid var(--border-color, var(--ke5e7eb, #e5e7eb)); padding: 14px 20px; }
.tk-results-meta {
  font-size: 12px; color: var(--text-secondary); margin-bottom: 12px; line-height: 1.5;
}
.tk-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (max-width: 400px) { .tk-cards { grid-template-columns: 1fr; } }

.tk-card {
  border: 1px solid var(--border-color, var(--ke5e7eb, #e5e7eb));
  border-radius: 10px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 3px;
}
.tk-card.ok   { border-color: #22c55e33; background: #f0fdf440; }
.tk-card.stub { border-color: var(--border-color, var(--ke5e7eb, #e5e7eb)); background: var(--bg-alt, var(--kf9f9f7, #f9f9f7)); }
.tk-card.err  { border-color: #f871711a; background: #fff1f040; }

.tk-card-name  { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.tk-card-price {
  font-size: 22px; font-weight: 700; color: var(--text-primary, var(--k1a1a1a, #1a1a1a)); line-height: 1.2;
}
.tk-card-price.stub  { font-size: 20px; color: var(--text-tertiary, var(--k9ca3af, #9ca3af)); }
.tk-card-price.error { font-size: 20px; color: var(--kef4444, #ef4444); }
.tk-currency { font-size: 15px; font-weight: 400; }
.tk-card-days  { font-size: 12px; color: var(--text-secondary); }
.tk-card-error { font-size: 11px; color: var(--text-tertiary, var(--k9ca3af, #9ca3af)); margin-top: 2px; line-height: 1.4; }

/* ===== «Товары» (пресеты параметров груза) для калькулятора ТК ===== */
.tk-preset-modal { max-width: 480px; }
.tk-preset-body { padding: 16px 20px; }
.tk-preset-empty { font-size: 13px; color: var(--text-muted); padding: 10px 2px; }
.tk-preset-list { display: flex; flex-direction: column; gap: 8px; }
.tk-preset-item {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border-color, var(--ke5e7eb, #e5e7eb));
  border-radius: 10px; padding: 4px;
}
.tk-preset-pick {
  flex: 1; min-width: 0; text-align: left; border: none; background: none;
  cursor: pointer; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px;
  border-radius: 8px;
}
.tk-preset-pick:hover:not(:disabled) { background: var(--bg); }
.tk-preset-pick:disabled { cursor: default; opacity: .8; }
.tk-preset-name  { font-size: 14px; font-weight: 700; }
.tk-preset-dims  { font-size: 12px; color: var(--text-secondary); }
.tk-preset-route { font-size: 12px; color: var(--text-muted); }
.tk-preset-actions { display: flex; gap: 4px; flex: 0 0 auto; padding-right: 4px; }
.tk-preset-form-wrap { margin-top: 14px; }
.tk-preset-form {
  display: flex; flex-direction: column; gap: 10px;
  border-top: 1px solid var(--border-color, var(--ke5e7eb, #e5e7eb)); padding-top: 14px;
}
.tk-preset-form-title { font-size: 13px; font-weight: 700; color: var(--text-secondary); }
.tk-preset-form-actions { display: flex; gap: 10px; }
.tk-preset-form-actions .btn, .tk-preset-form-actions .btn-outline { flex: 1; }

/* ===== Модалка обзора заказа (Отправить → выбор CRM) ===== */

/* Расширенная модалка — шире стандартной */
.send-modal.send-overview-modal { max-width: 600px; }
@media (max-width: 560px) { .send-modal.send-overview-modal { max-width: 100%; } }

/* Бейдж поставщика */
.so-supplier {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; margin-bottom: 4px;
  font-size: 12.5px; font-weight: 600;
  background: var(--green-tint); color: var(--green); border-radius: 20px;
}

/* Таблица позиций */
.so-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.so-table th {
  text-align: left; font-weight: 700; color: var(--text-muted);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 7px 5px; border-bottom: 2px solid var(--border);
}
.so-table th.so-right { text-align: right; }
.so-table th.so-center { text-align: center; }
.so-table td { padding: 7px 5px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.so-table td.so-right { text-align: right; }
.so-table td.so-center { text-align: center; font-weight: 700; }
.so-item-name { font-weight: 600; line-height: 1.3; }
.so-item-article { font-size: 10.5px; color: var(--text-muted); }

/* Редактируемые поля цены в таблице — расширены (были 60px, обрезали
   6-значные суммы), плюс убраны нативные стрелки у type=number (сами
   съедали часть видимой ширины и всё равно не нужны при вводе цены). */
.so-price-input {
  width: 86px; padding: 4px 6px; font-size: 12.5px; font-family: var(--font-body);
  text-align: right; border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg); color: var(--text); transition: border-color .15s;
  -moz-appearance: textfield;
}
.so-price-input::-webkit-outer-spin-button,
.so-price-input::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
.so-price-input:focus { outline: none; border-color: var(--accent); }

/* Крестик удаления позиции из корзины прямо в таблице обзора заказа */
.so-del-btn {
  width: 24px; height: 24px; border-radius: 7px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 13px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto; transition: all .15s;
}
.so-del-btn:hover { background: var(--accent-tint); border-color: var(--kf0c4c0, #F0C4C0); color: var(--accent); }

/* Пагинация */
.so-pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 3px; padding: 10px 0 4px;
}
.so-page-btn {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 7px; font-size: 12px; font-weight: 700; cursor: pointer; transition: all .15s;
}
.so-page-btn:hover { background: var(--bg); }
.so-page-btn.active { background: var(--dark-2); color: #fff; border-color: var(--dark-2); }
.so-page-btn.so-arrow { color: var(--text-muted); font-size: 15px; font-weight: 800; }
.so-page-btn.so-arrow:hover { background: var(--border-soft); }
.so-page-btn:disabled { opacity: 0.3; cursor: default; }
.so-page-info { font-size: 11px; color: var(--text-muted); padding: 0 6px; }

/* Итоги */
.so-totals {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0 0; border-top: 2px solid var(--border);
  font-family: var(--font-head);
}
.so-totals-label { font-size: 13px; font-weight: 700; }
.so-totals-vals { display: flex; gap: 14px; font-size: 13px; font-weight: 700; }
.so-totals-nal { color: var(--green); }
.so-totals-bnal { color: var(--blue); }
/* в тёмной теме синий «Безнал» плохо читался — делаем ярче */
html[data-theme="dark"] .so-totals-bnal { color: #7DB4FF; }

/* CRM-кнопки внутри overview-модалки */
.so-crm-btns {
  display: flex; gap: 10px; padding-top: 8px;
  border-top: 1px solid var(--border); margin-top: 4px;
}
.so-crm-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 14px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface); cursor: pointer;
  font-family: var(--font-head); font-weight: 700; font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s, transform .05s;
}
.so-crm-btn:hover { box-shadow: 0 3px 10px rgba(60,50,25,.10); }
.so-crm-btn:active { transform: translateY(1px); }
.so-crm-btn.onec { border-color: #E7C200; }
.so-crm-btn.onec:hover { border-color: #C9A800; }
.so-crm-btn.ms { border-color: #7FB2E6; }
.so-crm-btn.ms:hover { border-color: #4C8FD1; }
.so-crm-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; font-weight: 800; font-size: 11.5px; color: #fff; flex: 0 0 auto;
}
.so-crm-btn.onec .so-crm-badge { background: #E1B700; color: #7A1F1F; }
.so-crm-btn.ms .so-crm-badge { background: #1F63B8; }
.so-crm-txt { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.so-crm-txt small { font-weight: 500; font-size: 10.5px; color: var(--text-muted); }

/* «Предварительная заявка» — отдельная иконка-кнопка (Telegram) в том же
   ряду, что и «Счёт»/«Заказ», но не растягивается на всю ширину (flex:1), а
   остаётся узкой — это вспомогательное действие, не выбор CRM. */
.so-prelim-btn {
  flex: 0 0 48px; width: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; border: 1.5px solid var(--telegram);
  background: var(--surface); cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .05s;
}
.so-prelim-btn:hover { background: rgba(34, 158, 217, .10); box-shadow: 0 3px 10px rgba(34, 158, 217, .18); }
.so-prelim-btn:active { transform: translateY(1px); }
.so-prelim-btn:disabled { opacity: .5; cursor: default; }

.so-prelim-status {
  margin-top: 8px; padding: 7px 11px; border-radius: 9px;
  font-size: 11.5px; line-height: 1.4;
}
.so-prelim-status.ok { background: var(--green-tint); color: var(--green); }
.so-prelim-status.fail { background: var(--accent-tint); color: var(--accent); }

/* Выбор цен для «Предварительной заявки»: МС (нал) или 1С (безнал). */
.so-prelim-choice {
  margin-top: 8px; padding: 10px 12px; border-radius: 12px;
  border: 1.5px solid var(--telegram); background: var(--surface);
  display: flex; flex-direction: column; gap: 8px;
}
.so-prelim-choice[hidden] { display: none; }
.so-prelim-choice-q { font-size: 12.5px; font-weight: 600; }
.so-prelim-choice-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.so-prelim-opt {
  flex: 1 1 90px; display: flex; flex-direction: column; align-items: center; line-height: 1.15;
  padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--surface); cursor: pointer; color: inherit;
  font-family: var(--font-head); font-weight: 700; font-size: 13px;
}
.so-prelim-opt small { font-weight: 500; font-size: 10.5px; color: var(--text-muted); }
.so-prelim-opt.ms { border-color: #7FB2E6; }
.so-prelim-opt.ms:hover { border-color: #4C8FD1; }
.so-prelim-opt.onec { border-color: #E7C200; }
.so-prelim-opt.onec:hover { border-color: #C9A800; }
.so-prelim-opt-cancel { flex: 0 0 auto; padding: 9px 14px; }

@media (max-width: 560px) {
  .so-table { font-size: 11.5px; }
  .so-price-input { width: 70px; font-size: 11.5px; padding: 4px 4px; }
  .so-crm-btns { flex-direction: column; gap: 8px; }
  .so-prelim-btn { flex-basis: auto; width: 100%; }
}

/* ===== Кнопка-калькулятор в шапке + плавающее окно калькулятора =====
   Кнопка добавляется в JS (initFloatingCalculator, app.js) в ту же .topbar,
   что и «Домой», сразу слева от неё. Окно — одно на страницу, вставляется
   в document.body (не внутрь .topbar), поэтому не зависит от переполнения/
   overflow родителей — те же соображения, что и у поиска в Корзине. */
.topbar-calc-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; border: 0; flex: 0 0 auto;
  background: transparent; color: var(--accent, #C0392B); cursor: pointer;
}
.topbar-calc-btn:hover { background: var(--accent-tint); }

.calc-widget {
  position: fixed; top: 64px; right: 12px; z-index: 300;
  width: 216px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
  overflow: hidden; font-family: var(--font-body); user-select: none;
}
.calc-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; background: var(--accent); color: #fff;
  font-size: 12.5px; font-weight: 700; cursor: move; touch-action: none;
}
.calc-close {
  border: 0; background: transparent; color: #fff; font-size: 18px;
  line-height: 1; cursor: pointer; padding: 2px 4px;
}
.calc-display {
  padding: 12px 10px; text-align: right; font-size: 21px; font-weight: 700;
  font-family: var(--font-head); color: var(--text); background: var(--bg);
  overflow-x: auto; white-space: nowrap;
}
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--border-soft); }
.calc-keys button {
  border: 0; background: var(--surface); color: var(--text);
  font-size: 15px; font-weight: 600; padding: 12px 0; cursor: pointer;
}
.calc-keys button:active { background: var(--accent-tint); }
.calc-keys .calc-zero { grid-column: span 2; }
.calc-keys .calc-eq { background: var(--accent); color: #fff; }
.calc-keys .calc-eq:active { filter: brightness(0.92); }

/* ===== Поиск контрагента в Мой Склад (модалка отправки) ===== */
/* Ищем по ФИО или телефону: кнопка под полем, затем список найденных,
   выбор из списка — и только после этого «Создать заказ». */
/* Тело модалки — flex-колонка, и по умолчанию она СЖИМАЕТ эти блоки:
   строки списка расплющивались до обрезка, а зелёная плашка — до полоски,
   из-за чего крестик сброса было нечем нажать. flex:0 0 auto держит их
   в натуральную высоту, прокрутка живёт внутри .send-ms-results. */
.send-ms-find {
  flex: 0 0 auto;
  width: 100%;
  margin: -2px 0 2px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--kfbfaf7, #FBFAF7);
  color: var(--text);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.send-ms-find:hover { background: var(--kf1ece0, #F1ECE0); border-color: var(--kd6cfbe, #D6CFBE); }
.send-ms-find:disabled { opacity: .55; cursor: default; }

.send-ms-results {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 232px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px;
  margin-bottom: 2px;
}
.send-ms-option {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.send-ms-option:hover { border-color: var(--green); background: var(--kf4faf6, #F4FAF6); }
.send-ms-option-name { font-family: var(--font-head); font-weight: 700; font-size: 13.5px; color: var(--text); }
.send-ms-option-sub { font-size: 11.5px; color: var(--text-secondary); }
.send-ms-empty { flex: 0 0 auto; font-size: 12.5px; color: var(--text-secondary); padding: 8px 2px; }

.send-ms-chosen {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 9px 12px;
  border: 1px solid var(--green);
  border-radius: 10px;
  background: var(--green-tint);
  margin-bottom: 2px;
}
.send-ms-chosen-label { font-size: 11.5px; font-weight: 600; color: var(--text-secondary); }
.send-ms-chosen-name { font-family: var(--font-head); font-weight: 800; font-size: 13.5px; color: var(--text); }
.send-ms-chosen-phone { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.send-ms-chosen-clear {
  flex: 0 0 auto;
  margin-left: auto;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 6px;
  background: transparent; color: var(--text-secondary);
  font-size: 21px; line-height: 1; cursor: pointer;
}
.send-ms-chosen-clear:hover { background: rgba(0, 0, 0, .07); color: var(--text); }

/* Телефон: кнопки и строки списка крупнее, список ниже — чтобы влезала
   клавиатура и оставалось видно «Создать заказ». */
@media (max-width: 560px) {
  .send-ms-find { padding: 12px 14px; font-size: 14px; }
  .send-ms-results { max-height: 30vh; }
  .send-ms-option { padding: 12px; }
  .send-ms-option-name { font-size: 14px; }
  .send-ms-chosen { padding: 11px 12px; }
}

/* ===== Корзина → Мой Склад: «Добавить товары в заказ» =====
   После выбора контрагента показываем его заказы. ПК (≥900px): карточка
   справа от окна отправки (оба центрируются в .send-modal-overlay). Телефон
   и узкие окна: отдельное модальное окно поверх (position:fixed + свой фон). */
.send-orders-panel { flex: 0 0 auto; margin-left: 14px; }
.send-orders-card {
  width: 360px; max-height: 92vh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 16px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .30);
}
.send-orders-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.send-orders-title { font-weight: 800; font-size: 15px; flex: 1; }
.send-orders-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.send-orders-new {
  flex: 0 0 auto; width: 100%; padding: 11px 14px; border-radius: 10px; cursor: pointer;
  border: 1.5px solid var(--accent); background: var(--accent-tint); color: var(--accent);
  font-family: var(--font-head); font-weight: 800; font-size: 13.5px;
}
.send-orders-new:hover { filter: brightness(0.96); }
.send-orders-sub { flex: 0 0 auto; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.send-orders-list { display: flex; flex-direction: column; gap: 6px; }
.send-order-row { flex: 0 0 auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); overflow: hidden; }
.send-order-row.is-picked { border-color: var(--green); background: var(--green-tint); }
.send-order-pick {
  display: flex; flex-direction: column; gap: 3px; width: 100%; text-align: left;
  padding: 10px 12px; border: 0; background: transparent; cursor: pointer; font: inherit; color: var(--text);
}
.send-order-row:not(.is-picked) .send-order-pick:hover { background: var(--green-tint); }
.send-order-top { display: flex; align-items: baseline; gap: 8px; }
.send-order-num { font-family: var(--font-head); font-weight: 800; font-size: 13.5px; }
.send-order-date { font-size: 11.5px; color: var(--text-secondary); }
.send-order-sum { margin-left: auto; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.send-order-sub { font-size: 11.5px; color: var(--text-secondary); overflow-wrap: anywhere; }
.send-order-confirm { padding: 0 12px 10px; display: flex; flex-direction: column; gap: 8px; }
.send-order-confirm[hidden] { display: none; }
.send-order-q { font-size: 12.5px; font-weight: 600; }
.send-order-btns { display: flex; gap: 8px; }
.send-order-btns .btn, .send-order-btns .btn-outline { flex: 1; padding: 9px 10px; }
.send-order-warn { font-size: 12px; color: var(--k8a5a22, #8A5A22); background: var(--kfbefe4, #FBEFE4); border-radius: 8px; padding: 7px 10px; }
@media (max-width: 899.98px) {
  .send-orders-panel {
    position: fixed; inset: 0; z-index: 5; margin: 0; padding: 10px;
    display: flex; align-items: flex-end; justify-content: center;
    background: rgba(30, 26, 18, .42);
  }
  .send-orders-card { width: 100%; max-width: 480px; max-height: 80vh; border-radius: 16px; }
  .send-order-pick { padding: 12px; }
}

/* ===== Контрагенты: раскрывающиеся карточки с поиском внутри ===== */
.cp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.cp-card.is-open { border-color: var(--green); }

.cp-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
}
.cp-card-head:hover { background: var(--kfbfaf7, #FBFAF7); }
.cp-card-head .option-icon {
  flex: 0 0 auto;
  width: 46px; height: 46px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
}
.cp-card-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.cp-card-title { font-family: var(--font-head); font-weight: 800; font-size: 16px; color: var(--text); }
.cp-card-sub { font-size: 12.5px; color: var(--text-secondary); }
.cp-card-chevron { flex: 0 0 auto; color: var(--text-muted); transition: transform .18s; }
.cp-card.is-open .cp-card-chevron { transform: rotate(180deg); }

.cp-card-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 16px 16px;
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
}

/* Таблица документов выбранного контрагента: на телефоне уезжает вбок,
   а не ломает колонки — номер и суммы должны читаться целиком. */
.cp-docs-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 8px;
}
.cp-docs-title span { font-weight: 600; color: var(--text-muted); }
.cp-docs-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cp-docs-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cp-docs-table th {
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 0 10px 6px 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.cp-docs-table td {
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--kefeadd, #EFEADD);
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}
.cp-docs-table td.num { font-weight: 700; white-space: nowrap; }
.cp-docs-table th:nth-child(2), .cp-docs-table td:nth-child(2) { white-space: nowrap; }
.cp-docs-table tr:last-child td { border-bottom: none; }

/* Выбранная строка в списке найденных */
.send-ms-option.is-picked { border-color: var(--green); background: var(--green-tint); }

@media (max-width: 560px) {
  .cp-card-head { padding: 12px 14px; gap: 10px; }
  .cp-card-head .option-icon { width: 40px; height: 40px; border-radius: 12px; }
  .cp-card-title { font-size: 15px; }
  .cp-card-body { padding: 14px 14px 16px; }
  .cp-docs-table { font-size: 12px; }
}

/* Возврат на шаг назад внутри раскрытой карточки */
.cp-back-link {
  align-self: flex-start;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.cp-back-link:hover { text-decoration: underline; }

.cp-docs-head {
  display: flex; flex-direction: column; gap: 4px;
  padding-bottom: 10px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.cp-docs-name { font-family: var(--font-head); font-weight: 800; font-size: 15px; color: var(--text); }

/* Колонки: разделители между всеми ячейками и читаемая ширина.
   Комментарий забирает остаток, остальное — по содержимому. */
.cp-docs-table { table-layout: auto; }
.cp-docs-table th,
.cp-docs-table td {
  padding: 9px 12px;
  border-right: 1px solid var(--border-soft);
}
.cp-docs-table th:last-child,
.cp-docs-table td:last-child { border-right: none; padding-right: 0; }
.cp-docs-table th:first-child,
.cp-docs-table td:first-child { padding-left: 0; }
.cp-docs-table thead th { border-bottom: 1px solid var(--border); }

@media (min-width: 900px) {
  .cp-docs-table { font-size: 13px; min-width: 100%; }
  /* Номер, дата и денежные колонки не переносятся, текст — переносится. */
  .cp-docs-table th:not(:last-child),
  .cp-docs-table td:not(:last-child) { white-space: nowrap; }
  .cp-docs-table td:last-child { min-width: 220px; }
  .cp-docs-table th, .cp-docs-table td { padding: 10px 16px; }
}

/* ===== Контрагенты: широкая колонка под таблицу документов =====
   Базовая .app — 480px (макет под телефон). Для этой страницы таблице
   нужно место, иначе колонки приходится прокручивать вбок. */
@media (min-width: 900px) {
  .app.centered.cp-page { max-width: 1100px; }
  /* Места хватает — горизонтальная прокрутка больше не нужна. */
  .cp-page .cp-docs-scroll { overflow-x: visible; }
  .cp-page .cp-docs-table td:last-child { min-width: 0; white-space: normal; }
}

/* ===== Корзина по поставщикам: количество у каждого поставщика, цвета, широкая панель ===== */

/* Цвет поставщика: --sc (акцент), --sc-bg (лёгкая подложка), --sc-on (подложка, когда добавлен), --sc-bd (рамка) */
.sup-c0 { --sc: #3F86D6; --sc-bg: rgba(63,134,214,.08);  --sc-on: rgba(63,134,214,.22);  --sc-bd: rgba(63,134,214,.40); }
.sup-c1 { --sc: #2E9E6B; --sc-bg: rgba(46,158,107,.08);  --sc-on: rgba(46,158,107,.22);  --sc-bd: rgba(46,158,107,.40); }
.sup-c2 { --sc: #C58B14; --sc-bg: rgba(197,139,20,.09);  --sc-on: rgba(197,139,20,.24);  --sc-bd: rgba(197,139,20,.42); }
.sup-c3 { --sc: #8E5BD0; --sc-bg: rgba(142,91,208,.08);  --sc-on: rgba(142,91,208,.22);  --sc-bd: rgba(142,91,208,.40); }
.sup-c4 { --sc: #C2477A; --sc-bg: rgba(194,71,122,.08);  --sc-on: rgba(194,71,122,.22);  --sc-bd: rgba(194,71,122,.40); }
.sup-c5 { --sc: #2A9AA5; --sc-bg: rgba(42,154,165,.08);  --sc-on: rgba(42,154,165,.22);  --sc-bd: rgba(42,154,165,.40); }
/* в тёмной теме акцентные цвета чуть светлее — иначе названия плохо читаются */
html[data-theme="dark"] .sup-c0 { --sc: #6FA8EE; }
html[data-theme="dark"] .sup-c1 { --sc: #4FC08C; }
html[data-theme="dark"] .sup-c2 { --sc: #E0B04F; }
html[data-theme="dark"] .sup-c3 { --sc: #B58CF0; }
html[data-theme="dark"] .sup-c4 { --sc: #E577A3; }
html[data-theme="dark"] .sup-c5 { --sc: #55C3CE; }

/* Прайс: строки поставщиков с «− N +» напротив каждого */
.price-table table.sup-table { border-collapse: separate; border-spacing: 0 3px; }
.price-table table.sup-table th { padding-top: 0; padding-bottom: 2px; }
.price-table tr.sup-row td { background: var(--sc-bg); padding-top: 5px; padding-bottom: 5px; transition: background .15s; }
.price-table tr.sup-row td:first-child {
  padding-left: 11px; color: var(--sc); font-weight: 700;
  box-shadow: inset 3px 0 0 var(--sc); border-radius: 8px 0 0 8px;
}
.price-table tr.sup-row td:last-child { border-radius: 0 8px 8px 0; }
.price-table tr.sup-row.is-on td { background: var(--sc-on); }
.price-table .sup-step-col { width: 112px; text-align: right; padding-right: 6px; }
.sup-row .stepper { justify-content: flex-end; }
.sup-row .stepper button { width: 28px; height: 28px; }
.sup-row .stepper .qty { min-width: 20px; }
.sup-row.is-on .stepper .qty { color: var(--sc); }

/* Панель корзины: итоги */
.cart-sums { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cart-sum { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 7px 12px; display: flex; flex-direction: column; }
.cart-sum small { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.cart-sum b { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cart-sum.nal b { color: var(--green); }
.cart-sum.bez b { color: var(--blue); }
html[data-theme="dark"] .cart-sum.bez b { color: #7DB4FF; }
.cart-weight { font-weight: 600; }
@media (max-width: 899.98px) {
  .cart-sum { padding: 5px 10px; }
  .cart-sum b { font-size: 15px; }
}

/* Список корзины по поставщикам */
.cart-list-group { background: var(--sc-bg); border: 1px solid var(--sc-bd); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.cart-list-ghead { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--sc-bd); }
.cart-list-gname { font-weight: 800; font-size: 13.5px; color: var(--sc); }
.cart-list-gcount { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.cart-list-group .cart-list-head,
.cart-list-group .cart-list-row { grid-template-columns: 1fr 78px 78px; padding-left: 12px; padding-right: 12px; }
.cart-list-group .cart-list-head { padding-top: 7px; }
.cart-list-group .cart-list-row:last-child { border-bottom: none; }
.cart-list-group .cart-list-body { max-height: none; overflow: visible; }
.cart-list-gsum { display: flex; justify-content: flex-end; gap: 16px; padding: 8px 12px; background: rgba(0,0,0,.06); font-size: 12.5px; font-weight: 700; }
.cart-list-gsum .nal { color: var(--green); }
.cart-list-gsum .bez { color: var(--blue); }
html[data-theme="dark"] .cart-list-gsum .bez { color: #7DB4FF; }

/* ПК: панель корзины шире, итоги/вес/«Отправить» закреплены сверху, список прокручивается */
@media (min-width: 900px) {
  .cart-page .cart-bar {
    flex: 0 0 clamp(380px, 27vw, 460px);
    width: clamp(380px, 27vw, 460px);
    align-self: stretch;
    max-height: none;
    overflow: hidden;
  }
  .cart-page .cart-bar > .cart-list {
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    margin-top: 2px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
  }
}

/* Обзор заказа: поставщики цветом */
.so-sups { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.so-sup-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px;
  font-size: 12.5px; font-weight: 700; color: var(--sc);
  background: var(--sc-bg); border: 1px solid var(--sc-bd); border-radius: 20px;
}
.so-sup-tag {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px;
  font-size: 10.5px; font-weight: 700; color: var(--sc);
  background: var(--sc-bg); border: 1px solid var(--sc-bd);
}
.so-table tr.so-row-sup td { background: var(--sc-bg); }
.so-table tr.so-row-sup td:first-child { box-shadow: inset 3px 0 0 var(--sc); }


/* ===== Цены закупа поставщиков (виден только владельцу) ===== */
/* ПК: приглушённые колонки слева от цен продажи, чтобы главными оставались цены продажи */
.price-table .cost-col { font-weight: 500; font-size: 12px; color: var(--text-faint); opacity: .8; }
.price-table th.cost-col { font-weight: 500; font-size: 11px; }
.price-table .cost-tip { display: none; }
.price-table .unit-col { width: 1%; white-space: nowrap; text-align: left; padding-left: 0; padding-right: 8px; }
.price-table .unit-tag { color: var(--text-faint); font-size: 12px; font-weight: 500; }
.no-costs .cost-col, .no-costs .cost-tip, .no-costs .cost-sum { display: none !important; }
.cart-sum .cost-sum { font-size: 11px; font-weight: 500; color: var(--text-faint); opacity: .85; font-variant-numeric: tabular-nums; }
.cart-list-gcost { display: flex; justify-content: flex-end; gap: 16px; padding: 4px 12px 7px; font-size: 11px; font-weight: 500; color: var(--text-faint); background: rgba(0,0,0,.06); }

/* Телефон: закуп виден постоянно под ценой продажи (приглушённо).
   Если в Настройках → Цены включено «скрывать закуп» (html.cost-autohide) — закуп
   скрыт, двойной тап по цене продажи / по итогу показывает его на 10 с. */
@media (max-width: 899.98px) {
  .price-table .unit-col { display: none; }
  .price-table .cost-col { display: none; }
  .price-table .cost-tip { display: block; font-size: 10.5px; font-weight: 500; color: var(--text-faint); line-height: 1.2; }
  .cart-sum .cost-sum { display: block; }
  .cart-list-gcost { display: flex; }
  html.cost-autohide .price-table td[data-cost-tap], html.cost-autohide .cart-sum[data-cost-tap], html.cost-autohide .cart-list-gcost { -webkit-user-select: none; user-select: none; touch-action: manipulation; }
  html.cost-autohide .price-table .cost-tip { display: none; }
  html.cost-autohide .price-table tr.cost-open .cost-tip { display: block; }
  html.cost-autohide .cart-sum .cost-sum { display: none; }
  html.cost-autohide .cart-sums.cost-open .cost-sum { display: block; }
  html.cost-autohide .cart-list-gcost { display: none; }
  html.cost-autohide .cart-list-gcost.cost-open { display: flex; }
}

/* ===== Шаблоны корзины ===== */
.cart-search-wrap { display: flex; gap: 8px; align-items: stretch; }
.cart-search-box { flex: 1 1 auto; min-width: 0; }
.cart-tpl-btn {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.cart-tpl-btn svg { color: var(--accent); }
.cart-tpl-btn:hover { border-color: var(--accent); }
.cart-list-tpl { padding: 4px 0 14px; }
.cart-list-tpl .btn-outline { width: 100%; height: 40px; border-style: dashed; font-size: 14px; }

.tpl-modal { max-width: 560px; }
.tpl-list { display: flex; flex-direction: column; gap: 8px; }
.tpl-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--bg); }
.tpl-info { display: flex; flex-direction: column; min-width: 0; flex: 1 1 160px; }
.tpl-info b { font-size: 14px; overflow-wrap: anywhere; }
.tpl-info small { font-size: 12px; color: var(--text-muted); }
.tpl-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tpl-actions button, .tpl-save { border-radius: 10px; font: inherit; font-size: 13px; font-weight: 700; padding: 8px 12px; cursor: pointer; }
.tpl-apply, .tpl-save { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
.tpl-sec { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.tpl-del { color: #B23B3B; }
.tpl-save[disabled], .tpl-foot .btn-outline[disabled] { opacity: .5; cursor: default; }
.tpl-empty { font-size: 13px; color: var(--text-faint); padding: 6px 2px; }
.tpl-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); flex: 0 0 auto; flex-wrap: wrap; }
.tpl-foot-btn { flex: 1 1 150px; height: 42px; font-size: 13.5px; }
.tpl-foot .tpl-save { flex: 1 1 150px; height: 42px; }
.tpl-items { display: flex; flex-direction: column; gap: 6px; }
.tpl-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 8px; align-items: center; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--bg); }
.tpl-item-name { display: flex; flex-direction: column; min-width: 0; }
.tpl-item-name span { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-item-name small { font-size: 11px; color: var(--text-faint); }
.tpl-item select { border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 13px; background: var(--surface); color: var(--text); }
.tpl-x { border: 0; background: none; color: var(--text-muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px; }
.tpl-add { position: relative; }
.tpl-add > input { width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 14px; background: var(--bg); color: var(--text); }
.tpl-add-results { display: flex; flex-direction: column; margin-top: 6px; }
.tpl-add-results:empty { display: none; }
.tpl-hit { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border: 1px solid var(--border-soft); border-top: 0; cursor: pointer; background: var(--surface); }
.tpl-hit:first-child { border-top: 1px solid var(--border-soft); border-radius: 10px 10px 0 0; }
.tpl-hit:last-child { border-radius: 0 0 10px 10px; }
.tpl-hit:hover { background: var(--accent-tint); }
.tpl-hit b { font-size: 13px; }
.tpl-hit small { font-size: 11.5px; color: var(--accent); }
@media (max-width: 520px) {
  .tpl-item { grid-template-columns: minmax(0, 1fr) auto auto; }
  .tpl-item select { grid-column: 1 / 3; }
  .cart-tpl-btn { padding: 0 10px; }
}


/* ===== Иконка «Домой» в шапке ПК (.d-topbar) — слева от «Ассистент» ===== */
.d-actions .d-home-btn {
  order: -1; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 36px; height: 36px; border-radius: 10px; color: var(--accent, #C0392B); text-decoration: none;
}
.d-actions .d-home-btn:hover { background: var(--accent-tint); }

/* ===== ПК: «Калькулятор / Домой / Ассистент» — только в верхней шапке (.d-topbar) =====
   Внутри страницы (.d-main) мобильная полоса .topbar на ПК дублировала эти значки. */
.d-actions .d-calc-btn { order: -1; width: 36px; height: 36px; border-radius: 10px; }
@media (min-width: 900px) {
  .d-main .topbar [data-calc-btn],
  .d-main .topbar [data-home-btn],
  .d-main .topbar .as-launch { display: none !important; }
}

/* ===== Значки шапки (калькулятор, «Домой», микрофон ассистента) — контрастные ===== */
.topbar-calc-btn,
.d-actions .d-home-btn,
.topbar [data-home-btn],
.brand-bar [data-home-btn],
.as-launch.m:not(.on) { color: var(--text) !important; }
html[data-theme="dark"] .topbar-calc-btn,
html[data-theme="dark"] .d-actions .d-home-btn,
html[data-theme="dark"] .topbar [data-home-btn],
html[data-theme="dark"] .brand-bar [data-home-btn],
html[data-theme="dark"] .as-launch.m:not(.on) { color: #fff !important; }

/* ===== Корзина на телефонах: адаптация под разную ширину/высоту экрана, края не обрезаются ===== */
/* высота страницы — по видимой области (с учётом адресной строки браузера), а не по 100vh */
@supports (height: 100dvh) {
  .app.cart-page { height: 100dvh; }
  .cart-page .cart-bar { max-height: 42dvh; }
}
.cart-page .cart-bar { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
.cart-search-box input { min-width: 0; }
.item-name { overflow-wrap: anywhere; }
@media (max-width: 899.98px) {
  /* таблица цен поставщиков: колонка «− N +» больше не выталкивается за край карточки */
  .price-table .sup-step-col { width: 1%; white-space: nowrap; }
  .price-table th, .price-table td { padding-left: 5px; padding-right: 5px; }
  .price-table tr.sup-row td:first-child { padding-left: 10px; }
  .price-table .sup-step-col { padding-right: 4px; }
}
@media (max-width: 430px) {
  .price-table table { font-size: 13px; }
  .price-table th { font-size: 12px; }
  .price-table td small, .price-table td .buy { font-size: 10.5px; }
  .item-row { padding: 10px 10px; }
  .sup-row .stepper { gap: 3px; }
  .sup-row .stepper button { width: 26px; height: 26px; }
  .sup-row .stepper .qty { min-width: 16px; }
  .cart-search-wrap { padding-left: 12px; padding-right: 12px; }
  .cart-page [data-cart-search] { padding-left: 12px; padding-right: 12px; }
  .content { padding-left: 12px; padding-right: 12px; }
  .cart-bar { padding-left: 12px; padding-right: 12px; }
}
@media (max-width: 360px) {
  .price-table th, .price-table td { padding-left: 3px; padding-right: 3px; }
  .price-table tr.sup-row td:first-child { padding-left: 8px; }
  .sup-row .stepper button { width: 24px; height: 24px; }
  .item-name { font-size: 14.5px; }
  .cart-sum b { font-size: 14px; }
}

/* ===== Значки «Расчёт ТК» и «Корзина» в шапках ===== */
a.topbar-calc-btn{text-decoration:none}
.hd-ic{display:none !important}
@media (min-width: 900px) {
  .hd-ic{display:inline-flex !important; margin-left:4px}
  .d-main .topbar [data-tk-btn-m] { display: none !important; }
}
.d-actions .d-calc-btn[data-tk-btn-d],
.d-actions .d-calc-btn[data-cart-btn-d]{order:-1}

/* ПК, главная: значки ТК / Корзина / Калькулятор — вплотную слева от кнопки «Ассистент» (справа) */
@media (min-width: 900px) {
  .tdash .headr [data-tk-btn-hd]{margin-left:auto !important}
  .tdash .headr .as-launch.d{margin-left:8px !important}
}

/* ===== Корзина (ПК): «Быстрый доступ» — стильные кнопки частых разделов справа ===== */
.cq{display:none}
@media (min-width: 1360px) {
  .cq-host{flex-direction:row !important}
  .cq-host>div:first-child{flex:0 0 680px !important}
  .cq{display:block;flex:1 1 auto;min-width:0;max-width:820px;margin-left:36px;margin-top:0;position:sticky;top:20px;align-self:flex-start}
  .cq-h{display:flex;align-items:baseline;gap:10px;margin:2px 2px 12px;font-family:var(--font-head);font-weight:700;font-size:15px;color:var(--text)}
  .cq-sub{font-family:var(--font-body);font-weight:400;font-size:12.5px;color:var(--text-muted)}
  .cq-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}
  @media (max-width:1699px){.cq-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
  .cq-btn{position:relative;display:flex;flex-direction:column;justify-content:space-between;gap:8px;min-height:92px;padding:14px 14px 12px;border-radius:14px;
    text-decoration:none;color:var(--text);border:1px solid var(--border);
    background:linear-gradient(145deg,var(--surface) 0%,var(--bg) 140%);box-shadow:0 1px 0 rgba(0,0,0,.04);
    transition:transform .12s ease,box-shadow .12s ease,border-color .12s ease;overflow:hidden}
  .cq-btn::before{content:"";position:absolute;left:0;top:0;bottom:0;width:4px;background:var(--accent)}
  .cq-btn:hover{transform:translateY(-2px);border-color:var(--accent);box-shadow:0 8px 22px rgba(0,0,0,.18)}
  .cq-btn.pin{border-color:var(--accent)}
  .cq-t{font-weight:700;font-size:14px;line-height:1.25;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;padding-right:34px}
  .cq-c{font-size:12px;color:var(--text-muted);line-height:1.2}
  .cq-tools{position:absolute;top:8px;right:8px;display:flex;gap:2px;opacity:0;transition:opacity .12s}
  .cq-btn:hover .cq-tools,.cq-btn.pin .cq-tools{opacity:1}
  .cq-btn.pin .cq-tools [data-del]{display:none}
  .cq-i{width:24px;height:24px;border-radius:7px;border:0;background:transparent;color:var(--text-muted);cursor:pointer;font-size:12px;display:flex;align-items:center;justify-content:center;padding:0}
  .cq-i:hover{background:var(--accent-tint);color:var(--accent)}
  .cq-btn.pin [data-pin]{color:var(--accent)}
  .cq-empty{border:1px dashed var(--border);border-radius:14px;padding:22px 20px;font-size:13.5px;line-height:1.5;color:var(--text-secondary)}
}

/* Быстрый доступ: цвет категории и перетаскивание */
@media (min-width: 1360px) {
  .cq-btn{--cq-c:var(--accent);border-color:color-mix(in srgb,var(--cq-c) 45%,var(--border));cursor:grab}
  .cq-btn::before{background:var(--cq-c)}
  .cq-btn:hover{border-color:var(--cq-c);box-shadow:0 8px 22px color-mix(in srgb,var(--cq-c) 28%,transparent)}
  .cq-btn.pin{border-color:var(--cq-c);box-shadow:0 0 0 1px var(--cq-c) inset}
  .cq-btn.pin [data-pin]{color:var(--cq-c)}
  .cq-i:hover{background:color-mix(in srgb,var(--cq-c) 18%,transparent);color:var(--cq-c)}
  .cq-btn.drag{opacity:.35;transform:scale(.97)}
  .cq-btn.over-l{box-shadow:-5px 0 0 0 var(--cq-c)}
  .cq-btn.over-r{box-shadow:5px 0 0 0 var(--cq-c)}
}
