/* ============================================================================
   №322 (19.09.2026) — DESKTOP-СЛОЙ ДЛЯ ВСЕЙ PWA (адаптив, ЧАСТЬ B)
   ============================================================================
   Владелец: «все страницы, кроме дашборда, — mobile-вёрстка на десктопе:
   форма в одну колонку, поля огромные, max-width не ограничен, пустое место
   справа».

   ЗАЧЕМ ОТДЕЛЬНЫЙ ФАЙЛ: страницы рисуют свои <style>-блоки ВНУТРИ <head> в
   момент рендера (mobile-first: .pp-btn { width:100% }, поля 44-48px).
   Поэтому desktop-правила должны идти ПОСЛЕ и с !important.

   ПРАВИЛА (по ТЗ владельца):
     ≥1024px  — max-width 1200px по центру; кнопки/поля 36-40px;
                отступы 16-24px; шрифт 14-16px; формы 2 колонки;
                карточки 2-3 колонки; счётчики 4 в ряд.
     1400px+  — 3 колонки карточек, контейнер 1280px.
     768-1023 — 1-2 колонки (планшет), mobile-размеры тапов сохраняются.
     <768px   — НЕ ТРОГАЕМ (остаётся mobile: 1 колонка, кнопки 44-48px).

   ⚠️ Медиа-запросы только ≥768px, поэтому мобильная вёрстка не меняется.
   ========================================================================= */

@media (min-width: 1024px) {
    /* ── 1. Контейнер: 1200px по центру, отступы 16-24px ───────────────── */
    .container {
        max-width: 1200px !important;
        margin-left: auto !important;
        margin-right: auto !important;
        padding: 20px 24px 28px !important;
        font-size: 15px !important;
    }
    /* вход/регистрация — узкая колонка (форма не растягивается на монитор) */
    .container.auth-page,
    .login-wrap,
    .cv-form-narrow {
        max-width: 560px !important;
    }

    /* ── 2. Кнопки: 36-40px, не «простыня» на всю ширину ───────────────── */
    .btn, .btn-primary, .btn-secondary, .btn-danger, .btn-vk,
    .pp-btn, .fp-btn, .wh-btn, .wa-btn, .emp-btn, .ac-btn,
    .cv-btn, .lg-btn, .v-btn {
        min-height: 38px !important;
        font-size: 14px !important;
        padding: 9px 16px !important;
        width: auto !important;
        max-width: none !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    .cv-btn-sm, .btn-sm {
        min-height: 32px !important;
        padding: 6px 12px !important;
        font-size: 13px !important;
    }
    /* внутри форм и футеров действий — на всю ширину своей колонки */
    .cv-actions-end .cv-btn, .cv-actions-end .btn,
    .cv-form-grid .cv-btn, .cv-form-grid .btn,
    .pp-btn.mid, .fp-btn.mid { width: 100% !important; }

    /* ── 3. Поля: 36-40px, шрифт 14px ──────────────────────────────────── */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
    select, textarea,
    .input, .pp-input, .pp-select, .fp-in, .fp-input, .wh-input, .cv-input {
        min-height: 38px !important;
        font-size: 14px !important;
        padding: 8px 12px !important;
    }
    textarea { min-height: 96px !important; }

    /* ── 4. Типографика 14-16px ────────────────────────────────────────── */
    .h2, h2 { font-size: 22px !important; }
    h3 { font-size: 17px !important; }
    .text-muted, .fp-muted, .pp-muted, .kb-meta, .leg-empty {
        font-size: 13px !important;
    }

    /* ── 5. Карточки компактнее (отступы 16px, не 32-48px) ─────────────── */
    .card, .pp-card, .fp-card, .cv-card { padding: 16px !important; }

    /* ── 6. Списки карточек → 2 колонки ─────────────────────────────────
       :has(> .card + .card) = «есть минимум две карточки подряд» —
       значит это список, а не одиночный блок. */
    .container > div:has(> .card + .card),
    .container > div:has(> .pp-card + .pp-card),
    .container > div:has(> .fp-card + .fp-card),
    .container > div:has(> .cv-card + .cv-card) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 16px !important;
        align-items: start !important;
    }
    .container > div:has(> .card + .card) > *,
    .container > div:has(> .cv-card + .cv-card) > * {
        margin-bottom: 0 !important;
    }
    /* служебные блоки в списке — на всю ширину сетки */
    .container > div:has(> .card + .card) > .cv-grid-wide,
    .container > div:has(> .card + .card) > .error,
    .container > div:has(> .card + .card) > .loader {
        grid-column: 1 / -1 !important;
    }

    /* ── 7. Счётчики — 4 в ряд ─────────────────────────────────────────── */
    .cv-stats, .stats, .p-stats, .fp-sums, .cards-grid.cards-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }

    /* ── 8. Паспорт авто: 2 колонки (клиент | авто), шапка на всю ширину ─ */
    #pp-body {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 16px !important;
        align-items: start !important;
    }
    #pp-body > .pp-card { margin-bottom: 0 !important; }
    #pp-body > .pp-card:first-child { grid-column: 1 / -1 !important; }
    /* галерея фото — плотнее (мелкие плитки вместо трёх огромных) */
    .pp-grid { grid-template-columns: repeat(6, 1fr) !important; }
    .pp-seg button { font-size: 13px !important; }

    /* ── 9. Чат: 900px по центру, бабблы на всю ширину колонки ─────────── */
    .chat-page { max-width: 900px !important; margin: 0 auto !important; }
    .chat-log { max-height: 62vh !important; }

    /* ── 10. Таблицы (график, выручка, обмен, легенды) ─────────────────── */
    .container table, .desk-table { width: 100% !important; }
    .container td, .container th { font-size: 14px !important; }

    /* ── 11. Нижняя навигация — «док» по центру ────────────────────────── */
    #bottom-nav { max-width: 900px !important; }
}

/* ── Очень широкие мониторы: 3 колонки карточек ───────────────────────── */
@media (min-width: 1400px) {
    .container { max-width: 1280px !important; }
    .container > div:has(> .card + .card + .card),
    .container > div:has(> .cv-card + .cv-card + .cv-card) {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
    #pp-body { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    .pp-grid { grid-template-columns: repeat(8, 1fr) !important; }
}

/* ── Планшет 768-1023: 1-2 колонки, тапы остаются крупными ─────────────── */
@media (min-width: 768px) and (max-width: 1023.98px) {
    .container:not(.auth-page):not(.login-wrap) {
        max-width: 100% !important;
        padding: 16px !important;
    }
    .container > div:has(> .card + .card),
    .container > div:has(> .cv-card + .cv-card) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 14px !important;
        align-items: start !important;
    }
    #pp-body { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 14px !important; }
}


/* ============================================================================
   №322 этап 3-4 (19.09.2026) — очереди карточек на всех страницах
   ============================================================================
   Замер показал: у большинства страниц после дашборда НЕТ сетки — карточки
   идут одной колонкой на 1232px (works/.wa-card, employees/.emp-card,
   legends/.rec-card, cash/.cash-card, profile/.card). Правила ниже кладут
   ОДНОТИПНЫЕ карточки в 2-3 колонки. Селектор :has(> X + X) висит на самой
   обёртке, поэтому не зависит от уровня вложенности (в employees карточки
   лежат внутри .card).
   ========================================================================= */
@media (min-width: 1024px) {
    /* Работы: «назначение авто» и список работ */
    div:has(> .wa-card + .wa-card),
    div:has(> .emp-card + .emp-card),
    div:has(> .doc-card + .doc-card),
    div:has(> .cv-card + .cv-card) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 14px !important;
        align-items: start !important;
    }
    /* Легенды: рекорды и лента */
    div:has(> .rec-card + .rec-card),
    div:has(> .lead-card + .lead-card) {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 14px !important;
        align-items: start !important;
    }
    /* Касса: карточки выручки (наличные/безнал/итог) — 3 в ряд */
    div:has(> .cash-card + .cash-card) {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 14px !important;
        align-items: start !important;
    }
    div:has(> .cash-card + .cash-card) > .cash-form,
    div:has(> .cash-card + .cash-card) > .cash-note { grid-column: 1 / -1 !important; }

    /* Рейтинг: строки таблицы — в 2 колонки (компактнее) */
    div:has(> .board-row + .board-row) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px 14px !important;
        align-items: start !important;
    }
    div:has(> .board-row + .board-row) > :first-child { grid-column: 1 / -1 !important; }

    /* Профиль и любые страницы, где .card — прямые дети .container */
    .container:has(> .card + .card):not(.dash-home) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 16px !important;
        align-items: start !important;
    }
    .container:has(> .card + .card):not(.dash-home) > .card:first-child,
    .container:has(> .card + .card):not(.dash-home) > div:first-child:not(.card) { grid-column: 1 / -1 !important; }
    .container:has(> .card + .card):not(.dash-home) > .card { margin-bottom: 0 !important; }

    /* Быстрые правки: форма + фильтры сверху, карточки — 2 колонки */
    div:has(> .qt-card + .qt-card) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 14px !important;
        align-items: start !important;
    }

    /* Склад (нет .container — своя .wh-wrap) */
    .wh-wrap {
        max-width: 1200px !important;
        margin: 0 auto !important;
        padding: 20px 24px 90px !important;
    }
    /* Логистика/моно (monoblock) и прочие wrap-страницы */
    .mono-wrap, .lg-wrap, .page-wrap { max-width: 1200px !important; margin: 0 auto !important; }

    /* ── 13. Поля/кнопки: ЖЁСТКАЯ высота 38px (было 45-48 у части страниц) ── */
    .container input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
    .container select,
    .wh-wrap input:not([type="checkbox"]):not([type="radio"]),
    .wh-wrap select {
        height: 38px !important;
        min-height: 38px !important;
        padding: 6px 10px !important;
        font-size: 14px !important;
        box-sizing: border-box !important;
    }
    .container textarea, .wh-wrap textarea { font-size: 14px !important; min-height: 84px !important; }
    /* кнопки-иконки навигации в шапках остаются мелкие, крупные CTA — 38px */
    .container button:not(.kb-switch):not(.icon-btn):not(.cv-icon):not(.pp-tab):not(.tab):not(.qt-filter):not(.qt-pr):not(.qt-src):not(.chat-icon-btn),
    .wh-wrap button {
        min-height: 36px !important;
        font-size: 14px !important;
    }
    /* таблицы: компактные строки */
    .container .board-row { padding: 9px 12px !important; font-size: 14px !important; }
}

@media (min-width: 1400px) {
    /* 3 колонки для «широких» списков */
    div:has(> .wa-card + .wa-card + .wa-card) { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    div:has(> .emp-card + .emp-card + .emp-card) { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    div:has(> .rec-card + .rec-card + .rec-card) { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
    .container:has(> .card + .card):not(.dash-home) { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

/* ── Планшет 768-1023: 2 колонки для тех же списков (тапы остаются крупными) ── */
@media (min-width: 768px) and (max-width: 1023.98px) {
    div:has(> .wa-card + .wa-card),
    div:has(> .emp-card + .emp-card),
    div:has(> .rec-card + .rec-card),
    div:has(> .cash-card + .cash-card) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px !important;
        align-items: start !important;
    }
    .container:has(> .card + .card):not(.dash-home) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 14px !important;
        align-items: start !important;
    }
}

/* ── №322 этап 3-4, добивка: чат 900px, уведомления 900px, паспорт-поиск ── */
@media (min-width: 1024px) {
    /* Чат: узкая колонка по центру (разметка чата — прямые дети .container) */
    .container:has(> .chat-log) { max-width: 900px !important; }
    .container:has(> .chat-log) .chat-input-row { position: sticky !important; bottom: 8px !important; }
    /* Уведомления: одна колонка, но не «простыня» на 1232px */
    #notif-list, .notif-list, .container:has(> div > .notif-title) { max-width: 820px !important; }
    .notif-card, .notif-item { max-width: 820px !important; }
    /* Паспорт: экран поиска авто — форма по центру, не растянута */
    .container:has(> #pp-body) { max-width: 1280px !important; }
    #pp-body { font-size: 14px !important; }
    /* Кнопки-иконки в шапках страниц (◀ / 🔄) — компактные, не 38px */
    .container > div:first-child button:has(svg), .container > div:first-child > button.icon-btn { min-height: 32px !important; }
}

/* ============================================================================

/* ============================================================================
   🔴 №322-РЕГРЕССИЯ (19.09.2026) — ДАШБОРД ВНЕ СЕТОК
   ============================================================================
   Правило №322 «.container:has(> .card + .card)» ловило контейнер ДАШБОРДА
   (прямые дети: #card-decisions, красная строка «🏁 Каваллино · Сегодня»,
   .cards-grid) — карточки встали в 3 колонки по 400px: «Требует решения»
   и дата рядом, посты 196px, погода ужалась до 123px и уехала вниз,
   тумблеры зон выросли до 36px («в 2 ряда»).
   Лечим В ИСТОЧНИКЕ (см. :not(.dash-home) выше) — иначе не перебить
   специфичность. Класс dash-home ставит dashboard.js (директор + рабочий
   экран) на div.container.
   Здесь — только страховка и вид свёрнутой карточки решений.
   ========================================================================= */
.container.dash-home {
    display: block !important;
    grid-template-columns: none !important;
}
.container.dash-home > .card { margin-bottom: 12px !important; }
.container.dash-home .cards-grid { display: grid !important; }
.container.dash-home .kb-zone-row { min-height: 30px !important; }

/* «Требует решения», когда разбирать нечего — свёрнутая тонкая строка */
#card-decisions.dec-empty { padding: 9px 14px !important; margin-bottom: 12px !important; }
#card-decisions.dec-empty #decisions-head { gap: 8px !important; }
#card-decisions.dec-empty #decisions-head > div:first-child { font-size: 19px !important; }
#card-decisions.dec-empty #decisions-head > div:nth-child(2) > div:first-child {
    font-size: 13.5px !important;
}
