/* CRM El'Auto — оформление по дизайн-системе сайта elautogroup.ru
   (тема el-auto-new: main.css и design-system.tokens). Значения перенесены с сайта как есть:
   фон, поверхности, красный и жёлтый, Montserrat 400–600, радиусы 10/12/16, переход 180 мс. */
:root {
  /* цвета сайта */
  --bg: #141419; --surface: #292b2f; --surface-2: #202126; --surface-soft: #34363a;
  --line: rgba(255,255,255,.18); --line-strong: rgba(255,255,255,.32);
  --fg: #ffffff; --muted: #b7b7b7;
  --brand: #9f2925; --brand-bright: #c82823; --nav-current: rgba(177,151,151,.15);
  --accent: #df5a55; --yellow: #cdbb45; --yellow-soft: rgba(205,187,69,.12);
  --fill: rgba(255,255,255,.05); --fill-2: rgba(255,255,255,.11);
  --ghost: rgba(255,255,255,.07); --ghost-hover: rgba(255,255,255,.13);
  --focus: #ffffff;
  /* состояния CRM: ожидание — жёлтым сайта, ошибка — красным текстом сайта, успех — единственный свой цвет */
  --ok: #7fc79a; --ok-soft: rgba(127,199,154,.13); --bad: #df5a55; --bad-soft: rgba(200,40,35,.16);
  --warn: #cdbb45; --warn-soft: rgba(205,187,69,.12);
  /* форма и движение сайта */
  --r-control: 10px; --r-panel: 12px; --r-card: 16px; --r-pill: 999px;
  --motion: 180ms ease; --shadow: 0 12px 30px rgba(10,10,14,.12); --shadow-pop: 0 24px 60px rgba(10,10,14,.55);
  --f-display: 'Montserrat', Arial, sans-serif;
  --f-body: 'Montserrat', Arial, sans-serif;
  --f-mono: 'JetBrains Mono', Consolas, 'Courier New', monospace;
  color-scheme: dark;
}
/* Светлый вариант — цвета светлых разделов сайта. По умолчанию CRM всегда тёмная, как сайт;
   светлый включается атрибутом data-theme="light" на <html>. */
:root[data-theme="light"] {
  --bg: #f0f0f0; --surface: #ececea; --surface-2: #ffffff; --surface-soft: #e2e2e0;
  --line: rgba(20,20,25,.18); --line-strong: rgba(20,20,25,.32);
  --fg: #141419; --muted: #5c5d64;
  --brand: #9f2925; --brand-bright: #c82823; --nav-current: rgba(159,41,37,.1);
  --accent: #9f2925; --yellow: #7f701a; --yellow-soft: rgba(205,187,69,.24);
  --fill: rgba(20,20,25,.04); --fill-2: rgba(20,20,25,.09);
  --ghost: rgba(20,20,25,.05); --ghost-hover: rgba(20,20,25,.1);
  --focus: #9f2925;
  --ok: #1f7a4d; --ok-soft: rgba(31,122,77,.12); --bad: #c82823; --bad-soft: rgba(200,40,35,.08);
  --warn: #7f701a; --warn-soft: rgba(205,187,69,.24);
  --shadow: 0 12px 30px rgba(10,10,14,.08); --shadow-pop: 0 24px 60px rgba(10,10,14,.25);
  color-scheme: light;
}
/* Шапка как на сайте всегда тёмная — логотип читается и в светлом варианте */
:root[data-theme="light"] .top {
  --surface: #292b2f; --surface-2: #202126; --surface-soft: #34363a;
  --line: rgba(255,255,255,.18); --line-strong: rgba(255,255,255,.32); --fg: #fff; --muted: #b7b7b7;
  --brand-bright: #c82823; --nav-current: rgba(177,151,151,.15); --accent: #df5a55; --yellow: #cdbb45;
  --fill: rgba(255,255,255,.05); --fill-2: rgba(255,255,255,.11); --focus: #fff; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 14px/1.55 var(--f-body); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--yellow); text-underline-offset: 4px; }
b, strong { font-weight: 600; }
::selection { background: var(--yellow); color: #141419; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 600; letter-spacing: 0; text-wrap: balance; margin: 0; }
h3 { font-size: 12px; font-weight: 500; line-height: 16px; text-transform: uppercase; color: var(--accent); margin-top: 6px; }
.eyebrow { font-size: 12px; font-weight: 500; line-height: 16px; text-transform: uppercase; color: var(--accent); }
.muted, .s { color: var(--muted); }
.s { font-size: 12.5px; }
.small { font-size: 13px; }
.mono { font-family: var(--f-mono); }
.over { color: var(--bad); font-weight: 600; }
.tel { font-family: var(--f-mono); font-weight: 600; color: var(--fg); text-decoration: none; }
.tel:hover { color: var(--yellow); }

/* верхняя панель — как шапка сайта */
.top { position: sticky; top: 0; z-index: 20; background: rgba(20,20,25,.98); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 12px; padding: 10px 24px; max-width: 1540px; margin: 0 auto; }
.brand { display: inline-flex; align-items: center; gap: 10px; flex: 0 0 auto; color: var(--fg); text-decoration: none; }
.brand .logo { display: block; width: 95px; height: 44px; }
.brand small { font: 500 11px/16px var(--f-body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.top-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin: 0; }
.tab { border: 1px solid transparent; background: none; padding: 8px 14px; border-radius: var(--r-control); font-weight: 500; font-size: 14px; line-height: 20px; color: var(--fg); text-decoration: none; transition: color var(--motion), background-color var(--motion), border-color var(--motion); }
.tab:hover { color: var(--yellow); }
.tab[aria-current="true"] { color: var(--fg); background: var(--nav-current); border-color: var(--brand-bright); }
.fmt { margin-left: auto; flex: 0 0 auto; }
.who { font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.find { position: relative; margin-left: 12px; }
.find input { width: 220px; height: 40px; padding: 0 12px; border-radius: var(--r-control); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--fg); font: 500 14px/20px var(--f-body); }
.find-list { position: absolute; top: 100%; right: 0; min-width: 330px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-panel); margin-top: 6px; z-index: 30; overflow: hidden; display: grid; box-shadow: var(--shadow-pop); }
.find-list a { display: grid; padding: 10px 14px; color: var(--fg); text-decoration: none; border-top: 1px solid var(--line); }
.find-list a:first-child { border-top: 0; }
.find-list a:hover { background: var(--fill-2); }
.find-list span { font-size: 12.5px; color: var(--muted); }
.find-list .none { padding: 10px 14px; color: var(--muted); font-size: 13px; }

.wrap { max-width: 1540px; margin: 0 auto; padding: 24px 24px 64px; }
.msg { border-radius: var(--r-panel); padding: 12px 16px; font-size: 14px; margin-bottom: 14px; }
.msg.ok { background: var(--ok-soft); border-left: 3px solid var(--ok); }
.msg.bad { background: var(--bad-soft); border-left: 3px solid var(--bad); white-space: pre-line; }
.flash { animation: fadeout .5s 9s forwards; }
@keyframes fadeout { to { opacity: 0; } }

/* заголовок страницы */
.page-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 16px; }
.page-h h1 { font-size: 24px; line-height: 1.3; }
.page-h p { margin: 3px 0 0; }
.crumbs { font-size: 13px; font-weight: 500; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--fg); }
/* разделы админки — одна строка вкладок; на узком экране переносятся и прокручиваются */
.subnav { display: flex; align-items: center; gap: 2px; flex-wrap: nowrap; overflow-x: auto; margin-bottom: 16px; border-bottom: 1px solid var(--line); padding-bottom: 8px; scrollbar-width: thin; }
.subnav a { flex: 0 0 auto; padding: 7px 12px; border: 1px solid transparent; border-radius: var(--r-control); font-weight: 500; font-size: 13.5px; line-height: 20px; color: var(--fg); text-decoration: none; white-space: nowrap; transition: color var(--motion), background-color var(--motion), border-color var(--motion); }
.subnav a:hover { color: var(--yellow); }
.subnav a[aria-current="true"] { color: var(--fg); background: var(--nav-current); border-color: var(--brand-bright); }

/* общие блоки — карточка сайта: поверхность, светлая рамка, 16px */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px 24px; display: grid; gap: 10px; min-width: 0; }
.card h2 { font-size: 17px; }
.card p { margin: 0; }
.stack { display: grid; gap: 16px; align-content: start; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
/* широкая таблица слева, короткий список справа — как причины отказов и источники */
.grid2.wide-left { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stack-form { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > form { margin: 0; }
.row.tight { gap: 8px 14px; margin-top: 6px; align-items: baseline; }

/* поля — подпись мелкая без капса, поле на поверхности чуть темнее, рамка 10px */
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > span { font-size: 12px; font-weight: 500; line-height: 16px; color: var(--muted); }
.field small { color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=password], input[type=number], input[type=tel], input[type=email], input[type=search],
input[type=url], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 12px; border-radius: var(--r-control); border: 1px solid var(--line-strong); background: var(--surface-2);
  color: var(--fg); font: 500 14px/20px var(--f-body); transition: border-color var(--motion), background-color var(--motion); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input:-webkit-autofill { -webkit-text-fill-color: var(--fg); box-shadow: 0 0 0 1000px var(--surface-2) inset; caret-color: var(--fg); }
input[type=number] { font-variant-numeric: tabular-nums; }
textarea { min-height: 84px; line-height: 1.5; resize: vertical; }
/* выбор файла — кнопка как контурная кнопка сайта, имя файла рядом */
input[type=file] { font-size: 13px; color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button { font: 500 13px/20px var(--f-body); color: var(--fg); background: var(--ghost); border: 1px solid var(--line-strong); border-radius: var(--r-control); padding: 7px 12px; margin-right: 12px; cursor: pointer; transition: background-color var(--motion), color var(--motion); }
input[type=file]::file-selector-button:hover { background: var(--ghost-hover); color: var(--yellow); }
.upload input[type=file] { flex: 0 1 380px; }
select { cursor: pointer; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; cursor: pointer; }
.check input { width: 18px; height: 18px; }
/* переключатели — свои вместо родных: включённый — жёлтый акцент сайта, метка цветом фона (в светлом варианте жёлтый тёмный) */
input[type=checkbox], input[type=radio] { appearance: none; -webkit-appearance: none; position: relative; display: inline-block; width: 18px; height: 18px; margin: 0; flex: 0 0 auto; vertical-align: middle; border: 1.5px solid var(--line-strong); border-radius: 5px; background: var(--surface-2); cursor: pointer; transition: background-color var(--motion), border-color var(--motion); }
input[type=radio] { border-radius: 50%; }
input[type=checkbox]::after { content: ''; position: absolute; inset: 2px 3px; background: var(--bg); clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); transform: scale(0); transition: transform var(--motion); }
input[type=radio]::after { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: var(--bg); transform: scale(0); transition: transform var(--motion); }
input[type=checkbox]:hover, input[type=radio]:hover { border-color: var(--yellow); }
input[type=checkbox]:checked, input[type=radio]:checked { background: var(--yellow); border-color: var(--yellow); }
input[type=checkbox]:checked::after, input[type=radio]:checked::after { transform: scale(1); }
input[type=checkbox]:disabled, input[type=radio]:disabled { opacity: .5; cursor: not-allowed; }
.check.big { font-size: 15px; font-weight: 600; margin: 14px 0; }

/* кнопки сайта: красная основная, контурная на поверхности, 10px, подъём на 1px при наведении */
.btn { border: 1px solid transparent; border-radius: var(--r-control); padding: 12px 24px; line-height: 20px; font-weight: 500; font-size: 14px; background: var(--brand); color: #fff; text-decoration: none; display: inline-block; white-space: nowrap; transition: background-color var(--motion), color var(--motion), border-color var(--motion), transform var(--motion), box-shadow var(--motion); }
a.btn { color: #fff; }
.btn:hover, .btn:focus-visible { background: var(--brand-bright); transform: translateY(-1px); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.ghost { background: var(--ghost); border-color: var(--line-strong); color: var(--fg); }
.btn.ghost:hover, .btn.ghost:focus-visible { background: var(--ghost-hover); border-color: var(--line-strong); color: var(--yellow); }
.btn.ghost:active { background: var(--surface-2); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.danger { background: transparent; border-color: var(--brand-bright); color: var(--accent); }
.btn.danger:hover, .btn.danger:focus-visible { background: var(--brand-bright); color: #fff; }
.btn.link { background: none; border: 0; color: var(--muted); padding: 7px 8px; text-decoration: underline; font-weight: 500; }
.btn.link:hover, .btn.link:focus-visible { background: none; color: var(--yellow); transform: none; }
.btn.link:active { transform: none; }
.iconbtn { border: 1px solid var(--line-strong); background: transparent; border-radius: var(--r-control); width: 36px; height: 36px; display: inline-grid; place-items: center; font-size: 15px; color: var(--fg); transition: color var(--motion), border-color var(--motion); }
.iconbtn:hover { color: var(--yellow); border-color: var(--yellow); }
.mini { border: 0; background: none; border-radius: 8px; padding: 2px 6px; font-size: 13px; font-weight: 500; color: var(--yellow); text-decoration: underline; text-underline-offset: 4px; }
.mini:hover { color: var(--fg); }

/* таблица */
.tbl { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); }
.tbl table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.tbl th, .tbl td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th { font-size: 12px; font-weight: 500; color: var(--muted); background: var(--fill); white-space: nowrap; }
.tbl td a { font-weight: 600; color: var(--fg); text-decoration: none; transition: color var(--motion); }
.tbl td a:hover { color: var(--yellow); }
.tbl .c-owner { color: var(--muted); }
.tbl select { padding: 6px 8px; font-size: 13px; min-width: 190px; }
tr.unused { opacity: .55; }
/* импорт: пустые колонки файла скрыты, пока не включён переключатель над таблицей */
.cols-toggle:has(#show-empty:not(:checked)) ~ .tbl tr.empty { display: none; }
tr.warn td:last-child { color: var(--warn); }

/* ярлыки этапа — как значки сайта; «в работе» — как текущий пункт меню сайта */
.pill { font-size: 12px; font-weight: 500; line-height: 16px; padding: 4px 12px; border-radius: var(--r-pill); border: 1px solid transparent; white-space: nowrap; }
.pill.open { background: var(--nav-current); border-color: var(--brand-bright); color: var(--fg); }
.pill.won { background: var(--ok-soft); color: var(--ok); }
.pill.parked { background: var(--warn-soft); color: var(--warn); }
.pill.lost { background: var(--fill-2); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line-strong); background: transparent; border-radius: var(--r-pill); padding: 7px 16px; font-weight: 500; font-size: 13px; color: var(--fg); transition: color var(--motion), background-color var(--motion), border-color var(--motion); }
.chip.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.chip.check:has(input:checked) { border-color: var(--yellow); background: var(--yellow-soft); color: var(--yellow); }
.flag { font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: var(--r-pill); background: var(--fill-2); color: var(--muted); white-space: nowrap; }
.flag.bad { background: var(--bad-soft); color: var(--bad); }
.flag.ok { background: var(--ok-soft); color: var(--ok); }

.auth { max-width: 420px; margin: 6vh auto 0; display: grid; gap: 18px; }
.auth.wide { max-width: 820px; margin-top: 3vh; }
.auth h1 { font-size: 28px; line-height: 1.25; }

/* цифры — плитки как блоки «c 2019 / 2500+» на сайте */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--fill); border: 1px solid var(--line); border-radius: var(--r-card); padding: 14px 24px; color: inherit; text-decoration: none; display: grid; transition: border-color var(--motion), transform var(--motion); }
.tile:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.tile b { font: 600 24px/1.2 var(--f-display); font-variant-numeric: tabular-nums; }
.tile span { font-size: 12.5px; color: var(--muted); }
.tile.warn b { color: var(--warn); } .tile.bad b { color: var(--bad); } .tile.ok b { color: var(--ok); }
/* статистика владельца: изменение к прошлому периоду в подписи плитки, план, строка текущего месяца и бездействующие */
.tile .delta { font-style: normal; font-weight: 600; } .tile .delta.up { color: var(--ok); } .tile .delta.down { color: var(--bad); }
.tile .delta.new { color: var(--yellow); font-weight: 500; }
.stats-plan { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); align-items: end; }
.stats-plan .field input { padding: 7px 8px; }
.stats-plan > div { margin-top: 16px; }
.matrix tr.current td { background: var(--fill-2); }
tr.idle td { color: var(--muted); }

/* фильтры — селекты каталога сайта */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input[type=search], .filters select { width: auto; min-width: 130px; height: 40px; padding: 0 12px; border-radius: var(--r-control); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--fg); font: 500 14px/20px var(--f-body); }
.filters input[type=search] { min-width: 190px; }
.fbox { margin-bottom: 12px; }
.fbox > summary { display: none; }

/* переключатели-сегменты: «Очно / Онлайн / Все» в шапке и вкладки доски */
.seg { display: inline-flex; align-items: stretch; max-width: 100%; overflow-x: auto; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface-2); }
.seg > * { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 8px 14px; border: 0; border-left: 1px solid var(--line); background: none; color: var(--muted); font: 500 13px/20px var(--f-body); text-decoration: none; white-space: nowrap; transition: color var(--motion), background-color var(--motion); }
.seg > :first-child { border-left: 0; }
.seg > :hover { color: var(--fg); background: var(--fill); }
.seg > [aria-pressed="true"], .seg > [aria-current="true"] { color: var(--fg); background: var(--nav-current); box-shadow: inset 0 0 0 1px var(--brand-bright); }
.seg > [aria-pressed="true"] { pointer-events: none; }
.seg .n { font-size: 12px; line-height: 16px; color: var(--muted); background: var(--fill-2); border-radius: var(--r-pill); padding: 1px 7px; }
.seg > [aria-current="true"] .n { color: var(--yellow); }
.seg.tabs { margin-bottom: 12px; }

/* этапы доски, когда колонки не помещаются в экран: лента над доской, нажатие — прыжок к колонке */
.stage-tabs { position: sticky; top: var(--top-h, 56px); z-index: 10; display: flex; gap: 8px; overflow-x: auto; margin-bottom: 10px; padding: 4px 0; background: var(--bg); scrollbar-width: none; }
.stage-tabs::-webkit-scrollbar { display: none; }
.stage-tab { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: var(--surface-2); color: var(--muted); padding: 8px 12px; font: 500 13px/16px var(--f-body); }
.stage-tab .n { font-size: 12px; line-height: 16px; background: var(--fill-2); border-radius: var(--r-pill); padding: 1px 7px; }
.stage-tab.on { color: var(--fg); border-color: var(--brand-bright); background: var(--nav-current); }

/* значки — одна встроенная библиотека в base.html */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* нижнее меню — на экранах уже 1400 px разделы переехали из шапки сюда */
.dock { display: none; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px)); background: rgba(20,20,25,.98); border-top: 1px solid var(--line); }
.dock-a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; border: 0; border-radius: var(--r-control); background: none; color: var(--muted); font: 500 11px/14px var(--f-body); text-decoration: none; list-style: none; cursor: pointer; }
.dock-a::-webkit-details-marker { display: none; }
.dock-a:hover { color: var(--fg); }
.dock-a[aria-current="true"] { color: var(--fg); background: var(--nav-current); box-shadow: inset 0 0 0 1px var(--brand-bright); }
.dock-more { position: relative; }
.dock-menu { position: absolute; right: 0; bottom: calc(100% + 10px); display: grid; gap: 2px; min-width: 190px; padding: 6px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-panel); box-shadow: var(--shadow-pop); }
.dock-menu a, .dock-menu button, .dock-menu .who-mini { display: block; width: 100%; border: 0; border-radius: 8px; background: none; color: var(--fg); font: 500 14px/20px var(--f-body); text-align: left; text-decoration: none; padding: 10px 12px; }
.dock-menu a:hover, .dock-menu button:hover { background: var(--fill-2); }
.dock-menu .who-mini { display: none; color: var(--muted); font-size: 12.5px; padding-bottom: 4px; }

/* задачи */
.trow { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.card > .trow:first-of-type { border-top: 0; }
.trow.over .when { color: var(--bad); }
.trow.gone { opacity: .35; pointer-events: none; }
.when { font: 600 15px var(--f-mono); font-variant-numeric: tabular-nums; }
.when small { display: block; font: 500 12px var(--f-body); color: var(--muted); }
.what { min-width: 0; }
.what a { font-weight: 600; color: var(--fg); text-decoration: none; transition: color var(--motion); }
.what a:hover { color: var(--yellow); }
.acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.nrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); color: inherit; text-decoration: none; font-weight: 600; transition: color var(--motion); }
.card > .nrow:first-of-type { border-top: 0; }
a.nrow:hover > span:first-child { color: var(--yellow); }
.nrow .s { grid-column: 1 / -1; font-weight: 500; }
.nrow .pill { justify-self: start; }
.nrow .what { grid-column: 1 / -1; }
.desk, .deal-grid { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 16px; align-items: start; }
.what > a + a, .what > a + .flag, .what > .d-tel { margin-left: 8px; }
.find-btn { display: none; }

/* рабочий стол: срок и чьи задачи, группы задач, заявки без менеджера, подсказка «как работать» */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 14px; }
.group { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.group.over { color: var(--bad); }
.group span { font-weight: 500; background: var(--fill-2); border-radius: var(--r-pill); padding: 1px 8px; }
.lead { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.card > .lead:first-of-type { border-top: 0; }
.how ol { margin: 0; padding-left: 20px; display: grid; gap: 8px; }

/* меню «Позже» в строке задачи */
.pop { position: relative; }
.pop > summary { list-style: none; }
.pop > summary::-webkit-details-marker { display: none; }
.pop-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 15; display: grid; gap: 2px; min-width: 232px; padding: 6px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-panel); box-shadow: var(--shadow-pop); }
.pop-list button { border: 0; border-radius: 8px; background: none; color: var(--fg); font: 500 14px/20px var(--f-body); text-align: left; padding: 9px 12px; white-space: nowrap; }
.pop-list button:hover { background: var(--fill-2); }
.pop-list button.quiet { color: var(--muted); border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; }
.pop-form { min-width: 220px; padding: 8px; }             /* меню-форма («Передать» в карточке сделки): выбор и кнопка на всю ширину */
.pop-form select { width: 100%; }
.pop-form .btn { width: 100%; }

/* сообщение после действия — с кнопкой «Отменить», если действие можно вернуть */
.msg.ok { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.msg.ok .btn { flex: 0 0 auto; }

/* итог звонка без суфлёра: большим кнопкой, затем нужные поля */
dialog .out-card { width: min(560px, 94vw); max-height: calc(100vh - 40px); overflow-y: auto; }
.out-group + .out-group, .out-more { margin-top: 10px; }
.out-group h3 { margin: 0 0 6px; }
.out-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.out { display: grid; gap: 2px; align-content: start; text-align: left; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface-2); color: var(--fg); transition: border-color var(--motion), background-color var(--motion), transform var(--motion); }
.out:hover { border-color: var(--yellow); background: var(--surface-soft); transform: translateY(-1px); }
.out b { font-size: 14.5px; font-weight: 600; }
.out small { font-size: 12.5px; color: var(--muted); }
.out.wide { border-color: var(--brand-bright); }
.out.danger b { color: var(--accent); }
.out-more summary { cursor: pointer; }
.out-more[open] summary { margin-bottom: 8px; }
#out-step { display: grid; gap: 10px; }
#out-step h3 { margin: 0; }
#out-back, #out-save { justify-self: start; }
.chips.quick { gap: 6px; }
button.chip { cursor: pointer; }
.chip.on { border-color: var(--yellow); background: var(--yellow-soft); color: var(--yellow); }
.reasons { display: grid; gap: 6px; }
.reason { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-control); cursor: pointer; transition: border-color var(--motion), background-color var(--motion); }
.reason:has(input:checked) { border-color: var(--yellow); background: var(--yellow-soft); }
.reason input { width: 18px; height: 18px; margin-top: 2px; }
.reason span { display: grid; gap: 1px; }
.reason small { font-size: 12.5px; color: var(--muted); }

/* карточка заявки: «назад», этап с подсказкой, rarely needed — свёрнуто */
.back { display: inline-block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--fg); }
.stage-line { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; margin: -6px 0 14px; }
.more-form summary.mini { font-size: 13.5px; list-style: none; }
.more-form summary.mini::-webkit-details-marker { display: none; }
.more-form summary.mini:hover { color: var(--fg); }
.more-form[open] > summary { margin-bottom: 8px; }
.feed form { margin-top: 4px; }
.done-list { display: grid; gap: 6px; margin: 8px 0 0; }

/* воронка — колонки панелями на фоне, карточки поверх. Колонки делят ширину экрана, прокрутка в сторону —
   только когда они не помещаются (на телефоне — одна колонка на экран, ниже). Полоса прокрутки жёлтая, как на сайте.
   Высота колонок — до низа экрана: 245 px над доской и 78 px полей под ней, чтобы страница не прокручивалась */
.board { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(212px, 1fr); gap: 12px; overflow-x: auto; align-items: stretch; padding-bottom: 14px; }
.col { min-width: 0; background: var(--fill); border: 1px solid var(--line); border-radius: var(--r-card); display: flex; flex-direction: column; max-height: calc(100vh - 323px); min-height: 180px; }
.col.kind-won { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.col.over { outline: 2px dashed var(--yellow); outline-offset: -2px; }
.col-h { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.col-h b { font-size: 14px; }
.col-h .n { margin-left: auto; font: 500 12px/16px var(--f-body); color: var(--muted); background: var(--fill-2); border-radius: var(--r-pill); padding: 2px 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.dot.accent { background: var(--brand-bright); } .dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
/* что значит этап — значком в заголовке колонки: текст появляется при наведении и по нажатию и не сдвигает карточки */
.hint { position: relative; display: inline-grid; place-items: center; flex: 0 0 auto; width: 26px; height: 26px; margin: 0 -6px 0 -2px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); transition: color var(--motion), background-color var(--motion); }
.hint:hover, .hint:focus-visible, .hint.open { color: var(--yellow); background: var(--fill-2); }
.hint-pop { display: none; position: absolute; top: calc(100% + 8px); right: 0; z-index: 15; width: max-content; max-width: min(260px, calc(100vw - 48px)); padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface); box-shadow: var(--shadow-pop); color: var(--fg); font: 400 13px/1.45 var(--f-body); text-align: left; white-space: normal; cursor: default; }
.hint:focus-visible .hint-pop, .hint.open .hint-pop { display: block; }
@media (hover: hover) { .hint:hover .hint-pop { display: block; } }
.col-body { overflow-y: auto; overflow-x: hidden; padding: 8px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; align-content: start; flex: 1; }
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 18px 0; border: 1px dashed var(--line-strong); border-radius: var(--r-panel); }
.deal { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 12px 14px; display: grid; gap: 3px; cursor: grab; transition: border-color var(--motion), transform var(--motion); }
.deal:hover { border-color: var(--line-strong); }
.deal.dragging { opacity: .45; cursor: grabbing; }
.d-name { font-weight: 600; color: var(--fg); text-decoration: none; transition: color var(--motion); }
.d-name:hover { color: var(--yellow); }
.d-tel { color: inherit; font-family: var(--f-mono); text-decoration: none; white-space: nowrap; }
.d-tel:hover { color: var(--yellow); }
.call { display: none; vertical-align: -2px; margin-left: 3px; color: var(--yellow); }
.d-prod { font-size: 13px; }
.d-next { font-size: 12.5px; color: var(--muted); }
.d-next.over { color: var(--bad); }
/* пометка сделки (правка 9 от 03.12.2026): на карточке доски и в списке сделок — до двух строк с чертой слева, как заметка
   (была одна строка с обрезкой — на телефоне длинную пометку было не прочитать) */
.d-mark { font-size: 12.5px; line-height: 1.4; color: var(--fg); padding-left: 8px; border-left: 2px solid color-mix(in srgb, var(--yellow) 55%, transparent); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.flags { display: flex; flex-wrap: wrap; gap: 4px; }
.flags .flag { white-space: normal; }
.flag.none { background: var(--warn-soft); color: var(--warn); }
.d-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 4px; }
details.move summary { cursor: pointer; list-style: none; font-size: 12.5px; font-weight: 500; color: var(--yellow); }
details.move form { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
details.move input, details.move select { padding: 6px 8px; font-size: 13px; width: auto; min-width: 120px; max-width: 230px; }
dialog { border: 0; border-radius: var(--r-card); padding: 0; background: transparent; color: var(--fg); }
dialog::backdrop { background: rgba(20,20,25,.72); }
dialog .card { width: min(440px, 92vw); box-shadow: var(--shadow-pop); }
/* окно удаления сделки (правка 8 от 03.12.2026): строки — что уйдёт вместе со сделкой, что останется; оплаты — красной рамкой */
#deal-del .card { width: min(560px, 92vw); }
#deal-del h2 { color: var(--bad); }
.del-body { display: grid; gap: 8px; }
.del-row { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-control); font-size: 14px; line-height: 1.45; }
.del-opts { display: grid; gap: 6px; margin-top: 8px; }
.del-row.bad { border-color: color-mix(in srgb, var(--bad) 55%, transparent); background: var(--bad-soft); }
.del-row .check { font-size: 14px; font-weight: 400; }
.pop-list button.danger { color: var(--bad); }
.pop-list.solo { min-width: 0; }                                                    /* меню из одного действия — по ширине пункта */
/* журнал действий: многострочные подробности — первая строка как есть, снимок удалённой сделки — под кнопкой */
.a-more > summary { cursor: pointer; list-style: none; display: inline-block; margin-top: 4px; color: var(--yellow); font-size: 12.5px; font-weight: 500; }
.a-more > summary::-webkit-details-marker { display: none; }
.a-more > summary::before { content: '▸ '; }
.a-more[open] > summary::before { content: '▾ '; }
.a-more > pre { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 760px; max-height: 340px; overflow: auto; margin: 8px 0 0; padding: 8px 10px; background: var(--surface-2); border-radius: var(--r-panel); font-size: 12px; line-height: 1.45; }
.board, .col-body, .tbl, .mail-text { scrollbar-width: thin; scrollbar-color: var(--yellow) var(--fill-2); }
.board::-webkit-scrollbar, .col-body::-webkit-scrollbar, .tbl::-webkit-scrollbar, .mail-text::-webkit-scrollbar { width: 6px; height: 6px; }
.board::-webkit-scrollbar-track, .col-body::-webkit-scrollbar-track, .tbl::-webkit-scrollbar-track, .mail-text::-webkit-scrollbar-track { border-radius: var(--r-pill); background: var(--fill-2); }
.board::-webkit-scrollbar-thumb, .col-body::-webkit-scrollbar-thumb, .tbl::-webkit-scrollbar-thumb, .mail-text::-webkit-scrollbar-thumb { border-radius: var(--r-pill); background: var(--yellow); }

/* журнал звонков: итоги и возражения полосами, меню «Ещё» в строке — с текстом, а не только кнопками */
.bars .line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.bars h2 + .line { border-top: 0; }
.bars .bar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--fill-2); overflow: hidden; }
.bars .bar i { display: block; height: 100%; border-radius: 2px; background: var(--yellow); }
.bars .miss span { color: var(--bad); }
.bars p { margin-top: 10px; }
.pop-text { min-width: min(300px, 84vw); max-width: 340px; gap: 2px; }
.pop-text .pt { padding: 6px 8px; font-size: 13px; }
.pop-text .pt b { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.pop-text .pt p { margin: 2px 0 0; white-space: pre-wrap; }
.pop-text .miss p { color: var(--bad); }
.pop-text .pt-link { display: block; padding: 8px; border-radius: 8px; font-size: 14px; font-weight: 500; text-decoration: none; }
.pop-text .pt-link:hover { background: var(--fill-2); }
.seg-date input, .seg-range input { width: auto; padding: 6px 10px; font-size: 13.5px; }
/* период «с … по …» — вторая форма в той же ленте пресетов; кнопка не выше соседних пресетов */
.seg .seg-range .btn { min-height: 0; padding: 5px 10px; }
/* действия в строке журнала — значки одной высоты справа: «+» сделать сделку, «▶» запись, «⋯» меню */
.pill.plain { background: var(--fill-2); color: var(--muted); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.tbl .c-acts { white-space: nowrap; text-align: right; vertical-align: middle; }
/* тема письма в журнале почты — не уже 220 px (классом, не строкой стиля: на телефоне карточка сбрасывает min-width, а строку стиля не перебить) */
.tbl td.c-subject { min-width: 220px; }
.tbl .iconbtn { width: 32px; height: 32px; }
.tbl .c-acts > * + * { margin-left: 4px; }
.tbl .c-acts > .pop { display: inline-block; vertical-align: top; }   /* меню «⋯» — в том же ряду, что и значки, а не второй строкой */
.tbl .c-acts > form { display: inline-block; vertical-align: middle; }   /* кнопки-формы (почта) — в ряд, не столбиком */
.pop > summary.iconbtn::-webkit-details-marker { display: none; }
.pop[open] > summary.iconbtn { color: var(--yellow); border-color: var(--yellow); }
.tbl.menu-open { overflow: visible; }                                     /* пока открыто меню строки, таблица его не обрезает (app.js) */
.pop-list.up { top: auto; bottom: calc(100% + 6px); }                    /* у низа экрана меню открывается вверх */

/* страницы длинных списков (web.paged, _pager.html): счётчик записей слева, «назад / дальше» справа;
   над таблицей и под ней — один и тот же блок */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; margin: 10px 0; }
.pager.bottom { margin: 12px 0 0; }
.pager-nav { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.pager-nav .btn { text-decoration: none; }
.pager-gap { width: 86px; }

/* сообщение клиенту в карточке сделки: выбор варианта и готовый текст */
.seg-msg { display: flex; flex-wrap: wrap; overflow: visible; }
.seg-msg > * { border-bottom: 1px solid var(--line-strong); }
.msg-text { margin: 0; padding: 12px 14px; white-space: pre-wrap; font: 400 13.5px/1.55 var(--f-body); color: var(--fg);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-control); max-height: 280px; overflow: auto; }
/* список жилья (03.12.2026): каждый вариант — несколько строк, сообщение длиннее остальных — показываем целиком, без прокрутки в окне */
.msg-text.long { max-height: none; }
.msg-actions { display: grid; gap: 10px; justify-items: start; }          /* «Скопировать» строкой выше, мессенджеры — рядом */
.msg-apps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; }
.msg-apps .btn { min-width: 0; padding-left: 8px; padding-right: 8px; }

/* карточка сделки */
.orow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0; }
.orow input, .orow select { width: auto; flex: 1 1 150px; }
.orow input[type=number] { flex: 0 1 130px; }
.orow > .btn { flex: 0 0 auto; }
.orow > .check, .orow > .chip { flex: 0 0 auto; }          /* галочки в строке формы (метки клиента) не тянут ширину */
.orow input[type=checkbox], .orow input[type=radio] { flex: 0 0 auto; width: 18px; }
.pay-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 20px; align-items: center; }
.pay-grid ul { margin: 6px 0 0; padding-left: 18px; }
#timeline form { display: grid; gap: 8px; margin-bottom: 12px; }
#timeline .btn { justify-self: start; }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.feed li { border-left: 2px solid var(--line-strong); padding-left: 12px; font-size: 13.5px; overflow-wrap: anywhere; }
.feed li.k-call { border-color: var(--accent); }
.feed li.k-stage { border-color: var(--warn); }
.feed li.k-pay { border-color: var(--ok); }
.feed li.k-note { border-color: var(--fg); }

/* «Что обсуждали» (03.12.2026): итоги звонков с комментарием менеджера и заметки от руки — новое сверху, без служебной
   истории; звонок без комментария — одна бледная строка (видно, что звонок был и о нём не написали) */
.story-about { margin: 0; font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
.story-about > b { color: var(--muted); font-weight: 500; margin-right: 8px; }
.story-about .mini { margin-left: 8px; white-space: nowrap; }
.story-note { display: grid; gap: 8px; }
.story-note .btn { justify-self: start; }
.story { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.story-row { padding-left: 12px; border-left: 2px solid var(--accent); min-width: 0; }
.story-row.k-note { border-left-color: var(--fg); }
.story-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 13px; line-height: 20px; color: var(--muted); }
.story-at { color: var(--fg); font-weight: 600; white-space: nowrap; }
.story-text { margin-top: 4px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.story-row.bare .story-at { color: var(--muted); font-weight: 500; }
.story-row.bare .pill { opacity: .85; }
.story-more[open] > summary { margin-bottom: 10px; }

/* запись в группу — часть карточки «Сделка» (0.38.0): панель под полями сделки, на тёмном фоне-2 */
.deal-booking { display: grid; gap: 10px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface-2); }
.deal-booking > h3 { margin: 0 0 2px; }
/* запись в очную группу: факты брони, форма «поток → группа» и выбор потока с группой в диалоге итога;
   создание группы или потока — та же форма, развёрнутая на месте или в диалоге */
.bk-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 20px; }
.bk-facts > div { display: grid; gap: 2px; align-content: start; }
.bk-facts .s { color: var(--muted); }
.bk-facts .pill { justify-self: start; }                 /* статус — метка, а не растянутый на колонку список */
.bk-acts { margin-top: 4px; }
.bk-form-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) auto; gap: 12px; align-items: end; }
.bk-form-row > .bk-new { grid-column: 1 / -1; display: flex; gap: 4px 18px; flex-wrap: wrap; }
.ro { padding: 9px 12px; border-radius: var(--r-control); border: 1px solid var(--line); background: var(--fill); min-height: 40px; font-weight: 500; }
.ro.warn { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.field small a { color: var(--yellow); }
.flags a.flag { text-decoration: none; }
.flags a.flag.bad:hover { background: var(--brand-bright); color: #fff; }
.lead.link { color: inherit; text-decoration: none; }
.lead.link:hover b { color: var(--yellow); }
.bk-pick { display: grid; gap: 10px; }
.bk-pick .bk-note { color: var(--muted); font-size: 12.5px; }
.bk-pick .bk-add { display: flex; gap: 4px 18px; flex-wrap: wrap; }
.bk-form { padding: 12px; border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface-2); }
.bk-form-in { display: grid; gap: 10px; }
.bk-form-in > b { font-size: 14.5px; }
.bk-form-in .msg { margin: 0; padding: 8px 12px; }
.bk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.bk-grid .bk-wide { grid-column: 1 / -1; margin: 0; }
.bk-days { padding: 0; border: 0; }
.bk-days legend { margin-bottom: 4px; }
.bk-slots { display: flex; gap: 6px; flex-wrap: wrap; }
.bk-slots .chip { padding: 5px 12px; }
dialog.bk-dialog .bk-form-in { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px 24px; width: min(560px, 94vw); max-height: calc(100vh - 40px); overflow: auto; box-shadow: var(--shadow-pop); }

/* админка */
.lrow { display: grid; grid-template-columns: minmax(0, 1.3fr) 150px auto auto; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); margin: 0; }
.lrow.grow { grid-template-columns: minmax(0, 1fr) 124px 96px auto; }
.lrows { display: grid; }
/* причины отказов: пять полей одной строкой — код, название, действие, срок и кнопка */
.lrow.codes { grid-template-columns: 36px minmax(0, 1fr) 292px 84px auto; }
.lrow.codes.head { padding-bottom: 0; font-size: 12px; font-weight: 500; color: var(--muted); border-top: 0; }
.lrow-wrap { border-top: 1px solid var(--line); padding: 8px 0; }
.lrow-wrap:first-of-type { border-top: 0; }
.lrow-wrap details { margin-top: 6px; }
/* этапы воронки: две воронки рядом, строка этапа — стрелки, название, тип, код, «Сохранить» */
.srow { display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--line); padding: 6px 0; }
.srow:first-of-type { border-top: 0; }
.srow .grow { flex: 1 1 auto; min-width: 0; margin: 0; }
.srow input, .srow select { padding: 6px 10px; }
.srow .iconbtn { width: 32px; height: 32px; }
.srow .iconbtn:active { color: var(--yellow); border-color: var(--yellow); }
.srow.kind-lost { opacity: .8; }
.moves { display: flex; gap: 4px; margin: 0; }
/* продукты (правка 3 от 03.12.2026): карточки по направлениям — свёрнутая карточка показывает название, варианты
   и сводку цен; внутри строка на вариант (формат и подпись, цена или два пакета, ссылка, признаки и запасной курс);
   выключенный вариант приглушён */
.pgroups { display: grid; gap: 12px; }
details.pgroup > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 6px 14px; flex-wrap: wrap; }
details.pgroup > summary::-webkit-details-marker { display: none; }
details.pgroup > summary::before { content: ''; flex: 0 0 auto; width: 8px; height: 8px; margin-right: -6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; color: var(--muted); transform: rotate(-45deg); transition: transform var(--motion, .18s ease); }
details.pgroup[open] > summary::before { transform: rotate(45deg); }
details.pgroup > summary:hover .pg-name { color: var(--yellow); }
.pg-name { font-size: 16px; font-weight: 600; }
.pg-prices { margin-left: auto; }
.pg-form { margin-top: 6px; display: grid; gap: 12px; }
.pg-form input, .pg-form select { min-width: 0; }                  /* поле не шире своей колонки (иначе на телефоне вылезает) */
.pg-title { max-width: 520px; grid-template-columns: minmax(0, 1fr); }
.pg-head, .pg-row { display: grid; grid-template-columns: 180px 200px minmax(200px, 1fr) minmax(300px, 1.2fr); gap: 10px 18px; align-items: center; }
.pg-head { font-size: 12px; font-weight: 500; color: var(--muted); }
.pg-row { padding: 12px 0; border-top: 1px solid var(--line); }
.pg-row:has(input[name^=active]:not(:checked)) { opacity: .55; }
.pg-var { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.pg-var > b { font-size: 14px; }
.pg-row input, .pg-row select { padding: 7px 10px; font-size: 13.5px; }
.pg-var input { padding: 4px 8px; font-size: 12.5px; }
.pg-row input[type=number] { -moz-appearance: textfield; }
.pg-row input::-webkit-outer-spin-button, .pg-row input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.pg-flags { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.pg-flags .check { font-size: 12.5px; }
.pg-flags select { flex: 1 1 240px; width: auto; min-width: 0; }
.mapgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
/* правила CRM: кто видит сделки, затем числа в две колонки — подпись сверху, число одной ширины, пояснение мелким под полем */
.settings-form { display: flex; flex-direction: column; gap: 14px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; }
.settings-grid > .span, .settings-grid > h3 { grid-column: 1 / -1; }
.settings-grid > h3 { margin-top: 6px; }
.settings-form > .btn { align-self: flex-start; }
.settings-form .field { grid-template-columns: minmax(0, 1fr); }
.settings-form .field > span { font-size: 12.5px; font-weight: 500; color: var(--muted); line-height: 1.35; }
.settings-form .field small { line-height: 1.35; opacity: .85; }
.settings-form .field input { width: 120px; padding: 7px 10px; }
.settings-form .field.span select { max-width: 380px; }
/* админка «Сотрудники и правила»: две карточки одной высоты, действие внизу карточки — у её нижнего края
   (колонкой flex: в сетке с align-content: start автоматический отступ не прижимает) */
.grid2.even { align-items: stretch; }
.grid2.even > .card { display: flex; flex-direction: column; }
.grid2.even > #settings > .settings-form { flex: 1; }
.grid2.even > #users > h3, .grid2.even > #settings > .settings-form > .btn { margin-top: auto; }
/* новый сотрудник: пять полей и кнопка — сеткой 3 × 2, кнопка прижата вниз к полям */
.add-user { align-items: end; }
/* поле с кнопкой рядом (адрес уведомлений и «Скопировать») */
.field-act { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; }
/* карточка-инструкция: свёрнута до заголовка, раскрывается щелчком или ссылкой на её адрес (#tel-setup) */
details.fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; font: 600 17px/1.3 var(--f-display); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: ''; flex: 0 0 auto; width: 8px; height: 8px; margin-left: 2px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; color: var(--muted); transform: rotate(-45deg); transition: transform var(--motion); }
details.fold[open] > summary::before { transform: rotate(45deg); }
details.fold > summary:hover { color: var(--yellow); }
details.fold > summary .s { font: 500 13px/1.4 var(--f-body); }
.fold-body { display: grid; gap: 10px; min-width: 0; }
.grid3 > .span2 { grid-column: 1 / -1; }
/* справочник «Жильё рядом со школой»: вариант слева, «Скрыть» и «Удалить» справа; скрытый приглушён */
.hrow { display: flex; justify-content: space-between; align-items: center; gap: 4px 14px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); min-width: 0; }
.hrow:first-of-type { border-top: 0; }
.hrow.off { opacity: .6; }
/* сделка из звонка: подсказка над формой и пометка в журнале «Звонки» у звонка без сделки */
.call-note { margin-bottom: 4px; }
.no-deal { color: var(--warn); font-weight: 500; }
.mail-text { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 420px; max-height: 260px; overflow: auto; margin: 6px 0 0; font: 400 13px/1.5 var(--f-body); background: var(--surface-2); border-radius: var(--r-panel); padding: 8px 10px; }
/* «Почта с заявками» — свёрнутая карточка (details.fold): состояние ящика в заголовке, значок «?» с инструкцией у правого края,
   поля одной сеткой в пять колонок: подключение (ящик, сервер, порт, пароль, папка), затем разбор (частота, отправители, после разбора, папка) */
details.card.fold > summary > .hint { margin: 0 0 0 auto; }
.hint.wide .hint-pop { max-width: min(400px, calc(100vw - 48px)); }
.mail-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px 16px; }
/* контакты без имени: свёрнутая группа внизу списка, имя вписывается прямо в строке — поле и кнопка одним рядом */
details.nameless > summary .n { color: var(--yellow); font-weight: 600; }
.name-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.name-form input { width: min(280px, 100%); height: 40px; padding: 0 12px; border-radius: var(--r-control); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--fg); font: 500 14px/20px var(--f-body); }

@media (max-width: 1399px) {
  /* шапка короче: разделы уходят в нижнее меню, выход — в «Ещё» */
  .top-nav.main, .logout-desk { display: none; }
  .dock { display: grid; }
  .find { margin-left: 0; }
  .wrap { padding-bottom: 96px; }
  .col { max-height: calc(100vh - 355px); }
  /* причины отказов: пять полей в строку не помещаются — действие и срок второй строкой под названием */
  .lrow.codes.head { display: none; }
  .lrow.codes { grid-template-columns: 36px minmax(0, 1fr) 84px 100px; }
  .lrow.codes > input[type=text], .lrow.codes > select { grid-column: 2 / 4; }
  .lrow.codes > .btn { grid-column: 4; grid-row: 1; }
  /* этапы: узкой колонке не хватает ширины строке этапа — в одну колонку */
  .stages { grid-template-columns: 1fr; }
}
@media (max-width: 1180px) {
  .desk, .deal-grid { grid-template-columns: 1fr; }
  /* админка, продукты: строка варианта в две колонки, признаки — во всю ширину; правила и поля почты — в три колонки */
  .pg-head { display: none; }
  .pg-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pg-flags { grid-column: 1 / -1; }
  .field-act { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .mail-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (hover: none) and (pointer: coarse) { .call { display: inline-block; } }
@media (max-width: 760px) {
  /* шапка: логотип, формат и кнопка поиска; поиск разворачивается строкой ниже */
  .top-in { flex-wrap: wrap; gap: 8px; min-height: 56px; padding: 8px 12px; }
  .brand .logo { width: 78px; height: 36px; }
  .brand small { display: none; }
  .seg > * { padding: 8px 10px; }
  .who { display: none; }
  .dock-menu .who-mini { display: block; }
  .find { display: none; order: 10; flex: 1 1 100%; }
  .top.search-on .find { display: block; }
  .find input { width: 100%; }
  .find-list { left: 0; right: 0; min-width: 0; }
  .call { display: inline-block; }
  .wrap { padding-inline: 16px; }
  .card { padding: 16px; }
  .page-h h1 { font-size: 22px; }
  .grid2, .grid2.wide-left, .grid3 { grid-template-columns: 1fr; }
  .pg-row { grid-template-columns: minmax(0, 1fr); }
  .upload input[type=file] { flex: 1 1 100%; }
  .subnav { flex-wrap: wrap; overflow: visible; }
  details.fold > summary { flex-wrap: wrap; gap: 2px 10px; font-size: 15.5px; }
  .mail-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-form .field.span select { max-width: none; }
  .lrow, .lrow.grow { grid-template-columns: 1fr 1fr; }
  /* причины отказов на телефоне: код и название, действие, срок и кнопка */
  .lrow.codes { grid-template-columns: 36px minmax(0, 1fr) auto; }
  .lrow.codes > input[type=text] { grid-column: 2 / -1; }
  .lrow.codes > select { grid-column: 1 / -1; max-width: 100%; }
  .lrow.codes > input[type=number] { grid-column: 2; }
  .lrow.codes > .btn { grid-column: auto; grid-row: auto; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 12px 14px; }
  .tile b { font-size: 20px; }
  /* кнопки — не ниже 40 px, чтобы попадать пальцем */
  .btn.small, .btn.link { min-height: 40px; padding: 9px 14px; }
  .mini { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-control); text-decoration: none; }
  details.move > summary { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-control); color: var(--fg); }
  details.move[open] { flex: 1 1 100%; }
  details.move[open] > summary { margin-bottom: 8px; }
  details.move select, details.move input { flex: 1 1 100%; max-width: none; }
  /* поля — 16 px, иначе телефон приближает страницу при вводе */
  .field input, .field select, .field textarea, .filters input, .filters select, .orow input, .orow select,
  dialog input, dialog select, details.move input, details.move select, .find input,
  .lrow input, .lrow select, .pg-row input, .pg-row select, .pg-title input { font-size: 16px; }
  .orow input, .orow select { flex: 1 1 100%; }
  /* фильтры — кнопкой, разворачиваются списком */
  .fbox > summary { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface-2); font: 500 14px/20px var(--f-body); cursor: pointer; list-style: none; }
  .fbox > summary::-webkit-details-marker { display: none; }
  .fbox > summary::before { content: ''; width: 8px; height: 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); margin-top: -4px; }
  .fbox[open] > summary { margin-bottom: 10px; }
  .fbox[open] > summary::before { transform: rotate(45deg); margin-top: 4px; }
  .filters > * { flex: 1 1 100%; width: 100%; }
  .filters .btn { flex: 0 0 auto; }
  .name-form input { flex: 1 1 100%; width: 100%; }
  .name-form .btn { flex: 1 1 100%; }
  /* таблицы — карточками: имя и телефон, этап справа, остальное ниже */
  .tbl.cards { overflow: visible; border: 0; border-radius: 0; background: none; }
  .tbl.cards thead { display: none; }
  .tbl.cards tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; align-items: start; margin-bottom: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); }
  /* min-width: 0 — ячейка не вылезает из своей колонки сетки: тема письма (220 px) налезала на соседнюю ячейку и та перехватывала
     нажатия — «текст письма» на телефоне не открывался (аудит 06.12.2026) */
  .tbl.cards td { display: block; padding: 0; border: 0; min-width: 0; }
  /* числовые таблицы (статистика, оплата): подпись столбца — над числом, у таблицы без шапки; колонки — равные,
     чтобы длинная ячейка не отжимала первую */
  .tbl.cards td[data-l]::before { content: attr(data-l); display: block; font-size: 11.5px; line-height: 1.35; color: var(--muted); }
  .tbl.cards.nums tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tbl.cards td[colspan] { grid-column: 1 / -1; }
  .tbl.cards .hide-m { display: none; }
  .tbl.cards .c-main { grid-column: 1; grid-row: 1; order: 1; }
  .tbl.cards .c-main a { font-size: 16px; }
  .tbl.cards .c-side { grid-column: 2; grid-row: 1; order: 2; justify-self: end; text-align: right; }
  .tbl.cards .c-top, .tbl.cards .c-prod, .tbl.cards .c-next, .tbl.cards .c-owner, .tbl.cards .c-deals { grid-column: 1 / -1; }
  .tbl.cards .c-prod { order: 3; } .tbl.cards .c-next { order: 4; } .tbl.cards .c-owner { order: 5; }
  .tbl.cards .c-acts { grid-column: 1 / -1; order: 6; display: flex; align-items: center; }
  .tbl.cards .iconbtn { width: 40px; height: 40px; }
  /* задачи: кнопки строкой ниже */
  .trow { grid-template-columns: 44px minmax(0, 1fr); }
  .trow .acts { grid-column: 1 / -1; justify-content: flex-start; }
  .pay-grid { grid-template-columns: 1fr; }
  .bk-form-row, .bk-grid { grid-template-columns: 1fr; }
  .bk-facts { grid-template-columns: 1fr; }
  .tbl.cards .c-book { grid-column: 1 / -1; order: 5; }
  .tbl.cards .cq-cell { grid-column: 1 / -1; }          /* «Качество звонков»: числовая ячейка — во всю ширину карточки */
  .cq-prop { padding: 12px; }
  /* воронка: одна колонка на экран, листается в сторону; лента этапов прилипает под шапкой */
  .stage-tabs { margin-inline: -16px; padding-inline: 16px; }
  .out-grid { grid-template-columns: 1fr; }
  .pop-list { right: auto; left: 0; min-width: min(250px, 84vw); max-width: calc(100vw - 24px); }
  .page-h .pop-list { left: auto; right: 0; min-width: min(220px, 84vw); }   /* «Передать» в шапке карточки: меню не выезжает вправо */
  .find-btn { display: inline-grid; }
  .board { grid-auto-columns: 100%; gap: 0; margin-inline: -16px; padding-bottom: 0; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; }
  .col { max-height: none; min-height: 55vh; border-radius: 0; border-left: 0; border-right: 0; scroll-snap-align: start; scroll-snap-stop: always; }
  .col-h { padding: 12px 16px; }
  .col-body { overflow: visible; padding: 8px 12px 16px; }
  .deal { cursor: default; }
  /* карточка сделки: сначала итог звонка, история и задачи, переписка, что обсуждали, поля сделки — ниже */
  .deal-grid > .stack, .deal-grid > aside { display: contents; }
  .deal-grid > * > section { order: 10; }
  #outcome { order: 1; } #timeline { order: 2; } #tasks { order: 3; } #story { order: 5; } #chat { order: 4; } #message { order: 6; } #booking { order: 7; } #pay { order: 8; } #fields { order: 9; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; } .flash { animation: none; } }

/* новые заявки (news.py, news.js): строки в списках, колокольчик в шапке, счётчик в нижнем меню, сообщение о пришедшей заявке.
   Заявка подсвечена, пока сотрудник не откроет её карточку или не закроет список */
.is-new { box-shadow: inset 3px 0 0 var(--yellow); background: var(--yellow-soft); }
.trow.is-new, .lead.is-new { padding-left: 12px; padding-right: 10px; border-top-color: transparent; border-radius: var(--r-control); }
.deal.is-new { border-color: var(--yellow); }
.tbl tr.is-new td { background: var(--yellow-soft); }
.tbl tr.is-new td:first-child { box-shadow: inset 3px 0 0 var(--yellow); }
.tbl.cards tr.is-new { background: var(--yellow-soft); box-shadow: inset 3px 0 0 var(--yellow); }
.tbl.cards tr.is-new td { background: none; box-shadow: none; }
.flag.new { background: var(--yellow); color: var(--bg); }
.news { position: relative; flex: 0 0 auto; }
.news > summary { position: relative; }
.news-bell.has { color: var(--yellow); border-color: var(--yellow); }
.news-n { position: absolute; top: -6px; right: -7px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill); background: var(--brand-bright); color: #fff; font: 600 11px/18px var(--f-body); text-align: center; }
.news-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; display: grid; gap: 8px; width: min(340px, calc(100vw - 24px)); padding: 12px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-panel); box-shadow: var(--shadow-pop); }
.news-menu > b { font-size: 13px; }
.news-list { display: grid; max-height: 50vh; overflow: auto; }
.news-list .lead.is-new { padding: 8px 10px; }
.news-list .lead:first-child { border-top: 0; }
.lead .what > a.news-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.news-tel { display: flex; flex-wrap: wrap; align-items: center; font-size: 13px; }
.news-tel .d-tel { color: var(--fg); }
.news-list .muted { margin: 0; padding: 6px 2px; font-size: 13px; }
.news-tools { display: flex; flex-wrap: wrap; gap: 6px; }
/* уведомления push (push.py, push.js): кнопка «Включить», «Проверить» и подсказка для iPhone — под списком колокольчика */
.news-push { display: grid; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.news-push[hidden] { display: none; }
.news-push .s { margin: 0; color: var(--muted); line-height: 1.4; }
.dock-a { position: relative; }
.dock-badge { position: absolute; top: 1px; left: calc(50% + 9px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill); background: var(--brand-bright); color: #fff; font: 600 11px/18px var(--f-body); }
.news-box h2 { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.count-n { font: 500 12px/16px var(--f-body); background: var(--yellow); color: var(--bg); border-radius: var(--r-pill); padding: 1px 7px; }
.news-toast { position: fixed; top: calc(var(--top-h, 64px) + 12px); left: 50%; z-index: 70; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); padding: 14px 46px 14px 16px; background: var(--surface); border: 1px solid var(--yellow); border-left: 4px solid var(--yellow); border-radius: var(--r-card); box-shadow: var(--shadow-pop); opacity: 0; pointer-events: none; transform: translate(-50%, -12px); transition: opacity var(--motion), transform var(--motion); }
.news-toast.on { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.news-toast > b { font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--yellow); }
.news-toast > p { margin: 0; font-size: 14px; line-height: 1.45; }
.news-toast .acts { display: flex; gap: 8px; justify-content: flex-start; }
.news-x { position: absolute; top: 6px; right: 8px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 20px; line-height: 1; padding: 0 0 0 6px; cursor: pointer; }
.news-x:hover { color: var(--fg); }

/* кто сейчас в карточке (presence.js): зелёная строка с «дышащей» точкой в шапке карточки сделки или клиента
   и сообщение снизу, когда в карточку приходит ещё кто-то */
.presence { display: inline-flex; align-items: center; align-self: center; gap: 8px; max-width: 100%; padding: 4px 12px 4px 10px; border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent); border-radius: var(--r-pill); background: var(--ok-soft); color: var(--ok); font-size: 13px; font-weight: 500; line-height: 20px; }
.presence[hidden] { display: none; }
.presence .pulse { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: presence-pulse 2s ease-out infinite; }
@keyframes presence-pulse { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } to { box-shadow: 0 0 0 9px transparent; } }
.presence-toast { position: fixed; left: 50%; bottom: 20px; z-index: 70; max-width: min(520px, calc(100vw - 32px)); padding: 12px 18px; background: var(--surface); border: 1px solid var(--ok); border-left: 4px solid var(--ok); border-radius: var(--r-card); box-shadow: var(--shadow-pop); color: var(--fg); font-size: 14px; line-height: 1.45; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity var(--motion), transform var(--motion); }
.presence-toast.on { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 760px) { .presence-toast { bottom: 84px; } }   /* выше нижнего меню */
@media (prefers-reduced-motion: reduce) { .presence .pulse { animation: none; } }

/* время региона по номеру (phonetime.js): рядом с каждым номером — сколько сейчас у клиента. Московское время — тихо,
   другой пояс — жёлтым, рано или поздно для звонка — красным; под полем номера — то же при вводе */
.ph-time { display: inline-flex; align-items: center; gap: 5px; margin-left: 8px; font: 500 12.5px var(--f-mono); color: var(--muted); white-space: nowrap; cursor: help; }
.ph-time::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }
.ph-time.far { color: var(--yellow); }
.ph-time.quiet { color: var(--bad); }
.what > .ph-time + .flag { margin-left: 8px; }
.ph-hint { font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.ph-hint b { font: 600 13px var(--f-mono); color: var(--fg); }
.ph-hint.far b { color: var(--yellow); }
.ph-hint.quiet b { color: var(--bad); }

/* чат сотрудников (chat.py, chat.js): комнаты слева, сообщения и форма справа; непрочитанные — тем же счётчиком, что у колокольчика */
.chat-link, .dock-menu a { position: relative; }
.chat { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; height: calc(100vh - 200px); height: calc(100dvh - 200px); min-height: 420px; }
.chat-rooms { display: grid; gap: 4px; align-content: start; }
.chat-room { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 12px; border-radius: var(--r-control); color: var(--fg); font-size: 14px; text-decoration: none; }
.chat-room:hover { background: var(--fill-2); }
.chat-room.on { background: var(--fill-2); box-shadow: inset 3px 0 0 var(--yellow); }
.chat-room .chat-n { position: static; flex: none; }
.chat-main { display: flex; flex-direction: column; min-height: 0; padding: 0; }
.chat-h { display: flex; align-items: baseline; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-h h1 { font-size: 16px; margin: 0; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 78%; }
.chat-msg.mine { align-self: flex-end; text-align: right; }
.chat-text { padding: 8px 12px; border-radius: var(--r-panel); background: var(--fill-2); white-space: pre-wrap; overflow-wrap: anywhere; text-align: left; }
.chat-msg.mine .chat-text { background: var(--yellow-soft); }
.chat-msg.system { align-self: stretch; max-width: none; }
.chat-msg.system .chat-text { background: transparent; border: 1px dashed var(--line-strong); color: var(--muted); }
.chat-tools { padding: 0 16px 6px; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); }
.chat-form textarea { flex: 1; min-width: 0; min-height: 44px; max-height: 160px; resize: vertical; }
@media (max-width: 760px) {
  .chat-link { display: none; }                               /* шапка узкая: значок чата — в меню «Ещё», счётчик там же */
  .chat { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); gap: 8px; height: calc(100vh - 220px); height: calc(100dvh - 220px); min-height: 380px; }
  .chat-rooms { display: flex; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .chat-room { flex: 0 0 auto; white-space: nowrap; padding: 6px 10px; border: 1px solid var(--line); }
  .chat-room.on { box-shadow: none; border-color: var(--yellow); }
  .chat-msg { max-width: 92%; }
  .chat-form { padding: 10px 12px; }
  .chat-form textarea { font-size: 16px; }                    /* иначе телефон приближает страницу при вводе */
  .chat-log { padding: 10px 12px; }
}

/* переписка в канале (channels.py, channels.js): лента сообщений в карточке сделки, свои — справа на жёлтом;
   состояние отправки — под временем; строка «в переписке есть номер» — кнопка записать номер клиенту */
.chan-log { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; padding: 12px; border: 1px solid var(--line);
  border-radius: var(--r-panel); background: var(--surface-2); }
.chan-msg { max-width: 84%; min-width: 0; display: grid; gap: 4px; padding: 0 10px; }
.chan-msg.mine { align-self: flex-end; text-align: right; justify-items: end; }
.chan-text { padding: 8px 12px; border-radius: var(--r-panel); background: var(--fill); color: var(--fg); white-space: pre-wrap; overflow-wrap: anywhere; text-align: left; }
.chan-msg.mine .chan-text { background: var(--yellow-soft); }
.chan-img { display: block; width: fit-content; max-width: min(280px, 100%); border-radius: var(--r-panel); overflow: hidden; background: var(--fill);
  text-decoration: none; transition: background var(--motion); }
.chan-img:hover { background: var(--fill-2); }
.chan-img img { display: block; max-width: 100%; max-height: 280px; object-fit: contain; }
.chan-msg.mine .chan-img { background: var(--yellow-soft); }
.chan-wait { display: block; padding: 8px 12px; color: var(--fg); text-align: left; text-decoration: underline dotted; }
.chan-msg .mini { justify-self: end; }
.chan-state.bad { color: var(--bad); }
.chan-form { display: grid; gap: 8px; }
.chan-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chan-tools select { width: auto; max-width: 100%; height: 40px; }
.chan-tools [data-chan-count] { margin-left: auto; }
.chan-note { min-height: 18px; margin: 0; }
.chan-note.bad { color: var(--bad); }
.chan-tel { display: grid; gap: 8px; }
.chan-tel form { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--yellow); border-radius: var(--r-control); }
.chan-tel form > span { flex: 1 1 180px; font-size: 13.5px; }
.chan-cut { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.chan-raw { margin: 6px 0 0; padding: 8px 10px; max-width: 520px; max-height: 220px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 12px/1.5 var(--f-mono); background: var(--surface-2); border-radius: 8px; }
.how-steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
@media (max-width: 760px) {
  .chan-msg { max-width: 92%; }
  .chan-form textarea, .chan-tools select { font-size: 16px; }  /* иначе телефон приближает страницу при вводе */
  .chan-tools select { width: 100%; }
  .chan-tools [data-chan-count] { margin-left: 0; }
}

/* объединение дублей в карточке клиента (03.12.2026): кандидат на объединение с кнопкой и выбор основной сделки */
.merge-list { display: grid; }
.merge-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.merge-row:first-child { border-top: 0; }
.merge-row > span { flex: 1 1 220px; min-width: 0; }
.merge-box { display: grid; gap: 10px; padding: 12px 14px; border: 1px solid var(--brand); border-radius: var(--r-control); }

/* разборы звонков («Качество звонков»): значок оценки в журнале и блок в карточке сделки */
.pill.qa { background: var(--yellow-soft); color: var(--yellow); border-color: transparent; }
a.pill.qa:hover { border-color: var(--yellow); }
.qa-item { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.qa-item:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.qa-item summary { cursor: pointer; display: flex; align-items: center; gap: 10px; }
.qa-summary { margin: 8px 0; }
.qa-grid { display: grid; gap: 4px 28px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .qa-grid { grid-template-columns: 1fr 1fr; } }
.qa-list { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 3px; font-size: 13px; }
.qa-list li::before { content: '✓'; color: var(--ok); margin-right: 7px; }
.qa-list li.no::before { content: '×'; color: var(--accent); }
.qa-obj.over { color: var(--accent); }
.qa-transcript summary { cursor: pointer; }
.qa-pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: var(--fill); padding: 10px 12px; border-radius: var(--r-control); max-height: 340px; overflow: auto; }
.qa-token { font-size: 13px; word-break: break-all; background: var(--fill); padding: 7px 10px; border-radius: var(--r-control); }

/* страница «Качество звонков» (quality.py): худшие связки, блок потока, пропуски в строке сделки */
.cq-worst { margin: 0; padding-left: 20px; font-size: 13.5px; display: grid; gap: 6px; }
.cq-intake { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 10px; }
.cq-intake h3 { margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 15px; }
.cq-deal .s { display: block; }                       /* в строке сделки номер и курс — под именем, а не слитно с ним */
.cq-miss { line-height: 2.1; }
.cq-miss .flag + .flag { margin-left: 3px; }

/* предложения по скрипту (quality.proposals): карточка — статус и заголовок, числа, «сейчас в скрипте», слова из звонков, правка, решение */
.cq-prop { border: 1px solid var(--line); border-radius: var(--r-panel); padding: 14px 16px; margin-top: 12px; display: grid; gap: 10px; }
.cq-prop-h { display: flex; align-items: flex-start; gap: 10px 12px; flex-wrap: wrap; }
.cq-prop-title { flex: 1 1 300px; font-size: 15.5px; font-weight: 600; line-height: 1.35; }
.cq-prop-h .pill { flex: 0 0 auto; }
.cq-facts { margin: 0; padding-left: 20px; font-size: 13.5px; display: grid; gap: 4px; }
.cq-script { margin: 0; display: grid; gap: 8px; font-size: 13.5px; }
.cq-script > div { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 2px 16px; }
.cq-script p { margin: 0; }
.cq-script dt { color: var(--muted); }
.cq-script dd { margin: 0; overflow-wrap: anywhere; }
.cq-script .offer dt, .cq-script .offer dd { font-weight: 500; color: var(--fg); }
.cq-effect { margin: 0; font-size: 13.5px; padding: 8px 12px; border-radius: var(--r-control); background: var(--fill); }
.cq-effect.helped { background: var(--ok-soft); }
.cq-effect.again { background: var(--bad-soft); }
.cq-prop-form { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.cq-prop-more { margin-top: 14px; }
.cq-prop-more > summary { cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--yellow); }

@media (max-width: 760px) {
  .cq-script > div { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }   /* предложение по скрипту: подпись над текстом */
  .cq-script dd { margin-bottom: 8px; }
  .cq-prop { padding: 12px; }
  .cq-prop-form .btn { flex: 1 1 auto; }                                  /* решения — на всю ширину, друг под другом */
}

/* подсказки по скрипту в блоке переписки (chatscript.py, channels.js) */
.chan-hints { display: grid; gap: 8px; margin: 12px 0 2px; }
.chan-progress, .chan-opts, .chan-alts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chan-opts .chip, .chan-alts .chip { padding: 5px 12px; font-size: 12.5px; cursor: pointer; }
.chan-hint { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid var(--yellow); border-radius: var(--r-panel); background: var(--yellow-soft); }
.chan-hint-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.chan-hint-h b { font-size: 14px; }
.chan-hint-vars { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.chan-var { display: grid; gap: 3px; text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface); color: var(--fg); font: inherit; cursor: pointer; }
.chan-var:hover { border-color: var(--yellow); }
.chan-var b { font-size: 13px; }
.chan-var span { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }

/* секретарь переписки (chatsec.py, channels.js): варианты ответа от модели — над подсказками скрипта; кнопка-вариант — текст в
   поле ответа. Ждёт модель — строка состояния пунктиром; не ответил — с причиной и кнопкой «Составить заново» */
.chan-sec { margin-top: 12px; }
.chan-sec[hidden] { display: none; }
.chan-sec-box { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-panel); background: var(--surface-2); }
.chan-sec-box.wait { border-style: dashed; color: var(--muted); }
.chan-sec-box.bad { border-color: var(--bad); }
.chan-sec-box.bad .s { color: var(--bad); }
.chan-sec-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.chan-sec-h b { font-size: 14px; }
.chan-sec-h .btn { margin-left: auto; }
.chan-sec-box > .btn, .chan-sec-box .row { justify-self: start; }
.chan-sec-box .chan-var { background: var(--surface); }
.chan-sec-box .chan-var i { font-style: normal; font-size: 12px; color: var(--muted); }
.chan-sec-need { margin: 0; color: var(--muted); }

/* итог переписки (0.41.0, channels.outcome): меню под формой ответа; каждая строка — своё действие со своим полем.
   На компьютере раскрывается вниз от кнопки (переписка остаётся видна), места внизу нет — вверх (channels.js);
   на телефоне — панель над нижней навигацией: целиком на экране, длинное — прокручивается */
.chan-out { justify-self: start; }
.chan-out-list { position: absolute; left: 0; top: calc(100% + 6px); z-index: 15; display: grid; gap: 8px; width: min(600px, calc(100vw - 48px)); padding: 10px;
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-panel); box-shadow: var(--shadow-pop); }
.chan-out.up .chan-out-list { top: auto; bottom: calc(100% + 6px); }
.chan-out-list form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chan-out-list form > span { flex: 1 1 0; min-width: max-content; font-size: 13.5px; white-space: nowrap; }
.chan-out-list select, .chan-out-list input { flex: 999 1 160px; width: auto; min-width: 0; height: 36px; font-size: 13px; }
.chan-out-list .btn { flex: 0 0 auto; white-space: nowrap; }
.chan-out-list .btn.danger { color: var(--bad); }

@media (max-width: 720px) {
  .chan-out-list, .chan-out.up .chan-out-list { position: fixed; left: 12px; right: 12px; top: auto;
      bottom: calc(70px + env(safe-area-inset-bottom, 0px)); width: auto; max-height: calc(100vh - 150px); overflow-y: auto; }
  .chan-out-list form > span { flex: 1 1 100%; }
  .chan-out-list select, .chan-out-list input { flex: 1 1 140px; }
}
