/* Общая геометрия витрины, кабинетов и рабочих экранов */
@media screen {
  #adminMain :is(.main-h, .panel, .card, .form, .inp, .filters),
  #zbRoot :is(.card, .form, .inp) { min-inline-size: 0; }
  #adminMain .main-h > *, .zr-filters label { max-inline-size: 100%; }
  #adminMain .kpi b { white-space: normal; overflow-wrap: anywhere; }
  #adminMain .kpi .d, #adminMain .li .grow, .zc-row summary > span { overflow-wrap: anywhere; }
  .zr .zr-filters, .zr .zr-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,10rem),1fr)); }
  .zr-filters select { width: 100%; min-width: 0; }
  .zr-scroll { max-inline-size: 100%; overscroll-behavior-x: contain; }
  #shop .p-foot { flex-wrap: wrap; row-gap: 6px; }
  #shop .p .p-foot:not(:has(.stepper)) { flex-wrap: nowrap; align-items: flex-end; gap: 6px; }
  #shop .p .p-foot > div:first-child { min-width: 0; flex: 1 1 auto; }
  #shop .p .p-foot > [data-ctl]:not(:has(.stepper)) { flex: none; }
  #drawer .fd .mono { white-space: nowrap; }
}
@media screen and (max-width: 860px) {
  #shop .bnav { grid-auto-columns: minmax(0,1fr); align-items: stretch; }
  #shop .bnav > :is(a,button), #admin .side button.t {
    display: grid; grid-template-rows: 20px 14px; align-content: center;
    justify-items: center; align-items: center; row-gap: 4px;
    box-sizing: border-box; min-block-size: 46px; line-height: 14px;
  }
  #shop .bnav > :is(a,button) { padding-inline: 0; min-inline-size: 0; }
  #shop .bnav [data-ico], #shop .bnav svg.i, #admin .side button.t > svg.i {
    display: block; width: 20px; height: 20px;
  }
  #shop .head .search { min-width: 0; }
  #adminMain .main-h { align-items: center; }
  #adminMain .main-h > h2 { flex-basis: 100%; margin: 0; }
  #adminMain .main-h > .btn { white-space: normal; height: auto; min-height: 44px; }
  #adminMain .filters .chip { min-height: 44px; }
  #adminMain .kpis { grid-template-columns: repeat(2,minmax(0,1fr)); }
  #adminMain .panel .li > .r { max-width: 55%; white-space: normal; overflow-wrap: anywhere; text-align: right; }
  .zr-kpi strong { overflow-wrap: anywhere; }
  .zr-bars > div { grid-template-columns: auto minmax(0,1fr) auto; }
  #channelSpendDialog fieldset { min-width: 0; }
}
@media screen and (max-width: 520px) {
  #drawer .d-foot .btn-primary { flex: 1 1 100% !important; }
  #drawer .d-foot > [data-act="doc"], #drawer .d-foot > [data-amo] { flex: 1 1 auto; }
}

@media screen and (max-width: 480px) {
  #adminMain .main-h > .note { flex-basis: 100%; }
  #adminMain :is(.kpi,.panel) { padding-inline: 14px; }
  .zr .zr-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .zr-grid .zr-kpi { padding: 12px; }
  #zbRoot .form { grid-template-columns: minmax(0,1fr); }
}

/* Одинаковая базовая линия полей при переносе подписей. */
#ztAdd .inp:has(> .lbl) { display: flex; flex-direction: column; align-self: stretch; }
#ztAdd .inp > .lbl { flex: 1 0 auto; }

/* Подпись и печать (24.11): как на бумажном документе — крупная печать с прозрачным фоном стоит у начала линии,
   подпись идёт поверх печати. Всё внутри листа — и на экране, и в печати/PDF. */
.sheet .d-sign { align-items: flex-end; flex-wrap: wrap; break-inside: avoid; }
.sheet .d-sign:has(.d-mp) { margin: 96px 0 110px; }
.sheet .d-sign i.d-sig {
  position: relative; display: inline-block; flex: 0 0 auto;
  width: 220px; max-width: 46%; height: 22px; margin: 0 18px 0 10px;
  border: 0; border-bottom: 1px solid currentColor;
}
.sheet .d-sign i.d-sig img {
  /* только высота: ширина по пропорциям картинки (html2canvas не знает object-fit и растягивал подпись в PDF) */
  position: absolute; left: 70px; bottom: -86px; width: auto; height: 190px;
  transform: none; margin: 0; max-width: none; z-index: 3;
}
.sheet .d-sign i.d-sig img.d-mp {
  left: -34px; bottom: -112px; width: 180px; height: auto;
  transform: rotate(-4deg); opacity: .95; mix-blend-mode: multiply; z-index: 1;
}

/* Доска заказов (24.11): этап и «кол-во · сумма» на отдельных строках, шапки колонок одной высоты —
   карточки во всех колонках начинаются на одном уровне, длинные этапы amo переносятся внутри плашки. */
#adminMain .kanban .col-h {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start;
  gap: 6px; min-height: 80px; padding: 4px 6px 10px; box-sizing: border-box;
}
#adminMain .kanban .col-h .st { white-space: normal; max-width: 100%; line-height: 1.25; text-align: left; }
#adminMain .kanban .col-h .c { margin-left: 0; white-space: nowrap; }
#adminMain .kanban .oc .top { gap: 8px; }
#adminMain .kanban .oc .top > span:last-child { white-space: nowrap; }
#adminMain .kanban .oc .cl { overflow-wrap: anywhere; }
#adminMain .kanban .amo-src { color: var(--accent); font-weight: 600; }
#adminMain .kanban .oc-kind { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; }
#adminMain .kanban .oc-amo { display: inline-block; margin-top: 4px; font-size: 11.5px; font-weight: 600; color: var(--accent); text-decoration: none; }
#adminMain .kanban .oc-amo:hover { text-decoration: underline; }
#adminMain .kanban .oc .top > span:first-child { white-space: nowrap; }

/* Доска заявок (24.11): переключатель воронок / 1С и поиск над колонками */
#adminMain .kb-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; min-width: 0; }
#adminMain .kb-view { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--chip, rgba(0,0,0,.05)); max-width: 100%; overflow-x: auto; scrollbar-width: none; flex: 0 1 auto; }
#adminMain .kb-view::-webkit-scrollbar { display: none; }
#adminMain .kb-view button { flex: 0 0 auto; border: 0; background: transparent; padding: 8px 12px; border-radius: 10px; font: inherit; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; }
#adminMain .kb-view button .mono { opacity: .6; font-weight: 500; margin-left: 2px; }
#adminMain .kb-view button.on { background: var(--surface, #fff); color: var(--ink, inherit); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
#adminMain .kb-search { position: relative; flex: 1 1 260px; min-width: 0; max-width: 520px; display: block; margin: 0; }
#adminMain .kb-search > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
#adminMain .kb-search input { width: 100%; box-sizing: border-box; height: 42px; border-radius: 13px; border: 1px solid var(--line); background: var(--surface); padding: 0 40px 0 40px; font: inherit; font-size: 14px; outline: none; }
#adminMain .kb-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
#adminMain .kb-search .icon-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; }
@media (max-width: 700px) { #adminMain .kb-top { flex-direction: column; align-items: stretch; } #adminMain .kb-view { flex-wrap: wrap; overflow: visible; } #adminMain .kb-view button { flex: 1 1 auto; padding: 8px 10px; } #adminMain .kb-search { max-width: none; flex: none; } }

/* Мобильная полировка и карточка заказа (25.11) */
#zsFile { max-width: 100%; width: 100%; min-width: 0; box-sizing: border-box; }
#drawer .specs select[data-za="setMgr"] { width: 100%; max-width: 100%; text-overflow: ellipsis; }
#drawer .d-foot { align-items: center; gap: 6px; padding: 12px 18px; }
#drawer .d-foot .btn { height: 42px; padding: 0 12px; font-size: 13px; white-space: nowrap; }
#drawer .d-foot .btn-primary { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

@media screen and (max-width: 860px) {
  #adminMain { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  #adminMain input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.cell-in),
  #adminMain select,
  #adminMain textarea,
  #drawer input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
  #drawer select,
  #drawer textarea { font-size: 16px; }
  #adminMain .btn-sm, #adminMain .chip, #drawer .btn-sm, #drawer .chip, .modal .btn-sm { min-height: 44px; }
  #drawer .icon-btn, .modal .icon-btn { min-width: 44px; min-height: 44px; }
  #drawer select[data-za="setMgr"] { height: 44px !important; min-height: 44px; }
  #drawer .d-foot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  #drawer .d-foot .btn { min-height: 44px; height: 44px; padding: 0 10px; font-size: 12.5px; }
  #drawer .specs > span:nth-child(odd) { align-self: center; }
}

@media screen and (max-width: 640px) {
  #shop .p .zo-opt { white-space: normal; font-size: 10.5px; line-height: 1.2; }
  #shop .head .wrap { height: auto; min-height: 56px; padding-block: 8px; flex-wrap: wrap; row-gap: 8px; }
  #shop .head .logo { margin-right: auto; }
  #shop .head .search { order: 5; flex: 1 1 100%; max-width: none; min-width: 0; }
  #shop .cats { position: static; }
  #adminMain .opts > .search { flex: 1 1 100%; max-width: none !important; min-width: 0; margin: 4px 0 0 !important; }
  .zt-url code { min-width: 0; width: 100%; }
  #zhPay { grid-template-columns: minmax(0, 1fr) 128px !important; }
  #zhPay > .inp:last-child { grid-column: 1 / -1; }
  #zhPay > .inp:last-child .btn { width: 100%; }
  #zhInv { grid-template-columns: 1fr !important; }
  #zhInv .btn { width: 100%; }
  #zaOrderBonus .zb-ba { grid-template-columns: 1fr !important; }
  #zaOrderBonus .zb-ba .btn { width: 100%; }
}

@media screen and (max-width: 560px) {
  #zwCompose .zw-row { flex-wrap: wrap; gap: 6px; }
  #zwCompose .zw-row textarea { flex: 1 1 100%; min-width: 0; }
  #zwCompose .zw-row .btn { min-height: 44px; }
  #zwCompose .zw-row .zw-send { flex: 1; }
  #zaAssign, #zaInfo { grid-template-columns: 1fr !important; }
  #zhPay { grid-template-columns: 1fr !important; }
}

@media screen and (max-width: 480px) {
  #adminMain .kpi b, #adminMain .zr .zr-kpi strong { font-size: clamp(13.5px, 3.7vw, 22px); }
  #drawer .specs { grid-template-columns: 108px minmax(0, 1fr); column-gap: 10px; }
}

@media screen and (max-width: 440px) {
  .ribbon .wrap { gap: 6px; padding-inline: 10px; }
  .ribbon .ribbon-logo img { height: 16px; }
  .ribbon .seg button { padding: 4px 9px; font-size: 12px; gap: 4px; }
  .ribbon .seg svg.i { width: 13px; height: 13px; }
  .ribbon .icon-btn { width: 28px; height: 28px; }
  body.zb-staff .ribbon .tag { font-size: 0; gap: 0; }
  body.zb-staff .ribbon .tag > a:not(.ribbon-logo) { display: none; }
}

/* ===== 25.11 UI-аудит (телефон 390 / планшет 768 / ноутбук 1440) — только раскладка, дизайн прежний ===== */
/* Шапка витрины 1101–1560px: 7 пунктов меню + поиск + «Войти» + «Корзина» не влезали, корзина уходила за правый край */
@media screen and (min-width: 1101px) and (max-width: 1560px) {
  #shop .head .wrap { gap: 10px; }
  #shop .head .nav { gap: 2px; flex: 0 1 auto; min-width: 0; }
  #shop .head .nav a { padding: 7px 7px; font-size: 13.5px; }
  #shop .head .search { min-width: 150px; flex: 1 1 160px; }
  #shop .head .zb-acc { padding: 0 11px; font-size: 13.5px; }
}
@media screen and (min-width: 1101px) and (max-width: 1240px) {
  #shop .head .nav a { padding: 6px 5px; font-size: 13px; }
  #shop .head .logo img, #shop .head .logo svg { max-width: 118px; height: auto; }
}
/* Окно документа: кнопка «?» подсказок не перекрывает PDF */
body:has(#docv:not(.hidden)) .zt-help { display: none; }
/* Суммы в списках дашборда и кабинета не рвутся на строки («24 / 350 / ₸») */
#adminMain .li > .r, #zbRoot .li > .r { white-space: nowrap; flex: none; }
@media screen and (max-width: 860px) {
  /* Ряды переключателей (период, тип, источник, статус) — одной строкой с прокруткой вбок, как фильтры «Заказов» */
  #adminMain .opts:has(> button.chip):not(:has(> label)),
  #drawer .d-body > .opts:has(> [data-zsrv]),
  #drawer .d-body > .opts:has(> [data-za="dSet"]),
  #zbRoot .zb-tabs {
    flex-wrap: nowrap !important; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
    scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-padding-inline: 16px;
    margin-inline: -16px; padding-inline: 16px; padding-block: 2px;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 28px), transparent);
            mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 28px), transparent);
  }
  #adminMain .opts:has(> button.chip):not(:has(> label))::-webkit-scrollbar,
  #drawer .d-body > .opts::-webkit-scrollbar, #zbRoot .zb-tabs::-webkit-scrollbar { display: none; }
  #adminMain .opts:has(> button.chip):not(:has(> label)) > *,
  #drawer .d-body > .opts:has(> [data-zsrv]) > *,
  #drawer .d-body > .opts:has(> [data-za="dSet"]) > *,
  #zbRoot .zb-tabs > * { flex: none; }
  #adminMain .card .opts:has(> button.chip):not(:has(> label)) { margin-inline: 0; padding-inline: 0; }
  #drawer .d-body > .opts:has(> [data-zsrv]),
  #drawer .d-body > .opts:has(> [data-za="dSet"]) { margin-inline: -18px; padding-inline: 18px; }
}
/* Шапка админки на телефоне: логотип не обрезается, «Кабинет клиента (демо)» → «Кабинет (демо)» */
@media screen and (max-width: 440px) {
  body.zb-staff .ribbon .tag { flex: none; }
  body.zb-staff .ribbon .seg { flex: none; }
  body.zb-staff .ribbon .seg svg { display: none; }
  .ribbon .zc-demo-cab { font-size: 0 !important; white-space: nowrap; flex: none; }
  .ribbon .zc-demo-cab::after { content: "Кабинет (демо)"; font-size: 11px; }
  .ribbon .wrap > .icon-btn { flex: none; margin-left: auto; }
}
/* Боковое меню админки на ноутбуке (высота окна до 1000px): все 21 раздел видны без прокрутки меню */
@media screen and (min-width: 861px) and (max-height: 1000px) {
  #admin .side { gap: 1px; padding-block: 12px; }
  #admin .side button.t { padding-block: 6px; font-size: 14px; }
  #admin .side .logo { margin-bottom: 4px; }
}
/* Окна снизу (телефон/планшет): содержимое с ограниченной шириной по центру, а не прижато влево */
@media screen and (max-width: 860px) {
  #modalBox > form, #modalBox > div { margin-inline: auto; }
}
/* Длинные формы в окнах (документ, КП, сделка, состав заказа): «Отмена / Сохранить» всегда видны внизу окна */
#modalBox form[style*="padding:28px"] > div:has(> [data-act="close"], > [data-zh="edClose"]):has(> .btn-primary, > .btn-dark) {
  position: sticky; bottom: 0; z-index: 3; background: var(--surface);
  margin-inline: -28px; padding: 12px 28px calc(12px + env(safe-area-inset-bottom));
  margin-bottom: -28px; border-top: 1px solid var(--line);
}
@media screen and (max-width: 560px) {
  #modalBox form[style*="padding:28px"] > div:has(> [data-act="close"], > [data-zh="edClose"]):has(> .btn-primary, > .btn-dark) { flex-wrap: nowrap !important; }
  #modalBox form[style*="padding:28px"] > div:has(> [data-act="close"], > [data-zh="edClose"]):has(> .btn-primary, > .btn-dark) > .btn-primary,
  #modalBox form[style*="padding:28px"] > div:has(> [data-act="close"], > [data-zh="edClose"]):has(> .btn-primary, > .btn-dark) > .btn-dark { flex: 1 1 auto; justify-content: center; }
}
/* Мелкие кнопки на телефоне: зона нажатия больше, вид прежний */
@media screen and (max-width: 860px) {
  .sw::before { content: ""; position: absolute; inset: -9px -4px; }
  .ci .stepper button, .ci [data-act="rm"] { position: relative; }
  .ci .stepper button::before, .ci [data-act="rm"]::before { content: ""; position: absolute; inset: -6px -3px; }
  .oc-amo { padding-block: 6px; margin-block: -2px -6px; }
  #drawer .zw-amo, #drawer .li > a.r { display: inline-block; padding-block: 8px; margin-block: -8px; }
}
/* Карточка заказа: правка клиента прямо в шапке (карандаш у «Клиент» и «Телефон») */
#drawer .za-hv { display: flex; align-items: center; gap: 8px; min-width: 0; }
#drawer .za-hv > :first-child { min-width: 0; overflow-wrap: anywhere; }
#drawer .za-hedit { width: 32px; height: 32px; flex: none; margin-block: -6px; }
#drawer .za-hedit svg { width: 15px; height: 15px; }
#drawer .za-hform[hidden] { display: none !important; }
#drawer .za-hform { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); }
@media screen and (max-width: 860px) {
  #drawer .za-hedit { width: 36px; height: 36px; margin-block: -8px; }
  #drawer .za-hform { grid-template-columns: 1fr !important; }
}
/* Витрина: каталог первым блоком под шапкой — небольшой отступ сверху, баннер ниже с прежним отступом */
#top > #catalog:first-child { padding-top: 22px; }
#top > #catalog:first-child + .hero { padding-top: 0; }
@media screen and (max-width: 860px) { #top > #catalog:first-child { padding-top: 14px; } }


/* ===== 25.11 UI-аудит, вторая порция: мелочи на телефоне (визуально тот же стиль) ===== */
.zd-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.zd-tools .zd-srcs { flex: 1 1 auto; min-width: 0; margin-bottom: 0; }
.zd-tools .zd-q { flex: 0 1 280px; }

@media screen and (max-width: 860px) {
  /* 1. Чёрная шапка: зона нажатия ≥44px, внешний вид кнопок прежний */
  .ribbon .seg button,
  .ribbon .icon-btn,
  .ribbon .zc-demo-cab,
  .ribbon a.ribbon-logo {
    position: relative;
  }
  .ribbon .seg button::before,
  .ribbon .icon-btn::before,
  .ribbon .zc-demo-cab::before,
  .ribbon a.ribbon-logo::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: max(100%, 44px);
    height: 44px;
    transform: translate(-50%, -50%);
  }

  /* 2. Кнопка «?» не накрывает суммы в списках: стоит на нижней панели справа */
  .zt-help {
    bottom: calc(8px + env(safe-area-inset-bottom));
    right: 8px;
    height: 44px;
    width: 44px;
    min-width: 44px;
    z-index: 58;
  }
  .adm .side { padding-right: 48px; }
  .adm::after { width: 52px; }

  /* 3. Документы: источники одной строкой с прокруткой, поиск на следующей
     (общие правила для .opts уже дают прокрутку и маску — без второго отрицательного margin) */
  #adminMain .zd-tools { flex-direction: column; align-items: stretch; gap: 8px; }
  #adminMain .zd-tools .zd-srcs { flex-wrap: nowrap !important; }
  #adminMain .zd-tools .zd-q { flex: 1 1 auto; max-width: none !important; margin: 0 !important; width: 100%; }

  /* 2b. Запас справа у нижней панели, чтобы «?» не накрывал последний пункт */
  body:has(#ztHelp:not([style*="none"])) #shop .bnav { padding-right: 52px; }
  .adm .side { padding-right: 56px; }
  .adm::after { width: 60px; background: linear-gradient(90deg, transparent, var(--surface) 40%, var(--surface)); }

  /* 4. «Кто» и значение в одной строке, не столбиком */
  #adminMain .tbl-cards td[data-l="Кто"] {
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
    white-space: nowrap;
  }

  /* 6. Кабинет: компактные 2×2 карточки, вкладки ближе к верху */
  .zb-page { padding-top: 14px; margin-bottom: 28px; }
  .zb-page > .sec-head { margin-bottom: 10px; gap: 8px; align-items: flex-start; }
  .zb-page > .sec-head .sub { margin-top: 4px; }
  #zbRoot .zc-topbar { margin-bottom: 8px; gap: 8px; }
  #zbRoot .kpis { gap: 6px; margin-bottom: 8px; }
  #zbRoot .kpi { padding: 8px 10px; }
  #zbRoot .kpi .l { font-size: 11.5px; gap: 4px; }
  #zbRoot .kpi .l svg { width: 14px; height: 14px; }
  #zbRoot .kpi b { font-size: 16px; margin-top: 2px; line-height: 1.2; }
  #zbRoot .kpi b[style] { font-size: 14.5px !important; line-height: 1.25 !important; }
  #zbRoot .kpi .d { font-size: 10.5px; margin-top: 1px; }
  #zbRoot .zb-tabs { margin-top: 0; margin-bottom: 10px; }
}
