/* Линия — экраны администрирования: «Настройки», «Менеджеры», «Сетка» и их модалки.
   Только переменные из tokens.css (DESIGN.md §2). Кнопки, статус .st, таблица, панель, модалка — из app.css. */

/* ===== Общее: шапка панели, ряд кнопок ===== */
.adm-head { display: flex; flex-direction: column; gap: 4px; padding: 16px 20px 12px; }
.adm-head h2 { color: var(--text); }
.adm-head p { max-width: 68ch; color: var(--text-2); font-size: var(--fs-md); }
.adm-head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.adm-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ===== Настройки: секции «подпись / значение / действие»; журнал событий справа с 1280 ===== */
.settings-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; width: 100%; }   /* до 1280 — на всю ширину, как другие экраны */
.settings-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (min-width: 1280px) {
 .settings-layout { grid-template-columns: minmax(0, 760px) minmax(320px, 1fr); max-width: 1240px; }
 .settings-layout > .events-panel { position: sticky; top: 0; max-height: calc(100dvh - 104px); overflow: auto; }   /* журнал виден, пока листаются секции */
}
.set-rows { margin: 0; }
.set-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; min-height: 56px; padding: 12px 20px; border-top: 1px solid var(--line); }
.set-row dt { display: flex; flex: 1 1 240px; flex-direction: column; gap: 2px; min-width: 0; font-weight: 500; }
.set-row dt small { color: var(--text-3); font-size: var(--fs-sm); font-weight: 400; overflow-wrap: anywhere; }
.set-row dd { margin: 0; }
.set-value { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--text-2); font-size: var(--fs-md); }
.set-strong { color: var(--text); font-weight: 500; }
.set-action { display: flex; flex-wrap: wrap; gap: 8px; }
.set-value:empty, .set-action:empty { display: none; }

.event-log { margin: 0; padding: 0 20px 8px; border-top: 1px solid var(--line); list-style: none; }
.event-log li { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: var(--fs-md); line-height: 1.45; }
.event-log li:first-child { border-top: 0; }
.event-log time { padding-top: 1px; color: var(--text-3); font-size: var(--fs-sm); white-space: nowrap; }
.event-log span { color: var(--text-2); overflow-wrap: anywhere; }
.events-panel .ui-empty { border-top: 1px solid var(--line); }

/* ===== Таблицы администрирования: шапка липнет к прокрутке страницы (обёртка не прокручивается) ===== */
.admin-table { overflow: visible; }
/* Sticky отсчитывается от края контента .page, а не от края прокрутки: компенсируем её верхний отступ
   (app.css: .page — 24 px, на ≤ 1279 — 20 px), иначе над шапкой остаётся полоса, где видны ушедшие под неё строки. */
.admin-table thead th { top: calc(-1 * var(--page-pt)); }
.adm-head + .admin-table { border-top: 1px solid var(--line); }
.admin-panel > .admin-table:first-child th:first-child { border-top-left-radius: calc(var(--r-md) - 1px); }
.admin-panel > .admin-table:first-child th:last-child { border-top-right-radius: calc(var(--r-md) - 1px); }
.admin-table .num { text-align: right; }
.admin-table th.num { white-space: normal; line-height: 1.25; }
.admin-table td.num { font-weight: 500; white-space: nowrap; }
.admin-table td.num .cell-sub { font-weight: 400; }
.rtable tbody th { position: static; height: var(--row-h); padding: 8px 16px; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); font-size: var(--fs-base); font-weight: 500; text-align: left; white-space: normal; }
.rtable tbody tr:last-child th { border-bottom: 0; }
.admin-panel > .ui-empty { border-top: 1px solid var(--line); }

/* Метрики: итог окна — строкой текста, разрез — чипами над таблицей */
.metric-line, .metric-kinds { max-width: 80ch; margin: 0; padding: 0 20px; color: var(--text-2); font-size: var(--fs-md); line-height: 1.5; }
.metric-line strong { color: var(--text); font-weight: 600; }
.metric-kinds { padding-top: 4px; color: var(--text-3); font-size: var(--fs-sm); }
.admin-table + .metric-kinds { padding-top: 12px; padding-bottom: 12px; }
.metric-dims { padding: 12px 20px 16px; }
.metric-unit { color: var(--text-3); font-size: var(--fs-sm); font-weight: 400; }

/* ===== Менеджеры (t1-A, 5-design §3): рейтинг-таблица, ≤767 — карточки ===== */
.mgr-none { background: var(--raised); color: var(--text-3); }
.mgr-none .ui-icon { width: 16px; height: 16px; }
.lb-panel { flex: none; overflow: hidden; }   /* .page — колонка с прокруткой: панель не сжимается до высоты окна */
.lb { table-layout: fixed; }
.lb th, .lb td { padding-left: 12px; padding-right: 12px; }
.lb thead th { position: static; height: auto; padding-top: 10px; padding-bottom: 10px; vertical-align: bottom; line-height: 1.25; white-space: normal; }
.lb .th-sub { display: block; margin-top: 2px; font-size: var(--fs-xs); font-weight: 400; }
.lb th.c-who { width: 22%; } .lb th.c-acc { width: 16%; } .lb th.c-wait { width: 13%; } .lb th.c-rep { width: 11%; }
.lb th.c-greet { width: 12%; } .lb th.c-err { width: 9%; } .lb th.c-run { width: 12%; }
.mgr-head .page-title { flex: 1 1 320px; }
@media (min-width: 768px) { .mgr-head .page-actions { flex: none; } }
.lb .c-go { width: 56px; padding-left: 0; text-align: right; }
.lb .group-row th { height: auto; padding: 16px 12px 8px; border-bottom: 0; background: var(--panel); color: var(--text); font-size: var(--fs-md); font-weight: 600; white-space: normal; }
.lb .group-row .n { margin-left: 8px; color: var(--text-3); font-weight: 500; }
.lb tbody tr.group-row:hover { background: var(--panel); }
.lb-row { cursor: pointer; }
.lb-row td { line-height: 1.35; }
.lb .who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.lb .who > div { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.lb .who .cell-sub .st { gap: 6px; font-weight: 400; font-size: var(--fs-sm); }
.lb .who .cell-sub .st-off { color: var(--text-3); }
.mgr-open { max-width: 100%; padding: 0; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text); font-weight: 500; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.lb-v { display: block; font-weight: 600; }
.lb-seg { width: min(132px, 100%); margin-bottom: 6px; }
.mgr-clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row.is-off td { color: var(--text-3); }
.lb-row.is-off .mgr-open { color: var(--text-2); }
tr.is-selected .cell-sub, tr.is-selected .t3 { color: var(--text-2); }
.seg { display: flex; gap: 2px; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line); }
.seg i { display: block; min-width: 3px; height: 100%; }
.seg .s-ok { background: var(--ok); } .seg .s-warn { background: var(--warn); } .seg .s-bad { background: var(--bad); } .seg .s-off { background: var(--text-3); }
.mgr-load { min-height: 160px; }
.mgr-foot { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: var(--fs-sm); }
.mgr-period { overflow: visible; }   /* кольцо фокуса вкладки не обрезается */
.mgr-period .tab:focus-visible { outline-offset: -2px; }
.acc-owner select { width: auto; min-width: 180px; max-width: 100%; }
.acc-owner select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }   /* кольцо ≥ 2 px, как у кнопок (общее для полей — 1 px внутри) */
.set-value #first-limit { width: auto; min-width: 72px; }   /* t1-A: общий лимит первых сообщений («Система») */
#first-limit:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* ≤1279 без «Запуска», ≤1099 ещё без «Первых сообщений» (данные — в листе менеджера, 5-design §10.1); colspan групп считает managersView по тем же порогам */
@media (max-width: 1279px) { .lb .c-run { display: none; } .lb th.c-who { width: 24%; } .lb th.c-acc { width: 17%; } .lb th.c-wait { width: 14%; } .lb th.c-rep { width: 12%; } .lb th.c-greet { width: 14%; } .lb th.c-err { width: 13%; } }
@media (max-width: 1099px) { .lb .c-greet { display: none; } .lb th.c-who { width: 30%; } .lb th.c-acc { width: 22%; } .lb th.c-wait { width: 16%; } .lb th.c-rep { width: 14%; } .lb th.c-err { width: 14%; } }
.hist { display: inline-flex; align-items: flex-end; gap: 2px; width: 136px; height: 28px; vertical-align: middle; }
.hist i { flex: 1; height: max(2px, var(--h)); border-radius: 2px 2px 0 0; background: var(--text-3); }
.hist i.is-zero { height: 2px; background: var(--line-2); }
.hist-wide { width: 264px; max-width: 100%; }   /* 24 часа суток */
.param-name .cell-sub { font-weight: 400; }

/* ===== Модалки администрирования ===== */
.adm-list { display: flex; flex-direction: column; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); list-style: none; }
.adm-list-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px 16px; border-top: 1px solid var(--line); }
.adm-list-row:first-child { border-top: 0; }
.adm-list-main { display: flex; flex: 1 1 240px; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.adm-list-main small { color: var(--text-3); font-size: var(--fs-sm); }
.adm-list-main small.bad-t { color: var(--bad); }
.adm-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: var(--fs-md); }
.adm-facts > div { display: contents; }
.adm-facts dt { color: var(--text-3); }
.adm-facts dd { margin: 0; overflow-wrap: anywhere; }
.modal-body td .adm-actions { gap: 4px; }
.modal-body td .cell-sub.bad-t { color: var(--bad); }

/* ===== ≤ 767: таблицы становятся карточками (DESIGN.md §3), цели касания ≥ 40 ===== */
@media (max-width: 767px) {
 .set-row { padding: 12px 16px; }
 .adm-head { padding: 16px 16px 12px; }
 .event-log { padding: 0 16px 8px; }
 .set-action .btn-sm, .adm-actions .btn-sm { height: 40px; }
 .rtable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
 .rtable, .rtable tbody { display: block; }
 .rtable tr { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 16px; border-bottom: 1px solid var(--line); }
 .rtable tbody tr:last-child { border-bottom: 0; }
 .rtable td, .rtable tbody th { display: block; height: auto; padding: 0; border: 0; text-align: left; }
 .rtable td[data-label] { flex: 1 1 calc(50% - 16px); align-self: flex-start; min-width: 0; }   /* подписи соседних значений — на одной высоте */
 .rtable td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--text-3); font-family: var(--font-ui); font-size: var(--fs-sm); font-weight: 400; }
 .admin-table .num { text-align: left; }
 .rtable tbody th, .rtable .pair-risk, .rtable .cell-full { flex: 1 1 100%; }
 .rtable .cell-full:empty { display: none; }
 /* «Менеджеры»: карточка — имя и «Войти» сверху, ниже 2×2 «Аккаунты / Ждут ответа / Ответы / Ошибки», затем «Первые сообщения» и «Запуск» (5-design §10.1) */
 .lb thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
 .lb, .lb tbody, .lb tr.group-row, .lb .group-row th { display: block; }
 .lb .group-row th { padding: 16px 16px 4px; }
 .lb tr.lb-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 16px; padding: 16px; border-bottom: 1px solid var(--line); }
 .lb tbody tr:last-child { border-bottom: 0; }
 .lb td { display: block; height: auto; padding: 0; border: 0; }
 .lb td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--text-3); font-family: var(--font-ui); font-size: var(--fs-sm); font-weight: 400; }
 .lb td.c-who { grid-column: 1 / -1; padding-right: 48px; }
 .lb td.c-go { position: absolute; top: 12px; right: 12px; width: 40px; padding: 0; }
 .lb td.c-go:empty { display: none; }
 .lb td.c-go .btn { width: 40px; height: 40px; }
 .lb td.c-acc { order: 1; } .lb td.c-wait { order: 2; } .lb td.c-rep { order: 3; } .lb td.c-err { order: 4; }
 .lb td.c-greet { order: 5; grid-column: 1 / -1; display: block; } .lb td.c-run { order: 6; grid-column: 1 / -1; display: block; }
 .lb-seg { width: min(160px, 100%); }
 [data-testid=managers-unowned-notice] .btn, .mgr-foot .btn { height: 40px; }
 [data-testid=managers-unowned-notice] .btn { width: 100%; }
 .mgr-period { flex: 1 1 100%; } .mgr-period .tab { flex: 1; justify-content: center; }
 .acc-owner { flex: 1 1 100%; } .acc-owner select { width: 100%; height: 40px; }
 .set-value #first-limit { height: 40px; }
 .set-row dt { flex: 1 1 100%; }   /* одна раскладка для всех строк: подпись сверху, ниже значение слева и действие справа */
 .set-row .set-action { margin-left: auto; }
 .adm-facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
 .adm-facts > div + div dt { margin-top: 8px; }
}

/* ===== 5.3/5.7 (S5c): карточка менеджера (боковой лист), шкала .seg, журнал действий. Только токены. ===== */
.mgr-sheet { width: min(600px, 100vw); }
.mgr-sheet-head { gap: 12px; padding-left: 20px; }
.mgr-sheet-title { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.mgr-sheet-title h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mgr-sheet-title .cell-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-3); font-size: var(--fs-sm); }
.head-actions { display: flex; flex: none; align-items: center; gap: 4px; }
.mgr-sheet .sheet-body { gap: 24px; }
.mgr-sheet-foot { justify-content: space-between; }
#manager-sheet-body:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.sec { display: flex; flex-direction: column; gap: 12px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; }
.sec h3 { font-size: var(--fs-md); }
.issues, .wait-list, .runs-mini, .audit-list { margin: 0; padding: 0; list-style: none; }
.issues { display: flex; flex-direction: column; gap: 8px; }
.issue { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r-sm); background: var(--raised); }
.issue.is-warn { background: var(--warn-soft); }
.issue.is-bad { background: var(--bad-soft); }
.issue > .ui-icon { flex: none; color: var(--text-2); }
.issue.is-warn > .ui-icon { color: var(--warn); }
.issue.is-bad > .ui-icon { color: var(--bad); }
.issue .btn { flex: none; }
.issue-text { flex: 1; min-width: 0; }
.issue-text b { font-weight: 600; }
.issue-text p { color: var(--text-2); font-size: var(--fs-md); line-height: 1.45; }

/* Шкала: один компонент на экран; смысл всегда продублирован словами рядом (легенда или строка чисел) */
/* .seg и .seg i — общие со шкалой «Менеджеров» (S5b, выше) */
.seg-ok { background: var(--ok); }
.seg-info { background: var(--accent); }
.seg-warn { background: var(--warn); }
.seg-bad { background: var(--bad); }
.seg-off { background: var(--text-3); }
.seg-none { background: var(--line-2); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 0; list-style: none; color: var(--text-2); font-size: var(--fs-md); }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend i { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.legend b { color: var(--text); font-weight: 600; }

.facts { display: grid; grid-template-columns: minmax(120px, 200px) minmax(0, 1fr); gap: 8px 12px; margin: 0; font-size: var(--fs-md); }
.facts > div { display: contents; }
.facts dt { color: var(--text-3); }
.facts dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }

.wait-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: var(--fs-md); }
.wait-list li:first-child { border-top: 0; padding-top: 0; }
.wait-who { display: flex; flex-direction: column; min-width: 0; }
.wait-who b { overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.wait-list li > span:last-child { flex: none; font-variant-numeric: tabular-nums; }

.runs-mini li { display: grid; grid-template-columns: 124px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: var(--fs-md); }
.runs-mini li:first-child { border-top: 0; }
.runs-mini time { color: var(--text-2); }
.runs-mid { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.runs-mid .cell-sub { overflow: hidden; color: var(--text-3); font-size: var(--fs-sm); text-overflow: ellipsis; white-space: nowrap; }

/* Журнал действий: время · кто · что (· пространство в корне) */
.audit-list { width: 100%; }
.audit-list li { display: grid; grid-template-columns: 128px minmax(0, 150px) minmax(0, 1fr); gap: 2px 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: var(--fs-md); line-height: 1.45; }
.audit-list li:first-child { border-top: 0; }
.audit-list li:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.audit-list time { padding-top: 1px; color: var(--text-3); font-size: var(--fs-sm); }
.audit-who { color: var(--text); font-weight: 500; overflow-wrap: anywhere; }
.audit-what { min-width: 0; color: var(--text-2); overflow-wrap: anywhere; }
.audit-list li.has-space { grid-template-columns: 128px minmax(0, 150px) minmax(0, 1fr) minmax(0, 150px); }   /* корень: ещё колонка «Пространство» */
.audit-space { font-size: var(--fs-sm); overflow-wrap: anywhere; }
.audit-panel .audit-body { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 0 20px 16px; }
.audit-panel .ui-empty, .audit-panel .notice { width: 100%; }
.audit-filter { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: var(--fs-md); }
.audit-filter select { width: auto; min-width: 0; }
.audit-filter select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }   /* кольцо ≥ 2 px (test_next_a11y: select:focus рисует 1 px) */
@media (min-width: 1280px) {
 .settings-layout > .audit-panel { position: sticky; top: 0; max-height: calc(100dvh - 104px); overflow: auto; }
}
@media (max-width: 767px) {
 .mgr-sheet { width: 100%; }
 .mgr-sheet .sheet-body { padding: 20px 16px; }
 .mgr-sheet-head { padding-left: 16px; }
 .mgr-sheet-foot { flex-direction: column-reverse; align-items: stretch; }
 .mgr-sheet-foot .btn, .issue .btn, .audit-panel .btn, .audit-filter select, .sec-head .btn { height: 40px; justify-content: center; }
 .mgr-sheet .head-actions .icon-btn { flex: none; min-width: 40px; }
 .issue { flex-wrap: wrap; }
 .issue .btn { width: 100%; }
 .facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
 .facts > div { display: flex; flex-direction: column; gap: 2px; padding-bottom: 6px; }
 .runs-mini li { grid-template-columns: minmax(0, 1fr) auto; }
 .runs-mini time { grid-column: 1 / -1; }
 .audit-list li, .audit-list li.has-space { grid-template-columns: minmax(0, 1fr); }
 .audit-panel .audit-body { padding: 0 16px 16px; }
}
