/* ============================================================
   Телефон (SPEC-redesign §8, этап D): ≤ 480 px, проверка на 390 и 360.
   Ссылки из Telegram открывают с телефона — Главная, панель проблем и
   страница кабинета здесь должны работать безупречно, остальные разделы —
   быть пригодными для работы.

   Правила для всех разделов:
   • хит-зоны кнопок, ссылок, полей и флажков — не меньше 44 × 44 px;
   • у страницы нет горизонтальной прокрутки: широкие таблицы
     прокручиваются внутри своей карточки, первый (опознающий строку)
     столбец при этом закреплён слева;
   • поля ввода — 16 px: мельче iOS увеличивает страницу при фокусе;
   • цвета — только токены styles.css (контраст ≥ 4,5:1 в обеих темах).
   Десктоп (≥ 481 px) этот файл не меняет, кроме кнопки меню, которая
   там скрыта.
   ============================================================ */

/* Только для телефона: кнопка меню, короткая свежесть данных в шапке, полоса
   «‹ Назад … ✕» панели проблем — на десктопе их нет. */
.menu-toggle { display: none; }
.status-short { display: none; }
.drawer-bar { display: none; }
/* Хит-зона флажка строки «Отчётов»: на десктопе обёртка раскладки не меняет. */
.c-check-hit { display: contents; }

@media (max-width: 480px) {
  :root { --page-pad: 16px; --topbar-h: 56px; }
  html { scroll-padding-top: calc(var(--topbar-h) + 12px); }

  /* ---------- Шапка: одна строка ----------
     «dashbox» · свежесть данных · «Главная» со счётчиком · меню.
     Узлы — те же, что на десктопе: обёртки шапки не участвуют в раскладке
     (display: contents), их содержимое расставляет сетка. */

  .topbar { position: sticky; top: 0; min-height: 57px; }
  .topbar-inner {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center;
    column-gap: 6px; row-gap: 0; min-height: 56px; padding: 6px 6px 6px var(--page-pad);
  }
  .topbar-left, .topbar-right { display: contents; }

  .brand {
    grid-row: 1; grid-column: 1; display: inline-flex; align-items: center;
    min-height: 44px; padding-right: 2px; font-size: 18px;
  }
  .status-indicator { grid-row: 1; grid-column: 2; min-width: 0; font-size: 12px; gap: 5px; }
  .status-indicator > span { min-width: 0; gap: 5px !important; }
  .status-indicator .status-text, .status-indicator .status-busy, .status-indicator .stale-badge { display: none; }
  .status-short { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink2); }
  .status-short.is-stale { color: var(--warn); }
  .status-short.is-err { color: var(--crit); }

  /* «Главная» со счётчиком всегда на виду — остальные пункты в меню */
  .nav { grid-row: 1; grid-column: 3; display: flex; gap: 0; flex-wrap: nowrap; }
  .nav a:not([data-route="home"]) { display: none; }
  .nav a { min-height: 44px; padding: 0 10px; font-size: 15px; gap: 6px; border-radius: 8px; }
  .nav-badge { min-width: 22px; line-height: 18px; font-size: 12px; }

  .period-control, .theme-toggle, .user-menu { display: none; }

  .menu-toggle {
    grid-row: 1; grid-column: 4; display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--ink); cursor: pointer;
  }
  .menu-toggle:hover { background: var(--surface2); }
  .menu-icon, .menu-icon::before, .menu-icon::after {
    display: block; width: 20px; height: 2px; border-radius: 1px; background: currentColor;
    transition: transform 0.14s ease-out, background 0.14s ease-out;
  }
  .menu-icon { position: relative; }
  .menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0; }
  .menu-icon::before { top: -6px; }
  .menu-icon::after { top: 6px; }

  /* ---------- Открытое меню: лист под строкой шапки ---------- */

  .topbar.is-menu-open::before {
    content: ""; position: fixed; inset: 0; z-index: 1; background: var(--scrim);
    touch-action: none; /* страница под затемнением не прокручивается */
  }
  .topbar.is-menu-open .topbar-inner {
    position: fixed; top: 0; left: 0; right: 0; z-index: 2;
    max-height: 100vh; max-height: 100dvh; overflow-y: auto; overscroll-behavior: contain;
    align-content: start; row-gap: 4px; padding-bottom: 14px;
    background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-menu);
  }
  .topbar.is-menu-open .menu-icon { background: transparent; }
  .topbar.is-menu-open .menu-icon::before { transform: translateY(6px) rotate(45deg); }
  .topbar.is-menu-open .menu-icon::after { transform: translateY(-6px) rotate(-45deg); }

  /* Разделы — списком во всю ширину */
  .topbar.is-menu-open .nav {
    grid-row: 2; grid-column: 1 / -1; flex-direction: column; gap: 2px; width: auto;
    margin: 6px 10px 0 0; padding-top: 8px; border-top: 1px solid var(--line2);
  }
  .topbar.is-menu-open .nav a:not([data-route="home"]) { display: flex; }
  .topbar.is-menu-open .nav a { min-height: 48px; padding: 0 12px; font-size: 16px; justify-content: flex-start; }

  /* Свежесть данных — полной строкой, с пометками «идёт сбор», «нет обновления» */
  .topbar.is-menu-open .status-indicator {
    grid-row: 3; grid-column: 1 / -1; flex-wrap: wrap; min-height: 32px; margin: 4px 10px 0 12px; font-size: 13px;
  }
  .topbar.is-menu-open .status-indicator > span { flex-wrap: wrap; row-gap: 4px !important; }
  .topbar.is-menu-open .status-indicator .status-text,
  .topbar.is-menu-open .status-indicator .status-busy { display: inline; white-space: normal; }
  .topbar.is-menu-open .status-indicator .stale-badge { display: inline-block; }
  .topbar.is-menu-open .status-short { display: none; }

  /* Период, тема, пользователь — строками во всю ширину */
  .topbar.is-menu-open .period-control:not([hidden]),
  .topbar.is-menu-open .theme-toggle,
  .topbar.is-menu-open .user-menu { display: block; grid-column: 1 / -1; margin-right: 10px; }
  .topbar.is-menu-open .period-control { grid-row: 4; margin-top: 4px; }
  .topbar.is-menu-open .theme-toggle { grid-row: 5; }
  .topbar.is-menu-open .user-menu { grid-row: 6; padding-top: 8px; border-top: 1px solid var(--line2); margin-top: 6px; }

  .topbar.is-menu-open .period-btn,
  .topbar.is-menu-open .theme-toggle {
    min-height: 48px; padding: 0 12px; font-size: 15px; text-align: left; justify-content: flex-start;
  }
  .topbar.is-menu-open .period-btn { width: 100%; }
  .topbar.is-menu-open .theme-toggle { width: auto; }
  .topbar.is-menu-open .period-btn .chev { margin-left: auto; font-size: 12px; }
  .topbar.is-menu-open .user-btn {
    width: 100%; min-height: 48px; padding: 0 12px 0 8px; border-radius: 8px; font-size: 15px; color: var(--ink);
  }
  .topbar.is-menu-open .user-btn:hover { background: var(--surface2); }
  .topbar.is-menu-open .user-avatar { width: 32px; height: 32px; border-radius: 16px; font-size: 14px; }
  .topbar.is-menu-open .user-name-label { display: inline; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Поповеры внутри листа — прямо в листе, без всплывания */
  .topbar.is-menu-open .popover {
    position: static; min-width: 0; margin-top: 6px; box-shadow: none; animation: none;
  }
  .topbar.is-menu-open .period-preset { min-height: 44px; font-size: 15px; }
  .topbar.is-menu-open .period-custom-row label { width: 24px; font-size: 13px; }
  .topbar.is-menu-open .period-custom input[type="date"] { min-height: 44px; font-size: 16px; }
  .topbar.is-menu-open .period-custom .btn { min-height: 44px; font-size: 15px; }

  /* ---------- Главная: список кабинетов вместо матрицы ---------- */

  .home { gap: 12px; }
  .home .view-title { font-size: 22px; line-height: 1.25; }
  .home-sub { font-size: 13px; line-height: 1.45; }
  .since { font-size: 13px; }

  /* Плитки сигналов 2 × 2: число, название, пояснение; «Все →» — в углу */
  .ml-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ml-tile {
    position: relative; display: flex; min-width: 0;
    background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--line);
    border-radius: var(--radius-tile);
  }
  .ml-tile.sev-critical { border-top-color: var(--crit); }
  .ml-tile.sev-warning { border-top-color: var(--warn); }
  .ml-tile.sev-info { border-top-color: var(--info); }
  .ml-tile.is-on { background: var(--accent-bg); border-color: var(--accent); }
  .ml-tile-main {
    display: flex; flex-direction: column; gap: 4px; width: 100%; min-width: 0; min-height: 108px;
    padding: 10px 12px 12px; border: 0; border-radius: 0 0 7px 7px; background: none; cursor: pointer;
    text-align: left; color: inherit; font: inherit;
  }
  .ml-tile-main:focus-visible { outline-offset: -2px; }
  .ml-tile-num { font-size: 26px; line-height: 1.05; font-weight: 500; color: var(--ink3); margin-bottom: 2px; }
  .ml-tile.sev-critical .ml-tile-num { color: var(--crit); }
  .ml-tile.sev-warning .ml-tile-num { color: var(--warn); }
  .ml-tile.sev-info .ml-tile-num { color: var(--info); }
  .ml-tile-label { font-size: 13px; line-height: 1.25; font-weight: 600; color: var(--ink2); }
  .ml-tile:not(.is-zero) .ml-tile-label { color: var(--ink); }
  .ml-tile-note { font-size: 12px; line-height: 1.35; color: var(--ink3); overflow-wrap: anywhere; }
  .ml-tile.is-on .ml-tile-note { color: var(--ink2); }
  .ml-tile-all {
    position: absolute; top: 0; right: 0; display: inline-flex; align-items: center; justify-content: center;
    min-width: 64px; min-height: 44px; padding: 0 10px; border: 0; border-radius: 0 7px 0 8px; background: none;
    color: var(--accent); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  }
  .ml-tile-all:focus-visible { outline-offset: -2px; }

  /* Панель инструментов: поиск во всю ширину, чипы на одной строке, кнопки по 44 px */
  .home-search { width: 100%; min-height: 44px; font-size: 16px; }
  .quick { display: flex; width: 100%; gap: 6px; }
  .quick-chip { flex: 1 1 auto; justify-content: center; min-height: 44px; padding: 0 10px; align-items: center; font-size: 14px; }
  .col-chip { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; max-width: 100%; white-space: normal; text-align: left; }
  .home-toolbar .btn { min-height: 44px; font-size: 14px; }
  /* «Группировка» и «Столбцы» — строкой, «Сортировка» — под ними, счётчик — последним */
  .home-toolbar > .group-control, .home-toolbar > .cols-control { order: 5; flex: 1 1 auto; max-width: 100%; }
  .home-toolbar > .home-sort { order: 6; flex: 1 1 100%; }
  .home-toolbar > .home-count { order: 10; }
  .home-toolbar > .col-chip-host:empty { display: none; }
  .home-toolbar > .col-chip-host { flex-basis: 100%; }
  .home-toolbar > :is(.group-control, .cols-control) > .btn { width: 100%; justify-content: space-between; }

  /* Список */
  .ml-list { list-style: none; margin: 0; padding: 0; overflow: hidden; }
  .ml-item { display: flex; flex-direction: column; gap: 6px; padding: 4px 0 12px; border-bottom: 1px solid var(--line2); min-width: 0; }
  .ml-item:last-child { border-bottom: 0; }
  .ml-cab {
    display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 12px 2px 16px;
    color: inherit; border-radius: 0;
  }
  .ml-cab:hover { text-decoration: none; background: var(--surface2); }
  .ml-cab:focus-visible { outline-offset: -2px; }
  .ml-cab-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
  .ml-cab-name { font-size: 15px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
  .ml-cab-sub { font-size: 12px; line-height: 1.35; color: var(--ink3); overflow-wrap: anywhere; }
  .ml-cab-sub.is-warn { color: var(--warn); }
  .ml-cab-sub.is-crit { color: var(--crit); }
  .ml-chev { flex: none; font-size: 24px; line-height: 1; color: var(--ink3); }
  .ml-item.is-noaccess .ml-metric b { color: var(--ink2); }
  .ml-item.is-service { background: var(--surface2); }
  .ml-item.is-service .ml-cab:hover { background: none; }
  .ml-item.is-service .ml-cab-name, .ml-item.is-service .ml-cab-sub { color: var(--ink2); }

  .ml-pills { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px; }
  .ml-pill {
    display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 44px; padding: 0 10px;
    border-radius: 8px; border: 1px solid transparent; background: transparent; cursor: pointer;
    font: inherit; font-size: 13px; line-height: 1.25; text-align: left; transition: filter 0.12s ease-out;
  }
  button.ml-pill:hover { filter: brightness(0.97); }
  .ml-pill-label { font-weight: 500; color: var(--ink2); }
  .ml-pill-val { font-family: var(--font-num); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .ml-pill.sev-critical { background: var(--crit-bg); color: var(--crit); border-color: var(--crit-line); }
  .ml-pill.sev-warning { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
  .ml-pill.sev-info { background: var(--info-bg); color: var(--info); border-color: var(--line); }
  .ml-pill.is-muted { border: 1px dashed var(--ink3); color: var(--ink2); }
  .ml-pill.is-muted .ml-pill-val { font-weight: 500; }
  .ml-pill.is-nodata { background: var(--surface2); color: var(--ink2); cursor: default; }
  .ml-pill.is-nodata .ml-pill-val { font-weight: 500; }
  .ml-pill.is-col { box-shadow: 0 0 0 2px var(--accent); }
  .ml-pill .mx-count {
    flex: none; min-width: 18px; padding: 0 5px; border-radius: 9px; font-family: var(--font-num);
    font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; color: var(--surface);
  }
  .ml-pill.sev-critical .mx-count { background: var(--crit); }
  .ml-pill.sev-warning .mx-count { background: var(--warn); }
  .ml-pill.sev-info .mx-count { background: var(--info); }

  .ml-metrics { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 0; padding: 0 16px; font-size: 13px; color: var(--ink3); }
  .ml-metric { white-space: nowrap; }
  .ml-metric b { font-weight: 500; color: var(--ink); }
  .ml-metric-sep { white-space: pre; color: var(--ink3); }
  .ml-dev { font-size: 12px; }
  .ml-dev.is-crit { color: var(--crit); }
  .ml-dev.is-warn { color: var(--warn); }
  .ml-dev.is-ok { color: var(--ok); }
  .ml-spark { flex-basis: 100%; margin-top: 4px; }
  .ml-spark svg { display: block; }

  /* Группы и служебные строки */
  .ml-group { background: var(--surface2); border-bottom: 1px solid var(--line); }
  .ml-group-toggle {
    display: flex; gap: 8px; align-items: flex-start; width: 100%; min-height: 52px; padding: 10px 16px;
    border: 0; background: none; cursor: pointer; text-align: left; color: inherit; font: inherit;
  }
  .ml-group-toggle:focus-visible { outline-offset: -2px; }
  .ml-group-toggle .caret { flex: none; width: 12px; color: var(--ink2); font-size: 13px; line-height: 1.5; }
  .ml-group-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .ml-group-line { display: flex; gap: 4px 8px; align-items: baseline; flex-wrap: wrap; min-width: 0; }
  .ml-group-line .mx-group-name { white-space: normal; overflow-wrap: anywhere; }
  .ml-group-line .mx-group-count { color: var(--ink2); }
  .ml-group-sig { font-size: 12px; font-weight: 600; color: var(--ink2); }
  .ml-group-sig.sev-critical { color: var(--crit); }
  .ml-group-sig.sev-warning { color: var(--warn); }
  .ml-group-money { font-size: 12px; color: var(--ink2); }
  .ml-group-money b { font-weight: 500; color: var(--ink); }
  .ml-sep { padding: 10px 16px 8px; background: var(--surface2); border-bottom: 1px solid var(--line2); font-size: 12px; line-height: 1.4; color: var(--ink2); }

  .ml-skel { padding: 16px; gap: 10px; }
  .ml-skel .skel-bar { margin: 0; }
  .ml-skel .skel-bar.is-short { margin: 0; }
  .ml-empty { padding: 40px 16px; }
  .ml-empty .mx-reset { min-height: 44px; }

  /* Легенда и «Динамика» */
  .mx-legend { gap: 4px 14px; }
  .mx-legend .lg-link { display: inline-flex; align-items: center; min-height: 44px; }
  .lg-hint { flex-basis: 100%; line-height: 1.45; }
  .dyn-head { min-height: 52px; gap: 4px 14px; }
  .dyn-totals .tot { white-space: normal; }
  .dyn-body { padding: 0 12px 14px; }
  .dyn-bars { gap: 6px; }
  .dyn-bars.is-dense { gap: 2px; }
  .dyn-label > :nth-child(2) { display: none; }

  /* ---------- Панель проблем: во весь экран, одна прокрутка ---------- */

  .drawer { overflow-y: auto; overscroll-behavior: contain; animation: none; box-shadow: none; }
  .drawer-scroll { flex: none; overflow: visible; }
  .drawer-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    position: sticky; top: 0; z-index: 3; min-height: 52px; padding: 4px 6px 4px 4px;
    background: var(--surface); border-bottom: 1px solid var(--line2);
  }
  .drawer-back {
    display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px 0 10px;
    border: 0; border-radius: 8px; background: none; cursor: pointer;
    color: var(--accent); font: inherit; font-size: 16px; font-weight: 500;
  }
  .drawer-back:hover { background: var(--accent-bg); }
  .drawer-back-arrow { font-size: 26px; line-height: 0.8; margin-top: -3px; }
  .drawer-bar .drawer-close {
    width: 44px; height: 44px; border: 0; border-radius: 8px; background: none; color: var(--ink2); font-size: 18px;
  }
  .drawer-bar .drawer-close:hover { background: var(--surface2); color: var(--ink); }
  .drawer-head { padding: 14px 16px 8px; border-bottom: 0; }
  .drawer-title { font-size: 19px; line-height: 1.3; }
  .drawer-sub { font-size: 14px; }
  .drawer-tools { padding: 2px 16px 8px; gap: 0 14px; }
  .drawer-tools .filter-check { min-height: 44px; font-size: 14px; white-space: normal; }
  .drawer-tools .filter-check input { width: 20px; height: 20px; }
  .drawer-tools-gap { display: none; }
  .drawer-cab-link, .drawer-link, .drawer-note-link, .problem-muted-link {
    display: inline-flex; align-items: center; min-height: 44px; font-size: 14px;
  }
  .drawer-note { margin: 12px 16px 0; }
  .drawer-block-head { padding: 10px 16px 8px; }
  .drawer-body { padding-bottom: 88px; } /* последняя строка выше тоста «Отменить» */

  /* ---------- Строка проблемы (панель и страница кабинета) ---------- */

  .problem-row, .nt-item { padding: 16px; gap: 8px; }
  .problem-title { font-size: 16px; }
  .problem-entity { font-size: 14px; row-gap: 6px; padding: 4px 0; }
  /* Ссылка на сущность — в строке текста: хит-зону растим отступами, строку не раздвигаем */
  .problem-link { padding: 14px 0; margin: -14px 0; }
  .problem-camp { flex-basis: 100%; }
  .problem-foot { gap: 10px 16px; }
  .problem-actions { width: 100%; margin-left: 0; flex-wrap: nowrap; gap: 8px; justify-content: stretch; }
  .problem-actions > .btn, .problem-actions > .problem-menu { flex: 1 1 0; min-width: 0; }
  .problem-actions .btn { width: 100%; min-height: 44px; font-size: 15px; }
  .problem-actions > .problem-muted { max-width: none; align-items: flex-start; text-align: left; }
  .problem-muted-note { text-align: left; max-width: none; }
  .problem-reopened { font-size: 12px; }

  /* «Не проблема ▾» — лист снизу экрана, пункты по 48 px */
  .mute-menu {
    position: fixed; top: auto; left: 8px; right: 8px; bottom: 8px; z-index: 95;
    min-width: 0; padding: 8px; border-radius: 12px;
    box-shadow: 0 0 0 100vmax var(--scrim), var(--shadow-menu);
  }
  .mute-menu-note { padding: 8px 10px 10px; font-size: 13px; }
  .popover.mute-menu .period-preset { min-height: 48px; font-size: 16px; }

  /* ---------- Тосты: во всю ширину снизу, «Отменить» — 44 px ---------- */

  .toasts { left: 8px; right: 8px; bottom: 8px; transform: none; align-items: stretch; }
  .toast { max-width: none; width: 100%; justify-content: space-between; min-height: 52px; padding: 4px 4px 4px 16px; }
  .toast-action { min-height: 44px; padding: 0 14px; font-size: 15px; }
  .toast-kbd { display: none; }

  /* ---------- Общие элементы: кнопки, поля, чипы, сегменты ---------- */

  .view { padding: 14px var(--page-pad) 40px; }
  .view-title { font-size: 22px; }
  .btn { min-height: 44px; }
  .btn-sm { font-size: 14px; }
  .input, select.input, textarea.input { min-height: 44px; font-size: 16px; }
  /* Выпадающий список шириной не больше строки: длинные названия кабинетов в 16 px
     иначе раздвигали бы страницу. */
  select.input { min-width: 0; max-width: 100%; }
  .wins-select, .wins-cab-select { min-width: 0; }
  input[type="text"], input[type="search"], input[type="password"], input[type="number"], input[type="date"],
  input[type="email"], input[type="url"], input:not([type]), select, textarea { font-size: 16px; }
  .pg-chip, .pg-seg button { min-height: 44px; font-size: 14px; }
  .pg-seg { max-width: 100%; }
  .pg-btn-quiet { min-height: 44px; }
  .report-link, .pg-link { display: inline-flex; align-items: center; min-height: 44px; }
  .filter-check { min-height: 44px; }
  /* Сортировка по заголовку таблицы — кнопка во всю ячейку, 44 px */
  .pg-table .th-sort { min-height: 44px; }
  .pg-head { gap: 8px 16px; }
  .pg-meta { gap: 2px 12px; }
  .pg-field { flex-wrap: wrap; }
  .pg-field .input { width: 100%; }
  .pg-toolbar > .pg-chips { width: 100%; }
  .pg-card-head { padding: 12px 16px; }
  .pg-card-desc a, .pg-note a, .settings-desc a, .pg-sub a, .rule-desc a, .rule-off-note a {
    padding: 14px 0; margin: -14px 0;
  }
  .popover .period-preset { min-height: 44px; }
  /* Правила разделов с высотой 30–38 px (вес 0,2,0) — те же 44 px на телефоне */
  .pg-search, .pg-field .input, .rp-date, .rp-export, .rp-file, .upload-row .btn-primary, .gs-field .input,
  .gs-form-actions .btn-primary, .dialog-grid .input, .tg-chat-field .input, .settings-table .input, .st-search,
  .rule-param .input, .pass-form .input, .pass-form .btn-primary, .plans .pl-input, .wins-select { min-height: 44px; }
  .chev, .btn .chev, .period-btn .chev, .problem-menu .chev { font-size: 12px; }
  .win-aud-stop, .win-kind { font-size: 11px; }
  .cab-camps-foot a, .cab-notice a:not(.cab-notice-link) { padding: 14px 0; margin: -14px 0; }

  /* Панель «Столбцы» (Главная, «Отчёты»): строки и стрелки порядка — по 44 px */
  .cols-pop { width: calc(100vw - 32px); max-height: min(70vh, 560px); }
  .cols-item { gap: 6px; }
  .cols-check { min-height: 44px; font-size: 15px; }
  .cols-check input { width: 20px; height: 20px; }
  .cols-order { gap: 4px; }
  .cols-move { width: 44px; height: 44px; font-size: 15px; border-radius: 8px; }

  /* Окна (dialog): почти во весь экран, прокрутка внутри, кнопки по 44 px */
  dialog.user-dialog {
    width: calc(100vw - 24px); max-width: none; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
    overflow-y: auto; padding: 18px 16px 16px;
  }
  .dialog-actions { gap: 8px; }
  .dialog-actions .btn { flex: 1 1 auto; }

  /* Переключатель: сама дорожка 40 × 24, а касание — по всей зоне 44 × 44 */
  .switch input { inset: -10px -2px; width: auto; height: auto; }

  /* ---------- Широкие таблицы: прокрутка в карточке, первый столбец закреплён ----------
     Рамки ячеек — «separate»: при collapse у закреплённой ячейки пропадают
     разделители строк. Фон закреплённой ячейки — фон её строки (--row-bg). */

  :is(.pg-scroll, .settings-table-wrap, .cab-camps-scroll) > table { border-collapse: separate; border-spacing: 0; }
  .st-page :is(.pg-scroll, .settings-table-wrap) > table.settings-table { border-collapse: separate; }
  /* Нулевой вес (:where): закрепление по умолчанию уступает правилам разделов ниже. */
  :where(.pg-scroll, .settings-table-wrap, .cab-camps-scroll) > :where(table) > :where(thead, tbody, tfoot) > :where(tr) > :where(:first-child:not([colspan])) {
    position: sticky; left: 0; z-index: 2;
    background: var(--row-bg, var(--surface)); box-shadow: inset -1px 0 0 var(--line);
  }
  :where(.pg-scroll, .settings-table-wrap, .cab-camps-scroll) > :where(table) > :where(thead) { --row-bg: var(--surface2); }
  .pg-table > tfoot { --row-bg: var(--surface2); }
  .cmp-banners > thead { --row-bg: var(--surface); }
  tr.row-main:hover, tr.row-main.is-open { --row-bg: var(--surface2); }
  .reports-table tbody tr.row-sel { --row-bg: var(--accent-bg); }
  tr.cab-camp:hover, tr.cab-camp.is-open, tr.cab-group { --row-bg: var(--surface2); }
  .plans tr.plans-total { --row-bg: var(--surface2); }

  /* «Кампании»: первой на телефоне идёт «Кампания» (campaigns.js) — она и закреплена */
  table.campaigns-table { min-width: 940px; }
  .campaigns-table .c-name { width: 196px; min-width: 196px; }
  .campaigns-table .c-cab { width: 124px; min-width: 124px; }
  .cmp-cab { display: inline-flex; align-items: center; min-height: 44px; overflow-wrap: normal; }
  .cmp-toggle { min-height: 44px; align-items: center; }
  .cmp-toggle .cell-name { font-size: 13px; }
  .cmp-sub { padding-left: 18px; }
  /* Карточка раскрытой кампании — ширины экрана, не таблицы: закреплена слева */
  .campaigns-table { --detail-w: calc(100vw - 2 * var(--page-pad) - 2px); }
  tr.row-detail > td > .cmp-detail {
    position: sticky; left: 0; width: var(--detail-w); max-width: var(--detail-w);
    padding: 14px 12px 16px;
  }
  .cmp-detail-head { gap: 6px 12px; }
  .cmp-detail-link { display: inline-flex; align-items: center; min-height: 44px; }
  .cmp-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cmp-kpi { padding: 8px 10px; border-bottom: 1px solid var(--line2); }
  .cmp-charts { grid-template-columns: minmax(0, 1fr); }
  table.cmp-banners { min-width: 560px; }
  .cmp-banners .cmp-banner-name { max-width: 170px; }

  /* «Отчёты»: закреплены первый столбец (отметка строки или превью) и название —
     если «Столбцами» его не увели дальше; превью после отметки уезжает под
     название. Ширины первых столбцов заданы — от них сдвиги закрепления. Ширина
     таблицы — по содержимому (название ограничено своей шириной), а не заданная
     экраном под десктоп: иначе лишнее место раздавалось бы и отметке с превью.
     Уже экрана — растягивается до него. */
  .pg-scroll > table.reports-table { width: max-content; min-width: 100% !important; }
  .pg-table :is(th, td).c-check { width: 44px; min-width: 44px; padding: 0; text-align: center; }
  .pg-table :is(th, td).c-prev { width: 60px; min-width: 60px; padding-left: 12px; padding-right: 0; }
  .reports-table > * > tr > .c-check:first-child { z-index: 3; box-shadow: none; }
  .reports-table > * > tr > .c-prev:first-child { box-shadow: none; }
  .reports-table > * > tr > .c-check:first-child ~ .rp-name,
  .reports-table > * > tr > .c-prev:first-child ~ .rp-name {
    position: sticky; z-index: 2; background: var(--row-bg, var(--surface)); box-shadow: inset -1px 0 0 var(--line);
  }
  .reports-table > * > tr > .c-check:first-child ~ .rp-name { left: 44px; }
  .reports-table > * > tr > .c-prev:first-child ~ .rp-name { left: 60px; }
  .reports-table .rp-name { min-width: 140px; }
  .reports-table .cell-name, .reports-table .cell-above { max-width: 146px; }
  /* Флажок строки — в подписи 44 × 44 во всю ячейку */
  .c-check-hit { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin: 0 auto; cursor: pointer; }
  td.c-check .c-check-hit input { width: 20px; height: 20px; }

  /* «Посылы по месяцам», история загрузок, несведённые — первый столбец закреплён общим правилом */
  table.months-table { min-width: 720px; }
  .months-table .cell-name { max-width: 200px; }
  table.uploads-table { min-width: 980px; }
  .uploads-table .c-act .btn { min-height: 44px; }

  /* ---------- Страница кабинета: одна колонка ---------- */

  .cab-page { gap: 14px; }
  .crumbs { align-items: center; gap: 0 6px; margin: -10px 0 -8px; }
  .crumbs a { display: inline-flex; align-items: center; min-height: 44px; }
  .cab-title { font-size: 22px; line-height: 1.25; }
  .cab-archived-pill { margin-left: 6px; }
  .cab-titles { flex-basis: 100%; }
  .cab-meta { font-size: 13px; gap: 2px 14px; }
  .cab-actions { width: 100%; }
  .cab-actions .btn { flex: 1 1 auto; font-size: 14px; }
  .cab-signals { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .cab-signal { padding: 10px 12px; min-height: 80px; }
  .cab-signal-val { font-size: 17px; }
  .cab-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .cab-side { gap: 14px; }
  .cab-problems-head { padding: 12px 16px; }
  .cab-problems-head .filter-check { font-size: 14px; white-space: normal; }
  .cab-problems-head .filter-check input { width: 20px; height: 20px; }
  .cab-mutes-note { margin: 12px 16px 0; }
  .cab-mutes-link, .cab-plan-more, .cab-camps-all, .cab-notice-link, .cab-plan-empty a {
    display: inline-flex; align-items: center; min-height: 44px;
  }
  .cab-wins-more { display: flex; align-items: center; justify-content: flex-end; min-height: 44px; padding: 0 16px; }
  .cab-card-head { padding: 12px 16px; }
  .cab-kpi-row { padding: 10px 16px; }
  .cab-kpi-dd { flex-wrap: wrap; justify-content: flex-end; }
  .cab-win { padding: 10px 16px; }
  .cab-days-legend { display: none; }
  /* Подписи дат — через две, и видимая не обрезается шириной своего дня */
  .cab-days .dyn-label { overflow: visible; }
  .cab-days-bars { padding: 12px 12px 10px; background-position: 12px calc(12px + 90px); background-size: calc(100% - 24px) 1px; }
  table.cab-camps-table { min-width: 580px; }
  .cab-camps-table col.c-status { width: 92px; }
  .cab-camps-table col.c-spent { width: 100px; }
  .cab-camps-table col.c-leads { width: 52px; }
  .cab-camps-table col.c-cpl { width: 84px; }
  .cab-camps-table col.c-dev { width: 72px; }
  .cab-camp-toggle { min-height: 44px; padding: 10px 10px 10px 12px; }
  .cab-group-name { padding-left: 24px; }
  tr.cab-group-more td { padding-left: 24px; }

  /* ---------- «Планы» ---------- */

  .pl-month { width: 100%; justify-content: space-between; }
  .pl-month-btn { width: 44px; height: 44px; font-size: 20px; }
  .pl-sum-grid { gap: 14px; }
  table.plans { font-size: 13px; }
  .plans .pl-name { min-width: 150px; max-width: 176px; }
  .plans .plans-manager { max-width: 96px; }
  .plans .pl-cab { display: inline-flex; align-items: center; min-height: 44px; }
  .plans .pl-input { min-height: 44px; font-size: 16px; }
  .plans .input-num { width: 118px; }
  .plans .input-short { width: 76px; }
  .plans-src-link { display: inline-flex; align-items: center; min-height: 44px; }
  .plans .pl-input:disabled { min-height: 0; }

  /* ---------- «Настройки» ---------- */

  .st-nav { margin: 0 calc(-1 * var(--page-pad)); padding: 0 var(--page-pad) 4px; scroll-padding-inline: var(--page-pad); }
  .st-nav-link { display: flex; align-items: center; min-height: 44px; padding: 0 14px; font-size: 14px; }
  .st-page .card-head { padding: 12px 16px; }
  .st-body { padding: 12px 16px 16px; }
  .st-search { width: 100%; min-height: 44px; }
  .settings-table .input { min-height: 44px; font-size: 16px; }
  .st-page table.settings-table { min-width: 680px; }
  table.st-cabs { min-width: 880px; }
  .st-cab { min-width: 150px; max-width: 176px; }
  .st-cab-name { display: inline-flex; align-items: center; min-height: 44px; }
  .st-user-cabs { max-width: 200px; }
  .st-act .btn + .btn { margin-left: 4px; }
  .rule-row { grid-template-columns: 44px minmax(0, 1fr); padding: 12px 16px; }
  .rule-param { flex-wrap: wrap; }
  .rule-param .input { min-height: 44px; font-size: 16px; width: 104px; }
  .pass-form { grid-template-columns: minmax(0, 1fr); }
  .tg-block .btn { min-height: 44px; }
  .mutes-toolbar { padding: 12px 16px; }
  .mutes-select { min-width: 0; width: 100%; }
  .mutes-cab { display: inline-flex; align-items: center; min-height: 44px; }
  .st-dlg-all, .st-dlg-client { min-height: 44px; }
  .st-dlg-clients { max-height: 240px; }

  /* Чаты Telegram: поля в одну колонку, часы дайджеста — по 44 px */
  .tg-chat { margin: 12px; padding: 12px; }
  .tg-chat-grid { grid-template-columns: minmax(0, 1fr); }
  .tg-chat-field .input { min-height: 44px; font-size: 16px; }
  .tg-chat-field .input-num { max-width: none; }
  .tg-chat-actions { flex-wrap: wrap; white-space: normal; }
  .tg-modes { grid-template-columns: minmax(0, 1fr); }
  .tg-mode { min-height: 44px; }
  .tg-hours { gap: 6px; }
  .tg-hour { min-width: 44px; min-height: 44px; font-size: 13px; }
  .tg-chat-rules summary { display: flex; align-items: center; min-height: 44px; }
  .tg-chat-rule-list { padding-left: 0; grid-template-columns: minmax(0, 1fr); }
  .tg-chat-rule { min-height: 44px; }
  .tg-summary-toggle { min-height: 44px; }
  .tg-chat-quiet .input { min-width: 0; flex: 1 1 0; }

  /* ---------- «Отчёты»: панель, целевые из CRM, Google Таблица ---------- */

  .rp-toolbar .pg-field .input { max-width: none; }
  .rp-client { min-width: 0; }
  .rp-range { width: 100%; flex-wrap: wrap; }
  .rp-date { flex: 1 1 130px; min-height: 44px; }
  .report-exports { width: 100%; }
  .rp-export { flex: 1 1 0; }
  .rp-levels { width: 100%; }
  .rp-levels button { flex: 1 1 0; }
  .sel-bar { padding: 8px 12px; }
  .upload-scope { padding: 12px 16px 0; }
  .upload-scope-list { padding: 4px 10px; max-height: 280px; }
  .upload-scope-item { min-height: 44px; }
  .upload-scope-item input { width: 20px; height: 20px; }
  .upload-row { padding: 12px 16px 16px; }
  .rp-file-field { width: 100%; flex-wrap: wrap; }
  .rp-file { max-width: 100%; width: 100%; min-height: 44px; }
  .rp-file::file-selector-button { min-height: 34px; }
  .upload-row .btn-primary { width: 100%; }
  .gs-robot { margin: 12px 16px 0; }
  .gs-list { padding: 12px 16px 0; }
  .gs-source-actions { justify-content: flex-start; }
  .gs-source-actions .btn { flex: 1 1 auto; }
  .gs-form { padding: 12px 16px 16px; }
  .gs-field .input { min-height: 44px; }
  .gs-mode-item { min-height: 44px; }
  .gs-form-actions .btn { flex: 1 1 auto; }
  a.gs-source-title { display: inline-flex; align-items: center; min-height: 44px; }
  .gs-code-actions .btn { flex: 1 1 auto; }
  .group-suggest { min-height: 44px; }
  .group-actions .btn, .group-remove { min-height: 44px; }

  /* ---------- Вход ---------- */

  .login-screen { padding: 20px 16px; align-items: start; padding-top: max(20px, 10vh); }
  .login-card { padding: 22px 18px 20px; }
  .login-card .field input { min-height: 44px; font-size: 16px; }
  .login-card .btn-primary { min-height: 48px; font-size: 16px; }
}
