/* Линия — экран «Лиды и отправки» (DESIGN.md §3–§5, прототип docs/design/prototype/leads.dc.html).
   Вкладки «Запуски» (таблица запусков с раскрытием) и «Контакты и этапы» (цепочка этапов-фильтров, список лидов,
   справа «Требуют проверки»); модалки CSV и шаблонов.
   Только переменные из tokens.css. Компоненты (.btn, .chip, .st, .panel, таблица, .notice, .ui-empty) — из app.css. */

.lead-slot { display: contents; }   /* постоянный слот: появление/исчезновение узла не сдвигает соседей (uiPatchChildren) */

/* ===== Шапка: одна строка сводки вместо плиток ===== */
.leads-summary .warn-t { font-weight: 500; }

/* ===== Раскладка вкладки «Контакты и этапы»: список слева, проверка справа (≥1024); правая колонка липкая в прокрутке страницы ===== */
/* position: relative — блок содержимого для .sr-only (position: absolute) в списке: без него они считаются от окна,
   overflow у #content их не обрезает, документ вырастает выше окна и прокрутка колесом уводит всю оболочку вверх */
.leads-layout { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; gap: 16px; }
.leads-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.leads-side { position: sticky; top: 0; display: flex; flex-direction: column; gap: 16px; min-width: 0; max-height: calc(100dvh - 104px); overflow: auto; overscroll-behavior: contain; }

/* ===== Этапы: цепочка (фильтр) + статусы вне цепочки (чипы) ===== */
.lead-stages { display: flex; flex-direction: column; }
.stage-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 4px; border-bottom: 1px solid var(--line); }   /* ≥1024 не обрезается: переносится */
.stage-link, .stage-tail { display: inline-flex; flex: none; align-items: center; gap: 4px; }   /* этап + стрелка после него переносятся вместе: строка не начинается со стрелки */
.stage { display: inline-flex; flex: none; align-items: center; gap: 8px; height: 36px; padding: 0 8px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2); font-size: var(--fs-md); font-weight: 500; white-space: nowrap; transition: background-color var(--dur) ease-out, color var(--dur) ease-out; }
.stage .n { color: var(--text); font-size: var(--fs-base); font-weight: 600; }
.stage.is-zero .n { color: var(--text-3); font-weight: 500; }
.stage:hover { background: var(--hover); color: var(--text); }
/* Выбранный этап — инверсия, как у выбранного чипа-фильтра (DESIGN.md §4): этапы и чипы справа — один фильтр */
.stage[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.stage[aria-pressed="true"] .n { color: color-mix(in srgb, var(--bg) 72%, var(--text)); }
.stage-div { flex: none; width: 1px; height: 20px; margin: 0 4px; background: var(--line); }
.stage-sep { display: inline-flex; flex: none; color: var(--text-3); }
.stage-sep .ui-icon { width: 14px; height: 14px; }
.stage-side { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
.stage-chip .n { font-weight: 600; }
.stage-chip[aria-pressed="true"] .st { color: inherit; }   /* на инверсии подпись читается цветом чипа, точка остаётся цветной */

/* ===== Список лидов ===== */
.leads-list { display: flex; flex-direction: column; min-width: 0; }
.leads-list tbody, .leads-list .leads-empty { transition: opacity 150ms ease-out; }
.leads-list[aria-busy="true"] tbody, .leads-list[aria-busy="true"] .leads-empty { opacity: .55; }
.lead-tools { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.lead-search { flex: 0 1 320px; min-width: 0; }
.lead-cap { margin-left: auto; font-size: var(--fs-md); white-space: nowrap; }
/* ===== «Контакты и этапы»: фильтр запуска, число контактов, чип «Ответили» (3.1-design §6) ===== */
.ct-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.ct-run { flex: 0 1 320px; width: auto; min-width: 0; }   /* родной select: высота и вид — общие поля (app.css) */
.ct-run:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }   /* кольцо клавиатуры 2 px, как у кнопок (поле даёт 1 px внутри) */
.ct-count { font-size: var(--fs-md); white-space: nowrap; }
.ct-file { flex-basis: 280px; }
.lead-reason.is-closed { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }   /* длинное имя — не растягивает строку, полный текст в title */
.leads-list .table-wrap { overflow: visible; }   /* шапка таблицы липнет к прокрутке страницы */
.leads-table { table-layout: fixed; }
.leads-table th { top: calc(-1 * var(--page-pt)); }   /* липкость отсчитывается от padding .page: шапка прилегает к верху области прокрутки */
.leads-table th.lead-sel { width: 48px; }   /* lead-files 4.5: галочка строки — та же .acc-check 40 × 40, что в «Аккаунтах» */
.leads-table .lead-sel { padding: 0 0 0 8px; }
.leads-table th.lead-contact { width: 28%; }
.leads-table th.lead-status { width: 176px; }   /* статус D-30: «Закрыт для сообщений» целиком */
.leads-table th.lead-attempts { width: 96px; }
.leads-table th.lead-acc { width: 144px; }   /* точка + «Имя Ф.» или номер аккаунта без имени целиком — как в «Требуют проверки» */
.leads-table .lead-attempts { text-align: right; }
.lead-contact { min-width: 0; }
.leads-table .lead-name, .leads-table .lead-phone { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-name { font-weight: 500; }
.lead-phone { color: var(--text-2); }
.lead-reason { display: block; margin-top: 4px; color: var(--text-3); font-size: var(--fs-sm); line-height: 1.4; }
.lead-k { display: none; }
.lead-k.lead-pin { display: inline; color: var(--text-3); font-size: var(--fs-sm); white-space: nowrap; }   /* «закреплён за» — на любой ширине (лид ждёт этот аккаунт) */
/* Аккаунт-отправитель — как в «Сообщениях»: точка + «Имя Ф.» (номер без имени обрезается с начала, dir=rtl) */
.lead-account { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-width: 0; color: var(--text-2); font-size: var(--fs-md); white-space: nowrap; vertical-align: middle; }
.lead-account > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.review-acc { white-space: nowrap; }   /* в строке текста: точка по оси строчных (vertical-align у .acc-dot) */
.review-acc .acc-dot { margin-right: 4px; }
.lead-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 8px 12px 8px 16px; border-top: 1px solid var(--line); font-size: var(--fs-md); }
.lead-pager-ctl { display: flex; align-items: center; gap: 4px; }
.lead-pager-page { min-width: 10ch; color: var(--text-2); text-align: center; }

/* ===== Правая колонка: требуют проверки ===== */
.leads-rail { display: flex; flex-direction: column; }
.rail-sec { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px 20px; }
.rail-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 24px; }
.rail-review .rail-head { justify-content: flex-start; }
.run-facts { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; font-size: var(--fs-md); }
.run-facts:empty { display: none; }
.run-facts > div { display: contents; }
.run-facts dt { color: var(--text-3); }
.run-facts dd { font-weight: 500; text-align: right; }
.run-summary { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.run-summary li { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.run-summary .n { font-weight: 600; }
.run-hint { color: var(--text-3); font-size: var(--fs-sm); line-height: 1.45; }
.run-hint:empty { display: none; }
.rail-note { color: var(--text-2); font-size: var(--fs-md); line-height: 1.5; }
.review-list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.review-item { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--raised); }
.review-top { display: flex; align-self: stretch; align-items: center; justify-content: space-between; gap: 8px; }
.review-top time { font-size: var(--fs-sm); }
.review-who { font-size: var(--fs-md); }
.review-meta { color: var(--text-2); font-size: var(--fs-md); overflow-wrap: anywhere; }
.review-error { color: var(--text-3); font-size: var(--fs-sm); line-height: 1.4; }
.review-item .btn { margin-top: 4px; }
.review-acts { display: flex; flex-wrap: wrap; gap: 8px; }

/* ===== Вкладки страницы (DESIGN.md §4): разделы экрана, а не фильтры списка; вид — как у вкладок «Сообщений» ===== */
.leads-screen { position: relative; display: flex; flex-direction: column; gap: 16px; min-width: 0; }   /* relative: .sr-only в таблице не растит документ */
.ptabs { display: flex; border-bottom: 1px solid var(--line); }
.ptab { position: relative; display: inline-flex; flex: none; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2); font-size: var(--fs-base); font-weight: 500; white-space: nowrap; cursor: pointer; transition: color var(--dur) ease-out; }
.ptab:hover, .ptab[aria-selected="true"] { color: var(--text); }
.ptab:focus-visible { outline-offset: -2px; }   /* кольцо внутри: не обрезается краем блока */
.ptab::after { content: ""; position: absolute; right: 12px; bottom: -1px; left: 12px; height: 2px; border-radius: 2px 2px 0 0; background: var(--accent); opacity: 0; transition: opacity var(--dur) ease-out; }
.ptab[aria-selected="true"]::after { opacity: 1; }
@media (forced-colors: active) { .ptab::after { background: Highlight; } }   /* высокий контраст Windows: полоса выбора не пропадает */

/* ===== Вкладка «Запуски»: подсказка, таблица запусков с раскрытием, легенда шкалы ===== */
.leads-runs { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.runs-bar { margin: 0; color: var(--text-2); font-size: var(--fs-md); line-height: 1.5; }
.runs-panel .table-wrap { overflow: visible; }   /* шапка таблицы липнет к прокрутке страницы */
.runs-table { table-layout: fixed; }
.runs-table th { top: calc(-1 * var(--page-pt)); }
.rc-tog { width: 44px; }   /* ширины — в colgroup: ячейка подробностей на всю строку (colspan) иначе добавляет таблице лишнюю колонку */
.rc-when { width: 188px; }
.rc-acc { width: 88px; }
.rc-dur { width: 120px; }
.rc-st { width: 176px; }
.runs-table th:nth-child(1) { padding: 0 4px; }
.runs-table th:nth-child(3) { text-align: right; }
.runs-table td { overflow: hidden; }
.runs-table td.run-tog { padding: 0 4px; }
.runs-table .run-acc { text-align: right; font-variant-numeric: tabular-nums; }
.run-row { cursor: pointer; }
.run-date { display: block; overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.run-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-meta { display: none; }
/* Раскрытая строка: фон --accent-soft, пояснения в ней — --text-2 (контраст); наведение не перекрашивает подробности */
tbody tr.run-row.is-open, tbody tr.run-row.is-open:hover { background: var(--accent-soft); }
.run-row.is-open .cell-sub { color: var(--text-2); }
.run-chevron .ui-icon { transition: transform var(--dur) ease-out; }
.run-row.is-open .run-chevron .ui-icon { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { .run-chevron .ui-icon { transition: none; } }
tbody tr.run-detail-row, tbody tr.run-detail-row:hover { background: var(--rail); }
tr.run-detail-row[hidden] { display: none; }
.runs-table td.run-st .cell-sub { white-space: normal; }
.runs-table tr.run-detail-row td { height: auto; padding: 0; overflow: visible; }
.runs-more { padding: 8px 12px; border-top: 1px solid var(--line); }

/* Шкала запуска: 8 px, сегменты через зазор 2 px; доля — flex-grow из числа лидов, ненулевой сегмент не уже 3 px */
.run-bar { display: flex; gap: 2px; height: 8px; overflow: hidden; border-radius: 3px; background: var(--line); }
.run-bar > i { display: block; flex: 1 1 0; min-width: 3px; }
.k-ok { background: var(--ok); }
.k-work { background: var(--accent); }
.k-skip { background: var(--text-3); }
.k-bad { background: var(--bad); }
.k-warn { background: var(--warn); }
.k-rest { background: var(--line-2); }
.run-count { display: block; margin-top: 8px; color: var(--text-2); font-size: var(--fs-md); font-variant-numeric: tabular-nums; line-height: 1.4; }
.run-count strong { color: var(--text); font-weight: 600; }
.rlegend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0; padding: 0; color: var(--text-3); font-size: var(--fs-sm); list-style: none; }
.rlegend li { display: inline-flex; align-items: center; gap: 8px; }
.rlegend i { flex: none; width: 8px; height: 8px; border-radius: 2px; }

/* Подробности запуска: четыре секции в ряд, под ними полоса действий */
.run-detail { display: grid; grid-template-columns: 1.1fr 1fr 1fr 1fr; }
.run-detail[aria-busy="true"] { opacity: .75; }
.run-sec { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 16px 20px; }
.run-sec + .run-sec { border-left: 1px solid var(--line); }
.run-sec h3 { color: var(--text-3); font-size: var(--fs-sm); font-weight: 500; }
.run-sec h4 { color: var(--text-3); font-size: var(--fs-sm); font-weight: 500; }
.run-note { margin: 0; font-size: var(--fs-sm); line-height: 1.4; }   /* C-7: подпись о заморозке сводки у остановленного запуска */
.run-why { padding-top: 12px; border-top: 1px solid var(--line); }
.run-summary li.is-sub { padding-left: 15px; }   /* «Проверяется» и т. п. — под «В работе» */
.run-reason-group { display: flex; flex-direction: column; gap: 8px; }
.run-reasons { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.run-reasons li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.run-reasons li > span:first-child { color: var(--text-2); font-size: var(--fs-md); overflow-wrap: anywhere; }   /* объяснение, а не данные: переносится, не обрезается */
.run-reasons .n { font-weight: 500; }
.run-wait { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 0; font-size: var(--fs-md); }
.run-accounts { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.run-accounts li { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: var(--fs-md); }
.run-acc-name { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.run-acc-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-acc-n { flex: none; color: var(--text-2); white-space: nowrap; }
.run-sec .btn-ghost { align-self: flex-start; }
.run-variants { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.run-variant { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--raised); font-size: var(--fs-md); }
.run-variant-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-variant-n { color: var(--text-2); font-size: var(--fs-sm); white-space: nowrap; }
.run-sec { container-type: inline-size; }
@container (min-width: 340px) {   /* в широкой секции — как в макете: текст слева, «52 отпр. · 18% ответов» справа */
 .run-variant { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
 .run-variant-text { flex: 1 1 auto; min-width: 0; }
 .run-variant-n { flex: none; }
}
.run-edited { padding: 8px 12px; }
.run-loading { display: grid; place-items: center; height: 160px; color: var(--text-2); font-size: var(--fs-md); }   /* строки ниже не прыгают дважды */
.run-failure { margin: 16px 20px 0; }
.run-detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }
.run-note { flex: 1 1 240px; margin: 0; color: var(--text-3); font-size: var(--fs-sm); line-height: 1.45; text-align: right; }
.run-note:empty { display: none; }

/* ≤1439: подробности — 2 × 2; ≤1279 (рейка сайдбара): колонка «Длительность» скрыта — время уже в пояснении статуса */
@media (max-width: 1439px) {
 .run-detail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
 .run-sec:nth-child(n+3) { border-top: 1px solid var(--line); }
 .run-sec:nth-child(odd) { border-left: 0; }
}
@media (max-width: 1279px) {
 .rc-dur { width: 0; }   /* колонка нулевой ширины: display: none у ячеек сдвинул бы остальные колонки, а колонка из colspan осталась бы лишней */
 .runs-table th:nth-child(5), .runs-table td.run-dur { padding: 0; border: 0; overflow: hidden; visibility: hidden; }
}
@media (max-width: 1023px) {
 .rc-when { width: 160px; }
 .rc-acc { width: 72px; }
 .rc-st { width: 150px; }
 .run-detail { grid-template-columns: minmax(0, 1fr); }
 .run-sec + .run-sec { border-top: 1px solid var(--line); border-left: 0; }
 .ct-run { flex: 1 1 100%; }
}
/* ===== Модалки: импорт CSV и шаблоны первого сообщения ===== */
.csv-result:empty { display: none; }
.csv-step { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.csv-step-title { color: var(--text-2); }
.csv-step-title strong { color: var(--text); }
.csv-map { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.csv-preview th { position: static; height: 32px; padding: 0 12px; background: var(--raised); }
.csv-preview td { height: auto; padding: 8px 12px; white-space: nowrap; }   /* шрифт интерфейса; телефоны в итоге — .mono */
.csv-summary { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.csv-issues { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; color: var(--text-2); font-size: var(--fs-md); list-style: none; }
.csv-issues li { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.template-fields { display: flex; flex-direction: column; gap: 12px; }
.template-field span { color: var(--text-3); font-size: var(--fs-sm); }
.template-field textarea { min-height: 72px; }
.template-field textarea, .csv-map select { color: var(--text); font-weight: 400; }   /* поле не наследует вес подписи */
.template-count.is-short { color: var(--warn); }   /* заполнены не все варианты или есть повтор; смысл — в тексте подсказки */
.template-options { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 12px 16px 16px; border: 1px solid var(--line); border-radius: var(--r-md); }
.template-options legend { padding: 0 4px; font-size: var(--fs-md); font-weight: 600; }
/* «Запустить отправку?»: лимит 1 / 2 / 3 в одну строку (группа — та же рамка .template-options) */
.run-limit { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.run-limit .option-check { align-items: center; }
.run-limit input { margin: 0; }
.run-files { max-height: 240px; overflow: auto; }   /* lead-files 4.3: окно не растёт от числа файлов — прокручивается список */   /* родной отступ радио сверху опускал кружок ниже цифры */

/* «Компактно» (DESIGN.md §2): строка 48 — ячейка в две строки (имя + телефон) с полями 8+8 давала 54 */
@media (min-width: 768px) {
 :root[data-density="compact"] .leads-table td { padding-top: 4px; padding-bottom: 4px; }
 :root[data-density="compact"] .leads-table .acc-check { height: 32px; }
}

/* ===== ≤1279: правая колонка уже, ячейки плотнее ===== */
@media (max-width: 1279px) {
 .leads-layout { grid-template-columns: minmax(0, 1fr) 300px; }
 .leads-table th { padding: 0 12px; }
 .leads-table td { padding: 8px 12px; }
 .leads-table th.lead-status { width: 150px; }
 .leads-table th.lead-attempts { width: 84px; }
 .leads-table th.lead-acc { width: 104px; }
 .rail-sec { padding-right: 16px; padding-left: 16px; }
}

/* ===== ≤1023: одна колонка, «Требуют проверки» поднимается над списком ===== */
@media (max-width: 1023px) {
 .leads-layout { display: flex; flex-direction: column; align-items: stretch; }
 .leads-side { display: contents; }
 .leads-rail { order: -1; }
 .stage-chain, .stage-side { flex-wrap: nowrap; overflow-x: auto; }   /* DESIGN.md §3: фильтры в одну прокручиваемую строку */
 .stage-side > * { flex: none; }
}

/* ===== ≤767: карточки вместо таблиц, цели касания ≥ 40 ===== */
@media (max-width: 767px) {
 .rail-sec { padding: 16px; }
 .lead-pager .btn, .review-item .btn, .leads-empty .btn { height: var(--btn-h); }
 .runs-table, .runs-table tbody { display: block; }
 .runs-table thead, .runs-table colgroup { display: none; }
 .runs-table tr.run-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "when status" "ct ct" "meta meta"; align-items: start; gap: 8px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
 .runs-table tr.run-row td { display: block; height: auto; padding: 0; border: 0; }
 .runs-table tr.run-row td.run-when { grid-area: when; }
 .runs-table tr.run-row td.run-st { grid-area: status; padding-right: 44px; text-align: right; }   /* справа от статуса — кнопка раскрытия 40 × 40 в углу карточки */
 .runs-table tr.run-row td.run-ct { grid-area: ct; }
 .runs-table tr.run-row td.run-meta { grid-area: meta; display: block; color: var(--text-3); font-size: var(--fs-sm); }
 .runs-table tr.run-row td.run-acc, .runs-table tr.run-row td.run-dur { display: none; }
 .runs-table tr.run-row td.run-tog { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; }
 .run-tog .btn { width: 40px; height: 40px; }
 .runs-table tr.run-detail-row { display: block; }
 .runs-table tr.run-detail-row td { display: block; }
 .run-sec { padding: 16px; }
 .run-failure { margin: 16px 16px 0; }
 .run-detail-actions { padding: 12px 16px; }
 .run-detail-actions .btn, .runs-more .btn { height: var(--btn-h); }
 .run-detail-actions .btn { flex: 1 1 auto; }
 .run-note { flex-basis: 100%; text-align: left; }
 .ptab { min-width: 44px; justify-content: center; }
 .stage { height: 40px; }
 .lead-tools { flex-wrap: wrap; padding: 12px; }
 .lead-search { flex: 1 1 100%; height: var(--btn-h); }
 .ct-reply { height: var(--btn-h); }
 .lead-cap { margin-left: 0; }
 .leads-table, .leads-table tbody { display: block; }
 .leads-table thead { display: none; }
 .leads-table tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "sel contact acc" "sel status att" "sel state state"; align-items: start; gap: 8px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
 .leads-table .lead-sel { grid-area: sel; margin: -8px 0 0 -8px; padding: 0; }   /* галочка 40 × 40 — по верху карточки */
 .leads-table .lead-status { grid-area: status; }
 .leads-table .lead-state .lead-k, .leads-table .lead-status .lead-k { color: var(--text-3); font-size: var(--fs-sm); }
 .leads-table tbody tr:last-child { border-bottom: 0; }
 .leads-table td { display: block; height: auto; padding: 0; border: 0; }
 .leads-table .lead-contact { grid-area: contact; }
 .leads-table .lead-acc { grid-area: acc; text-align: right; }
 .leads-table .lead-state { grid-area: state; }
 .leads-table .lead-attempts { grid-area: att; color: var(--text-3); font-size: var(--fs-sm); }
 .lead-k { display: inline; }
 .leads-table .lead-acc.is-none { display: none; }   /* без аккаунта — без «—» в углу карточки */
 .leads-table .lead-acc .lead-k { color: var(--text-3); font-size: var(--fs-sm); }   /* подпись — как «Попыток:» */
 .lead-pager { padding: 8px 12px; }
 .csv-map { grid-template-columns: minmax(0, 1fr); }
 .run-limit .option-check { flex: 1; min-height: 40px; }   /* вариант лимита — вся подпись целью касания */
}

/* ===== lead-files 4.5: панель выбора лидов — .acc-bulk «Аккаунтов» + список статуса ===== */
.lead-bulk-st { display: inline-flex; align-items: center; gap: 8px; margin-right: 4px; color: var(--text-2); font-size: var(--fs-md); font-weight: 500; }
.lead-bulk-st select { width: auto; height: var(--btn-h-sm); font-weight: 400; }
@media (max-width: 767px) {
 .acc-bulk.lead-bulk { flex-wrap: wrap; gap: 8px; padding: 8px; white-space: normal; }   /* 375 px: «Выбрать все по фильтру» и список — второй строкой */
 .lead-bulk .acc-bulk-sep { display: none; }
 .lead-bulk .btn { width: auto; height: 40px; padding: 0 12px; }
 .lead-bulk .icon-btn { width: 40px; padding: 0; }
 .lead-bulk-st { flex: 1 1 140px; min-width: 0; }   /* список и «Применить» — одной строкой под счётчиком */
 .lead-bulk-st select { flex: 1 1 auto; min-width: 0; height: 40px; }
}

/* ===== lead-files 4.2: виды строк в итоге проверки CSV ===== */
.csv-kinds { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 0; color: var(--text-2); font-size: var(--fs-md); list-style: none; }
.csv-kinds strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.csv-kinds .t3 strong { color: inherit; font-weight: 500; }

/* ===== lead-files 4.1: вкладка «Файлы» — таблица файлов с раскрытием, как «Запуски» (DESIGN.md §4) ===== */
.files-panel .table-wrap { overflow: visible; }   /* шапка липнет к прокрутке страницы */
.files-table { table-layout: fixed; }
.files-table th { top: calc(-1 * var(--page-pt)); }
.files-table th:first-child, .files-table td.run-tog { padding: 0 4px; }
.fc-n { width: 100px; }
.fc-act { width: 172px; }
.files-table td { overflow: hidden; }
.files-table .file-n { padding: 0 8px; text-align: right; font-variant-numeric: tabular-nums; }
.files-table td.file-n { padding: 8px; }
.files-table .file-act { text-align: right; }
.file-row { cursor: pointer; }
tbody tr.file-row.is-open, tbody tr.file-row.is-open:hover { background: var(--accent-soft); }
.file-row.is-open .cell-sub { color: var(--text-2); }
.file-row.is-open .run-chevron .ui-icon { transform: rotate(90deg); }
.file-title { display: block; overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.file-sum { display: none; }
.files-table tr.run-detail-row td { height: auto; padding: 0; overflow: visible; }
.file-detail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.file-detail .run-sec:nth-child(odd) { border-left: 0; }
@media (max-width: 1279px) {
 .fc-n { width: 88px; }
 .fc-act { width: 56px; }
 .file-act .btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* иконка; подпись — для скринридера (aria-label) */
 .file-act .btn { width: var(--btn-h-sm); padding: 0; }
}
/* ≤1023: семь числовых колонок не оставляют места имени — карточки, как у запусков на телефоне */
@media (max-width: 1023px) {
 .file-detail { grid-template-columns: minmax(0, 1fr); }
 .file-detail .run-sec + .run-sec { border-top: 1px solid var(--line); border-left: 0; }
 .files-table, .files-table tbody { display: block; }
 .files-table thead, .files-table colgroup { display: none; }
 .files-table tr.file-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name act" "sum sum"; align-items: start; gap: 8px 12px; padding: 12px 16px 12px 56px; border-bottom: 1px solid var(--line); }
 .files-table tr.file-row td { display: block; height: auto; padding: 0; border: 0; overflow: visible; }   /* ячейка = кнопка: кольцо фокуса не обрезается (имя режет .file-title) */
 .files-table tr.file-row td.file-n { display: none; }
 .files-table tr.file-row td.file-name { grid-area: name; }
 .files-table tr.file-row td.file-act { grid-area: act; }
 .files-table tr.file-row td.file-sum { grid-area: sum; display: block; color: var(--text-2); font-size: var(--fs-md); font-variant-numeric: tabular-nums; line-height: 1.5; }
 .file-sum strong { color: var(--text); font-weight: 600; }
 .files-table tr.file-row td.run-tog { position: absolute; top: 8px; left: 8px; width: 40px; height: 40px; }
 .files-table .run-tog .btn { width: 40px; height: 40px; }
 .files-table tr.run-detail-row, .files-table tr.run-detail-row td { display: block; }
 .files-table tr.run-detail-row[hidden] { display: none; }
}
@media (max-width: 767px) {
 .file-act .btn { width: 40px; height: 40px; }
}
