/* Телефон (≤ 768px): общие правила страниц. Меню на телефоне — нижняя панель и верхняя строка (дизайн-блок, Д3: shell/shell.css);
   прежние «☰» и выезжающее меню убраны. На ширине > 768px этот файл ничего не меняет — все правила внутри @media.
   Н0 «Основа Н4» (24.10.2026): правки телефона со стенда Н4 (разбор audit + adapt на 360, 390, 430): Задачи — колонки друг под
   другом, поиск во всю ширину, сегменты строками с прокруткой; Клиенты и Пользователи — карточки вместо таблиц; «Добавить задачу» —
   срок во всю ширину; остальные таблицы прокручиваются внутри своей рамки. Вид страниц на компьютере — шаги страниц. */

@media (max-width: 768px) {
  .page-header { flex-wrap: wrap; gap: 10px; }
  .table-wrap { overflow-x: auto; }
  .modal { padding: 22px 18px; }
}

@media screen and (max-width: 768px) {
  /* ── Задачи: фильтры — поиск во всю ширину, каждый ряд сегментов — во всю ширину с прокруткой; колонки — одна под другой ── */
  .tasks-filter-bar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 12px; }
  .tasks-filter-bar .an-fb-sep { display: none; }
  .tasks-filter-bar #tf-search { min-width: 0 !important; max-width: none !important; width: 100%; min-height: 44px; font-size: 16px !important;
    padding: 0 14px !important; }
  .tasks-filter-bar .an-period-group { display: flex; width: 100%; }
  .tasks-filter-bar .an-period-btn { flex: 1 0 auto; }
  .tasks-filter-bar #tf-manager { min-width: 0 !important; min-height: 44px; font-size: 16px !important; width: 100%; }
  .task-kanban { grid-template-columns: minmax(0, 1fr) !important; gap: 12px; }
  .task-col-body { max-height: none !important; min-height: 0 !important; }
  .tasks-stat-label { font-size: 12.5px !important; }

  /* «Добавить задачу»: срок — во всю ширину, приоритет и повтор — по половине */
  #add-task-modal div[style*="grid-template-columns:1fr 1fr 1fr"] { grid-template-columns: 1fr 1fr !important; }
  #add-task-modal div[style*="grid-template-columns:1fr 1fr 1fr"] > div:first-child { grid-column: 1 / -1; }

  /* ── Клиенты: таблица → карточки (галочка; имя, телефон; источник; число КП справа) ── */
  #page-clients .table-wrap { overflow: visible; }
  #page-clients .table-filters { display: flex; flex-wrap: nowrap; gap: 8px; align-items: center; }
  #page-clients .table-filters .form-input { flex: 1; min-width: 0 !important; width: auto !important; }
  #page-clients table, #page-clients thead, #page-clients tbody { display: block; }
  #page-clients thead tr { display: flex; align-items: center; min-height: 44px; border-bottom: 1px solid var(--c-line-2); }
  #page-clients thead th { display: none; }
  #page-clients thead th:first-child { display: flex; align-items: center; width: auto !important; padding: 0 0 0 16px !important; border: 0;
    font-size: 13px; color: var(--c-sub); }
  #page-clients thead th:first-child input { width: 20px !important; height: 20px !important; }
  #page-clients thead th:first-child::after { content: "Выбрать все"; }
  #clients-tbody tr { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-areas: "cb name kp" "cb phone kp" "cb meta meta";
    align-items: center; column-gap: 4px; padding: 12px 14px 12px 4px; border-bottom: 1px solid var(--c-line-2); }
  #clients-tbody td { border: 0 !important; padding: 0 !important; min-width: 0; }
  #clients-tbody td:nth-child(1) { grid-area: cb; display: flex; align-items: center; justify-content: center; align-self: stretch; }
  #clients-tbody td:nth-child(1) input { width: 20px !important; height: 20px !important; }
  #clients-tbody td:nth-child(2) { grid-area: name; font-size: 15px; }
  #clients-tbody td:nth-child(3) { grid-area: phone; font-size: 14px; color: var(--c-sub) !important; }
  #clients-tbody td:nth-child(4) { grid-row: 3; grid-column: 2 / 4; font-size: 12.5px; color: var(--c-sub) !important; margin-top: 4px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #clients-tbody td:nth-child(5), #clients-tbody td:nth-child(6) { display: none; }
  #clients-tbody td:nth-child(7) { grid-area: kp; font-size: 13px; font-weight: 600; background: var(--c-fill); border-radius: 9999px; padding: 2px 10px !important; }
  #clients-tbody td:nth-child(7)::before { content: "КП\00a0"; font-weight: 500; color: var(--c-sub); }
  #clients-tbody td[colspan] { grid-column: 1 / -1; grid-row: auto; background: none; }
  #clients-tbody td[colspan]::before { content: none; }

  /* ── Пользователи: таблица → карточки (имя и должность; логин и статус; действия строкой) ── */
  #page-users table thead { display: none; }
  #page-users table, #users-tbody { display: block; }
  #users-tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 12px 14px; border-bottom: 1px solid var(--c-line-2); }
  #users-tbody td { border: 0 !important; padding: 0 !important; min-width: 0; }
  #users-tbody td:nth-child(1) { font-size: 15px; }
  #users-tbody td:nth-child(2) { grid-column: 1; grid-row: 2; color: var(--c-sub) !important; font-size: 13px; }
  #users-tbody td:nth-child(3) { grid-column: 2; grid-row: 1; justify-self: end; }
  #users-tbody td:nth-child(4) { grid-column: 2; grid-row: 2; justify-self: end; }
  #users-tbody td:nth-child(5) { display: none; }
  #users-tbody td:nth-child(6) { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
  #users-tbody td[colspan] { grid-column: 1 / -1; grid-row: auto; display: block; }

  /* Воронка: поиск, менеджер, период и «Фильтры» — 44 px, шрифт 16 px (iOS не увеличивает страницу); вид Воронки — шаг «Воронка» */
  :is(.pl-in, .pl-fbtn) { height: 44px; min-height: 44px; font-size: 16px; }

  /* остальные таблицы (прайс-листы, акции, журнал) — прокрутка внутри своей рамки */
  .table-wrap:not(.kp-doc *) { overflow-x: auto; }
  #page-promotions :is(.form-input, .form-select) { width: 100% !important; max-width: none !important; }
}
