/* Общий стиль CRM (crm.php, crm-rules.php, crm-contacts.php, crm-leads.php,
   crm-production.php, crm-referrals.php). Один файл вместо вшитых <style> в
   каждой странице - проще поддерживать и меньше шанс визуального расхождения.
 *
 * Цветовые токены и карточки/таблицы - общий язык с остальной админкой
 * (admin/index.php и т.д.): тот же зелёный акцент --br, тот же плоский стиль.
 *
 * НО (решение пользователя, 2026-10-21): у CRM-раздела - свой каркас
 * страницы (.crm-shell/.crm-rail/.crm-topbar), в духе AmoCRM: тёмная
 * иконочная панель слева + светлая панель действий сверху, а не общий
 * хэдер-крошки, как у остальной админки. Это сознательное расхождение,
 * не недосмотр - см. [[own-crm-build-plan]]. Токены и мелкие компоненты
 * (кнопки, бейджи, карточки) остаются теми же, чтобы не плодить два
 * визуальных языка одновременно.
 *
 * ДИЗАЙН-ПРИНЦИПЫ:
 *   1. Один акцент - зелёный --br. Только для действия/активного состояния/
 *      крупных чисел - не красим им фон целиком.
 *   2. Иерархия через вес и размер шрифта. Крупные числа (KPI, суммы) -
 *      жирные и заметно крупнее обычного текста.
 *   3. Воздух важнее линий. Карточка держится на тонкой границе + мягкой
 *      тени, а не на тяжёлой обводке.
 *   4. Числа - моноширинные (tabular-nums) в колонках сумм.
 *   5. Статусы/бейджи - пастельный фон + тёмный текст того же оттенка.
 *   6. Движение - только там, где подтверждает действие.
 *   7. Никаких градиентов и стекла - плоские заливки.
 *   8. Отступы/скругления - по шкале (--sp-N / --rad-N), не "на глаз".
 */

:root {
  --br: #00884b;
  --br-dark: #046b3c;
  --br-dim: rgba(0, 136, 75, .10);

  --bg: #f6f7f6;
  --surface: #ffffff;
  --surface-2: #f3f5f3;  /* чуть темнее белого - вложенные элементы (kanban-cards, рамки полей) */
  --line: #dce0dc;
  --line-soft: #eef0ee;
  --text: #1c1f1c;
  --muted: #6a716a;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --rad-sm: 8px; --rad-md: 11px; --rad-lg: 16px; --rad-pill: 999px;
  --radius: var(--rad-lg);
  --shadow: 0 1px 2px rgba(20, 30, 25, .04), 0 4px 14px rgba(20, 30, 25, .05);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: var(--sp-5) var(--sp-4) var(--sp-7); }

/* Каркас CRM-раздела: тёмная иконочная панель слева (в духе Amo) + светлая
   верхняя панель действий справа от неё - остальная админка (admin/index.php
   и т.п.) этот каркас не использует и не затронута. */
.crm-shell { display: flex; min-height: 100vh; background: var(--bg); }
.crm-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.crm-main .wrap { padding: var(--sp-2) var(--sp-4) var(--sp-7) var(--sp-2); margin: 0; max-width: none; }

.crm-rail {
  flex: 0 0 auto; width: 76px; background: #182233; display: flex; flex-direction: column;
  align-items: stretch; padding: var(--sp-3) 0;
  /* панель всегда на высоту окна: колокольчик и настройки внизу экрана, а не внизу длинной страницы */
  position: sticky; top: 0; height: 100vh; align-self: flex-start; overflow-y: auto; scrollbar-width: none;
}
.crm-rail::-webkit-scrollbar { display: none; }
.rail-item {
  --ico-color: #8fb3c9;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 11px 4px; color: #8b97ad; text-decoration: none; font-size: 10px; font-weight: 600;
}
.rail-item:hover { color: #fff; text-decoration: none; }
.rail-item:hover .rail-ico { filter: brightness(1.15); }
.rail-item.active { color: #fff; }
.rail-item.active .rail-ico { background: var(--br); color: #fff; }
.rail-ico {
  width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; margin: 0 auto; position: relative;
  background: color-mix(in srgb, var(--ico-color) 28%, #182233);
  color: var(--ico-color);
}
.rail-ico svg { width: 19px; height: 19px; }
.rail-label { text-align: center; line-height: 1.2; }
.rail-spacer { flex: 1 1 auto; }

.rail-badge {
  position: absolute; top: -3px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--rad-pill); background: #e14b4b; color: #fff; font-size: 9.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid #182233;
}

.crm-topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 24px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.crm-topbar h1 { font-size: 18px; }
.crm-topbar-actions { display: flex; gap: 8px; margin-left: auto; flex: 0 0 auto; }
.crm-search-form { flex: 1 1 auto; min-width: 0; max-width: 480px; }
.crm-search-form input[type="search"] { flex: 1 1 auto; min-width: 0; }

h1 { font-size: 23px; font-weight: 650; letter-spacing: -.01em; margin: 0; }
h3 { font-size: 14px; font-weight: 650; margin: 0 0 14px; color: var(--text); }

a { color: var(--br); text-decoration: none; }
a:hover { color: var(--br-dark); text-decoration: underline; }

.top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.top .crumbs { font-size: 12.5px; }
.top .crumbs a { color: var(--muted); text-decoration: none; }
.top .crumbs a:hover { color: var(--br); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
}
.crm-ozon-delivery > :first-child { margin-block-start: 0; }
.crm-ozon-delivery > :last-child { margin-block-end: 0; }

.msg, .err {
  border-radius: var(--rad-md);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  font-size: 13px;
}
.msg { background: #e7f6ee; border: 1px solid #b7e3c9; color: #0a5c33; }
.err { background: #fdecec; border: 1px solid #f3c2c2; color: #8a2020; }

.muted { color: var(--muted); font-size: 12.5px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; vertical-align: top; }
th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 650; border-bottom: 1px solid var(--line);
}
td { border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
tbody tr:hover td, table tr:hover td { background: var(--surface-2); }
td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }

.badge {
  display: inline-block; padding: 3px var(--sp-3); border-radius: var(--rad-pill);
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
}
.b-synced, .b-on { background: #e7f6ee; color: #0a5c33; }
.b-pending_push { background: #fff6e0; color: #7a5a00; }
.b-local_only, .b-off { background: var(--surface-2); color: var(--muted); }

/* Кружок-аватар с инициалами - клиент/контакт узнаётся с одного взгляда,
   не читая имя целиком. Цвет - по хэшу имени, см. crm_avatar() в PHP. */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: var(--rad-pill);
  font-size: 10.5px; font-weight: 700; color: #1a1a1a; flex: 0 0 auto;
  margin-right: 8px; vertical-align: middle;
}

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }

input, select, textarea {
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line); border-radius: var(--rad-sm);
  font: inherit; font-size: 13.5px; background: #fff; color: var(--text);
  transition: border-color .12s;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--br); }
textarea { width: 100%; min-height: 72px; resize: vertical; }

label.f { display: block; margin-bottom: var(--sp-3); }
label.f > span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: var(--sp-1); font-weight: 600; }
label.f input, label.f select { width: 100%; }

button {
  background: var(--br); color: #fff; border: 0; border-radius: var(--rad-pill);
  padding: var(--sp-2) var(--sp-4); font: inherit; font-size: 13.5px; font-weight: 650;
  cursor: pointer; transition: background .12s, box-shadow .12s;
}
button:hover { background: var(--br-dark); }
button.ghost { background: #fff; color: var(--br); border: 1px solid #c7e4d4; border-radius: var(--rad-md); }
button.ghost:hover { background: #f1faf5; }
button.danger { background: #fff; color: #b3372e; border: 1px solid #f0c9c4; border-radius: var(--rad-md); }
button.danger:hover { background: #fdf3f2; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 16px; }
legend { font-size: 11.5px; color: var(--muted); padding: 0 6px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }

.cond-row, .act-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px;
  margin-bottom: 8px; align-items: center;
}
.act-row { grid-template-columns: 1fr 2fr auto; }

/* Канбан - доска в духе Amo: серый холст, белые карточки-плитки на нём (не
   наоборот), цвет стадии - полоской по верху колонки, не точкой в тексте. */
.view-toggle { display: inline-flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 9px; }
.view-toggle a {
  padding: 6px 14px; border-radius: 7px; text-decoration: none; font-size: 12.5px;
  font-weight: 600; color: var(--muted);
}
.view-toggle a.active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.kanban { display: flex; gap: 14px; overflow-x: auto; padding: 4px 4px 18px; align-items: flex-start; }
.kanban-col {
  --stage-color: var(--br);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  min-width: 264px; max-width: 264px; flex: 0 0 auto; overflow: hidden;
}
.kanban-col::before { content: ""; display: block; height: 4px; background: var(--stage-color); }
.kanban-col h4 {
  margin: 0; padding: 13px 14px 4px; font-size: 11.5px; font-weight: 700; color: var(--text);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  text-transform: uppercase; letter-spacing: .04em;
}
.kc-stage-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-col h4 .cnt {
  color: var(--muted); font-weight: 700; font-size: 11px; background: var(--surface);
  border-radius: var(--rad-pill); padding: 1px 7px; flex: 0 0 auto;
}
.kanban-col-sum {
  padding: 0 14px 10px; font-size: 15px; font-weight: 700; color: var(--stage-color);
  font-variant-numeric: tabular-nums; min-height: 1em;
}
.kanban-cards { padding: 0 8px 10px; min-height: 60px; }
.kanban-col.dragover .kanban-cards { background: var(--br-dim); }
.kanban-card {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--rad-lg);
  box-shadow: var(--shadow);
  padding: 13px 14px; margin-bottom: 10px; cursor: grab; font-size: 12.5px;
  transition: border-color .12s, transform .12s, box-shadow .12s;
}
.kanban-card:hover { border-color: var(--stage-color, var(--br)); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(20,30,25,.09); }
.kanban-card:active { cursor: grabbing; }
/* перетаскивание плиток (crm-kanban.php): копия едет за курсором непрозрачной, на старом месте - пунктир */
.kanban-card { user-select: none; -webkit-user-select: none; }
.kanban-card a { -webkit-user-drag: none; }
.kc-ghost, .kanban-card.kc-ghost { position: fixed; z-index: 3000; margin: 0 !important; pointer-events: none; opacity: 1; transform: rotate(2deg); box-shadow: 0 14px 34px rgba(0,0,0,.22) !important; cursor: grabbing; }
.kanban-card.kc-source { background: transparent; border: 2px dashed #c9d1c9; box-shadow: none; transform: none; }
.kanban-card.kc-source > * { visibility: hidden; }
body.kanban-dragging, body.kanban-dragging * { cursor: grabbing !important; user-select: none !important; }
/* есть новое уведомление по сделке - плитка красная, пока карточку не откроют */
.kanban-card.is-alert, .deal-tile.is-alert { background: #fff0ef; border-color: #e14b4b; box-shadow: 0 0 0 1px #e14b4b, var(--shadow); }
.kanban-card.is-alert .kc-title, .deal-tile.is-alert .dt-title { color: #b3261e; }
/* «Сохранено» - короткая плашка сверху, без сдвига вёрстки карточки */
.save-toast { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 1500; background: #1f7a4d; color: #fff; padding: 8px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 600; box-shadow: 0 6px 18px rgba(0,0,0,.18); animation: save-toast 2.6s ease forwards; pointer-events: none; }
.save-toast.is-err { background: #b3261e; animation-duration: 7s; }
@keyframes save-toast { 0% { opacity: 0; transform: translate(-50%, -8px); } 8% { opacity: 1; transform: translate(-50%, 0); } 85% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
.kc-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.kc-client { font-size: 12px; color: var(--muted); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kc-title { display: block; font-weight: 650; color: var(--text); font-size: 13px; margin-bottom: 8px; }
.kc-sub-stage { display: inline-block; margin: 0 0 6px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 600; }
.kc-title:hover { color: var(--br); }
.kc-amount { font-size: 17px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; margin-bottom: 8px; }
.kc-tags { display: flex; flex-wrap: wrap; gap: 5px; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: var(--rad-sm);
  font-size: 10.5px; font-weight: 650; letter-spacing: .01em; background: var(--surface-2); color: var(--muted);
}
.tag-synced, .tag-on { background: #e7f6ee; color: #0a5c33; }
.tag-pending_push { background: #fff6e0; color: #7a5a00; }
.tag-local_only { background: var(--surface-2); color: var(--muted); }
.tag-assigned { background: var(--br-dim); color: var(--br-dark); }

.kanban-add {
  display: block; text-align: center; padding: 9px; margin: 2px 0 4px;
  border: 1px dashed var(--line); border-radius: var(--rad-md);
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.kanban-add:hover { color: var(--br); border-color: var(--br); text-decoration: none; background: var(--br-dim); }

.deal-list { display: flex; flex-direction: column; gap: 10px; }
.deal-list .deal-tile.is-wait { order: -1; } /* ждут ответа - в самом верху списка, и лиды, и сделки */
.deal-tile {
  display: flex; align-items: center; gap: 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--rad-lg); box-shadow: var(--shadow);
  padding: 14px 20px; text-decoration: none; color: inherit;
  transition: border-color .12s, transform .12s, box-shadow .12s;
}
.deal-tile:hover { border-color: var(--br); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(20,30,25,.09); text-decoration: none; }
.dt-client { display: flex; align-items: center; gap: 10px; flex: 0 0 200px; min-width: 0; }
.dt-text { display: flex; flex-direction: column; min-width: 0; }
.dt-name { font-weight: 650; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-sub { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.dt-title { font-weight: 650; font-size: 13.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-no { display: none; } /* номер заказа в плитке - только на телефоне (ниже) */
.dt-stage {
  flex: 0 0 auto; font-size: 11px; font-weight: 650; color: var(--stage-color, var(--muted));
  padding: 3px 10px; border-radius: var(--rad-pill); background: var(--surface-2);
  border: 1px solid var(--line-soft); white-space: nowrap;
}
.dt-amount { flex: 0 0 110px; text-align: right; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.dt-assigned { flex: 0 0 auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.m-stages, .m-only { display: none; } /* стадии кнопками и лиды карточками - только на телефоне */
.deal-list .deal-tile[hidden] { display: none; }
img.avatar { object-fit: cover; padding: 0; }

@media (max-width: 760px) {
  .deal-tile { flex-wrap: wrap; gap: 10px; }
  .dt-main { flex-basis: 100%; order: 3; }
  .dt-amount { flex: 1 1 auto; text-align: left; order: 4; }
}

.dd-title-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; min-height: 26px; }
.dd-title { font-size: 15px; font-weight: 650; line-height: 20px; color: var(--text); overflow-wrap: anywhere; }
.dd-title[hidden], .dd-title-edit[hidden], .dd-title-input[hidden] { display: none !important; }
/* поле переименования встаёт ровно на место названия: тот же шрифт, рамка «съедается» отрицательным отступом */
.cc-sec .dd-title-row input.dd-title-input:not([type="checkbox"]):not([type="hidden"]), .dd-title-row input.dd-title-input {
  flex: 1 1 auto; width: auto; min-width: 0; height: 30px; margin: -5px 0 -5px -5px; padding: 4px;
  font: inherit; font-size: 15px; font-weight: 650; line-height: 20px; color: var(--text);
  border: 1px solid var(--br); border-radius: 6px; background: #fff;
}
.dd-title-edit {
  flex: 0 0 auto; width: 26px; height: 26px; padding: 0; border-radius: var(--rad-sm);
  background: transparent; color: var(--muted); border: 1px solid transparent;
}
.dd-title-edit:hover { background: var(--surface-2); color: var(--br); }
.dd-title-edit svg { width: 14px; height: 14px; }

.field-list { max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--rad-md); }
.field-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft); font-size: 13px; cursor: pointer;
}
.field-row:last-child { border-bottom: 0; }
.field-row:hover { background: var(--surface-2); }
.field-row input[type="checkbox"] { flex: 0 0 auto; width: auto; }
.field-row-label { flex: 1 1 auto; }
.field-row-code { flex: 0 0 auto; font-size: 11px; }

.deal-detail { display: flex; align-items: flex-start; gap: 16px; }
.dd-fields { flex: 0 0 320px; width: 320px; padding: var(--sp-3); }
.dd-fields .row { margin-bottom: 10px; }
.dd-main {
  flex: 1 1 auto; align-self: stretch; min-height: 420px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad-lg);
  box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; text-align: center;
}

@media (max-width: 860px) {
  .deal-detail { flex-direction: column; }
  .dd-fields { width: 100%; flex-basis: auto; }
}

/* KPI-карточки (crm-referrals.php и т.п.) */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-4); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--sp-4) var(--sp-5); }
.kpi .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin-bottom: 8px; }
.kpi .value { font-size: 40px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .value .ac { color: var(--br); }
.kpi .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi .sub { font-size: 17px; font-weight: 650; color: var(--text); margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .pct { font-size: 15px; font-weight: 650; color: var(--br); margin-top: 6px; }

/* Рамка-плитка вокруг одного поля ввода - тот же язык, что у .kpi, для
   визуальной связности настроек и предпросмотра на одной странице. */
.field-box {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--rad-md);
  padding: var(--sp-3) var(--sp-4);
}
.field-box label.f { margin: 0; }
.field-box input { width: 90px; background: transparent; border: 0; padding: 0; font-size: 20px; font-weight: 700; }
.field-box input:focus { outline: none; }

.headline { font-size: 26px; font-weight: 700; letter-spacing: -.01em; margin: 2px 0 4px; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--br); font-weight: 700; margin-bottom: 4px; }

/* ---------- Настройка полей (crm-field-settings.php) ---------- */
.fs-note { border-left: 3px solid #e0b84c; }
.fs-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); margin-bottom: 12px; flex-wrap: wrap; }
.fs-head-actions { display: flex; align-items: center; gap: 10px; }
.field-filter { width: 100%; margin-bottom: 12px; }
.fs-group { margin-bottom: 10px; }
.fs-group > summary { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 2px; list-style: none; user-select: none; }
.fs-group > summary::-webkit-details-marker { display: none; }
.fs-group > summary::before { content: '▸'; color: var(--muted); font-size: 11px; transition: transform .15s; }
.fs-group[open] > summary::before { transform: rotate(90deg); }
.fs-group-title { font-weight: 650; }
.fs-group > .field-list { max-height: 360px; }
button.link { background: none; border: 0; padding: 0; color: var(--br); font-size: 12px; font-weight: 600; cursor: pointer; }
button.link:hover { background: none; text-decoration: underline; }
.fs-group summary button.fs-all { margin-left: auto; }
.fs-edit { flex: 0 0 auto; font-size: 12px; color: var(--br); text-decoration: none; }
.fs-edit:hover { text-decoration: underline; }
.tag-ro { background: var(--surface-2); color: var(--muted); font-size: 10.5px; font-weight: 600; padding: 1px 6px; vertical-align: 1px; }
.fs-create { max-width: 420px; }

/* ---------- Доп.поля в карточке сделки/лида (crm-fields-ui.php) ---------- */
.dd-section { border-top: 1px solid var(--line-soft); padding-top: 10px; margin-top: 4px; }
.dd-section-title { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.f-readonly { padding: 7px 0; color: var(--text); font-size: 13.5px; overflow-wrap: anywhere; }
.f-checks { display: flex; flex-direction: column; gap: 4px; }
.f-checks label, .f-bool { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 400; color: var(--text); }
.f-checks input, .f-bool input { width: auto; }
label.f.f-bool { display: flex; }

/* Изделия - аккордеон */
details.dd-acc { border: 1px solid var(--line); border-radius: var(--rad-md); padding: 0; margin: 8px 0 0; background: var(--surface); }
details.dd-acc + details.dd-acc { margin-top: 6px; }
details.dd-acc > summary { display: flex; flex-direction: column; gap: 2px; padding: 9px 30px 9px 12px; cursor: pointer; list-style: none; position: relative; user-select: none; }
details.dd-acc > summary::-webkit-details-marker { display: none; }
details.dd-acc > summary::after { content: '▸'; position: absolute; right: 12px; top: 10px; color: var(--muted); font-size: 11px; transition: transform .15s; }
details.dd-acc[open] > summary::after { transform: rotate(90deg); }
details.dd-acc > summary:hover { background: var(--surface-2); border-radius: var(--rad-md); }
details.dd-acc > summary .dd-section-title { margin: 0; }
.dd-acc-sum { font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-acc-body { padding: 4px 12px 2px; border-top: 1px solid var(--line-soft); }
div.f { margin-bottom: var(--sp-3); }
div.f > span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: var(--sp-1); font-weight: 600; }
.f-checks input[type="checkbox"], .f-bool input[type="checkbox"] { width: auto; flex: 0 0 auto; margin: 0; }

/* ---------- Выбор стадии в карточке (crm_stage_picker) - цвета как у колонок канбана ---------- */
.stage-pick { position: relative; --stage-color: var(--br); }
.stage-pick-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-radius: var(--rad-md); border: 1px solid var(--stage-color);
  border-left-width: 4px; background: color-mix(in srgb, var(--stage-color) 14%, #fff);
  color: var(--text); font-weight: 650; font-size: 13.5px; text-align: left; cursor: pointer;
}
.stage-pick-btn:hover { background: color-mix(in srgb, var(--stage-color) 22%, #fff); }
.stage-pick-caret { color: var(--muted); font-size: 11px; }
.stage-pick-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px;
  list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad-md);
  box-shadow: 0 8px 24px rgba(20,30,25,.14); max-height: 360px; overflow-y: auto;
}
.stage-pick-list [data-code] {
  padding: 7px 10px; margin: 2px 0; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600;
  color: var(--text); border-left: 4px solid var(--stage-color);
  background: color-mix(in srgb, var(--stage-color) 12%, #fff);
}
.stage-pick-list [data-code]:hover, .stage-pick-list [data-code]:focus { outline: none; background: color-mix(in srgb, var(--stage-color) 26%, #fff); }
.stage-pick-list [aria-selected="true"] { box-shadow: inset 0 0 0 1px var(--stage-color); }
.stage-pick-sep { padding: 8px 10px 2px; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }

/* =====================================================================
   Карточка сделки/лида по раскладке Bitrix (crm_card_render)
   Слева - колонка разделов (прокручивается сама), справа - окно под
   переписку: стоит на месте во всю высоту, страницу не скроллим.
   ===================================================================== */
.crm-main .wrap.wrap-detail { padding-bottom: var(--sp-2); }
.wrap-detail .deal-detail { height: calc(100vh - 2 * var(--sp-2)); align-items: stretch; }
.wrap-detail .dd-fields {
  flex: 0 0 360px; width: 360px; padding: 0 4px 0 0; height: 100%;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
}
.wrap-detail .dd-main { height: 100%; min-height: 0; align-self: stretch; }
.dd-form { margin: 0; }

.cc-sec {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad-lg);
  box-shadow: var(--shadow); padding: 12px 14px 6px; margin-bottom: 10px;
}
.cc-sec-title {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text); padding-bottom: 9px; margin-bottom: 10px; border-bottom: 1px solid var(--line-soft);
}
.cc-head { padding-bottom: 12px; }
.cc-head .dd-title-row { margin-bottom: 10px; }

/* строки: подпись серым, значение - как текст, рамка только при наведении/фокусе */
.cc-row { margin-bottom: 8px; }
.cc-sec .cc-row { margin-bottom: 4px; } /* поля карточки плотнее: label.f даёт 12px */
.cc-row > span { font-size: 11.5px; font-weight: 400; color: var(--muted); margin-bottom: 1px; }
.cc-sec input:not([type="checkbox"]):not([type="hidden"]),
.cc-sec select, .cc-sec textarea {
  width: calc(100% + 8px); margin-left: -4px; padding: 2px 4px; min-height: 0;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  font-size: 14px; color: var(--text); box-shadow: none;
}
.cc-sec input:not([type="checkbox"]):not([type="hidden"]):hover,
.cc-sec select:hover, .cc-sec textarea:hover { border-color: var(--line); }
.cc-sec input:not([type="checkbox"]):not([type="hidden"]):focus,
.cc-sec select:focus, .cc-sec textarea:focus { border-color: var(--br); background: #fff; outline: none; }
.cc-sec select { appearance: none; -webkit-appearance: none; cursor: pointer; }
.cc-sec select.is-empty, .cc-sec input::placeholder, .cc-sec textarea::placeholder { color: #a3aaa3; }
.cc-sec select.is-empty option { color: var(--text); }
.cc-sec textarea { min-height: 30px; resize: vertical; }
.cc-sec .f-readonly { padding: 2px 0; font-size: 14px; }
.cc-sec .f-readonly.is-empty { color: #a3aaa3; }
.cc-sec .f-checks label, .cc-sec .f-bool { font-size: 14px; }

/* ===== Подпись внутри поля (как в карточке клиента в чате) =====
   Пусто - название серым прямо в поле; заполнено или курсор в поле - название мелко сверху внутри рамки.
   Да/Нет, файлы и клиент - как были (подпись над полем). В «Настроить поля» - тоже как были. */
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> input:not([type="hidden"]):not([type="checkbox"]):not([type="file"])),
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> select),
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> textarea),
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .f-readonly),
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-user-sel),
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-obs),
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-money) {
  position: relative; border: 1px solid var(--line); border-radius: 10px; background: var(--surface, #fff);
  padding: 15px 10px 3px; margin-bottom: 5px; min-height: 38px; box-sizing: border-box; transition: border-color .15s;
}
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> input:not([type="hidden"]):not([type="checkbox"]):not([type="file"])):hover,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> select):hover,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> textarea):hover,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .f-readonly):hover,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-user-sel):hover,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-obs):hover,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-money):hover { border-color: #c6cec6; }
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> input:not([type="hidden"]):not([type="checkbox"]):not([type="file"])):focus-within,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> select):focus-within,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> textarea):focus-within,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .f-readonly):focus-within,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-user-sel):focus-within,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-obs):focus-within,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-money):focus-within { border-color: var(--br); }
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> input:not([type="hidden"]):not([type="checkbox"]):not([type="file"])) > span:first-child,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> select) > span:first-child,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> textarea) > span:first-child,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .f-readonly) > span:first-child,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-user-sel) > span:first-child,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-obs) > span:first-child,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-money) > span:first-child {
  position: absolute; left: 10px; top: 3px; margin: 0; max-width: calc(100% - 20px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 10.5px; line-height: 12px; font-weight: 400; color: var(--muted); pointer-events: none; transition: top .12s, font-size .12s, color .12s;
}
.dd-form:not(.cc-layout-on) .cc-sec .cc-row > span:first-child .cc-code { pointer-events: auto; }
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> input:not([type="hidden"]):not([type="checkbox"]):not([type="file"])) > input,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> select) > select,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> textarea) > textarea,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-user-sel) select {
  width: 100%; margin: 0; padding: 0; min-height: 18px; line-height: 18px; border: 0 !important; border-radius: 0; background: transparent !important; box-shadow: none; font-size: 14px;
}
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .f-readonly) > .f-readonly { padding: 0; }
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-money) .cc-money input { margin: 0; padding: 0; border: 0 !important; background: transparent !important; }
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> input:not([type="hidden"]):not([type="checkbox"]):not([type="file"]):placeholder-shown):not(:focus-within) > span:first-child,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> select.is-empty):not(:focus-within) > span:first-child,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .f-readonly.is-empty) > span:first-child,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-obs .cc-obs-list:empty):not(:focus-within) > span:first-child,
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-user-sel:not(.has-bx) select.is-empty):not(:focus-within) > span:first-child {
  top: 50%; transform: translateY(-50%); font-size: 14px; line-height: 18px; color: #a3aaa3;
}
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> textarea:placeholder-shown):not(:focus-within) > span:first-child { top: 9px; font-size: 14px; line-height: 18px; color: #a3aaa3; }
.dd-form:not(.cc-layout-on) .cc-sec .cc-row > input::placeholder, .dd-form:not(.cc-layout-on) .cc-sec .cc-row > textarea::placeholder { color: transparent; }
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-user-sel:not(.has-bx) select.is-empty):not(:focus-within) .cc-user-sel select { color: transparent; } /* пустой «Ответственный» - как остальные пустые поля */
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> select.is-empty):not(:focus-within) > select, .dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .f-readonly.is-empty) > .f-readonly, .dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-obs .cc-obs-list:empty) .cc-obs-empty { color: transparent; }

.cc-money { display: flex; align-items: baseline; gap: 6px; }
.cc-money input { font-size: 26px !important; font-weight: 300; width: auto !important; flex: 1 1 auto; }
.cc-money span { font-size: 20px; color: var(--muted); }

.cc-client { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px 6px; background: #fff; }
.cc-client-kind { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.cc-dupes { font-size: 12px; color: var(--muted); margin: 5px 0 2px; line-height: 1.4; }
.cc-dupes a { color: #1169c3; text-decoration: none; }
.cc-dupes a:hover { text-decoration: underline; }
.cc-client .cc-client-name { font-size: 15px !important; font-weight: 600; }
.cc-sec .cc-client textarea.cc-client-name { display: block; min-height: 0; height: auto; resize: none; overflow: hidden; line-height: 1.3; field-sizing: content; word-break: break-word; }
.cc-client input { font-size: 13px !important; }
.cc-emails { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.cc-emails input:not([type=hidden]) { box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; }

.cc-comment textarea { min-height: 70px; }
.cc-comment.cc-collapsed textarea { height: 110px; overflow: hidden; resize: none;
  -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.cc-expand { display: block; margin: 2px auto 0; }

.cc-more > summary { cursor: pointer; font-size: 12px; color: var(--br); padding: 2px 0 8px; list-style: none; }
.cc-more > summary::-webkit-details-marker { display: none; }
.cc-more[open] > summary { color: var(--muted); }
.cc-client-details > summary { display: flex; align-items: center; gap: 6px; min-height: 32px; width: fit-content; cursor: pointer; list-style: none; color: var(--br); font-size: 13px; font-weight: 600; }
.cc-client-details > summary::-webkit-details-marker { display: none; }
.cc-client-details > summary::after { content: '▸'; font-size: 11px; }
.cc-client-details[open] > summary::after { transform: rotate(90deg); }
.cc-client-details:not(:has(> [data-code]:not(.cc-row-wait):not([hidden]), > .cc-more:not([hidden]), > .cc-company)) { display: none; }

/* товары - раскрывающиеся разделы */
details.cc-acc { padding: 0; }
details.cc-acc > summary { list-style: none; cursor: pointer; padding: 11px 34px 11px 14px; position: relative; user-select: none; }
details.cc-acc > summary::-webkit-details-marker { display: none; }
details.cc-acc > summary::after { content: '▸'; position: absolute; right: 14px; top: 12px; color: var(--muted); font-size: 11px; transition: transform .15s; }
details.cc-acc[open] > summary::after { transform: rotate(90deg); }
details.cc-acc > summary .cc-sec-title { border: 0; padding: 0; margin: 0 0 3px; }
details.cc-acc[open] > summary { border-bottom: 1px solid var(--line-soft); }
.cc-acc-sum { display: block; font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-acc-body { padding: 10px 14px 6px; }
details.cc-acc.cc-off > summary { opacity: .5; }
details.cc-acc > summary { -webkit-touch-callout: none; }
details.cc-acc.is-drag { position: relative; z-index: 6; box-shadow: 0 10px 28px rgba(0,0,0,.18); transform: scale(1.01); } /* раздел тащат - выше остальных */
body.is-sec-drag, body.is-sec-drag details.cc-acc > summary { cursor: grabbing; user-select: none; }

/* кнопки сохранения - всегда под рукой внизу колонки */
.dd-actions {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 10px 2px; background: var(--bg); border-top: 1px solid var(--line);
}
.dd-actions-right { margin-left: auto; }
@media (max-width: 860px) {
  .wrap-detail .deal-detail { height: auto; }
  .wrap-detail .dd-fields { width: 100%; flex-basis: auto; height: auto; overflow: visible; }
  .wrap-detail .dd-main { height: 60vh; }
}
.cc-sec .cc-row > span { font-size: 11.5px; font-weight: 400; color: var(--muted); margin-bottom: 1px; }
.cc-money input { flex: 0 1 auto !important; width: auto !important; field-sizing: content; min-width: 3ch; max-width: 80%; }
.cc-money input { width: auto !important; flex: 0 0 auto !important; max-width: 80%; }
/* ширина поля - ровно по числу знаков (--n ставит карточка): знак ₽ стоит вплотную к сумме в любом браузере */
.cc-money input { field-sizing: fixed; width: calc(var(--n, 1) * 1ch + 2px) !important; min-width: 0 !important; box-sizing: content-box; }
/* все плашки - аккордеон; сводка в свёрнутом виде серым, в открытом - прячем */
details.cc-acc > summary .cc-acc-sum { color: var(--muted); }
details.cc-acc[open] > summary .cc-acc-sum { display: none; }
details.cc-acc[open] > summary .cc-sec-title { margin: 0; }
details.cc-acc[data-pos] > summary .cc-acc-sum { color: var(--text); }
details.cc-acc[hidden] { display: none !important; }
/* наблюдатели - переключатели-«пилюли» */
.cc-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 3px 0; }
.cc-chip { display: inline-flex; cursor: pointer; }
.cc-chip input { position: absolute; opacity: 0; pointer-events: none; }
.cc-chip span { padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; color: var(--muted); background: #fff; }
.cc-chip:hover span { border-color: var(--br); color: var(--text); }
.cc-chip input:checked + span { background: var(--br-dim); border-color: var(--br); color: var(--br-dark); font-weight: 600; }
.cc-chip input:focus-visible + span { outline: 2px solid var(--br); outline-offset: 1px; }
/* наблюдатели: пилюли с «×» + «добавить» */
.cc-obs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 3px 0; position: relative; }
.cc-obs-list { display: contents; }
.cc-obs-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 999px;
  background: var(--br-dim); border: 1px solid #c7e4d4; font-size: 13px; color: var(--br-dark); font-weight: 600; }
.cc-obs-x { background: none; border: 0; padding: 0 5px; font-size: 15px; line-height: 1; color: var(--muted); cursor: pointer; border-radius: 50%; }
.cc-obs-x:hover { background: #fff; color: #b3372e; }
.cc-obs-empty { color: #a3aaa3; font-size: 14px; }
.cc-obs-add { position: relative; margin-left: auto; }
.cc-obs-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; margin: 0; padding: 4px; list-style: none; min-width: 160px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad-md); box-shadow: 0 8px 24px rgba(20,30,25,.14); }
.cc-obs-menu li { padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.cc-obs-menu li:hover { background: var(--surface-2); }

/* ---------- Действия процессов (меню в шапке карточки) ---------- */
.bp-menu { position: relative; margin-top: 10px; }
.bp-menu-btn { width: 100%; }
.bp-menu-list {
  position: absolute; z-index: 25; left: 0; right: 0; top: calc(100% + 4px); padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad-md); box-shadow: 0 8px 24px rgba(20,30,25,.16);
}
.bp-menu-list .bp-act {
  display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text);
  padding: 8px 10px; border-radius: 6px; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.bp-menu-list .bp-act:hover { background: var(--surface-2); }
.bp-menu-list .bp-act small { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.bp-dialog { border: 1px solid var(--line); border-radius: var(--rad-lg); padding: 18px 20px; width: min(520px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.bp-dialog::backdrop { background: rgba(20,30,25,.35); }
.bp-dialog h3 { margin: 0 0 10px; }
.bp-dialog textarea, .bp-dialog input, .bp-dialog select { width: 100%; }
.bp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

/* ---------- История сделки (правая часть) ---------- */
.dd-main.dd-main-timeline { display: block; text-align: left; overflow-y: auto; padding: 0; align-items: stretch; }
.tl { padding: 14px 18px 24px; }
.tl-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.tl-title { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.tl-pinned { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.tl-pin { padding: 8px 12px; border-radius: var(--rad-md); font-size: 13px; line-height: 1.45; }
.tl-pin-task { background: #fff6e0; border: 1px solid #f1dfae; }
.tl-pin-msg { background: #eef6ff; border: 1px solid #cfe1f7; }
.tl-overdue { color: #b3372e; font-weight: 600; }
.tl-day { text-align: center; margin: 14px 0 8px; }
.tl-day span { display: inline-block; font-size: 11.5px; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 2px 12px; }
.tl-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.tl-ico { flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 13px; }
.tl-body { flex: 1 1 auto; min-width: 0; }
.tl-row { display: flex; justify-content: space-between; gap: 10px; }
.tl-name { font-weight: 600; font-size: 13.5px; }
.tl-time { font-size: 11.5px; color: var(--muted); flex: 0 0 auto; }
.tl-text { font-size: 13px; color: var(--text); margin-top: 3px; white-space: normal; overflow-wrap: anywhere; }
.tl-links { margin-top: 4px; font-size: 12.5px; }
.tl-warn .tl-ico { background: #fdecec; }
.tl-doc .tl-ico { background: var(--br-dim); }
.tl-empty { margin: 20px 0; }

/* ---------- Файлы и ссылки в полях карточки ---------- */
.cc-files { display: flex; flex-wrap: wrap; gap: 8px; padding: 3px 0; align-items: flex-start; }
.cc-files.is-busy { opacity: .55; pointer-events: none; }
.cc-drag-ghost { position: fixed; left: -1000px; top: -1000px; display: flex; flex-direction: column; gap: 3px; width: 104px; padding: 4px; box-sizing: border-box; background: #fff; border: 1px solid #d5dbe0; border-radius: 9px; font-size: 11px; color: #333; }
.cc-drag-ghost canvas { border-radius: 6px; display: block; }
.cc-drag-ghost span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-file { position: relative; width: 112px; display: flex; flex-direction: column; gap: 3px; font-size: 12px; min-width: 0; }
.cc-file-pv { display: flex; align-items: center; justify-content: center; width: 112px; height: 84px; padding: 0; margin: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; cursor: zoom-in; -webkit-tap-highlight-color: transparent; }
.cc-file-pv img { width: 100%; height: 100%; object-fit: contain; display: block; }
button.cc-file-pv, button.cc-file-pv:hover { background: #fff; color: inherit; }
button.cc-file-pv:hover { border-color: #b9c2ca; }
.cc-file-doc { background: #f5f7f8; color: var(--muted); font-weight: 700; font-size: 13px; letter-spacing: .04em; text-decoration: none; cursor: pointer; }
.cc-file-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; text-decoration: none; }
.cc-file-name:hover { text-decoration: underline; }
.cc-file-rm { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; margin: 0; border-radius: 50%; background: rgba(255,255,255,.94); box-shadow: 0 1px 4px rgba(0,0,0,.22); color: #c93a2f; display: flex; align-items: center; justify-content: center; cursor: pointer; opacity: 0; transition: opacity .15s; }
.cc-file:hover .cc-file-rm, .cc-file.is-rm .cc-file-rm { opacity: 1; }
@media (hover: none) { .cc-file-rm { opacity: 1; } }
.cc-file-rm input { position: absolute; opacity: 0; width: 0 !important; height: 0; margin: 0; pointer-events: none; }
.cc-file.is-rm .cc-file-rm { background: #c93a2f; color: #fff; }
.cc-file.is-rm .cc-file-pv, .cc-file.is-old .cc-file-pv { opacity: .35; }
.cc-file.is-rm .cc-file-name, .cc-file.is-old .cc-file-name { text-decoration: line-through; color: var(--muted); }
.cc-file.is-big { width: 100%; }
.cc-file.is-big .cc-file-pv { width: 100%; height: auto; cursor: zoom-out; }
.cc-file.is-big .cc-file-pv img { height: auto; max-height: 85vh; }
.cc-file-bx .cc-file-pv { cursor: default; }
.cc-file-ph { display: none; }
.cc-file.is-noimg .cc-file-pv { background: #f5f7f8; color: var(--muted); font-weight: 700; font-size: 13px; letter-spacing: .04em; cursor: default; }
.cc-file.is-noimg .cc-file-ph { display: inline; }
.cc-drop { position: relative; width: 112px; height: 84px; margin: 0; box-sizing: border-box; border: 1.5px dashed #c3cad1; border-radius: 8px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 6px; color: var(--muted); font-size: 12.5px; cursor: pointer; overflow: hidden; -webkit-tap-highlight-color: transparent; transition: border-color .15s, background .15s; }
.cc-drop .cc-drop-t { font-size: inherit; }
.cc-drop-plus { font-size: 26px; font-weight: 300; line-height: 1; }
.cc-drop.is-empty .cc-drop-plus, .cc-drop:not(.is-empty) .cc-drop-d, .cc-drop:not(.is-empty) .cc-drop-m { display: none !important; }
.cc-files[data-multi="0"] .cc-file:not(.is-rm):not(.cc-file-bx) ~ .cc-drop:not(.has-new) { display: none; } /* одно фото в поле: есть - плитки «+» нет; ✕ - снова пунктир */
.cc-drop.is-empty { width: 100%; max-width: 420px; height: 42px; border-radius: 12px; font-size: 13px; }
.cc-drop:hover, .cc-drop.is-over { border-color: #2fa36b; background: #f2faf6; color: #1e7a4e; }
.cc-drop input[type="file"] { display: none !important; }
.cc-drop-m { display: none; }
@media (hover: none), (max-width: 760px) { .cc-drop-d { display: none; } .cc-drop-m { display: inline; } }
.cc-drop.has-new .cc-drop-t { display: none; }
.cc-drop-pv { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px; background: #f2faf6; }
.cc-drop-pv img { flex: 1 1 0; height: 0; min-height: 0; width: 100%; object-fit: contain; }
.cc-drop-pv i { font-style: normal; font-size: 11.5px; color: #1e7a4e; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-url { display: flex; align-items: center; gap: 8px; }
.cc-url input { flex: 1 1 auto; min-width: 0; }
.cc-url-links { flex: 0 0 auto; font-size: 12.5px; white-space: nowrap; }
.bp-catalog td { vertical-align: top; font-size: 13px; }
.bp-settings { max-width: 560px; }
.bp-settings .f-bool { margin-bottom: 8px; }

/* сопоставление сотрудников Битрикса */
.staff-map .staff-row { display: grid; grid-template-columns: 52px 150px 80px minmax(160px, 240px); align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.staff-map .staff-id { font-weight: 650; }
@media (max-width: 640px) { .staff-map .staff-row { grid-template-columns: 44px 1fr; } }

/* ===== Чат карточки (правая панель, как в amoCRM) ===== */
.dd-main.dd-main-chat { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; text-align: left; padding: 0; overflow: hidden; }
.dd-main.dd-main-chat > .muted { margin: auto; }
.chat { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; width: 100%; position: relative; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.chat-ava { flex: 0 0 34px; height: 34px; border-radius: 50%; background: var(--br-dim); color: var(--br); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.chat-who { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.chat-who b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-who span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-filter { display: flex; gap: 2px; background: var(--surface-2); border-radius: 8px; padding: 2px; flex: 0 0 auto; }
.chat-filter button { background: transparent; color: var(--muted); border: 0; border-radius: 6px; padding: 4px 10px; font-size: 12px; font-weight: 600; }
.chat-filter button:hover { background: transparent; color: var(--text); }
.chat-filter button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.chat-feed { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 10px 16px 14px; background: #f4f6f4; display: flex; flex-direction: column; gap: 6px; }
.cm-empty { margin: auto; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.5; }
.cm-day { align-self: center; margin: 8px 0 2px; }
.cm-day span { font-size: 11.5px; color: var(--muted); background: var(--surface); border-radius: 999px; padding: 2px 12px; box-shadow: 0 1px 1px rgba(0,0,0,.04); }
.cm { display: flex; flex-direction: column; max-width: 80%; }
.cm-out { align-self: flex-end; align-items: flex-end; }
.cm-in { align-self: flex-start; align-items: flex-start; }
.cm-bubble { padding: 7px 11px; border-radius: 14px; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(0,0,0,.05); }
.cm-out .cm-bubble { background: #d9f2e2; border-bottom-right-radius: 4px; }
.cm-in .cm-bubble { background: #fff; border-bottom-left-radius: 4px; }
.cm-bubble a { color: var(--br); }
.cm-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 0 6px; align-items: baseline; }
.cm-meta .link { font-size: 11.5px; }
.cm-wait { color: #b3372e; }
.cm-ok { color: var(--br); }
.cm-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.cm-img img { display: block; max-width: 220px; max-height: 180px; border-radius: 8px; }
.cm-file { display: inline-block; padding: 4px 8px; background: rgba(0,0,0,.05); border-radius: 6px; font-size: 13px; color: var(--text); text-decoration: none; }
.cm-file:hover { background: rgba(0,0,0,.09); }
.cm-note { align-self: stretch; background: #fff8e1; border: 1px solid #f1e2b0; border-radius: 10px; padding: 7px 11px; font-size: 13.5px; line-height: 1.45; }
.cm-note-head { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: #8a6d1f; font-weight: 600; margin-bottom: 2px; }
.cm-note-text { overflow-wrap: anywhere; }
.cm-fabrics { overflow-wrap: anywhere; }
.cm-fabrics ul { list-style: none; margin: 5px 0 0; padding: 0; }
.cm-fabrics li { padding: 4px 0; }
.cm-fabrics li + li { border-top: 1px solid #f1e2b0; }
.cm-ev { align-self: stretch; display: flex; gap: 6px; align-items: baseline; font-size: 12.5px; color: var(--muted); padding: 1px 4px; line-height: 1.4; }
.cm-ev-ico { flex: 0 0 auto; font-size: 11px; }
.cm-ev-ico svg { display: block; width: 14px; height: 14px; margin-top: 2px; } /* значок - ровно по первой строке текста */
.cm-ev > .cm-ev-ico:has(svg) { align-self: flex-start; }
.cm-ev-task .cm-ev-ico { color: var(--br); }
.cm-ev-warn .cm-ev-ico { color: #b3372e; }
.cm-ev-body { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.cm-ev-body b { font-weight: 600; color: var(--text); }
.cm-ev-body a { color: var(--br); }
.cm-ev-time { flex: 0 0 auto; font-size: 11px; }
.cm-ev-warn .cm-ev-body b { color: #b3372e; }
.chat[data-f="msg"] .chat-feed > :not(.cm):not(.cm-day):not(.cm-ev-olh):not(.cm-filter-empty),
.chat[data-f="call"] .chat-feed > :not(.cm-call):not(.cm-day):not(.cm-filter-empty),
.chat[data-f="task"] .chat-feed > :not(.cm-ev-task):not(.cm-day):not(.cm-filter-empty),
.chat[data-f="file"] .chat-feed > :not(.cm-has-file):not(.cm-day):not(.cm-filter-empty),
.chat[data-f="link"] .chat-feed > :not(.cm-has-link):not(.cm-day):not(.cm-filter-empty) { display: none; }
.chat[data-f="audio"] .chat-feed > :not(.cm-call):not(.cm-has-audio):not(.cm-day):not(.cm-filter-empty) { display: none; }
.chat .cm-day.is-empty, .cm-filter-empty[hidden] { display: none; }

.chat-tasks { flex: 0 0 auto; max-height: 30%; overflow-y: auto; border-top: 1px solid var(--line); }
.chat-tasks:empty { display: none; }
.ct { display: flex; gap: 10px; align-items: flex-start; padding: 8px 16px; background: #fffaf0; border-bottom: 1px solid var(--line-soft); }
.ct.is-over { background: #fdf0ef; }
.ct-check { flex: 0 0 18px; width: 18px; height: 18px; margin-top: 2px; padding: 0; border-radius: 50%; border: 2px solid #b9c0b9; background: #fff; cursor: pointer; }
.ct-check:hover, .ct-check.is-done { border-color: var(--br); background: var(--br-dim); }
.ct-body { flex: 1 1 auto; min-width: 0; }
.ct-text { font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.ct-desc { font-size: 12.5px; color: var(--text); }
.ct-meta { font-size: 12px; color: var(--muted); }
.ct.is-over .ct-meta { color: #b3372e; }

.cmp { flex: 0 0 auto; border-top: 1px solid var(--line); padding: 6px 10px; background: var(--surface); }
.cmp-row { display: flex; align-items: flex-end; gap: 4px; }
.cmp-modes { position: relative; flex: 0 0 auto; }
.cmp-mode { background: var(--br-dim); color: var(--br); border: 0; border-radius: 8px; padding: 0 9px; height: 34px; font-size: 12.5px; font-weight: 650; white-space: nowrap; }
.cmp-mode::after { content: ' ▾'; font-size: 10px; }
.cmp-mode:hover { background: rgba(0, 136, 75, .18); }
.cmp[data-mode="note"] .cmp-mode { background: #fff3cd; color: #8a6d1f; }
.cmp[data-mode="task"] .cmp-mode { background: #fdebd3; color: #9a5b00; }
.cmp-menu { position: absolute; left: 0; bottom: calc(100% + 4px); z-index: 20; min-width: 160px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 4px; display: flex; flex-direction: column; }
.cmp-menu[hidden] { display: none; }
.cmp-menu button { background: transparent; color: var(--text); border: 0; border-radius: 6px; padding: 6px 10px; font-size: 13px; font-weight: 500; text-align: left; }
.cmp-menu button:hover, .cmp-menu button.on { background: var(--surface-2); }
.cmp-task { display: none; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 6px; font-size: 12.5px; color: var(--muted); }
.cmp[data-mode="task"] .cmp-task { display: flex; }
.cmp-task label { display: flex; align-items: center; gap: 6px; }
.cmp-task input, .cmp-task select { padding: 2px 6px; font-size: 13px; min-height: 0; width: auto; }
.cmp textarea { flex: 1 1 auto; min-width: 0; height: 34px; min-height: 34px; max-height: 140px; resize: none; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; line-height: 1.35; background: #fff; }
.cmp textarea:focus { border-color: var(--br); outline: none; }
.cmp[data-mode="note"] textarea { background: #fffbea; }
.cmp-files { display: flex; flex-wrap: wrap; gap: 4px; }
.cmp-files:not(:empty) { margin-bottom: 6px; }
.cmp-files { gap: 6px; }
.cmp-att { position: relative; width: 92px; display: flex; flex-direction: column; gap: 2px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 8px; font-size: 11.5px; }
.cmp-att img { width: 100%; height: 64px; object-fit: cover; border-radius: 5px; display: block; cursor: zoom-in; background: #fff; }
.cmp-att-ext { height: 64px; display: flex; align-items: center; justify-content: center; border-radius: 5px; background: #fff; color: var(--br); font-weight: 700; font-size: 13px; letter-spacing: .03em; }
.cmp-att-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.cmp-att-size { color: var(--muted); font-size: 10.5px; }
.cmp-att-x { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; padding: 0; border-radius: 50%; background: #fff; color: var(--muted); border: 1px solid var(--line); font-size: 14px; line-height: 1; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.cmp-att-x:hover { background: #fdf0ef; color: #b3372e; border-color: #f0c9c4; }
.cmp-attach { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--muted); cursor: pointer; }
.cmp-attach:hover { background: var(--surface-2); color: var(--br); }
.cmp-attach svg { width: 18px; height: 18px; }
.cmp[data-mode="task"] .cmp-attach { display: none; }
.cmp-send { flex: 0 0 auto; width: 34px; height: 34px; padding: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.cmp-send svg { width: 16px; height: 16px; margin-left: 2px; }
.cmp-send:disabled { opacity: .6; cursor: default; }
.chat.is-drop .chat-feed { outline: 2px dashed var(--br); outline-offset: -8px; }

/* ===== Всплывающие уведомления (со звуком) ===== */
.ntf-stack { position: fixed; right: 16px; top: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; width: min(340px, calc(100vw - 32px)); pointer-events: none; }
.ntf { pointer-events: auto; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--br); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 10px 12px; font-size: 13.5px; animation: ntf-in .25s ease-out; transition: opacity .4s, transform .4s; }
.ntf.ntf-hide { opacity: 0; transform: translateX(20px); }
.ntf-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ntf-head b { font-size: 13px; }
.ntf-x { background: transparent; color: var(--muted); border: 0; padding: 0 4px; font-size: 18px; line-height: 1; border-radius: 4px; }
.ntf-x:hover { background: var(--surface-2); color: var(--text); }
.ntf-text { margin: 3px 0 6px; line-height: 1.4; overflow-wrap: anywhere; }
.ntf-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; }
.ntf-foot a { color: var(--br); font-weight: 600; }
.ntf-mute { background: transparent; color: var(--muted); border: 0; padding: 0; font-size: 12px; font-weight: 500; }
.ntf-mute:hover { background: transparent; color: var(--text); text-decoration: underline; }
@keyframes ntf-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ===== Код поля для админа («i» в подписи) ===== */
.cc-code { display: none; align-items: center; justify-content: center; width: 14px; height: 14px; margin-left: 5px; padding: 0; vertical-align: 1px;
  border-radius: 50%; border: 1px solid #c5ccc5; background: #fff; color: #8a948a; font: italic 700 9px/1 Georgia, serif; box-shadow: none; cursor: pointer; opacity: .7; }
.cc-row:hover .cc-code, .cc-code:focus { opacity: 1; }
.cc-code:hover { background: #fff; border-color: var(--br); color: var(--br); } /* спокойнее: при наведении - только зелёная обводка, без заливки */
.show-codes .cc-code { display: inline-flex; } /* «Код поля» справа над карточкой */
button.cc-codes-btn { margin-left: auto; margin-right: 14px; display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; box-shadow: none; font-size: 12.5px; color: var(--muted); cursor: pointer; -webkit-tap-highlight-color: transparent; }
button.cc-codes-btn:hover { background: none; color: var(--br); }
.cc-sw { position: relative; flex: none; width: 26px; height: 14px; border-radius: 7px; background: #cfd5cf; transition: background .15s; }
.cc-sw::after { content: ''; position: absolute; left: 2px; top: 2px; width: 10px; height: 10px; border-radius: 50%; background: #fff; transition: transform .15s; }
button.cc-codes-btn[aria-pressed="true"] { color: var(--br); }
.cc-codes-btn[aria-pressed="true"] .cc-sw { background: var(--br); }
.cc-codes-btn[aria-pressed="true"] .cc-sw::after { transform: translateX(12px); }
@media (max-width: 760px), (hover: none) { .show-codes .cc-code, button.cc-codes-btn { display: none; } } /* на телефоне коды полей не нужны */
.cc-code-pop { position: fixed; z-index: 1100; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 8px 10px; font-size: 12.5px; display: flex; flex-direction: column; gap: 4px; }
.cc-code-line { display: grid; grid-template-columns: 68px auto auto; gap: 8px; align-items: center; }
.cc-code-line span { color: var(--muted); }
.cc-code-line code { font: 12px/1.3 ui-monospace, Consolas, monospace; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; user-select: all; }

/* ===== Ширина колонки с полями (перетаскивание границы) ===== */
.dd-resizer { display: none; }
body.is-resizing { cursor: col-resize; user-select: none; }
@media (min-width: 861px) {
  .wrap-detail .deal-detail { gap: 0; }
  .wrap-detail .dd-resizer { display: block; flex: 0 0 14px; align-self: stretch; position: relative; cursor: col-resize; touch-action: none; outline: none; }
  .wrap-detail .dd-resizer::after { content: ''; position: absolute; top: 8px; bottom: 8px; left: 6px; width: 2px; border-radius: 2px; background: transparent; transition: background .15s; }
  .wrap-detail .dd-resizer:hover::after, .wrap-detail .dd-resizer:focus-visible::after, body.is-resizing .dd-resizer::after { background: var(--br); opacity: .55; }
}

/* ===== Шаблоны документов ===== */
.tpl-help { font-size: 13.5px; line-height: 1.5; }
.tpl-help code, .tpl-mark code, .tpl-chip code { font: 12px/1.3 ui-monospace, Consolas, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.tpl-group .tpl-gh { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
details.tpl-group > summary.tpl-gh { cursor: pointer; margin: 0; }
details.tpl-group[open] > summary.tpl-gh { margin-bottom: 8px; }
.tpl-list { display: flex; flex-direction: column; }
.tpl-row { display: grid; grid-template-columns: minmax(220px, 1.4fr) auto minmax(260px, 1.2fr); gap: 6px 16px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--line-soft); }
.tpl-row:last-child { border-bottom: 0; }
.tpl-row:target, .tpl-row.is-open { background: #f6fbf8; }
.tpl-name { display: flex; flex-direction: column; min-width: 0; }
.tpl-name b { font-size: 13.5px; }
.tpl-name .muted { font-size: 12px; }
.tpl-state .tag { white-space: nowrap; }
.tag.tpl-orig { background: var(--surface-2); color: var(--muted); }
.tag.tpl-own { background: #e3f5ea; color: #1f7a4d; }
.tag.tpl-missing { background: #fdecec; color: #b3372e; }
.tpl-actions { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-size: 13px; }
.tpl-actions a { color: var(--br); font-weight: 600; font-size: 12.5px; }
.tpl-actions .tpl-up { margin: 0; display: inline; }
.tpl-actions label.link { color: var(--br); font-weight: 600; font-size: 12.5px; cursor: pointer; }
.tpl-actions label.link:hover, .tpl-actions a:hover { text-decoration: underline; }
button.link.danger-link { color: #b3372e; }
.tpl-scan { grid-column: 1 / -1; padding: 8px 0 4px; }
.tpl-chips { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.tpl-chip { font-size: 12px; color: var(--muted); background: #fff; border: 1px solid var(--line-soft); border-radius: 6px; padding: 2px 6px; }
.tpl-chip.is-bad { border-color: #f0c9c4; background: #fdf3f2; color: #b3372e; }
.tpl-marks { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 0 18px; }
.tpl-mark { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
@media (max-width: 760px) { .tpl-row { grid-template-columns: 1fr; } }

/* ===== Бизнес-процессы: схема + настройки ===== */
.bpx-general { display: grid; gap: 6px; margin-bottom: 12px; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }
.bpx-general .f { margin: 4px 0 0; max-width: 520px; }
details.bpx { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: var(--surface); }
details.bpx > summary { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; list-style: none; }
details.bpx > summary::-webkit-details-marker { display: none; }
details.bpx > summary::after { content: '▾'; margin-left: auto; color: var(--muted); transition: transform .15s; }
details.bpx[open] > summary::after { transform: rotate(180deg); }
.bpx-on { width: 16px; height: 16px; accent-color: var(--br); flex: 0 0 auto; }
.bpx-title { font-weight: 650; font-size: 14px; }
.bpx-how { font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 2px 9px; }
.bpx-bx { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
details.bpx.is-off .bpx-title { color: var(--muted); text-decoration: line-through; }
.bpx-body { display: grid; grid-template-columns: minmax(280px, 1.25fr) minmax(260px, 1fr); gap: 18px; padding: 4px 14px 14px; border-top: 1px solid var(--line-soft); }
.bpx-fields { padding-top: 10px; }
.bpx-fields .f { margin-bottom: 10px; }
.bpx-fields textarea { width: 100%; font-size: 13px; }
.bpx-fields small { display: block; margin-top: 2px; }
.bpx-save { margin-top: 12px; }
.bpx-rest { margin-top: 14px; }
.bpx-rest > summary { cursor: pointer; color: var(--muted); font-size: 13px; }
@media (max-width: 900px) { .bpx-body { grid-template-columns: minmax(0, 1fr); } }
details.bpx > summary { flex-wrap: wrap; row-gap: 4px; }
.bpx-title { min-width: 0; overflow-wrap: anywhere; }
/* схема */
.bpf { padding: 12px 0 4px; display: flex; flex-direction: column; align-items: stretch; font-size: 13px; }
.bpf-node { position: relative; display: flex; gap: 8px; align-items: flex-start; padding: 8px 11px; border-radius: 9px; border: 1px solid var(--line); background: #fff; line-height: 1.4; margin-bottom: 18px; }
.bpf-node:not(:last-child)::after, .bpf-node + .bpf-branches::before { content: ''; position: absolute; left: 22px; bottom: -19px; height: 18px; border-left: 2px solid #c9d1c9; }
.bpf-ico { flex: 0 0 18px; text-align: center; font-weight: 700; }
.bpf-start { background: #e9f7ef; border-color: #b9e2c9; }
.bpf-do { background: #fff; }
.bpf-wait { background: #f4f4f1; border-style: dashed; color: #555; }
.bpf-stop { background: #f6f6f6; color: var(--muted); }
.bpf-if, .bpf-switch { background: #fff8e1; border-color: #f1dfae; font-weight: 600; }
.bpf-next { background: transparent; border-style: dashed; color: var(--muted); font-size: 12px; justify-content: center; }
.bpf-branches { display: flex; gap: 10px; margin: -6px 0 16px; align-items: stretch; flex-wrap: wrap; }
.bpf-branch { flex: 1 1 140px; min-width: 0; border-left: 2px solid #e2c56d; padding: 2px 0 0 10px; }
.bpf-branch .bpf-node { margin-bottom: 10px; }
.bpf-branch .bpf-node:not(:last-child)::after { bottom: -11px; height: 10px; }
.bpf-blabel { display: inline-block; font-size: 11.5px; font-weight: 700; color: #8a6d1f; background: #fff3cd; border-radius: 999px; padding: 1px 9px; margin-bottom: 6px; }
.bpf-val { background: #e3f5ea; color: #1f6b44; border-radius: 4px; padding: 0 4px; font-weight: 600; cursor: pointer; }
.bpf-val:hover { background: #c9ecd6; }

/* ===== Вход в CRM ===== */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 16px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 10px; padding: 24px; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card .f { margin: 0; }
.login-card input { width: 100%; }
.login-card button { margin-top: 6px; }
.login-hint { margin: 6px 0 0; font-size: 12.5px; }

/* ===== Права доступа (как в Bitrix) ===== */
.acc-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 16px; align-items: start; }
.acc-nav { position: sticky; top: 8px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-size: 13.5px; }
.acc-nav b { display: inline-block; background: var(--br); color: #fff; border-radius: 999px; padding: 2px 12px; margin-bottom: 6px; align-self: flex-start; font-size: 12.5px; }
.acc-nav a { color: var(--text); text-decoration: none; padding: 5px 8px; border-radius: 6px; }
.acc-nav a:hover { background: var(--surface-2); }
.acc-nav .acc-nav-users { margin-top: 8px; border-top: 1px solid var(--line-soft); padding-top: 10px; border-radius: 0; }
.acc-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.acc-tools select, .acc-tools input { width: auto; }
.acc-addrole { display: flex; gap: 6px; margin: 0 0 0 auto; }
.acc-show { position: relative; }
.acc-show > summary { cursor: pointer; list-style: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; background: var(--surface); font-size: 13px; }
.acc-show > summary::-webkit-details-marker { display: none; }
.acc-show-list { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 220px; max-height: 360px; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 28px rgba(0,0,0,.14); padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.acc-show-list label { display: flex; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 6px; font-size: 13.5px; cursor: pointer; }
.acc-show-list label:hover { background: var(--surface-2); }
.acc-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.acc-grid { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 13px; }
.acc-grid th, .acc-grid td { border-bottom: 1px solid var(--line-soft); padding: 8px 10px; vertical-align: middle; }
.acc-grid td { text-align: center; min-width: 170px; border-left: 1px solid var(--line-soft); }
.acc-rowh { text-align: left; font-weight: 500; color: var(--text); min-width: 210px; position: sticky; left: 0; background: var(--surface); z-index: 2; }
thead .acc-rowh { font-size: 16px; font-weight: 600; }
.acc-role { vertical-align: top !important; min-width: 170px; border-left: 1px solid var(--line-soft); background: var(--surface); }
.acc-rname { width: 100%; text-align: center; font-weight: 600; font-size: 14px; border: 1px solid transparent; background: transparent; padding: 3px 6px; }
.acc-rname:hover, .acc-rname:focus { border-color: var(--line); background: #fff; }
.acc-unknown { font-size: 11px; color: #b3372e; margin-top: 2px; font-weight: 500; }
.acc-members { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin: 6px 0 4px; }
.acc-chip { display: inline-flex; align-items: center; gap: 2px; background: var(--br-dim); color: #1f6b44; border-radius: 999px; padding: 1px 4px 1px 9px; font-size: 11.5px; font-weight: 500; }
.acc-x { background: transparent; color: inherit; border: 0; padding: 0 4px; font-size: 14px; line-height: 1; border-radius: 50%; }
.acc-x:hover { background: rgba(0,0,0,.08); }
.acc-add { width: auto !important; max-width: 140px; font-size: 12px; padding: 2px 4px; color: var(--br); border-style: dashed; }
.acc-del { font-size: 11.5px; font-weight: 500; }
.acc-sech th { background: var(--surface-2); text-align: left; font-size: 14.5px; font-weight: 600; padding: 10px 12px; position: sticky; left: 0; }
.acc-fold { background: transparent; color: var(--br); border: 0; padding: 0 4px; font-size: 13px; }
.acc-sec.is-folded tr:not(.acc-sech) { display: none; }
.acc-sec.is-folded .acc-fold { transform: rotate(-90deg); display: inline-block; }
select.acc-sel { appearance: none; -webkit-appearance: none; width: auto; max-width: 100%; border: 0; border-bottom: 1px dashed #b7bfb7; border-radius: 0; background: transparent; padding: 2px 2px; font-size: 13px; color: var(--muted); text-align: center; text-align-last: center; cursor: pointer; }
select.acc-sel:hover, select.acc-sel:focus { color: var(--text); border-bottom-color: var(--br); outline: none; }
.acc-q { display: inline-flex; width: 14px; height: 14px; align-items: center; justify-content: center; border-radius: 50%; background: #c5ccc5; color: #fff; font-size: 10px; font-weight: 700; cursor: help; }
.acc-sw { display: inline-flex; cursor: pointer; }
.acc-sw input { position: absolute; opacity: 0; pointer-events: none; }
.acc-sw span { width: 30px; height: 16px; border-radius: 999px; background: #dfe3df; position: relative; transition: background .15s; }
.acc-sw span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: left .15s; }
.acc-sw input:checked + span { background: #2f7cf6; }
.acc-sw input:checked + span::after { left: 16px; }
.acc-sw input:disabled + span { opacity: .4; }
.acc-hide { display: none !important; }
.acc-dim { opacity: .3; }
.acc-savebar { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 14px; align-items: center; padding: 10px 14px; margin: 10px 0 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 -4px 14px rgba(0,0,0,.05); }
.acc-users { width: 100%; border-collapse: collapse; font-size: 13px; }
.acc-users th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.acc-users td { padding: 7px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.acc-users input[type=text], .acc-users input[type=password] { width: 100%; min-width: 150px; font-size: 13px; padding: 5px 8px; }
.acc-urow.is-fired { opacity: .5; }
@media (max-width: 900px) { .acc-layout { grid-template-columns: minmax(0, 1fr); } .acc-nav { position: static; flex-direction: row; flex-wrap: wrap; } }
.cmp-ro { flex: 0 0 auto; border-top: 1px solid var(--line); padding: 10px 14px; font-size: 13px; }
.ro-note { background: #fff8e1; border: 1px solid #f1e2b0; color: #6b5a1e; border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; font-size: 13px; }
fieldset.ro-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.rail-user .rail-label { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-grid th, .acc-users th { text-transform: none; letter-spacing: normal; }
.acc-grid th.acc-rowh { font-size: 13.5px; }
.acc-grid thead th.acc-rowh { font-size: 16px; }
.acc-role { width: 200px; max-width: 220px; white-space: normal; }
.acc-members { max-width: 210px; margin-left: auto; margin-right: auto; }
.acc-grid td { width: 200px; }

/* ===== Канбан «как в Bitrix» ===== */
.bx-top { flex-wrap: wrap; row-gap: 8px; }
/* «Создать»: зелёная таблетка, плюс в белом кружке слева; в простой CRM - стрелка и меню «Лид / Сделка» со значками */
.bx-create { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 16px 0 6px; margin-left: 14px; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, #0a9b57 0%, var(--br) 100%); color: #fff; font-weight: 650; font-size: 13.5px; line-height: 1; text-decoration: none; white-space: nowrap;
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 4px 12px rgba(0,136,75,.28); transition: box-shadow .15s, transform .1s, filter .15s; }
.bx-create:hover { color: #fff; text-decoration: none; filter: brightness(1.05); box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 6px 16px rgba(0,136,75,.34); }
.bx-create:active { transform: scale(.97); }
.bx-create:focus-visible { outline: 2px solid var(--br); outline-offset: 3px; }
.bx-create .bx-plus { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #fff; color: var(--br); flex: none; transition: transform .2s; }
.bx-create:hover .bx-plus { transform: rotate(90deg); }
.bx-create .bx-chev { margin: 0 -4px 0 -2px; opacity: .85; transition: transform .15s; }
.bx-create[aria-expanded="true"] .bx-chev { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .bx-create, .bx-create .bx-plus, .bx-create .bx-chev { transition: none; } .bx-create:hover .bx-plus { transform: none; } }
.bx-funnel { margin-left: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 600; background: var(--surface); }
.bx-search { display: flex; gap: 6px; flex: 1 1 320px; max-width: 560px; margin: 0 0 0 10px; }
.bx-search input[type=search] { flex: 1 1 auto; min-width: 0; }
.bx-search select { width: auto; flex: 0 0 auto; }
.bx-tabs { display: flex; align-items: center; gap: 10px; padding: 0 var(--sp-4) 2px var(--sp-2); flex-wrap: wrap; }
.bx-tabs ~ .wrap { padding-top: 2px; } /* канбан сразу под «Канбан / Список» */
/* «Лиды · Сделки» кружками в шапке, вместо заголовка */
.crm-sect { display: flex; align-items: center; gap: 6px; }
.crm-sect-i { --ico-color: #4f8db5; display: inline-flex; align-items: center; gap: 8px; padding: 3px 12px 3px 3px; border-radius: 999px; color: var(--text); font-size: 15px; font-weight: 600; text-decoration: none; }
.crm-sect-i:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.crm-sect-ico { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--ico-color) 16%, #fff); color: var(--ico-color); }
.crm-sect-ico svg { width: 17px; height: 17px; }
.crm-sect-i.active { font-weight: 700; }
.crm-sect-i.active .crm-sect-ico { background: var(--br); color: #fff; }
.crm-sect-i:not(.active) { color: var(--muted); }
.bx-counter { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); text-decoration: none; }
.bx-counter b { display: inline-flex; min-width: 20px; height: 20px; align-items: center; justify-content: center; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: 11.5px; }
.bx-counter.is-red b { background: #e14b4b; color: #fff; }
a.bx-counter:hover { color: var(--text); text-decoration: none; }

.bx-kanban { gap: 8px; }
.kanban-col.bx-col { background: transparent; border: 0; border-radius: 0; min-width: 250px; max-width: 360px; flex: 1 1 250px; overflow: visible; }
.kanban-col.bx-col::before { display: none; }
.bx-colhead { position: relative; display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 18px 0 10px; background: var(--stage-color); color: var(--fg, #fff);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); border-radius: 4px 0 0 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.bx-colhead .kc-stage-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bx-colwrap { position: relative; }
.bx-st-edit { margin-left: auto; background: transparent; border: 0; padding: 0 2px; color: inherit; font-size: 14px; line-height: 1; opacity: 0; cursor: pointer; }
.bx-colhead:hover .bx-st-edit, .bx-st-edit:focus-visible { opacity: .8; }
.bx-st-edit:hover { opacity: 1; background: transparent; }
.bx-st-add { position: absolute; right: -14px; top: 4px; z-index: 3; width: 22px; height: 22px; padding: 0; border-radius: 50%; background: #fff; color: #525c69; border: 1px solid #dfe3e6; font-size: 16px; line-height: 1; opacity: 0; box-shadow: 0 1px 3px rgba(0,0,0,.12); cursor: pointer; }
.bx-colwrap:hover .bx-st-add, .bx-st-add:focus-visible { opacity: 1; }
.bx-st-add:hover { background: #fff; color: var(--br); }
.bx-st-pop { position: fixed; z-index: 180; width: 260px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: 12px; box-shadow: 0 12px 34px rgba(20,30,40,.18); padding: 10px; }
.bx-st-pop input { font-size: 13px; padding: 6px 8px; }
.bx-st-colors { display: flex; flex-wrap: wrap; gap: 6px; }
.bx-st-colors button { width: 20px; height: 20px; padding: 0; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.bx-st-colors button.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #525c69; }
.bx-st-pop .bx-st-del { margin-left: auto; color: #b3372e; }
.bx-st-todeal { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.bx-st-todeal select { flex: 1 1 auto; font-size: 13px; padding: 4px 6px; min-height: 0; height: 30px; }
.bx-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; background: #263238; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.bx-toast a { color: #8fe3b5; font-weight: 600; margin-left: 6px; }
.cc-to-deal { margin-left: auto; white-space: nowrap; font-size: 12.5px; font-weight: 600; color: var(--br); }
.bx-st-pop .bx-st-del:disabled { opacity: .4; cursor: default; }
.bx-colhead .cnt { background: transparent; color: inherit; opacity: .75; font-weight: 600; padding: 0; font-size: 11.5px; }
.bx-colsum { margin: 6px 0; padding: 7px 10px; text-align: center; font-size: 17px; font-weight: 500; color: var(--text); background: var(--surface); border: 1px solid var(--line-soft); border-radius: 6px; min-height: 36px; }
.bx-quick { display: block; width: 100%; margin: 0 0 6px; padding: 4px; background: transparent; color: var(--muted); border: 0; border-radius: 6px; font-size: 18px; font-weight: 400; line-height: 1.2; }
.bx-quick.is-first { background: var(--surface); border: 1px solid var(--line-soft); font-size: 12.5px; font-weight: 600; padding: 6px; color: var(--text); }
.bx-quick:hover { background: var(--surface); color: var(--br); }
.bx-qform { display: flex; flex-direction: column; gap: 5px; background: var(--surface); border: 1px solid var(--br); border-radius: 8px; padding: 8px; margin-bottom: 8px; }
.bx-qform input { font-size: 13px; padding: 5px 8px; }
.bx-qrow { display: flex; gap: 6px; }
.bx-qrow button { padding: 5px 12px; font-size: 12.5px; }
.bx-col .kanban-cards { padding: 0; }

.kanban-card.bx-card { display: grid; grid-template-columns: minmax(0, 1fr) 22px; gap: 0 6px; padding: 10px 10px 0; margin-bottom: 8px; border-radius: 6px; border: 1px solid var(--line-soft); box-shadow: 0 1px 2px rgba(0,0,0,.06); font-size: 12px; }
.bx-card .kc-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; line-height: 1.3; overflow-wrap: anywhere; }
.bx-card .kc-amount { font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.bx-client { display: block; color: #2067b0; font-size: 12.5px; overflow-wrap: anywhere; text-decoration: none; }
.bx-client:hover { text-decoration: underline; }
.bx-date { color: var(--muted); font-size: 11.5px; margin: 2px 0 6px; }
.bx-f { margin-top: 6px; display: flex; flex-direction: column; gap: 1px; }
.bx-l { color: var(--muted); font-size: 11px; }
.bx-v { color: var(--text); font-size: 12px; }
.bx-user { color: #2067b0; font-weight: 600; }
.bx-pill { align-self: flex-start; display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 11.5px; font-weight: 600; }
.bx-pill.is-warn { background: #fff1d6; color: #b46a00; }
.bx-pill.is-bad { background: #fde3e1; color: #c0392b; }
.bx-pill.is-ok { background: #dff3e4; color: #1f7a4d; }
.bx-pill.is-plan { background: #e6f0fb; color: #2067b0; }
.bx-side { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bx-count { width: 18px; height: 18px; border-radius: 50%; background: #dfe3df; color: #fff; font-size: 10.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.bx-count.has { background: #8fb2d9; }
.bx-ico { color: #2f7cf6; display: flex; }
.bx-ico svg { width: 16px; height: 16px; }
.bx-ico.is-off { color: #c9d1c9; }
.bx-foot { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; margin-top: 8px; padding: 6px 0 7px; border-top: 1px solid var(--line-soft); font-size: 11.5px; }
.bx-add { color: var(--muted); font-weight: 600; text-decoration: none; }
.bx-add:hover { color: var(--br); text-decoration: none; }
.bx-when { color: var(--muted); }
.kanban-card.bx-card.is-alert { background: #fff0ef; border-color: #e14b4b; }
.bx-tasks { width: 100%; }
.bx-tasks tr.is-over .bx-deadline { color: #c0392b; font-weight: 600; }

/* ---------- Правка раскладки карточки («⚙ Настроить поля») ---------- */
.cc-layout-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 8px; }
.cc-layout-btn { font-size: 12.5px; padding: 0; }
.cc-layout-btn .cc-ok-ic { vertical-align: -2px; margin-right: 4px; } /* «Готово» - ровная галочка, не символ шрифта */
.cc-layout-hint { display: none; font-size: 11.5px; }
.cc-layout-on .cc-layout-hint { display: inline; }
.cc-more[hidden], .cc-removed { display: none; }
.cc-layout-on .cc-removed:not(:empty) { display: flex; }
.cc-layout-reset { display: none; font-size: 12px; padding: 0; margin-left: auto; }
.cc-layout-on .cc-layout-reset { display: inline; }
.cc-layout-on .cc-acc-body > [data-code], .cc-layout-on .cc-more > [data-code] { position: relative; outline: 1px dashed var(--line); outline-offset: 3px; border-radius: 4px; padding-right: 92px; }
.cc-layout-on .cc-more { border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 4px; }
.cc-tools { position: absolute; top: 0; right: 0; display: none; gap: 2px; }
.cc-layout-on .cc-tools { display: inline-flex; }
.cc-tools button { width: 22px; height: 20px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--muted); font-size: 12px; line-height: 1; cursor: pointer; box-shadow: none; }
.cc-tools button:hover { color: var(--br); border-color: var(--br); background: var(--br-dim); }
.cc-tools button[data-act="remove"]:hover { color: #c0392b; border-color: #c0392b; background: #fdecea; }
.cc-tools button svg { display: block; margin: auto; }
.cc-layout-on .cc-acc-body > [data-code], .cc-layout-on .cc-more > [data-code] { padding-right: 0; }
.cc-layout-on .cc-acc-body > [data-code] > span:first-child, .cc-layout-on .cc-more > [data-code] > span:first-child { padding-right: 172px; min-height: 20px; } /* подпись не под кнопками */
.cc-layout-on details.cc-acc > summary .cc-sec-title { display: inline-block; vertical-align: middle; }
.cc-sec-ren { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 20px; margin-left: 8px; padding: 0; vertical-align: 1px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--muted); box-shadow: none; cursor: pointer; }
.cc-sec-ren:hover { color: var(--br); border-color: var(--br); background: var(--br-dim); }
input.cc-ren-in { display: inline-block; width: min(240px, 100%); height: 26px; padding: 2px 8px; font: inherit; font-size: 13px; text-transform: none; letter-spacing: 0; }
.cc-move-pop { position: fixed; z-index: 1100; min-width: 180px; max-width: 280px; max-height: 60vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 28px rgba(0,0,0,.16); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.cc-move-head { font-size: 11.5px; color: var(--muted); padding: 2px 8px 4px; }
.cc-move-pop button { text-align: left; padding: 7px 10px; border: 0; border-radius: 7px; background: none; box-shadow: none; color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; }
.cc-move-pop button:hover { background: var(--br-dim); color: var(--br); }
.cc-layout-on [data-code].cc-moved { background: var(--br-dim); transition: background .6s; }
.cc-more > [data-code] .cc-tools button[data-act="hide"] { color: var(--br); border-color: var(--br); }
.cc-removed { flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 6px; font-size: 12px; }
.cc-restore { border: 1px dashed var(--line); background: transparent; color: var(--br); border-radius: 12px; padding: 1px 8px; font-size: 12px; cursor: pointer; box-shadow: none; }
.cc-restore:hover { border-color: var(--br); background: var(--br-dim); }
.cc-restored { color: var(--muted); font-size: 11.5px; }
.cc-saving > summary { opacity: .6; }

/* ---------- Старая переписка из открытых линий Bitrix в чате ---------- */
.cm-ol.cm-out .cm-bubble { background: #e8eef9; }
.cm-ol .cm-file { display: block; margin-top: 4px; }
.cm-ev-olh { margin-top: 6px; }
.cm-ol-tag { font-size: 10.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 0 5px; margin-left: 4px; white-space: nowrap; }
.cm-ev-ol { font-size: 11.5px; opacity: .85; }
.cm-ol-file { display: block; }
.cm-ol-file span { display: block; }
.cm-ol-img { display: block; max-width: 220px; max-height: 220px; border-radius: 8px; margin-bottom: 3px; }

/* кнопки сохранения не переносятся; телефон с трубкой */
.dd-actions { flex-wrap: nowrap; white-space: nowrap; }
.cc-phone { position: relative; display: flex; align-items: center; }
.cc-phone input { flex: 1 1 auto; min-width: 0; padding-right: 34px; }
.cc-phones { display: flex; flex-direction: column; gap: 2px; }
/* «+» ещё телефон: тихая кнопка без кружка рядом с трубкой; на компьютере - при наведении на номер или пока в нём курсор */
.cc-phone-add { position: absolute; right: 33px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0; border: 0; border-radius: 8px; background: transparent; box-shadow: none; color: #97a09b; font-size: 0; line-height: 1; cursor: pointer; transition: opacity .15s, background-color .15s, color .15s; }
.cc-phone-add::before { content: ""; width: 13px; height: 13px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M12 4v16M4 12h16'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M12 4v16M4 12h16'/%3E%3C/svg%3E") center/contain no-repeat; }
.cc-phone-add[hidden] { display: none; }
.cc-phone-add:hover, .cc-phone-add:focus-visible { background: var(--br-dim); color: var(--br); }
@media (hover: hover) { .cc-phone-add { opacity: 0; } .cc-phones:hover .cc-phone-add, .cc-phones:focus-within .cc-phone-add { opacity: 1; } }
.cc-phone:has(.cc-phone-add:not([hidden])) input { padding-right: 64px; }
/* Telegram клиента - строкой «Telegram  @ник · id …» под телефоном */
.cc-im-line { display: flex; flex-wrap: wrap; align-items: center; column-gap: 6px; row-gap: 0; margin-top: 2px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.cc-im-l { flex: none; }
.cc-im-line[hidden] { display: none; }
.cc-sec .cc-im-line input[name=im_tg] { flex: 0 1 auto; min-width: 60px; max-width: 100%; width: auto !important; margin: 0 !important; height: 24px; font-size: 13px !important; field-sizing: content; } /* ширина - по нику, не обрезается */
.cc-im-id { flex: none; white-space: nowrap; }
.cc-im-id::before { content: '· '; }
/* телефон лида в рамке: название внутри поля, как у остальных; пусто - «Телефон» серым на месте номера */
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-phones) {
  position: relative; border: 1px solid var(--line); border-radius: 10px; background: var(--surface, #fff);
  padding: 15px 10px 3px; margin-bottom: 5px; min-height: 38px; box-sizing: border-box; transition: border-color .15s;
}
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-phones):hover { border-color: #c6cec6; }
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-phones):focus-within { border-color: var(--br); }
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-phones) > span:first-child {
  position: absolute; left: 10px; top: 3px; margin: 0; max-width: calc(100% - 20px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 10.5px; line-height: 12px; font-weight: 400; color: var(--muted); pointer-events: none; transition: top .12s, font-size .12s, color .12s;
}
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-phones) .cc-phone input {
  width: 100%; margin: 0; padding: 0 34px 0 0; min-height: 20px; line-height: 20px; border: 0 !important; border-radius: 0; background: transparent !important; box-shadow: none; font-size: 14px;
}
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-phones) .cc-phone.is-main input::placeholder { color: transparent; }
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-phones) .cc-phone.is-more input::placeholder { color: #a3aaa3; }
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-phones) .cc-phone:has(.cc-phone-add:not([hidden])) input { padding-right: 64px; }
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-phones .is-main input:placeholder-shown):not(:has(> .cc-phones .is-main:focus-within)) > span:first-child { top: 15px; font-size: 14px; line-height: 20px; color: #a3aaa3; }
.dd-form:not(.cc-layout-on) .cc-sec .cc-row:has(> .cc-phones) .cc-im-line input[name=im_tg] { border: 0 !important; background: transparent !important; padding: 0 !important; box-shadow: none; }
.cc-call { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; background: var(--br); color: #fff; }
.cc-call[hidden] { display: none; }
.cc-call svg { width: 14px; height: 14px; }
.cc-call:hover { filter: brightness(1.1); }

/* ---------- Канбан: каждый столбец прокручивается отдельно, полоска цвета стадии у плиток ---------- */
@media (min-width: 861px) {
  .crm-main .wrap:has(.bx-kanban) { padding-bottom: 0; }
  .bx-kanban { height: calc(100vh - var(--kb-top, 140px) - 4px); align-items: stretch; padding-bottom: 8px; overflow-y: hidden; }
  .kanban-col.bx-col { display: flex; flex-direction: column; min-height: 0; }
  .kanban-col.bx-col > * { flex-shrink: 0; } /* шапка/сумма/«+» не сжимаются - иначе у столбцов с разным числом плиток разная толщина */
  .bx-col .kanban-cards { flex: 1 1 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 0 3px 8px 0; }
  .bx-col .bx-qform { flex: 0 0 auto; }
}
.bx-col .kanban-card.bx-card { border-left: 3px solid var(--stage-color); }
.bx-pill { padding: 2px 8px; border-radius: 3px; font-size: 11.5px; font-weight: 600; }
.bx-pill.is-ok { background: #c9f0bf; color: #2c6b16; }
.bx-pill.is-warn { background: #ffe88a; color: #725200; }
.bx-pill.is-bad { background: #ffd6d6; color: #c4161c; }
.bx-pill.is-plan { background: #d7ebff; color: #1c5fa8; }

/* ---------- Аватарки сотрудников (фото из Bitrix) ---------- */
img.avatar { object-fit: cover; background: var(--surface-2); padding: 0; }
.bx-user { display: inline-flex; align-items: center; }
.bx-user .avatar, .cc-obs-chip .avatar, .cc-obs-menu .avatar { width: 20px; height: 20px; margin-right: 6px; }
.bx-users { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.cc-user-sel { display: flex; align-items: center; cursor: text; }
.cc-user-sel .avatar { width: 28px; height: 28px; margin-right: 8px; }
.cc-user-sel select { flex: 1 1 auto; min-width: 0; }
.cc-user-sel select[hidden] { display: none !important; }
.cc-user-av { display: contents; }
.cc-obs-chip:has(> .avatar) { padding-left: 4px; }
.cc-obs-menu li { display: flex; align-items: center; }
/* «Ответственный» и «Наблюдатели»: список выпадает ровно из поля (во всю его ширину), в поле - поиск */
.cc-obs { cursor: text; }
.dd-form .cc-sec input.cc-pick-q { flex: 1 1 60px; min-width: 60px; width: auto !important; height: 22px; margin: 0 !important; padding: 0 !important;
  border: 0 !important; border-radius: 0; background: transparent !important; box-shadow: none !important; outline: none; font-size: 14px; color: var(--text); }
.dd-form .cc-sec .cc-user-sel input.cc-pick-q { flex: 1 1 auto; }
.dd-form .cc-sec input.cc-pick-q::placeholder { color: var(--text); opacity: .85; }
.dd-form:not(.cc-layout-on) .cc-sec .cc-row > .cc-obs { position: static; }
.dd-form:not(.cc-layout-on) .cc-sec .cc-obs-empty { display: none; }
/* Имена занимают до двух рядов. Пустой поиск остаётся рядом с ними. */
.dd-form:not(.cc-layout-on) .cc-sec .cc-obs { flex-wrap: nowrap; }
.dd-form:not(.cc-layout-on) .cc-sec .cc-obs-list {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  min-width: 0; max-height: 60px; overflow: auto;
}
.dd-form:not(.cc-layout-on) .cc-sec .cc-obs-list:empty { display: none; }
.dd-form:not(.cc-layout-on) .cc-sec .cc-obs-chip { max-width: 100%; overflow-wrap: anywhere; }
.dd-form:not(.cc-layout-on) .cc-sec .cc-obs input.cc-pick-q { flex: 1 0 1ch; min-width: 1ch; }
.dd-form:not(.cc-layout-on) .cc-sec .cc-obs.is-open input.cc-pick-q { flex-basis: 7ch; }
.cc-pick-menu { position: absolute; left: -1px; right: -1px; top: calc(100% + 2px); z-index: 30; margin: 0; padding: 4px; min-width: 0; max-height: 300px; overflow-y: auto; list-style: none;
  background: var(--surface); border: 1px solid var(--br); border-radius: 10px; box-shadow: 0 10px 28px rgba(0,0,0,.14); }
.cc-pick-menu[hidden] { display: none; }
.cc-pick-menu li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: 14px; font-weight: 400; color: var(--text); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-pick-menu li[hidden] { display: none; }
.cc-pick-menu li:hover, .cc-pick-menu li.is-hl { background: var(--surface-2); }
.cc-pick-menu li.is-cur { font-weight: 600; }
/* Галка - одна на весь проект: рисунок, а не символ шрифта («✓» в шрифтах кривая, с наклоном и прыгает по высоте).
   <i class="ck"></i> - в тексте и кнопках (цвет и размер - от текста); у псевдоэлементов - тот же рисунок маской. */
:root { --ck: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8.4l3.1 3.1L13 4.6'/%3E%3C/svg%3E"); }
.ck, .cc-pick-menu li.is-cur::after, .dk-pop button.on::after, .mbx-status.ok::before {
  content: ''; display: inline-block; flex: none; width: 1.15em; height: 1.15em; vertical-align: -0.22em; background: currentColor;
  -webkit-mask: var(--ck) center / contain no-repeat; mask: var(--ck) center / contain no-repeat; }
.ci-tick .ck + .ck { margin-left: -0.62em; } /* две галки «прочитано» - внахлёст (только в отметке сообщения) */
.cc-pick-menu li.is-cur::after { margin-left: auto; color: var(--br); width: 16px; height: 16px; }
.mbx-status.ok::before { margin-right: 5px; }
/* в шапке чата у диалога мессенджера - только значок; чей это канал - во всплывашке и в меню «Куда писать» */
.chat-sub-t .chat-ico ~ .chat-sub-n, .chat-sub-t .chat-ico-t ~ .chat-sub-n { display: none; }
.cc-pick-menu li[data-v=""] { color: var(--muted); }
.cc-pick-menu .avatar { width: 26px; height: 26px; margin: 0; flex: none; font-size: 11px; }
.cc-pick-menu.is-none::before { content: 'Никого не нашлось'; display: block; padding: 6px 8px; color: var(--muted); font-size: 13px; }
.cc-catalog-sel .cc-pick-menu.is-none::before { content: 'Товары не найдены'; }
.cc-catalog-sel .cc-pick-menu li { white-space: normal; overflow-wrap: anywhere; }
.cc-catalog-thumb, .cc-catalog-scheme { object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.cc-catalog-thumb { display: block; width: 38px; height: 38px; flex: none; margin-right: 8px; cursor: zoom-in; }
.cc-catalog-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.cc-catalog-viewer { overflow: hidden; padding: 12px; border: 0; border-radius: 12px; background: #fff; }
.cc-catalog-viewer::backdrop { background: rgba(13, 22, 33, .7); }
.cc-catalog-viewer img { display: block; max-width: min(80vw, 1000px); max-height: 80vh; object-fit: contain; }
.cc-catalog-viewer button { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; padding: 0; border-radius: 50%; font-size: 23px; }
details.cc-acc > summary > .cc-catalog-thumb { float: left; }
details.cc-acc > summary:has(> .cc-catalog-thumb:not([hidden])) { display: flow-root; }
details.cc-acc[open] > summary > .cc-catalog-thumb { display: none; }
.cc-catalog-scheme { display: block; width: 72px; height: 72px; margin-bottom: 5px; }
.cc-catalog-thumb[hidden], .cc-catalog-scheme[hidden],
.cc-row:has(.cc-file:not(.is-rm), .cc-drop.has-new) .cc-catalog-scheme { display: none; }
.cc-catalog-picker[hidden], .cc-catalog-actions[hidden] { display: none !important; }
.cc-catalog-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 4px 0 8px; }
form.dd-form:not(.cc-layout-on) .cc-catalog-mode:not(.cc-catalog-show-fields) > .cc-acc-body > :not(.cc-catalog-picker, .cc-catalog-actions) { display: none; }
@media (max-width: 760px) { .dd-form .cc-sec input.cc-pick-q { font-size: 16px; } }
.rail-ava { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; display: block; }
.acc-chip .avatar { width: 18px; height: 18px; margin-right: 5px; }
.acc-who { display: flex; align-items: center; }
.acc-who .avatar { width: 30px; height: 30px; }
/* кнопки под карточкой - плотнее: «Конфигуратор» сразу за «отмена» */
.dd-actions { gap: 8px; }
.dd-actions .dd-actions-right { margin-left: 4px; }
.dd-actions > button, .dd-actions > a { flex: 0 0 auto; }
.dd-actions > button { padding-left: 14px; padding-right: 14px; }
.dd-actions > button.ghost { border-radius: var(--rad-pill); padding-top: 7px; padding-bottom: 7px; } /* «Конфигуратор» - той же формы и высоты, что «Сохранить» */
.dd-cfg-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.dd-actions > button.dd-cfg-btn { font-weight: 400; }
.dd-form:not(.cc-layout-on) [data-bedonly][data-off] { display: none !important; } /* «Размер матраса» - только у кровати */
.dd-form:not(.cc-layout-on) [data-grp][data-wait] { display: none !important; } /* товар: схема (2)/(3) и подушка (2)/(3) ждут, пока заполнят предыдущее */
.dd-cfg-ico { display: block; flex: none; } /* «Конфигуратор» - всегда кнопкой-значком, подпись - во всплывашке */
.dd-cfg-t { display: none; }
.dd-actions > button.dd-cfg-btn { padding-left: 13px; padding-right: 13px; }

/* ---------- «Фильтр + поиск» как в Bitrix ---------- */
.fl { position: relative; flex: 1 1 340px; max-width: 620px; margin: 0 0 0 10px; }
/* «Простая CRM»: кнопки стадий лидов рядом с поиском (поиск при них короче) */
.bx-top:has(.lst-chips) .fl { flex: 0 1 340px; max-width: 340px; }
.bx-create-pick { position: relative; flex: none; }
.bx-create-pick > .bx-create { cursor: pointer; font-family: inherit; }
.bx-create-menu { position: absolute; left: 14px; top: calc(100% + 8px); z-index: 60; min-width: max(170px, calc(100% - 14px)); padding: 6px; border-radius: 14px; background: var(--surface); box-shadow: 0 14px 36px rgba(0,0,0,.18); display: grid; gap: 2px; }
.bx-create-menu[hidden] { display: none; }
.bx-create-menu a { display: flex; align-items: center; gap: 10px; padding: 7px 12px 7px 7px; border-radius: 10px; color: var(--text); font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap; }
.bx-create-menu a i { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--br-dim, #e6f4ec); color: var(--br); flex: none; }
.bx-create-menu a:hover { background: var(--surface-2); }
.lst-chips { position: relative; flex: 1 1 0; min-width: 170px; }
.lst-list { display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; overflow: hidden; }
.lst-toggle { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; box-shadow: none; white-space: nowrap; }
.lst-toggle[hidden] { display: none; }
.lst-toggle:hover { background: var(--surface-2); color: var(--text); }
.lst-toggle b { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--br); color: #fff; font-size: 11.5px; line-height: 18px; text-align: center; }
.lst-toggle b:empty { display: none; }
.lst-toggle.on { border-color: var(--br); }
.lst-car { width: 0; height: 0; border: 4px solid transparent; border-top-color: currentColor; border-bottom: 0; opacity: .6; }
.lst-chips.is-drop .lst-list { display: none; position: absolute; left: 0; top: calc(100% + 6px); z-index: 60; flex-direction: column; align-items: stretch; gap: 2px; min-width: 230px; padding: 6px; border-radius: 12px; background: var(--surface); box-shadow: 0 12px 34px rgba(0,0,0,.18); overflow: visible; }
.lst-chips.is-drop.open .lst-list { display: flex; }
.lst-chips.is-drop .lst-chip { border: 0; border-radius: 8px; height: 36px; justify-content: flex-start; box-shadow: none; }
.lst-chips.is-drop .lst-chip b { margin-left: auto; padding-left: 14px; }
.lst-chips.is-drop .lst-chip.on { background: color-mix(in srgb, var(--c) 14%, var(--surface)); }
.lst-chips.is-drop .lst-chip::after { content: ''; width: 16px; height: 16px; margin-left: 8px; background: transparent; mask: var(--ck) center/contain no-repeat; -webkit-mask: var(--ck) center/contain no-repeat; }
.lst-chips.is-drop .lst-chip.on::after { background: currentColor; }
.lst-chip { flex: none; }
.lst-chip { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; box-shadow: none; white-space: nowrap; }
.lst-chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.lst-chip b { font-weight: 500; color: var(--muted); }
.lst-chip:hover { background: var(--surface-2); color: var(--text); }
.lst-chip.on { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); background: color-mix(in srgb, var(--c) 14%, var(--surface)); }
.kanban-card[hidden] { display: none !important; }
.fl-bar { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 3px 4px 3px 6px; cursor: text; min-height: 36px; }
.fl-mobile-presets { display: none; }
.fl-bar:focus-within { border-color: var(--br); }
.fl-chip { display: inline-flex; align-items: center; gap: 4px; background: #e6f0fb; color: #1c5fa8; border-radius: 6px; padding: 3px 4px 3px 9px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.fl-chip-x { color: #1c5fa8; text-decoration: none; padding: 0 4px; font-size: 15px; line-height: 1; border-radius: 4px; }
.fl-chip-x:hover { background: rgba(28,95,168,.12); text-decoration: none; }
.fl-q { flex: 1 1 auto; min-width: 60px; border: 0 !important; padding: 5px 4px !important; background: transparent; font-size: 13.5px; }
.fl-q:focus { outline: none; }
.board-search button { flex: none; display: grid; place-items: center; width: 26px; height: 32px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--muted); box-shadow: none; }
.board-search button svg { width: 22px; height: 22px; }
.board-search button:hover { color: var(--br); background: transparent; }
.board-search { display: flex; align-items: center; flex: 1 1 0; min-width: 0; }
.board-search .fl-q { min-width: 0; width: 0; }
.board-search .fl-q::-webkit-search-cancel-button { -webkit-appearance: none; }
.board-search .fl-q[value=""]:placeholder-shown ~ .board-search-clear { display: none; }
.board-search button:focus-visible { outline: 2px solid var(--br); outline-offset: -2px; }
.bx-search:has(.board-search) { min-width: 0; }
.bx-search:has(.board-search) select { max-width: 48%; }
.bx-search .board-search { border: 1px solid var(--line); border-radius: 8px; padding: 0 3px 0 8px; background: var(--surface); }
.bx-search .board-search:focus-within { border-color: var(--br); }
.fl-pop { position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; width: min(760px, 94vw); display: flex; align-items: stretch;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 36px rgba(0,0,0,.16);
  max-height: calc(100vh - var(--fl-top, 70px) - 16px); overflow: hidden; }
.fl-pop[hidden] { display: none; }
.fl-presets { flex: 0 0 200px; background: var(--surface-2); padding: 8px 0; display: flex; flex-direction: column; overflow-y: auto; min-height: 0; }
.fl-pr { display: flex; align-items: center; }
.fl-pr a { flex: 1 1 auto; padding: 8px 16px; color: var(--text); text-decoration: none; font-size: 13.5px; }
.fl-pr a:hover { background: rgba(0,0,0,.04); text-decoration: none; }
.fl-pr.on a { background: var(--br-dim); color: var(--br-dark, var(--br)); font-weight: 600; }
.fl-pr-del { background: none; border: 0; color: var(--muted); padding: 0 10px; font-size: 16px; visibility: hidden; box-shadow: none; }
.fl-pr:hover .fl-pr-del { visibility: visible; }
.fl-save { margin: auto 12px 0; padding: 8px 4px; background: none; border: 0; color: var(--muted); text-align: left; font-size: 13px; box-shadow: none; }
.fl-save:hover { color: var(--br); background: none; }
.fl-fields { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.fl-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 18px 8px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; }
.fl-row { display: flex; flex-direction: column; gap: 3px; margin: 0; }
.fl-row[hidden] { display: none; }
.fl-row > span { display: flex; align-items: center; font-size: 12px; color: var(--muted); }
.fl-row-x { margin-left: auto; background: none; border: 0; padding: 0 4px; color: var(--muted); font-size: 15px; line-height: 1; visibility: hidden; box-shadow: none; }
.fl-row:hover .fl-row-x { visibility: visible; }
.fl-row-x:hover { color: #c0392b; background: none; }
.fl-row select, .fl-row input { width: 100%; height: 34px; padding: 5px 10px; font-size: 13.5px; }
.fl-num, .fl-date { display: flex; gap: 6px; }
.fl-num select { flex: 0 0 130px; width: 130px; }
.fl-num input { flex: 1 1 0; min-width: 0; }
.fl-date select { flex: 1 1 auto; }
.fl-range { display: flex; gap: 6px; flex: 1 1 auto; }
.fl-range[hidden] { display: none; }
.fl-links { flex: 0 0 auto; display: flex; gap: 16px; font-size: 13px; padding: 8px 18px 0; border-top: 1px solid var(--line-soft); }
.fl-links .link { padding: 0; font-size: 13px; }
.fl-def { color: var(--muted) !important; }
.fl-actions { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 10px 18px 12px; background: var(--surface); }
.fl-find { padding: 8px 22px; }
.fl-reset { color: var(--text); font-size: 13.5px; }
/* окно «Добавить поле» - поверх полей */
.fl-pick { position: absolute; inset: 8px; z-index: 2; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.18); }
.fl-pick[hidden] { display: none; }
.fl-pick-head { display: flex; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line-soft); }
.fl-pick-q { flex: 1 1 auto; height: 34px; padding: 5px 10px; }
.fl-pick-ok { padding: 6px 16px; }
.fl-pick-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px 12px 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px 14px; align-content: start; scrollbar-width: thin; }
.fl-pick-group { grid-column: 1 / -1; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 0 4px; }
.fl-pick-list label { display: flex; align-items: flex-start; gap: 7px; margin: 0; padding: 4px 2px; font-size: 13px; cursor: pointer; border-radius: 4px; }
.fl-pick-list label:hover { background: var(--surface-2); }
.fl-pick-list label[hidden] { display: none; }
.fl-pick-list input { width: auto; margin-top: 2px; }

/* ---------- «Чаты»: все переписки с клиентами (как imBox) ---------- */
.crm-main.chats-main { height: 100vh; overflow: hidden; }
.chats { display: flex; height: 100vh; min-height: 0; }
.chats-list { flex: 0 0 420px; max-width: 46%; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--surface); min-width: 280px; }
.chats-search { display: flex; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); margin: 0; }
.chats-search input { flex: 1 1 auto; min-width: 0; height: 36px; }
.chats-search button { flex: 0 0 auto; background: transparent; color: var(--muted); border: 1px solid var(--line); padding: 0 10px; box-shadow: none; display: flex; align-items: center; }
.chats-search button svg { width: 17px; height: 17px; }
.chats-search button:hover { color: var(--br); background: transparent; }
.chats-tabs { display: flex; align-items: center; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.chats-tabs a { padding: 4px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); text-decoration: none; }
.chats-tabs a:hover { color: var(--text); text-decoration: none; }
.chats-tabs a.on { background: var(--br-dim); color: var(--br); }
.chats-total { margin-left: auto; font-size: 12px; color: var(--muted); }
.chats-items { flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.chats-item { display: block; padding: 10px 14px 11px; border-bottom: 1px solid var(--line-soft); color: var(--text); text-decoration: none; }
.chats-item:hover { background: var(--surface-2); text-decoration: none; }
.chats-item.on { background: var(--surface-2); }
.ci-top { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.ci-tag { background: #2fa36b; color: #fff; border-radius: 3px; padding: 0 5px; font-weight: 700; font-size: 11px; }
.ci-tag.ci-lead { background: #5b8def; }
.ci-wait { color: #8a5a00; background: #ffe88a; border-radius: 3px; padding: 0 5px; font-weight: 600; }
.ci-time { margin-left: auto; white-space: nowrap; }
.ci-title { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13.5px; margin: 3px 0 2px; overflow-wrap: anywhere; }
.ci-badge { background: #e14b4b; color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; line-height: 17px; }
.is-unread .ci-title { color: var(--br); }
.ci-text { font-size: 12.5px; color: #5b625b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-text b { font-weight: 600; color: var(--text); }
.ci-text mark { background: #ffe88a; color: inherit; border-radius: 2px; }
.chats-more { display: block; text-align: center; padding: 12px; font-size: 13px; }
.chats-empty { padding: 24px; color: var(--muted); text-align: center; font-size: 13.5px; }
.chats-pane { flex: 1 1 auto; min-width: 0; display: flex; background: #f4f6f4; }
.chats-pane iframe { border: 0; width: 100%; height: 100%; display: block; }
.chats-pick { margin: auto; }
body.chats-frame { margin: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); overflow: hidden; }
.chats-fhead { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.chats-ftitle { font-weight: 700; font-size: 15px; color: var(--text); text-decoration: none; }
.chats-ftitle:hover { color: var(--br); }
.chats-fmeta { font-size: 12px; color: var(--muted); }
.chats-fresp { display: inline-flex; align-items: center; font-size: 12.5px; }
.chats-fresp .avatar { width: 22px; height: 22px; margin-right: 5px; }
.chats-fopen { margin-left: auto; font-size: 12.5px; white-space: nowrap; }
.dd-main.chats-fchat { flex: 1 1 auto; min-height: 0; height: auto; border: 0; border-radius: 0; box-shadow: none; }
@media (max-width: 860px) {
  .chats { flex-direction: column; height: auto; }
  .crm-main.chats-main { height: auto; overflow: visible; }
  .chats-list { flex: 0 0 auto; max-width: none; height: 45vh; }
  .chats-pane { height: 70vh; }
}

/* фильтр ленты: 6 вкладок - компактно, на узком окне прокручиваются вбок */
.chat-head { flex-wrap: wrap; }
.chat-filter { overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.chat-filter button { padding: 4px 8px; white-space: nowrap; }

/* ---------- Мессенджер сотрудников ---------- */
.crm-main.im-main { height: 100vh; overflow: hidden; }
.im { display: flex; height: 100vh; min-height: 0; }
.im-side { flex: 0 0 320px; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--surface); min-width: 0; }
.im-side-head { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line-soft); }
.im-search { flex: 1 1 auto; min-width: 0; height: 36px; }
.im-new { flex: 0 0 auto; padding: 0 12px; font-size: 13px; }
.im-lists { flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.im-people-title { padding: 12px 14px 4px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.im-item, .im-person { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 0; background: transparent; color: var(--text);
  text-align: left; text-decoration: none; box-shadow: none; font: inherit; cursor: pointer; }
.im-item:hover, .im-person:hover { background: var(--surface-2); text-decoration: none; }
.im-item.on { background: var(--surface-2); }
.im-item .avatar, .im-person .avatar, .im-gico { width: 38px; height: 38px; margin: 0; flex: 0 0 auto; border-radius: 50%; }
.im-gico { display: inline-flex; align-items: center; justify-content: center; color: #5b8def; }
.im-gico svg { width: 26px; height: 26px; }
.im-item-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.im-item-top { display: flex; align-items: baseline; gap: 6px; }
.im-item-top b, .im-person b { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.im-item-time { margin-left: auto; font-size: 11px; color: var(--muted); flex: 0 0 auto; }
.im-item-text { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.im-item-text i { font-style: normal; color: var(--text); }
.im-item.is-unread b { color: var(--br); }
.im-badge { flex: 0 0 auto; background: #e14b4b; color: #fff; border-radius: 9px; font-size: 11px; font-weight: 700; padding: 0 6px; line-height: 18px; }
.im-person b { display: block; }
.im-none { padding: 18px 14px; color: var(--muted); font-size: 13px; text-align: center; }
.im-pane { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; background: #f4f6f4; }
.im-placeholder { margin: auto; color: var(--muted); font-size: 14px; }
.im-head { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.im-head[hidden], .im-feed[hidden], .im-cmp[hidden], .im-placeholder[hidden] { display: none; }
.im-head-ava .avatar, .im-head-ava .im-gico { width: 36px; height: 36px; margin: 0; }
.im-head-main { flex: 1 1 auto; min-width: 0; }
.im-title { font-weight: 700; font-size: 15px; }
.im-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.im-feed { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 18px; display: flex; flex-direction: column; gap: 6px; }
.im-day { text-align: center; margin: 8px 0 4px; }
.im-day span { background: #e3e8e3; color: var(--muted); font-size: 11.5px; padding: 2px 10px; border-radius: 10px; }
.im-sys { align-self: center; font-size: 12px; color: var(--muted); padding: 2px 8px; }
.im-msg { display: flex; align-items: flex-end; gap: 8px; max-width: 78%; }
.im-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.im-mava { width: 28px !important; height: 28px !important; margin: 0 !important; flex: 0 0 auto; font-size: 12px !important; }
.im-bubble { background: var(--surface); border-radius: 14px; border-bottom-left-radius: 4px; padding: 6px 11px 4px; box-shadow: 0 1px 1px rgba(0,0,0,.05); font-size: 14px; line-height: 1.45; min-width: 60px; overflow-wrap: anywhere; }
.im-msg.mine .im-bubble { background: #d9f2e2; border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }
.im-author { font-size: 12px; font-weight: 700; color: #2067b0; margin-bottom: 1px; }
.im-bubble a { color: var(--br); }
.im-time { font-size: 10.5px; color: var(--muted); text-align: right; margin-top: 1px; }
.im-img { display: block; margin: 4px 0 2px; }
.im-img img { display: block; max-width: 260px; max-height: 260px; border-radius: 8px; }
.im-file { display: block; margin: 4px 0 2px; padding: 5px 9px; background: rgba(0,0,0,.05); border-radius: 6px; font-size: 13px; text-decoration: none; }
.im-cmp { flex: 0 0 auto; background: var(--surface); border-top: 1px solid var(--line); padding: 8px 12px; margin: 0; }
.im-row { display: flex; align-items: flex-end; gap: 6px; }
.im-row textarea { flex: 1 1 auto; min-height: 38px; max-height: 160px; resize: none; padding: 8px 10px; font-size: 14px; line-height: 1.4; }
.im-attach, .im-emoji { flex: 0 0 auto; width: 36px; height: 38px; display: flex; align-items: center; justify-content: center; color: var(--muted); cursor: pointer; background: transparent; border: 0; padding: 0; box-shadow: none; font-size: 19px; }
.im-attach svg { width: 20px; height: 20px; }
.im-attach:hover, .im-emoji:hover { color: var(--br); background: transparent; }
.im-send { flex: 0 0 auto; width: 40px; height: 38px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.im-send svg { width: 18px; height: 18px; }
.im-files { display: flex; flex-wrap: wrap; gap: 6px; }
.im-files:not(:empty) { margin-bottom: 6px; }
.im-fchip { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 6px; padding: 3px 4px 3px 8px; font-size: 12.5px; }
.im-fchip button { background: none; border: 0; padding: 0 4px; color: var(--muted); box-shadow: none; }
.im-dlg { position: fixed; inset: 0; z-index: 200; background: rgba(20,30,25,.35); display: flex; align-items: center; justify-content: center; }
.im-dlg[hidden] { display: none; }
.im-dlg-box { width: min(440px, 94vw); max-height: 86vh; display: flex; flex-direction: column; gap: 10px; background: var(--surface); border-radius: 12px; padding: 18px; box-shadow: 0 16px 48px rgba(0,0,0,.25); margin: 0; }
.im-dlg-box h3 { margin: 0; font-size: 16px; }
.im-dlg-people, .im-mem-list { overflow-y: auto; max-height: 46vh; display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--line-soft); border-radius: 8px; padding: 4px; }
.im-dlg-people label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; margin: 0; font-size: 13.5px; cursor: pointer; }
.im-dlg-people label:hover { background: var(--surface-2); }
.im-dlg-people input { width: auto; }
.im-dlg-people .avatar, .im-mem .avatar, .im-mem .im-gico { width: 26px; height: 26px; margin: 0; font-size: 12px; }
.im-mem { display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-size: 13.5px; }
.im-mem i { font-style: normal; color: var(--muted); font-size: 12px; }
.im-mem .im-rm { margin-left: auto; font-size: 12.5px; color: #c0392b; padding: 0; }
.im-rename { display: flex; gap: 6px; }
.im-rename input { flex: 1 1 auto; min-width: 0; }
.im-dlg-actions { display: flex; gap: 8px; justify-content: flex-end; }
.im-dlg-actions .danger { color: #c0392b; border-color: #e3b6b1; margin-right: auto; }
.im-head .im-back { display: none; flex: 0 0 auto; width: 34px; height: 34px; padding: 0; align-items: center; justify-content: center; background: transparent; border: 0; box-shadow: none; color: var(--text); font-size: 20px; }
@media (max-width: 860px) {
  .crm-main.im-main { height: 100dvh; }
  .im { flex-direction: column; height: 100%; }
  .im-side { flex: 1 1 auto; min-height: 0; border-right: 0; }
  .im-pane { display: none; min-height: 0; }
  .im.m-room .im-side { display: none; }
  .im.m-room .im-pane, .im-head .im-back { display: flex; }
}

/* смайлики */
.emj-panel { position: fixed; z-index: 300; width: 316px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 6px; }
.emj-panel[hidden] { display: none; }
.emj-tabs { display: flex; gap: 2px; margin-bottom: 4px; }
.emj-tabs button { background: transparent; border: 0; color: var(--muted); font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 6px; box-shadow: none; }
.emj-tabs button.on { background: var(--surface-2); color: var(--text); }
.emj-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 200px; overflow-y: auto; }
.emj-grid button { background: transparent; border: 0; font-size: 21px; line-height: 1; padding: 5px 0; border-radius: 6px; box-shadow: none; cursor: pointer; }
.emj-grid button:hover { background: var(--surface-2); }

/* вложения в чате - квадратики предпросмотра */
.cm-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.cm-tile { position: relative; width: 104px; height: 104px; border-radius: 8px; overflow: hidden; background: #fff; border: 1px solid var(--line-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 8px; text-decoration: none; color: var(--text); flex: 0 0 auto; }
.cm-tile:hover { border-color: var(--br); text-decoration: none; }
.cm-tile.is-img { padding: 0; }
.cm-tile.is-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm-tile.is-img .cm-tile-ico, .cm-tile.is-img .cm-tile-name { display: none; }
.cm-tile.is-img.is-noimg { padding: 8px; }
.cm-tile.is-img.is-noimg .cm-tile-ico, .cm-tile.is-img.is-noimg .cm-tile-name { display: block; }
.cm-tile-ico { display: block; min-width: 44px; padding: 9px 6px; border-radius: 6px; text-align: center; font-size: 11px; font-weight: 800; letter-spacing: .03em; color: #fff; background: #8a948a; }
.cm-k-pdf { background: #e5533d; } .cm-k-doc { background: #2f6fd6; } .cm-k-xls { background: #1e8a4c; }
.cm-k-zip { background: #8b6d3a; } .cm-k-vid { background: #7b4fc9; } .cm-k-aud { background: #d0812a; }
.cm-tile-name { width: 100%; font-size: 11px; line-height: 1.25; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.cm-out .cm-tile, .cm-ol.cm-out .cm-tile { background: rgba(255,255,255,.7); }
.chats-noreply { padding: 4px 10px; font-size: 12.5px; }

/* поле ввода: скрыть от клиента, смайлики */
.cmp-hide, .cmp-emoji { flex: 0 0 auto; width: 28px; height: 34px; margin: 0 -2px; display: flex; align-items: center; justify-content: center; padding: 0; background: transparent; border: 0; color: var(--muted); box-shadow: none; cursor: pointer; font-size: 18px; border-radius: 6px; }
.cmp-hide svg { width: 19px; height: 19px; }
.cmp-hide:hover, .cmp-emoji:hover { color: var(--br); background: transparent; }
.cmp-hide.on { color: #fff; background: #8a6d3a; }
.cmp.is-hidden-msg textarea { background: #fff8e6; border-color: #e6c77a; }
.cm-internal .cm-bubble { background: #fff3d6 !important; border: 1px dashed #d9b25c; }
.cm-int-tag { font-size: 11px; font-weight: 700; color: #8a6d3a; margin-bottom: 2px; }
img.avatar[hidden] { display: none !important; }

/* новый лид или сделка (и пришедшая заявка) - зелёная плитка наверху; ждёт ответа клиента - красная важнее */
.kanban-card.bx-card.is-fresh, .deal-tile.is-fresh { background: #eefaf3; border-color: #4fb67f; box-shadow: 0 0 0 1px #4fb67f, var(--shadow); }
.kanban-card.is-fresh .kc-title, .deal-tile.is-fresh .dt-title { color: #0b6a3b; }
.deal-list .deal-tile.is-fresh { order: -2; }
/* клиент написал и ждёт ответа - красная плитка, пока не ответят */
.kanban-card.is-wait, .kanban-card.bx-card.is-wait, .deal-tile.is-wait { background: #fff0ef; border-color: #e14b4b; box-shadow: 0 0 0 1px #e14b4b, var(--shadow); }
.kanban-card.is-wait .kc-title, .deal-tile.is-wait .dt-title { color: #b3261e; }
tr.is-wait td { background: #fff0ef; }
tr.is-wait td a { color: #b3261e; }

/* ---------- Производство и логистика: карточка записи ---------- */
.sp-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sp-head h2 { margin: 0; font-size: 18px; }
.sp-back { margin-left: auto; font-size: 13px; white-space: nowrap; }
.sp-detail { max-width: 720px; }
.sp-sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad-lg); box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 10px; }
.sp-rows { display: flex; flex-direction: column; gap: 9px; }
.sp-row { display: flex; flex-direction: column; gap: 1px; }
.sp-l { font-size: 11.5px; color: var(--muted); }
.sp-v { font-size: 14px; overflow-wrap: anywhere; }
.sp-v a { color: var(--br); }
.sp-over { color: #c0392b; font-weight: 600; }
.sp-detail .cc-sec-title, .sp-sec .cc-sec-title { margin-bottom: 8px; }

/* выбор канала по клику на имя клиента */
.chat-who-pick { position: relative; }
.chat-who-btn { display: inline-flex; align-items: center; gap: 5px; background: transparent; border: 0; padding: 2px 4px; margin: -2px -4px 0; border-radius: 6px; box-shadow: none; font: inherit; color: inherit; cursor: pointer; }
.chat-who-btn:hover { background: var(--surface-2); }
.chat-who-car { font-size: 10px; color: var(--muted); }
.chat-ch-menu { position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; margin: 0; padding: 4px; list-style: none; min-width: 220px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.14); }
.chat-ch-menu li { padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.chat-ch-menu li:hover { background: var(--surface-2); }
.chat-ch-menu li.on { background: var(--br-dim); color: var(--br); font-weight: 600; }
.chat-ch-menu .chat-ch-title { cursor: default; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.chat-ch-menu .chat-ch-title:hover { background: transparent; }

/* подсказка @упоминаний */
.mnt-box { position: fixed; z-index: 320; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 28px rgba(0,0,0,.16); padding: 4px; max-height: 220px; overflow-y: auto; }
.mnt-box[hidden] { display: none; }
.mnt-box button { background: transparent; border: 0; box-shadow: none; text-align: left; padding: 7px 10px; border-radius: 6px; font-size: 13.5px; color: var(--text); cursor: pointer; }
.mnt-box button:hover, .mnt-box button.on { background: var(--surface-2); }
.cmp-mail { display: none; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 6px; font-size: 12.5px; color: var(--muted); }
.cmp[data-mode="mail"] .cmp-mail { display: flex; }
.cmp-mail label { display: flex; align-items: center; gap: 6px; flex: 1 1 180px; }
.cmp-mail input, .cmp-mail select { padding: 2px 6px; font-size: 13px; min-height: 0; width: auto; flex: 1 1 auto; min-width: 0; }
.cmp-mail-no a { color: var(--br); }

/* «Почта»: ящики сотрудников */
.mbx .f > span:first-child { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.mbx-users { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2px 14px; margin-top: 4px; }
.mbx-users label { display: flex; align-items: center; gap: 7px; margin: 0; padding: 3px 2px; font-size: 13.5px; white-space: nowrap; overflow: hidden; border-radius: 6px; cursor: pointer; }
.mbx-users label:hover { background: var(--surface-2); }
.mbx-users input { width: auto; flex: 0 0 auto; margin: 0; }
.mbx-users .avatar { width: 22px; height: 22px; margin: 0; flex: 0 0 auto; }
.mbx-add { display: block; width: 100%; padding: 12px; background: transparent; border: 1px dashed var(--line); border-radius: var(--rad-lg); color: var(--muted); font-size: 13.5px; box-shadow: none; }
.mbx-add:hover { color: var(--br); border-color: var(--br); background: var(--br-dim); }
.mbx-status.ok { color: #1f7a4d; }
.mbx-status.err { color: #c0392b; }
.cc-newf-btn { border: 1px dashed var(--line); background: transparent; color: var(--br); border-radius: 12px; padding: 1px 8px; font-size: 12px; box-shadow: none; }
.cc-newf-btn:hover { border-color: var(--br); background: var(--br-dim); }
#ccNewField .f { margin: 0; }
#ccNewField .f > span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
#ccNewField input[type=text], #ccNewField select, #ccNewField textarea { width: 100%; }
.cc-newf-multi { display: flex; align-items: center; gap: 7px; font-size: 13px; }
#ccNewField label.cc-newf-multi { display: flex; align-items: center; gap: 7px; }
#ccNewField label.cc-newf-multi input { width: auto; flex: none; margin: 0; }
#ccNewField [hidden] { display: none !important; } /* label.f { display: block } перебивал hidden - были видны лишние поля */
#ccNewField .f > span.cc-newf-multi-t, label.f > span.cc-newf-multi-t { display: inline; margin: 0; font-size: 13px; font-weight: 400; color: var(--text); }
.cc-items { display: flex; flex-direction: column; gap: 6px; }
.cc-items-list { display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow-y: auto; padding: 1px; }
.cc-item { display: flex; align-items: center; gap: 4px; }
.cc-item input { flex: 1 1 auto; min-width: 0; width: auto !important; height: 34px; }
.cc-item input.is-dup { border-color: #e0a23a; background: #fffaf0; }
.cc-item-x { flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: transparent; box-shadow: none; color: var(--muted); font-size: 17px; line-height: 1; cursor: pointer; }
.cc-item-x:hover { background: #fdecea; color: #c0392b; }
.cc-item-x:disabled { opacity: .3; cursor: help; background: transparent; color: var(--muted); } /* вариант выбран в записях - не убрать */
.cc-items-add { align-self: flex-start; padding: 2px 0; border: 0; background: transparent; box-shadow: none; color: var(--br); font-size: 13px; font-weight: 600; cursor: pointer; }
.cc-items-add:hover { background: transparent; text-decoration: underline; }
.cc-items-err { color: #c0392b; font-size: 12.5px; }
.cc-items-err[hidden] { display: none; }
.cc-newf-multi input { width: auto; }

/* стрелки горизонтальной прокрутки канбана */
.kb-nav { position: fixed; z-index: 70; width: 62px; height: 62px; margin-top: -31px; border-radius: 50%; border: 0;
  background: rgba(250, 251, 250, .92); color: #9aa49a; box-shadow: 0 4px 18px rgba(20,30,25,.18); display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .18s; cursor: pointer; }
.kb-nav svg { width: 30px; height: 30px; }
.kb-nav.show { opacity: 1; }
.kb-nav:hover { color: var(--br); background: #fff; }

/* звонки в ленте чата */
.cm-call { align-self: stretch; display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--line-soft); border-radius: 10px; padding: 7px 10px; }
.cm-call-body { flex: 1 1 auto; min-width: 0; }
.cm-call-body b { color: var(--text); font-weight: 600; }
.cm-call.is-missed .cm-call-body b { color: #c0392b; }
.cm-call-rec { display: block; margin-top: 5px; }
.cm-call-rec audio { width: 100%; max-width: 360px; height: 32px; }

/* ---------- Мессенджер: ответы, реакции, правка, поиск ---------- */
.im-msg { position: relative; }
.im-quote { border-left: 3px solid var(--br); background: rgba(0,0,0,.04); border-radius: 5px; padding: 3px 7px; margin-bottom: 4px; font-size: 12.5px; cursor: pointer; }
.im-quote b { display: block; font-weight: 600; color: var(--br); font-size: 11.5px; }
.im-quote:hover { background: rgba(0,0,0,.07); }
.im-deleted { color: var(--muted); font-style: italic; font-size: 13px; }
.im-react { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.im-r { background: var(--surface-2); border: 1px solid transparent; border-radius: 12px; padding: 1px 7px; font-size: 12px; line-height: 1.5; box-shadow: none; cursor: pointer; }
.im-r:hover { border-color: var(--line); }
.im-r.on { background: var(--br-dim); border-color: var(--br); color: var(--br); font-weight: 600; }
.im-acts { position: absolute; top: -12px; right: 6px; display: none; gap: 1px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.12); padding: 1px; }
.im-msg.mine .im-acts { right: auto; left: 6px; }
.im-msg:hover .im-acts { display: flex; }
.im-acts button { width: 26px; height: 24px; padding: 0; background: transparent; border: 0; box-shadow: none; font-size: 13px; line-height: 1; color: var(--muted); cursor: pointer; border-radius: 6px; }
.im-acts button:hover { background: var(--surface-2); color: var(--text); }
.im-rpick { position: fixed; z-index: 320; display: flex; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.16); padding: 4px; }
.im-rpick button { background: transparent; border: 0; box-shadow: none; font-size: 20px; line-height: 1; padding: 4px 5px; border-radius: 7px; cursor: pointer; }
.im-rpick button:hover { background: var(--surface-2); }
.im-flash .im-bubble { animation: imflash 1.2s ease-out; }
@keyframes imflash { 0% { box-shadow: 0 0 0 3px var(--br); } 100% { box-shadow: 0 1px 1px rgba(0,0,0,.05); } }
.im-reply { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-left: 3px solid var(--br); border-radius: 6px; padding: 4px 8px; margin-bottom: 6px; font-size: 12.5px; color: var(--muted); }
.im-reply[hidden] { display: none; }
.im-reply-txt { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.im-reply-x, .im-find-x { background: none; border: 0; box-shadow: none; color: var(--muted); font-size: 16px; padding: 0 4px; cursor: pointer; }
.im-find { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.im-find[hidden] { display: none; }
.im-find-q { flex: 1 1 auto; height: 32px; }
.im-find-btn { background: transparent; border: 0; box-shadow: none; font-size: 15px; padding: 4px 6px; cursor: pointer; border-radius: 6px; }
.im-find-btn:hover { background: var(--surface-2); }
.im-hide { display: none !important; }
.im-hit .im-bubble { outline: 2px solid #ffd54a; }
.avatar-ini { color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; letter-spacing: .02em; }
.im-item .avatar-ini, .im-person .avatar-ini { font-size: 14px; }
.im-mava.avatar-ini { font-size: 11px; }

/* Личный кабинет */
.pf-head { display: flex; align-items: center; gap: 16px; }
.pf-ava { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; font-size: 26px !important; }
.pf-sw { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin: 8px 0 12px; }
.pf-sw input { width: auto; }

/* ---------- Массовые действия (галочки на плитках + панель) ---------- */
/* Галочка встаёт ровно на место счётчика дел и закрывает его собой (как в Bitrix).
   Появляется не по наведению, а когда плитку выбрали - или когда уже что-то выбрано. */
.bx-pick { position: absolute; top: 10px; right: 12px; z-index: 3; display: none;
  width: 18px; height: 18px; align-items: center; justify-content: center; background: var(--surface); border-radius: 50%; }
.bulk-on .bx-pick, .kanban-card.is-picked .bx-pick { display: flex; }
.bx-pick input { width: 16px; height: 16px; margin: 0; cursor: pointer; }
.kanban-card.bx-card:not(.kc-ghost) { position: relative; }  /* не трогаем копию, которая едет за курсором: ей нужен position: fixed */
.kanban-card.is-picked { outline: 2px solid var(--br); outline-offset: -1px; }
.bulk { position: sticky; top: 0; z-index: 65; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 var(--sp-4) 8px var(--sp-2); padding: 8px 12px; background: var(--surface); border: 1px solid var(--br);
  border-radius: 10px; box-shadow: 0 4px 16px rgba(20,30,25,.10); font-size: 13px; }
.bulk[hidden] { display: none; }
.crm-topbar:has(> .bulk-over) { position: relative; }
.bx-card .bx-main { cursor: pointer; } /* нажатие на плитку открывает сделку, выбор - правой кнопкой */
.bulk.bulk-over { position: absolute; inset: 6px 8px auto 8px; min-height: calc(100% - 12px); margin: 0; }
.bulk-n b { font-size: 14px; }
.bulk-x { background: none; border: 0; box-shadow: none; color: var(--muted); font-size: 17px; padding: 0 4px; cursor: pointer; }
.bulk-sep { width: 1px; height: 20px; background: var(--line); }
.bulk-act { position: relative; }
.bulk-act > button, .bulk-del { background: transparent; border: 0; box-shadow: none; color: var(--text); font-size: 13px; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.bulk-act > button:hover, .bulk-del:hover { background: var(--surface-2); color: var(--br); }
.bulk-del { color: #c0392b; margin-left: auto; }
.bulk-del:hover { background: #fdecea; color: #c0392b; }
.bulk-pop { position: absolute; z-index: 70; top: calc(100% + 6px); left: 0; display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 28px rgba(0,0,0,.16); padding: 8px; min-width: 260px; }
.bulk-pop[hidden] { display: none; }
.bulk-pop select, .bulk-pop input { height: 32px; font-size: 13px; flex: 1 1 140px; min-width: 0; }
.bulk-go { flex: 0 0 auto; padding: 6px 14px; font-size: 13px; }
.bulk-msg { color: var(--muted); font-size: 12.5px; }

/* ---------- Роботы (crm-robots.php): доска по стадиям и конструктор робота ---------- */
.rb-intro { margin: 0 0 10px; max-width: 760px; }
.rb-form [hidden] { display: none !important; }   /* .f задано display:flex - иначе скрытые поля триггера видны */
.rb-board { align-items: flex-start; margin-bottom: 14px; }
.rb-board .kanban-col { min-height: 0; }
.rb-board .kanban-cards { padding: 6px 6px 8px; min-height: 40px; overflow: visible; flex: 0 0 auto; }
.rb-card { background: var(--surface); border: 1px solid var(--line-soft); border-left: 3px solid var(--stage-color, var(--br));
  border-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,.06); padding: 8px 10px; margin-bottom: 8px; font-size: 12.5px; }
.rb-card.is-off { opacity: .55; border-left-style: dashed; }
.rb-name { display: inline-block; font-weight: 600; font-size: 13px; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.rb-name:hover { color: var(--br); }
.rb-delay { margin-left: 6px; font-size: 11px; color: #b46a00; background: #fff1d6; border-radius: 3px; padding: 1px 6px; white-space: nowrap; }
.rb-sum { color: var(--muted); font-size: 11.5px; margin-top: 3px; line-height: 1.35; overflow-wrap: anywhere; }
.rb-ops { display: flex; gap: 10px; margin-top: 6px; }
.rb-ops form { margin: 0; }
.rb-ops .link { font-size: 11.5px; }
.rb-add { display: block; padding: 6px; text-align: center; color: var(--muted); font-size: 12.5px; font-weight: 600; text-decoration: none;
  border: 1px dashed var(--line); border-radius: 6px; background: transparent; }
.rb-add:hover { color: var(--br); border-color: var(--br); background: var(--br-dim); text-decoration: none; }
.rb-wide { border-left-color: var(--line); margin-bottom: 6px; }
.rb-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; align-items: start; }
.rb-log { font-size: 12.5px; padding: 4px 0; border-bottom: 1px solid var(--line-soft); display: flex; gap: 8px; flex-wrap: wrap; }
.rb-log:last-child { border-bottom: 0; }
.rb-cond { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.rb-cond select, .rb-cond input { height: 34px; font-size: 13px; flex: 1 1 120px; min-width: 0; }
.rb-act { border: 1px solid var(--line-soft); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; background: var(--surface-2); }
.rb-arow { display: flex; gap: 8px; align-items: center; }
.rb-arow .rb-atype { height: 34px; font-size: 13px; flex: 0 1 260px; }
.rb-hint { color: var(--muted); font-size: 11.5px; flex: 1 1 auto; min-width: 0; }
audio { color-scheme: light; } /* голосовые в карточке - светлым плеером, как вся CRM (иначе браузер берёт тёмный из системы) */
@media (max-width: 760px) { .rb-arow { flex-wrap: wrap; } .rb-arow .rb-hint { order: 3; flex: 1 1 100%; } } /* телефон: подсказка строкой ниже, «×» на виду */
.rb-afields { margin-top: 6px; }
.rb-afields .f { margin-bottom: 6px; }
.rb-del { flex: 0 0 auto; width: 26px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface); color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer; box-shadow: none; }
.rb-del:hover { color: #c0392b; border-color: #c0392b; background: #fdecea; }
.rb-rm { margin-left: auto; color: #c0392b; border-color: #e3b6b1; }

/* ---------- Зарплата менеджеров (crm-payroll.php) ---------- */
.pr-sum { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.pr-kpi { flex: 1 1 180px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: 10px;
  padding: 14px 16px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.pr-kpi span { display: block; font-size: 23px; font-weight: 700; letter-spacing: -.02em; }
.pr-kpi small { color: var(--muted); font-size: 12px; }
.pr-kpi:first-child span { color: #1f8a56; }
.pr-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.pr-table th, .pr-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); }
.pr-table thead th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.pr-table .n { text-align: right; white-space: nowrap; }
.pr-table tbody tr:hover { background: var(--surface-2); }
.pr-table .avatar, .pr-rate .avatar { width: 24px; height: 24px; border-radius: 50%; vertical-align: middle; margin-right: 8px; }
.pr-table tfoot th { font-size: 13.5px; background: var(--surface-2); border-bottom: 0; }
.pr-row.is-open { background: var(--br-dim); }
.pr-deals > td { padding: 0 14px 14px 46px; background: var(--surface-2); }
.pr-sub { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.pr-sub th, .pr-sub td { padding: 6px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; }
.pr-sub .n { text-align: right; white-space: nowrap; }
.pr-sub thead th { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.pr-approx td { color: var(--muted); }
.pr-flag { color: #b46a00; cursor: help; }
.pr-note { max-width: 760px; margin: 10px 0 0; font-size: 12.5px; }
.pr-conf { margin-top: 16px; max-width: 820px; }
.pr-rates { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.pr-rate { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line-soft); border-radius: 8px; padding: 5px 8px; background: var(--surface); }
.pr-rate span { flex: 1 1 auto; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-rate input { flex: 0 0 64px; height: 30px; text-align: right; font-size: 13px; }

/* ===== Телефон (до 760px): панель разделов внизу (crm-rail.php), страницы во всю ширину ===== */
.dd-mtabs { display: none; }
@media (max-width: 860px) {
  .dd-mtabs button { flex: 1 1 0; height: 36px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); font-weight: 650; font-size: 14px; box-shadow: none; }
  .dd-mtabs button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
}
/* Пока двум колонкам сделки тесно, сохраняем выбранную вкладку и прокручиваем только её. */
@media (760px < width <= 860px) {
  .wrap-deal.has-mtabs { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
  .wrap-deal.has-mtabs > .dd-mtabs { display: flex; flex: none; gap: 4px; margin-bottom: var(--sp-2); }
  .wrap-deal.has-mtabs > .deal-detail { flex: 1 1 0; min-height: 0; }
  .wrap-deal.has-mtabs .dd-fields { width: 100% !important; flex: 1 1 0 !important; min-height: 0; overflow-y: auto; padding-right: 0; }
  .wrap-deal.has-mtabs .dd-main { flex: 1 1 0; height: auto; min-height: 0; }
  .wrap-deal.has-mtabs .m-chat .dd-fields, .wrap-deal.has-mtabs .deal-detail:not(.m-chat) .dd-main { display: none; }
}
@media (max-width: 760px) {
  body { padding-top: env(safe-area-inset-top, 0px); } /* приложение на iPhone: страница не под строкой состояния */
  .crm-shell { min-height: calc(100vh - env(safe-area-inset-top, 0px)); } /* иначе страница выше экрана на строку состояния: тянешь - чат уезжает, под ним пустая полоса */
  .crm-topbar { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .crm-topbar h1 { font-size: 17px; }
  .crm-main .wrap { padding: 8px 10px 20px; }
  .bx-create { margin-left: auto; }
  .fl, .bx-search { flex: 1 1 100%; max-width: none; min-width: 0; margin: 0; }
  .fl-q { width: 0; }
  .board-search button { width: 36px; height: 36px; }
  .bx-tabs { padding: 0 10px 2px; }
  .card table { display: block; overflow-x: auto; }
  input, select, textarea { font-size: 16px; } /* иначе iPhone увеличивает страницу при вводе */
  .crm-main input[type=file] { max-width: 100%; min-width: 0; }
  .fl-q { font-size: 16px; }
  /* телефон: поиск - просто строка, без выпадающего окна и плашки фильтра; плитки отбираются на лету */
  .fl-pop, .fl-chip { display: none !important; }
  .fl-mobile-presets { display: grid; place-items: center; position: relative; flex: 0 0 36px; height: 36px; color: var(--br); }
  .fl-mobile-presets select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
  .fl-mobile-presets:focus-within { outline: 2px solid var(--br); border-radius: 6px; }
  .deal-list .deal-tile.m-q-hide { display: none; }
  .fl-none { display: block; width: 100%; margin: 0 0 10px; padding: 10px; border: 1px dashed var(--line); border-radius: 10px; background: var(--surface); color: var(--br); font-weight: 600; box-shadow: none; }
  .fl-none[hidden] { display: none; }
  /* канбан: столбец почти во всю ширину, листаются пальцем по одному */
  .bx-kanban { scroll-snap-type: x mandatory; scroll-padding: 0 10px; gap: 10px; padding-left: 0; padding-right: 0; }
  .kanban-col.bx-col { flex: 0 0 calc(100vw - 52px); min-width: 0; max-width: none; scroll-snap-align: start; }
  /* задачи: столбцы друг под другом - просроченные, на сегодня, на завтра... */
  .bx-kanban.tk-board { flex-direction: column; align-items: stretch; overflow: visible; scroll-snap-type: none; }
  .tk-board .kanban-col.bx-col { flex: 0 0 auto; width: 100%; }
  .tk-form { width: min(340px, calc(100vw - 24px)); }
  /* карточка: вкладки «Карточка / Чат» вместо двух колонок */
  .wrap-detail:not(.has-mtabs) > .deal-detail { margin-top: 49px; } /* место под вкладки «Карточка / Чат» до их появления - без прыжка */
  .wrap-detail .dd-mtabs { display: flex; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; gap: 4px; margin: -8px -10px 8px; padding: 6px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
  .dd-mtabs button.dd-fs { flex: 0 0 40px; width: 40px; padding: 0; color: var(--text); } /* «Аа» - размер карточки и чата */
  html.dd-fs1 .wrap-detail .dd-fields, html.dd-fs1 .wrap-detail .dd-main .chat-feed { zoom: 1.14; }
  html.dd-fs2 .wrap-detail .dd-fields, html.dd-fs2 .wrap-detail .dd-main .chat-feed { zoom: 1.3; }
  html.dd-fs1 .wrap-detail .dd-actions { bottom: calc(var(--m-bar, 0px) / 1.14); }
  html.dd-fs2 .wrap-detail .dd-actions { bottom: calc(var(--m-bar, 0px) / 1.3); }
  .wrap-detail .dd-fields { width: 100% !important; flex-basis: auto !important; } /* ширина, растянутая на компьютере, здесь не нужна */
  .wrap-detail .deal-detail.m-chat .dd-fields, .wrap-detail .deal-detail:not(.m-chat) .dd-main { display: none; }
  /* чат - до панели внизу; точную высоту ставит crmFit (crm-rail.php): на iPhone в приложении 100dvh врёт на высоту строки состояния */
  html:has(.wrap-detail .deal-detail.m-chat),
  body:has(.wrap-detail .deal-detail.m-chat) { overflow: hidden; }
  .wrap-detail .deal-detail.m-chat .chat-feed { overscroll-behavior-y: contain; }
  .wrap-detail .deal-detail.m-chat .dd-main { height: calc(100dvh - var(--m-bar, 0px) - 62px); min-height: 300px; }
  .wrap-detail .deal-detail.m-chat .dd-main { margin: -8px -10px -8px; border: 0; border-radius: 0; box-shadow: none; } /* чат во всю ширину, вплотную к вкладкам и панели - как «Чаты» */
  .wrap-detail .dd-actions { bottom: var(--m-bar, 0px); }
  body .dk-toast, body .dk-up, .bx-toast { bottom: calc(var(--m-bar) + 12px); } /* подсказки - над панелью */
  body .dk-up { right: 12px; width: min(300px, calc(100vw - 24px)); }
  /* «Сводка» */
  .hm .crm-topbar { padding: 14px 12px 6px; }
  .hm-seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .hm-sel { flex-wrap: wrap; width: 100%; }
  .hm-sel select { flex: 1 1 140px; max-width: none; }
  /* уведомления, задачи и очередь сообщений (crm-rules.php): строки таблиц - карточками */
  #notifications table, #tasks table, #messages table { display: block; overflow: visible; }
  #notifications tr, #tasks tr, #messages tr { display: flex; flex-wrap: wrap; gap: 6px 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
  #notifications td, #tasks td, #messages td { display: block; width: auto !important; padding: 0; border: 0; }
  #notifications td:nth-child(2) { flex: 1 1 100%; order: -1; }
  #notifications td:last-child, #tasks td:last-child, #messages td:last-child { margin-left: auto; }
  #tasks td:first-child, #messages td:first-child { flex: 1 1 200px; }
  /* сделки карточками: название и сумма, клиент, стадия и ответственный; сверху стадии кнопками */
  .deal-list { gap: 8px; }
  .deal-tile { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main amount" "client client" "stage who"; gap: 6px 12px; align-items: center; padding: 12px 14px; }
  .deal-tile:hover { transform: none; }
  .deal-tile .dt-main { grid-area: main; order: 0; }
  .deal-tile .dt-main .dt-sub { display: none; }
  .deal-tile .dt-no { display: inline; margin-right: 6px; font-style: normal; font-weight: 600; color: var(--muted); }
  .deal-tile .dt-title { font-size: 15px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .deal-tile .dt-amount { grid-area: amount; order: 0; align-self: start; text-align: right; }
  .deal-tile .dt-client { grid-area: client; gap: 8px; }
  .deal-tile .dt-client .avatar { width: 24px; height: 24px; }
  .deal-tile .dt-stage { grid-area: stage; justify-self: start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .deal-tile .dt-assigned { grid-area: who; justify-self: end; }
  .m-stages { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -10px 10px; padding: 2px 10px 4px; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 15; background: var(--bg); }
  .m-stages::-webkit-scrollbar { display: none; }
  .m-stages button { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; white-space: nowrap; box-shadow: none; }
  .m-stages button[style]::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--stage-color); }
  .m-stages button b { font-weight: 600; color: var(--muted); }
  .m-stages button.on { background: var(--text); border-color: var(--text); color: #fff; }
  .m-stages button.on b { color: rgba(255,255,255,.7); }
  .bx-tabs { display: none; } /* «Канбан / Список / Дела» и счётчики дел: на телефоне только список, дела - в «Задачах» */
  .deal-list.m-only { display: flex; }
  .card.l-table { display: none; }
  /* Android: в конце прокрутки страница «растягивалась» и под панелью появлялся разрыв; iPhone - то же «пружинкой» */
  html, body { overscroll-behavior-y: none; }
  /* настройки на телефоне: ничего не шире экрана (иначе вся страница уезжала вбок, а панель внизу пропадала) */
  .crm-main { overflow-x: clip; }
  .crm-main .sf-bar { flex-wrap: wrap; gap: 8px 14px; }
  .crm-main .sf-bar input[type=search] { flex: 1 1 100%; max-width: none; }
  .crm-main .ar { grid-template-columns: minmax(0, 1fr); }
  .crm-main .ar-xg, .crm-main .ar-set { grid-template-columns: minmax(0, 1fr); }
  .crm-main .tpl-marks { grid-template-columns: minmax(0, 1fr); }
  .crm-main .tpl-mark { grid-template-columns: minmax(0, 1fr) auto; }
  .crm-main .tpl-mark span { grid-column: 1 / -1; }
  .crm-main .tpl-mark code { overflow-wrap: anywhere; }
  .crm-main .rp-row { grid-template-columns: minmax(0, 1fr) 62px; }
  .crm-main .ig-base { flex-wrap: wrap; }
  .crm-main .ig-base input { flex: 1 1 100%; min-width: 0; max-width: none; }
  .crm-main .ig-warn, .crm-main .ig-row > * { white-space: normal; min-width: 0; }
  .crm-main .ig-inv-row { flex-wrap: wrap; }
  .crm-main .ig-inv-row input, .crm-main .ig-form input { min-width: 0; flex: 1 1 100%; }
  .crm-main .pr-add { flex-wrap: wrap; }
  .crm-main .pr-add input { min-width: 0; flex: 1 1 100%; }
  .crm-main .ig-sub { grid-template-columns: minmax(0, 1fr); }
  .crm-main .ig-sub input { min-width: 0; max-width: 100%; }
  /* На телефоне crmFit уточняет доступную высоту над нижней панелью и клавиатурой. */
  .im { height: calc(100dvh - var(--m-bar, 0px)); }
  .crm-main.im-main { height: auto; overflow: visible; padding-bottom: var(--m-bar); }
  /* чат карточки: поле ввода во всю ширину, рядом «отправить»; канал, «скрыть», шаблоны и файл - строкой ниже */
  .cmp { position: relative; }
  .cmp-row { flex-wrap: wrap; row-gap: 6px; }
  .cmp-row .cmp-in { order: 1; flex: 1 1 calc(100% - 38px); }
  .cmp-row .cmp-send { order: 2; }
  .cmp-row .cmp-modes { order: 3; }
  .cmp-row .cmp-hide { order: 4; }
  .cmp-row .cmp-tpl { order: 5; margin-left: auto; }
  .cmp-row .cmp-attach { order: 6; }
  .cmp textarea { font-size: 16px; }
  .cmp .cmp-tpl { position: static; }
  .cmp .cmp-tpl-pop { left: 8px; right: 8px; width: auto; bottom: calc(100% + 4px); }
  html.kb-open .wrap-detail .deal-detail.m-chat .dd-main { min-height: 0; } /* клавиатура: чат до её верха, даже если места мало */
}

/* ===== Единый чат карточки: шапка как в переписке мессенджера, поиск, «О клиенте», голосовые ===== */
.chat-head { flex-wrap: nowrap; padding: 9px 12px 9px 14px; gap: 10px; min-height: 60px; }
.chat-ava { position: relative; flex: 0 0 40px; height: 40px; border-radius: 50%; overflow: hidden; font-size: 14px; }
.chat-ava img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-ava img[hidden] { display: none; }
.chat-nm { display: flex; align-items: center; gap: 2px; min-width: 0; }
.chat-nm b { font-size: 15px; font-weight: 650; flex: 0 0 auto; max-width: min(46ch, 55cqw); }
.chat-nm input { font: inherit; font-size: 14.5px; font-weight: 600; height: 28px; padding: 0 8px; border: 1px solid var(--br); border-radius: 6px; min-width: 0; width: min(280px, 100%); }
.chat-ren { flex: none; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); opacity: .6; display: flex; align-items: center; justify-content: center; box-shadow: none; }
.chat-ren svg { width: 15px; height: 15px; }
.chat-ren:hover { background: var(--surface-2); color: var(--br); opacity: 1; }
.chat-sub { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 12.5px; color: var(--muted); }
.chat-who .chat-sub span { font-size: 12.5px; }
.chat-sub-t { display: inline-flex; align-items: center; gap: 5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub-t .chat-ico { width: 14px; height: 14px; }
.chat-pres { flex: none; white-space: nowrap; }
.chat-pres.is-on { color: var(--br); font-weight: 600; }
.chat-ico { width: 18px; height: 18px; border-radius: 50%; display: block; flex: none; }
img[src$="/channels/instagram.svg"] { border-radius: 0 !important; }
.chat-ico-s { border-radius: 0; color: var(--muted); }
.chat-ico-t { display: inline-block; font-style: normal; min-width: 18px; height: 18px; line-height: 18px; padding: 0 3px; border-radius: 9px; background: #607d8b; color: #fff; font-size: 9px; font-weight: 700; text-align: center; flex: none; }
.chat-tools { flex: none; display: flex; align-items: center; gap: 2px; }
.chat-pick { position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-pick.is-pick { cursor: pointer; }
.chat-pick.is-pick:hover .chat-nm b { color: var(--br); }
.chat-pick .chat-who { flex: 1 1 auto; min-width: 0; }
.chat-car { flex: none; font-size: 10px; color: var(--muted); margin: 0 2px 0 5px; }
.chat-ch { display: inline-flex; align-items: center; gap: 6px; height: 32px; max-width: 220px; padding: 0 10px 0 6px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; box-shadow: none; }
.chat-ch:hover { background: var(--surface-2); color: var(--text); }
.chat-ch-i { display: flex; flex: none; }
.chat-ch-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-ch-car { font-size: 9px; color: var(--muted); }
.chat-pick .chat-ch-menu { left: 0; right: auto; top: calc(100% + 6px); width: max-content; min-width: 260px; max-width: min(420px, 92vw); cursor: default; }
.chat-ch-menu li[data-ch] { display: flex; align-items: center; gap: 9px; }
.chat-ch-li { display: flex; flex: none; }
.chat-ch-lt { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-ch-menu li small { flex: none; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.chat-tool { flex: none; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; box-shadow: none; }
.chat-tool svg { width: 20px; height: 20px; }
.chat-tool:hover, .chat-tool.on { background: var(--surface-2); color: var(--text); }
/* фильтры ленты - в строке шапки, посередине; узкий чат (телефон, узкая колонка) - строкой ниже, во всю ширину */
.chat { container-type: inline-size; }
.chat-head .chat-pick { flex: 0 0 auto; max-width: 62%; min-width: 0; }
.chat-head .chat-filter { margin: 0 auto; flex: 0 1 auto; min-width: 0; }
.chat-head .chat-tools { margin-left: auto; }
@container (max-width: 900px) {
  .chat-head { flex-wrap: wrap; row-gap: 8px; }
  .chat-head .chat-pick { flex: 1 0 auto; max-width: calc(100% - 90px); }
  .chat-head .chat-filter { order: 5; flex: 1 1 100%; margin: 0; }
}
.chat-findbar { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; padding: 5px 8px 5px 14px; border-bottom: 1px solid var(--line-soft); background: var(--surface); }
.chat-findbar[hidden] { display: none; }
.chat-findbar > svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.chat-findbar input { flex: 1 1 auto; min-width: 0; height: 32px; border: 0; padding: 0 6px; font-size: 14px; background: transparent; box-shadow: none; outline: none; }
.chat-find-n { flex: none; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.chat-findbar .chat-tool { width: 30px; height: 30px; }
.chat-findbar .chat-tool svg { width: 18px; height: 18px; }
mark.cm-hl { background: #ffe38a; color: inherit; border-radius: 2px; padding: 0; }
mark.cm-hl.on { background: #ffaa3b; }

/* «О клиенте» - панель справа поверх ленты */
.chat-info { position: absolute; right: 0; bottom: 0; z-index: 9; width: 340px; max-width: 100%; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); box-shadow: -10px 0 28px rgba(20,30,25,.10); }
.chat-info[hidden] { display: none; }
.ci-h { flex: none; display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line-soft); font-weight: 650; font-size: 14.5px; }
.ci-h span { flex: 1 1 auto; }
.ci-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px; }
.ci-who { text-align: center; padding: 4px 0 14px; }
.ci-who .chat-ava { width: 72px; height: 72px; margin: 0 auto 8px; display: flex; font-size: 24px; flex: none; }
.ci-who b { display: block; font-size: 16px; }
.ci-who small { color: var(--muted); font-size: 12.5px; }
.ci-rows { border-top: 1px solid var(--line-soft); }
.ci-visits { padding: 10px 2px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.ci-visits summary { cursor: pointer; font-weight: 600; }
.ci-visits ol { margin: 8px 0 0; padding: 0; list-style: none; }
.ci-visits li + li { margin-top: 7px; }
.ci-visits time { display: block; font-size: 11.5px; color: var(--muted); }
.ci-visits a { overflow-wrap: anywhere; }
.ci-row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.ci-row.act { cursor: pointer; }
.ci-row.act:hover { background: var(--surface-2); }
.ci-row > span { min-width: 0; flex: 1 1 auto; }
.ci-lab { display: block; font-size: 11.5px; color: var(--muted); }
.ci-val { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-secs { margin-top: 14px; display: flex; flex-direction: column; gap: 2px; }
.ci-sec { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font-weight: 500; font-size: 13.5px; text-align: left; box-shadow: none; }
.ci-sec:hover { background: var(--surface-2); color: var(--text); }
.ci-sec svg { width: 19px; height: 19px; color: var(--muted); flex: none; }
.ci-none { color: var(--muted); font-size: 13px; text-align: center; padding: 14px 0; }
.ci-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.ci-grid a { position: relative; display: block; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--surface-2); cursor: pointer; }
.ci-grid img, .ci-grid video { width: 100%; height: 100%; object-fit: cover; display: block; }
.ci-list a, .ci-list div { display: flex; align-items: center; gap: 8px; padding: 8px 2px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; color: var(--text); text-decoration: none; cursor: pointer; min-width: 0; }
.ci-list a:hover { color: var(--br); text-decoration: none; }
.ci-list .nm { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-list audio { width: 100%; height: 34px; }

/* под лентой: подсказка суфлёра и «аккаунт не на связи» */
.chat-hint { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; padding: 8px 14px; border-top: 1px solid var(--line-soft); background: #f7fbf8; max-height: 34%; overflow-y: auto; }
.chat-hint[hidden], .chat-warn[hidden] { display: none; }
.chat-hint > * { flex: none; } /* вариантов много - полоса прокручивается, а не сжимает их */
.chat-hint .hh { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; }
.chat-hint .hh b { font-weight: 650; }
.chat-hint .hx { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); box-shadow: none; font-size: 15px; }
.chat-hint .hx:hover { background: var(--surface-2); color: #b3372e; }
.chat-hint .hf { font-size: 12.5px; color: var(--muted); }
.chat-hint .ho { white-space: pre-wrap; line-height: 1.4; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 13.5px; cursor: pointer; }
.chat-hint .ho:hover { border-color: var(--br); }
.chat-warn { flex: 0 0 auto; padding: 8px 14px; background: #fff7e0; color: #7a5a00; font-size: 13px; border-top: 1px solid #f1e2b0; }

/* лента: «Показать раньше», «Отвечать не нужно» */
.cm-more { align-self: center; flex: none; margin: 2px 0 4px; padding: 5px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--br); font-size: 12.5px; font-weight: 600; box-shadow: none; }
.cm-more:hover { background: var(--surface-2); color: var(--br); }
.cm-noreply-w { align-self: flex-start; padding: 0 6px; }
.cm-noreply { font-size: 12px; color: var(--muted); text-decoration: underline dotted; background: transparent; border: 0; padding: 2px 0; box-shadow: none; }
.cm-noreply:hover { color: var(--br); background: transparent; }
.chat[data-act="0"] .cm-noreply-w { display: none; }

/* поле ввода: скрепка, шаблоны, ткани, конфигуратор, поле, «скрыть», микрофон */
.cmp-row { align-items: flex-end; gap: 2px; }
.cmp-modes { margin-right: 4px; }
.cmp-attach, .cmp-tool { flex: 0 0 auto; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: none; }
.cmp-attach svg, .cmp-tool svg { width: 20px; height: 20px; }
.cmp-attach:hover, .cmp-tool:hover { background: var(--surface-2); color: var(--br); }
.cmp .cmp-tpl-btn { width: 34px; margin: 0; border-radius: 8px; }
.cmp .cmp-tpl-btn svg { width: 20px; height: 20px; }
.cmp .cmp-tpl-btn:hover { background: var(--surface-2); }
.cmp-in { margin: 0 4px; }
.cmp-in textarea { border-radius: 10px; overflow-y: hidden; }
.cmp .cmp-hide { width: 34px; margin: 0; border-radius: 8px; }
.cmp .cmp-hide:hover { background: var(--surface-2); }
.cmp-send { width: 36px; height: 36px; margin-left: 2px; }
.cmp-send svg { display: none; }
.cmp-send .cmp-i-send { display: block; width: 16px; height: 16px; margin-left: 2px; }
.cmp-send.is-mic { background: transparent; color: var(--muted); }
.cmp-send.is-mic:hover { background: var(--surface-2); color: var(--br); }
.cmp-send.is-mic .cmp-i-send { display: none; }
.cmp-send.is-mic .cmp-i-mic { display: block; width: 20px; height: 20px; margin: 0; }
.cmp-send.is-rec, .cmp-send.is-rec:hover { background: #d4453a; color: #fff; }
.cmp-send.is-rec .cmp-i-send, .cmp-send.is-rec .cmp-i-mic { display: none; }
.cmp-send.is-rec .cmp-i-stop { display: block; width: 17px; height: 17px; }
.cmp[data-mode="task"] .cmp-fab, .cmp[data-mode="task"] .cmp-cfg { display: none; }
.cmp-rec { flex: 1 1 auto; min-width: 0; height: 36px; margin: 0 4px; display: flex; align-items: center; gap: 9px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 12.5px; color: var(--muted); }
.cmp-rec[hidden] { display: none; }
.cmp-rec audio { flex: 1 1 auto; min-width: 0; height: 32px; }
.cmp-rec .dot { width: 9px; height: 9px; border-radius: 50%; background: #d4453a; flex: none; animation: cmpRec 1s infinite; }
.cmp-rec .bad { color: #b3372e; font-weight: 600; }
.cmp-rec a { color: #b3372e; cursor: pointer; margin-left: auto; white-space: nowrap; }
@keyframes cmpRec { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.cmp.is-rec .cmp-in { display: none; }
.cmp-reply { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; padding: 5px 6px 5px 10px; border-left: 3px solid var(--br); border-radius: 6px; background: var(--surface-2); font-size: 12.5px; }
.cmp-reply[hidden] { display: none; }
.cmp-reply-q { flex: 1 1 auto; min-width: 0; }
.cmp-reply-q b { display: block; color: var(--br); font-weight: 650; font-size: 12px; }
.cmp-reply-q span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-reply-x { flex: none; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; box-shadow: none; }
.cmp-reply-x svg { width: 15px; height: 15px; }
.cmp-reply-x:hover { background: var(--surface); color: #b3372e; }
.cmp-clipmenu { position: absolute; z-index: 30; left: 8px; bottom: calc(100% + 6px); min-width: 220px; padding: 6px; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 28px rgba(20,30,25,.16); }
.cmp-clipmenu[hidden] { display: none; }
.cmp-clipmenu button { display: flex; align-items: center; gap: 10px; height: auto; padding: 10px 12px; border: 0; border-radius: 8px; background: none; box-shadow: none; color: var(--text); font-weight: 500; font-size: 14px; text-align: left; }
.cmp-clipmenu button:hover { background: var(--surface-2); color: var(--text); }
.cmp-clipmenu svg { width: 19px; height: 19px; flex: none; color: #6b7480; }
.cmp { position: relative; }
/* окно поверх: Диск, подбор ткани */
.cmp-ov { position: fixed; inset: 0; z-index: 400; display: flex; background: rgba(15,22,28,.45); }
.cmp-ov[hidden] { display: none; }
.cmp-ovbox { margin: auto; width: min(1100px, 96vw); height: min(860px, 92vh); display: flex; flex-direction: column; overflow: hidden; background: #fff; border-radius: 16px; box-shadow: 0 18px 50px rgba(0,0,0,.25); }
.cmp-ovh { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; border-bottom: 1px solid var(--line-soft); }
.cmp-ovh b { flex: 1 1 auto; font-size: 15px; }
.cmp-ovh .n { font-size: 13px; color: var(--br); }
.cmp-ovh button { border: 0; border-radius: 10px; background: var(--surface-2); color: var(--text); font-weight: 600; padding: 8px 14px; box-shadow: none; }
.cmp-ovh button:hover { background: #e6ebe7; color: var(--text); }
.cmp-ovbox iframe { flex: 1 1 auto; width: 100%; border: 0; }
@media (max-width: 760px) {
  .chat-head { padding: 7px 8px 7px 10px; gap: 8px; min-height: 54px; }
  .chat-ava { flex-basis: 36px; height: 36px; }
  .chat-nm b { font-size: 14.5px; }
  .chat-pick { gap: 8px; }
  .cmp .cmp-in textarea { height: 36px; min-height: 36px; padding-top: 6px; padding-bottom: 6px; } /* шрифт 16px - поле чуть выше, без полосы прокрутки */
  .chat-info { width: 100%; border-left: 0; }
  .cmp-ovbox { width: 100vw; height: 100%; border-radius: 0; padding-top: env(safe-area-inset-top, 0px); }
  /* поле ввода и «отправить» - первой строкой; что пишем, файлы, шаблоны, ткани, конфигуратор, «скрыть» - второй */
  .cmp-row .cmp-in, .cmp-row .cmp-rec { order: 1; flex: 1 1 calc(100% - 44px); margin: 0 2px 0 0; }
  .cmp-row .cmp-send { order: 2; }
  .cmp-row .cmp-modes { order: 3; }
  .cmp-row .cmp-attach { order: 4; }
  .cmp-row .cmp-tpl { order: 5; margin-left: 0; }
  .cmp-row .cmp-fab { order: 6; }
  .cmp-row .cmp-cfg { order: 7; }
  .cmp-row .cmp-hide { order: 8; margin-left: auto; }
  .cmp.is-rec .cmp-in { display: none; }
  /* суфлёр на телефоне - компактно: варианты в две строки, место остаётся переписке */
  .chat-hint { max-height: 24vh; padding: 6px 10px; gap: 4px; }
  .chat-hint .ho { font-size: 13px; padding: 5px 9px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}

/* фильтры ленты - в поиске (лупа), а не в шапке: на телефоне и на компьютере; «Отправить» ⇄ микрофон - зажать или провести */
.chat-head .chat-filter { display: none; }
.chat-findbar { flex-wrap: wrap; row-gap: 6px; padding-bottom: 8px; }
.chat-findbar .chat-filter-m { display: flex; order: 9; flex: 1 1 100%; margin: 0; }
.chat-findbar input { flex: 1 1 0; width: 0; min-width: 60px; } /* строка поиска и стрелки - одной строкой, фильтры - под ними */
.cmp-send { touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.cmp-send.is-flip svg { animation: cmpFlip .22s ease-out; }
@keyframes cmpFlip { 0% { transform: scale(.35) rotate(-40deg); opacity: .2; } 100% { transform: none; opacity: 1; } }

/* Без голубой подсветки: телефон при нажатии закрашивал кнопку, ссылку, карточку голубым - не нужно нигде.
   Текст на кнопках при долгом нажатии тоже не выделяется (а в полях, сообщениях и карточках - как обычно, можно копировать). */
html { -webkit-tap-highlight-color: transparent; }
button, [role="button"], .rail-item, .cc-chip span { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* Поле ввода: меню скрепки, плашка «что пишем»; на телефоне - одной строкой [скрепка][поле 😊 👁][отправить] */
.cmp-clipmenu .m-only, .cmp-modechip { display: none; }
.cmp-clipsep { display: block; height: 1px; margin: 4px 8px; background: var(--line-soft); }
.cmp:not([data-mode="chat"]) .cmp-in .cmp-hide { display: none; } /* «скрыть от клиента» - только для сообщения в чат */
@media (max-width: 760px) {
  .cmp-row { flex-wrap: nowrap; gap: 4px; }
  .cmp-row .cmp-modes, .cmp-row .cmp-fab, .cmp-row .cmp-cfg, .cmp .cmp-tpl-btn { display: none; } /* они - в меню скрепки */
  .cmp-row .cmp-attach { order: 1; }
  .cmp-row .cmp-in, .cmp-row .cmp-rec { order: 2; flex: 1 1 auto; margin: 0; }
  .cmp-row .cmp-send { order: 3; margin-left: 0; }
  .cmp-row .cmp-tpl { order: 4; margin: 0 0 0 -4px; }
  .cmp-clipmenu .m-only { display: flex; }
  .cmp-clipmenu .cmp-clipsep.m-only { display: block; }
  .cmp-clipmenu { min-width: 240px; }
  .cmp-modechip:not([hidden]) { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 6px; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--br-dim); color: var(--br); font-size: 13px; font-weight: 650; }
  .cmp-modechip[data-m="note"] { background: #fff3cd; color: #8a6d1f; }
  .cmp-modechip[data-m="task"] { background: #fdebd3; color: #9a5b00; }
  .cmp-modechip button { width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; display: flex; align-items: center; justify-content: center; box-shadow: none; }
  .cmp-modechip button svg { width: 14px; height: 14px; }
  .cmp-modechip button:hover { background: rgba(0,0,0,.06); color: inherit; }
}

/* Панель ввода в двухколоночной карточке зависит от ширины переписки. */
.wrap-deal .dd-main-chat .chat { container-name: card-chat; }
@media (min-width: 861px) {
  @container card-chat (max-width: 640px) {
    .cmp { --tools-in-clip: 1; }
    .cmp-row > .cmp-tool, .cmp .cmp-tpl-btn { display: none; }
    .cmp .cmp-tpl { position: static; }
    .cmp .cmp-tpl-pop { left: 8px; right: 8px; width: auto; bottom: calc(100% + 4px); }
    .cmp-clipmenu button.clip-tool { display: flex; }
    .cmp:not([data-mode="chat"]) .clip-tool[data-c="ask"],
    .cmp[data-mode="note"] .clip-tool[data-c="tpl"],
    .cmp[data-mode="task"] .clip-tool { display: none; }
    .cmp-clipmenu { max-height: min(60vh, 440px); overflow-y: auto; }
  }
}

/* Компания клиента в «Клиенте» сделки (юр. лицо / ИП) */
.cc-company { margin-top: 8px; padding: 8px 10px 6px; border: 1px solid var(--line); border-radius: 10px; background: #fff; position: relative; }
.cc-co-top { display: flex; align-items: center; gap: 8px; }
.cc-co-l { font-size: 11px; color: var(--muted); }
.cc-co-edit { margin-left: auto; font-size: 12.5px; }
.cc-co-x { border: 0; background: transparent; box-shadow: none; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 4px; cursor: pointer; }
.cc-co-x:hover { color: #c0392b; }
.cc-co-card { display: flex; flex-direction: column; gap: 1px; padding: 2px 0; }
.cc-co-card b { font-size: 14.5px; font-weight: 600; overflow-wrap: anywhere; }
.cc-co-card span { font-size: 12.5px; color: var(--muted); }
.cc-co-card .cc-co-warn { color: #b7791f; }
.cc-co-pick { position: relative; }
.cc-sec .cc-co-pick input.cc-co-q { width: 100% !important; margin: 0 !important; font-size: 13.5px; }
.cc-co-menu { position: absolute; left: -11px; right: -11px; top: calc(100% + 7px); z-index: 30; margin: 0; padding: 4px; list-style: none; max-height: 280px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--br); border-radius: 10px; box-shadow: 0 10px 28px rgba(0,0,0,.14); }
.cc-co-menu[hidden] { display: none; }
.cc-co-menu li { display: flex; flex-direction: column; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.cc-co-menu li span { font-size: 12px; color: var(--muted); }
.cc-co-menu li:hover, .cc-co-menu li.is-hl { background: var(--surface-2); }
.cc-co-menu li.cc-co-new { color: var(--br); font-weight: 600; }
.cc-co-dlg .im-dlg-box { width: min(660px, 96vw); max-height: 94vh; gap: 10px; padding: 16px; }
.cc-co-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 1px; }
/* поле - рамка, название мелко внутри сверху (как в карточке) */
.cc-co-f { grid-column: span var(--sp, 2); position: relative; display: block; margin: 0; min-width: 0; padding: 15px 9px 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: text; }
.cc-co-f:focus-within { border-color: var(--br); }
.cc-co-f > span { position: absolute; left: 9px; right: 9px; top: 3px; display: flex; justify-content: space-between; gap: 6px; font-size: 10.5px; line-height: 12px; color: var(--muted); font-weight: 400; white-space: nowrap; }
.cc-co-dlg .cc-co-f input { display: block; width: 100%; height: 20px; margin: 0; padding: 0; border: 0 !important; border-radius: 0; background: transparent !important; box-shadow: none; outline: none; font-size: 14px; }
.cc-co-look { font-size: 11px; font-weight: 600; line-height: 12px; padding: 0; }
.cc-co-msg { min-height: 16px; font-size: 12.5px; color: #c0392b; }
@media (max-width: 760px) { .cc-co-grid { grid-template-columns: 1fr 1fr; } .cc-co-f { grid-column: span 1; } .cc-co-f.is-wide { grid-column: 1 / -1; } .cc-co-dlg .cc-co-f input { font-size: 16px; } }
html:not(.show-codes) .dd-form:not(.cc-layout-on) .cc-sec .cc-row[data-code="CLIENT"] > span:first-child { display: none; } /* «Клиент» уже в заголовке плашки */
.cc-client2 { margin-top: 6px; }
.cc-client2[hidden] { display: none; }
.cc-client-kind { display: flex; align-items: center; }
/* Кнопки-значки в блоке клиента: один размер (26px), один правый край с кнопкой звонка; зелёная - только «позвонить» */
.cc-c2-add, .cc-c2-x, .cc-fio-btn { flex: none; width: 26px; height: 26px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 50%; background: transparent; box-shadow: none; color: var(--muted); cursor: pointer; }
.cc-c2-add, .cc-c2-x { margin: -4px 4px -4px auto; }
.cc-c2-add[hidden] { display: none; }
.cc-c2-add:hover, .cc-c2-x:hover, .cc-fio-btn:hover { border-color: var(--line); background: var(--surface-2); color: var(--text); }
.cc-fio-main { position: relative; }
.cc-fio-main textarea.cc-client-name { padding-right: 34px; }
.cc-fio-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.cc-fio-btn svg { transition: transform .15s; }
.cc-fio-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.cc-sec .cc-client2 input.cc-client-name { width: 100%; border: 0; border-radius: 0; background: transparent; box-shadow: none; outline: 0; padding: 2px 5px; }
.cc-fio { display: flex; gap: 8px; }
.cc-fio[hidden] { display: none; }
.cc-fio input { flex: 1 1 0; min-width: 0; }
/* маленькие кнопки-значки: общий зелёный фон при наведении им не нужен */
.cc-co-x:hover, .bulk-x:hover, .fl-pr-del:hover, .ibp-start:hover, .im-back:hover, .im-find-x:hover, .im-reply-x:hover, .push-x:hover { background: transparent; }
.im-info-x:hover { background: #e3e7ea; }
.st-btn:hover, .wc-x:hover { background: #f4f6f5; }
button.bad:hover { background: #fbdcdc; }
.im-r:hover { background: var(--br-dim); }
.ibp-tab:hover { background: rgba(0,136,75,.18); }
.sp-crm { display: flex; flex-direction: column; gap: 4px; }
.sp-crm-l { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sp-crm-l[hidden], .sp-crm-new[hidden], .sp-crm-add[hidden] { display: none; }
.sp-crm-l select { flex: 1 1 160px; min-width: 0; }
.sp-crm-new { display: flex; gap: 6px; flex: 1 1 100%; }
.sp-crm-new input { flex: 1 1 0; min-width: 0; }
.sp-crm-add, .sp-crm-x { flex: none; width: 26px; height: 26px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 6px; background: #fff; box-shadow: none; color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer; }
.sp-crm-add:hover, .sp-crm-x:hover { border-color: var(--br); background: var(--br-dim); color: var(--text); }
.sp-crm-l select { width: auto; order: 1; }
.sp-crm-add, .sp-crm-x { order: 2; }
.sp-crm-new { order: 3; }
.sp-crm-pick { position: relative; flex: 1 1 160px; min-width: 0; order: 1; }
.sp-crm-pick input.sp-crm-q { width: 100%; }
.sp-crm-pick .sp-crm-menu { left: 0; right: 0; top: calc(100% + 4px); }

/* ---------- «Отвечать не нужно»: на красных плитках и окно «задача / закрыть лид» ---------- */
.bx-noreply, .tile-noreply { display: none; }
.is-wait .bx-noreply, .is-wait .tile-noreply {
  display: inline-flex; align-items: center; align-self: flex-start; border: 0; background: none; padding: 0; font: inherit; font-size: 12px; font-weight: 600;
  color: #b3372e; cursor: pointer; text-decoration: underline; text-decoration-color: rgba(179,55,46,.35); text-underline-offset: 2px;
}
.is-wait .bx-noreply:hover, .is-wait .tile-noreply:hover { text-decoration-color: currentColor; }
.is-wait .tile-noreply { margin-top: 6px; }
.nr-dlg h3 { margin-bottom: 12px; }
.nr-seg { display: flex; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: 10px; margin-bottom: 14px; }
.nr-seg button { flex: 1 1 0; border: 0; background: none; color: var(--muted); font-weight: 600; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.nr-seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(20,30,25,.12); }
.nr-err { color: #b3372e; font-size: 13px; margin: 4px 0 0; }
.nr-dlg .row { margin-top: 14px; }
.is-wait .bx-foot { flex-wrap: wrap; row-gap: 6px; }
.is-wait .bx-noreply { order: -1; flex: 0 0 100%; }

/* «Кому сообщать о закрытом лиде» (Правила и процессы) */
.lc-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 2px 0 6px; }
.lc-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px 6px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13.5px; cursor: pointer; background: var(--surface); user-select: none; }
.lc-chip input { margin: 0; accent-color: var(--br); }
.lc-chip:has(input:checked) { background: var(--br-dim); border-color: rgba(0, 136, 75, .35); }
.lc-form.is-saved .lc-chips::after { content: 'Сохранено'; font-size: 12.5px; color: var(--br); }

/* имя у дополнительного номера: номер слева, имя справа («+» и трубка - поверх имени) */
.cc-phone.is-more input[type=tel] { flex: 1 1 46%; padding-right: 8px !important; }
.cc-phone .cc-phone-nm { flex: 1 1 54%; min-width: 0; border-left: 1px solid var(--line-soft) !important; border-radius: 0; padding-left: 8px !important; padding-right: 34px !important; }
.cc-phone:has(.cc-phone-add:not([hidden])) .cc-phone-nm { padding-right: 64px !important; }
.cc-phone:has(.cc-phone-nm):has(.cc-phone-add:not([hidden])) input[type=tel] { padding-right: 8px !important; }
/* «Отвечать не нужно» - в ленте, не на плитках (владелец, 17.11) */
.is-wait .bx-noreply, .is-wait .tile-noreply { display: none !important; }
/* кнопки «Настроить поля» после «Готово» прятались не везде: у строк-<label> правило «label.f > span» их снова показывало */
.cc-row > .cc-tools { display: none; }
.cc-layout-on .cc-row > .cc-tools { display: inline-flex; }

[data-web-ref] .web-presence{display:none}
[data-web-ref].web-online .web-presence{display:block;width:fit-content;color:#13603d;font-size:12px;font-weight:650}
.kanban-card.web-online,.deal-tile.web-online,.l-table tr.web-online>td,.chats-item.web-urgent{isolation:isolate}
.deal-tile.web-online,.l-table tr.web-online>td,.chats-item.web-urgent{position:relative}
:is(.kanban-card.web-online:not(.kc-source),.deal-tile.web-online,.l-table tr.web-online>td,.chats-item.web-urgent)::before{content:"";position:absolute;inset:0;z-index:-1;pointer-events:none;border-radius:inherit;background:#f5a83b;opacity:.22;animation:crm-web-attention 1.8s ease-in-out infinite}
@keyframes crm-web-attention{0%,100%{opacity:.06}50%{opacity:.40}}
@media(prefers-reduced-motion:reduce){:is(.kanban-card.web-online:not(.kc-source),.deal-tile.web-online,.l-table tr.web-online>td,.chats-item.web-urgent)::before{animation:none}}

/* Компактная схема горизонтальной прокрутки доски продаж. */
.kb-mini[hidden]{display:none}
.kb-mini{position:fixed;right:clamp(36px,4vw,72px);bottom:10px;z-index:10;box-sizing:border-box;width:clamp(176px,calc(var(--kb-count,8)*26px),320px);height:36px;border:1px solid var(--line,#d6dad7);border-radius:6px;background:var(--card,#fff);box-shadow:0 2px 9px #0002}
.kb-mini-cols,.kb-mini input{position:absolute;inset:3px}
.kb-mini-cols{display:grid;gap:2px;pointer-events:none}
.kb-mini-cols i{border-radius:3px;background:var(--surface-2,#eff1f0)}
.kb-mini input{appearance:none;-webkit-appearance:none;margin:0;padding:0;width:calc(100% - 6px);height:calc(100% - 6px);background:transparent;border:0;cursor:pointer}
.kb-mini input::-webkit-slider-runnable-track{height:100%;background:transparent}
.kb-mini input::-webkit-slider-thumb{-webkit-appearance:none;width:var(--kb-thumb);height:100%;background:#77837e55;border:1px solid #77837e66;border-radius:4px;cursor:grab}
.kb-mini input::-moz-range-track{height:100%;background:transparent}
.kb-mini input::-moz-range-thumb{box-sizing:border-box;width:var(--kb-thumb);height:100%;background:#77837e55;border:1px solid #77837e66;border-radius:4px;cursor:grab}
.kb-mini input:focus-visible{outline:2px solid var(--br,#00884b);outline-offset:2px}
.kb-mini{opacity:.65;transition:opacity .2s}
.kb-mini:hover,.kb-mini:has(input:focus-visible),.kb-mini:active{opacity:1}
@media(prefers-reduced-motion:reduce){.kb-mini{transition:none}}
@media(min-width:861px){.bx-kanban.kb-mini-enabled{scrollbar-width:none;padding-bottom:0}.bx-kanban.kb-mini-enabled::-webkit-scrollbar{display:none}}
@media(max-width:860px){.kb-mini{display:none}}

/* Подсветка остаётся внутри границ незаполненного поля. */
form.dd-form .cc-row-miss {
  background-color: #fff4f2 !important;
  box-shadow: inset 0 0 0 1px #e0a49d !important;
  border-radius: 6px;
}
form.dd-form .cc-row-miss:focus-within {
  box-shadow: inset 0 0 0 2px #bc7067 !important;
}
