
:root {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-soft: #eef6f3;
  --text: #18211f;
  --muted: #68746f;
  --border: #e4eae8;
  --border-strong: #d3dcd9;
  --accent: #4c63d8; /* индиго-синий из логотипа AiStrix (был зелёный) — един с кабинетом */
  --accent-strong: #3a4db5;
  --accent-soft: #eceefc;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --shadow: 0 18px 45px rgba(22, 36, 31, 0.08);
  --shadow-soft: 0 8px 20px rgba(22, 36, 31, 0.06);
  --radius: 8px;
  --tg: #2aabee;
  --viber: #7360f2;
  --wa: #25d366;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101614;
    --surface: #17201d;
    --surface-raised: #1d2824;
    --surface-soft: #182d28;
    --text: #eef5f1;
    --muted: #a3b0aa;
    --border: #26332e;
    --border-strong: #33443d;
    --accent: #7c8cf0; /* индиго для тёмной темы (был зелёный) */
    --accent-strong: #a6b3f7;
    --accent-soft: #1e2442;
    --danger: #ff9b8f;
    --danger-soft: #2a1613;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.25);
    --shadow-soft: 0 8px 20px rgba(0, 0, 0, 0.16);
  }
}
* { box-sizing: border-box; }
html { font-size: 93.75%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-strong); text-decoration: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }

/* ── Кнопки (как в кабинете) ── */
.button {
  border: none; border-radius: var(--radius);
  background: var(--accent); color: #fff;
  padding: 8px 14px; font-weight: 600;
}
.button:hover { background: var(--accent-strong); }
.button-secondary {
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  padding: 7px 13px; font-weight: 500;
}
.button-secondary:hover { border-color: var(--accent); }
.button-ghost { border: none; background: transparent; color: var(--muted); padding: 6px 8px; border-radius: var(--radius); }
.button-ghost:hover { background: var(--surface-soft); color: var(--text); }

/* ── Верхняя панель ── */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--surface);
  border-bottom: 1px solid var(--border); box-shadow: var(--shadow-soft);
  position: sticky; top: 0; z-index: 20;
  flex: none; /* ФИКСИРОВАННАЯ высота: шапку НЕ сжимает и НЕ переносит контент ниже (длинный список чатов). */
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand .mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, var(--accent), var(--accent-strong)); display: grid; place-items: center; color: #fff; font-size: 14px; }
.brand .sub { color: var(--muted); font-weight: 500; font-size: 13px; }
.topbar .spacer { flex: 1; }
.topbar.embedded { padding: 8px 16px; } /* встроено в кабинет: без бренда строка тоньше */
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.role-badge { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); }
.role-badge.mgmt { background: #fff3d6; color: #8a6100; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .role-badge.mgmt { background: #3a2f12; color: #e9c06a; } }

/* ── Панель инструментов (поиск + фильтры) ── */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 20px; background: var(--bg); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1; min-width: 260px; }
.search-wrap input {
  width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  padding: 10px 12px 10px 36px; font-size: 15px;
}
.search-wrap input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-wrap .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.filter-group { display: flex; align-items: center; gap: 6px; }
.chip { border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; }
.chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
/* Переключатель каналов: логотип + полное название. Неподключённые — приглушены («будут»). */
.chip.chan { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 8px; }
.chip.chan .ch-ico { width: 17px; height: 17px; flex: none; }
.chip.chan.off { opacity: 0.4; cursor: default; }
.chip.chan.off:hover { border-color: var(--border-strong); }
/* Счётчик непрочитанных у активного канала (Telegram/WhatsApp/Viber) в фильтре сверху. */
.chip.chan .chan-cnt { background: #eb5757; color: #fff; font-size: 10px; font-weight: 700; line-height: 1; border-radius: 999px; padding: 2px 5px; min-width: 16px; text-align: center; margin-left: 1px; }
select.mini { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 7px 10px; font-size: 13px; max-width: 180px; text-overflow: ellipsis; }

/* ── Раскладка: единая верхняя строка + всплывающий поиск + рабочая область во всю оставшуюся высоту ── */
body.app { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.topbar.onebar { flex-wrap: nowrap; gap: 8px; overflow-x: auto; }
.topbar.onebar > * { flex: 0 0 auto; } /* не сжимать/не переносить — при нехватке ширины строка прокрутится */
.topbar.onebar .spacer { flex: 1 1 0; } /* распорка толкает правую группу */
.topbar.onebar .button { white-space: nowrap; }
.topbar.onebar .who { white-space: nowrap; }
.iconbtn { flex: none; width: 36px; height: 36px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--muted); display: grid; place-items: center; font-size: 15px; }
.iconbtn:hover { border-color: var(--accent); color: var(--accent-strong); }
.searchrow { flex: none; display: none; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--bg); }
.searchrow.open { display: block; }
.searchrow input { width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 9px 12px; font-size: 15px; }
.searchrow input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.searchbox { position: relative; display: flex; align-items: center; }
.searchbox input { width: 100%; padding-right: 38px; }
.search-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: none; background: var(--surface-soft); color: var(--muted); width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-size: 12px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.search-clear:hover { background: var(--border-strong); color: var(--text); }
.list-head { padding: 8px 12px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.pad { padding: 10px 12px; }
.crm-co { color: var(--accent-strong); font-weight: 600; }
/* Колонки с изменяемой шириной (перетаскивание границ; ширины хранятся на сервере). Пределы: список 200–500, папки 52–120. */
:root { --rail-w: 66px; --list-w: 380px; }
.workspace { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: row; }
.dialogs { min-height: 0; flex: none; width: var(--list-w); overflow-y: auto; background: var(--surface); }
.col-resizer { flex: none; width: 6px; cursor: col-resize; background: var(--border); position: relative; touch-action: none; }
.col-resizer:hover, .col-resizer.dragging { background: var(--accent); }
.col-resizer[hidden] { display: none; }
body.col-resizing { cursor: col-resize; user-select: none; }
body.col-resizing iframe { pointer-events: none; }
/* Левый РЕЙЛ папок (как в Telegram): узкая вертикальная полоса, все папки видны, скролл вертикальный */
.folderrail { flex: none; width: var(--rail-w); display: flex; flex-direction: column; align-items: stretch; gap: 3px; padding: 5px 4px; overflow-y: auto; overflow-x: hidden; background: var(--surface-soft); scrollbar-width: none; }
.folderrail::-webkit-scrollbar { display: none; }
.folderrail[hidden] { display: none; }
.ftile { flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; border: none; background: transparent; color: var(--muted); cursor: pointer; border-radius: 10px; padding: 6px 2px 5px; font: inherit; }
.ftile:hover { background: var(--surface); color: var(--text); }
.ftile.active { background: var(--accent-soft); color: var(--accent-strong); }
.ftile .fi { position: relative; font-size: 19px; line-height: 1; }
.ftile .fn { font-size: 10px; line-height: 1.1; max-width: 58px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.ftile .fcount { position: absolute; top: -5px; right: -9px; min-width: 15px; height: 15px; padding: 0 3px; box-sizing: border-box; background: var(--accent); color: #fff; border-radius: 999px; font-size: 9.5px; line-height: 15px; text-align: center; font-weight: 700; }
.ftile.active .fcount { background: var(--accent-strong); }
.ftile .fcount.sys { background: var(--muted); } /* «Скрытые»: счётчик нейтральный, не «непрочитано» */
.ftile.sysfold { color: var(--muted); }
.ftile.add, .ftile.imp { color: var(--muted); }
.ftile.add { margin-top: 4px; }
/* меню «в папку» на строке диалога */
.folder-pop { position: absolute; z-index: 40; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; min-width: 190px; max-height: 320px; overflow-y: auto; }
.folder-pop .fp-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.folder-pop .fp-item:hover { background: var(--surface-soft); }
.folder-pop .fp-new { color: var(--accent-strong); border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; }
.pin-fold { flex: none; border: none; background: transparent; cursor: pointer; font-size: 12px; line-height: 1; padding: 2px; border-radius: 6px; opacity: 0; filter: grayscale(1); }
.dialog:hover .pin-fold { opacity: .5; }
.pin-fold:hover { opacity: 1 !important; background: var(--surface-soft); }
/* Кнопка «скрыть группу» (появляется по наведению на строку) + бейдж «группа». */
.pin-hide { flex: none; border: none; background: transparent; cursor: pointer; font-size: 12px; line-height: 1; padding: 2px 4px; border-radius: 6px; opacity: 0; color: var(--muted); }
.dialog:hover .pin-hide { opacity: .5; }
.pin-hide:hover { opacity: 1 !important; background: var(--danger-soft, #fde8e8); color: var(--danger, #d33); }
.pin-hide.back { opacity: .6; color: var(--accent-strong); } /* «вернуть» в папке «Скрытые» — всегда видно, не тревожный цвет */
.dialog:hover .pin-hide.back { opacity: 1; }
.pin-hide.back:hover { background: var(--surface-soft); color: var(--accent-strong); }
.grp-badge { font-size: 10px; font-weight: 700; color: #6b46c1; background: #ede9fe; border-radius: 5px; padding: 1px 5px; letter-spacing: .02em; vertical-align: middle; }
/* Название компании в шапке — ссылка в карточку Битрикса. */
.badge.crm-link { text-decoration: none; cursor: pointer; }
.badge.crm-link:hover { filter: brightness(0.96); text-decoration: underline; }
.drag-h { flex: none; cursor: grab; color: var(--muted); font-size: 13px; line-height: 1; padding: 0 2px; opacity: .35; touch-action: none; user-select: none; }
.dialog.pinned:hover .drag-h { opacity: .8; }
.dialog.dragging { opacity: .7; background: var(--accent-soft); box-shadow: var(--shadow); }
body.dragging-pin { cursor: grabbing; user-select: none; }
body.dragging-pin .dialog { cursor: grabbing; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(12px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); opacity: 0; transition: opacity .25s, transform .25s; z-index: 60; max-width: 80vw; }
.toast.show { opacity: .96; transform: translateX(-50%) translateY(0); }
/* Лента = flex-колонка: шапка сверху, сообщения со СВОИМ скроллом (открытие снизу + догрузка вверх),
   поле ответа прижато к низу. Скролл живёт в .messages, не в .pane. */
.pane { min-height: 0; flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }

/* ── Строка диалога — КОМПАКТНО, 2 строки (как в Telegram): имя+время сверху, превью+логотип снизу ── */
.dialog {
  display: grid; grid-template-columns: 42px 1fr; gap: 11px; align-items: center;
  padding: 9px 14px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.dialog:hover { background: var(--surface-soft); }
.dialog.active { background: var(--accent-soft); }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--surface-soft); color: var(--accent-strong); display: grid; place-items: center; font-weight: 700; font-size: 15px; border: 1px solid var(--border); }
img.avatar { object-fit: cover; }
.dinfo { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.drow1, .drow2 { display: flex; align-items: center; gap: 8px; }
.drow1 { align-items: baseline; }
.drow1 .dtitle { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 5px; overflow: hidden; }
.drow1 .name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; font-size: 14.5px; }
.drow1 .name.unread { font-weight: 800; }
/* Подпись владельца строки: «· вы» / «· Никита». Свои — приглушённо-акцентные, чужие — muted. Не сжимается. */
.owner-tag { flex: none; color: var(--muted); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.owner-tag.me { color: var(--accent-strong); }
.drow1 .time { flex: none; color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.drow2 .preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.drow2 .dright { flex: none; display: flex; align-items: center; gap: 5px; }
/* Переключатель «показывать чужие» в модалке «Аккаунт». */
.acc-toggle { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.acc-toggle-txt strong { font-size: 14px; }
.acc-sep { border-top: 1px solid var(--border); margin: 0 0 14px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .sl { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background .15s; }
.switch .sl::before { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .sl { background: var(--accent); }
.switch input:checked + .sl::before { transform: translateX(18px); }

/* ── Значки каналов ── */
.ch { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; padding: 2px 6px; border-radius: 5px; color: #fff; }
.ch.telegram { background: var(--tg); }
.ch.viber { background: var(--viber); }
.ch.whatsapp { background: var(--wa); }
.ch-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.ch-dot.telegram { background: var(--tg); } .ch-dot.viber { background: var(--viber); } .ch-dot.whatsapp { background: var(--wa); }

.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.hang { background: var(--danger-soft); color: var(--danger); }
.badge.unmatched { background: #fff3d6; color: #8a6100; }
.badge.matched { background: #e6f5ec; color: #1f7a4d; } /* найден в CRM / название компании */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.unmatched { background: #3a2f12; color: #e9c06a; }
  :root:not([data-theme="light"]) .badge.matched { background: #12321f; color: #6fce9a; }
}

/* ── Лента переписки ── */
/* Шапка диалога — ОДНА компактная строка: логотип канала + имя + телефон + ответственный + значок «не в CRM». */
.conv-header { flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.conv-ava { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none; border: 1px solid var(--border); }
.conv-header .ch-line { display: flex; align-items: center; gap: 9px; min-width: 0; }
.conv-header .ch-line .ch-ico { width: 18px; height: 18px; flex: none; }
.conv-header .cname { font-weight: 700; font-size: 15px; white-space: nowrap; }
.conv-header .csub { color: var(--muted); font-size: 13px; white-space: nowrap; }
.conv-header .clogo { display: inline-flex; align-items: center; }
.conv-header .clogo .ch-ico { width: 17px; height: 17px; }
.conv-header .dsep { color: var(--muted); opacity: .55; }
/* Значок канала в списке + правая мета-строка (индикатор нового ДО логотипа) */
.ch-ico { width: 18px; height: 18px; display: block; }
.metar { display: flex; align-items: center; gap: 5px; margin-top: 5px; }
.readonly-note { margin: 12px 22px 0; padding: 8px 12px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: var(--radius); color: var(--muted); font-size: 12.5px; }
.messages { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 18px 22px 24px; display: flex; flex-direction: column; gap: 10px; }
.load-older { text-align: center; color: var(--muted); font-size: 12px; padding: 6px; }
.day-sep { text-align: center; color: var(--muted); font-size: 12px; margin: 8px 0; }
/* Дубли в CRM: карточка-кнопка в шапке и список выбора. Оранжевый, а не красный: это не ошибка системы,
   а состояние данных в Битриксе, которое человек может разрешить. */
.badge.dup-crm { background: #fff4e5; color: #8a5300; border: 1px solid #f0c78a; cursor: pointer; font: inherit; font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.badge.dup-crm:hover { background: #ffe9cc; }
.badge.crm-undo { background: var(--surface-soft); color: var(--muted); border: 1px solid var(--border); cursor: pointer; font: inherit; font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.crm-card { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; }
.crm-card-main { flex: 1; min-width: 0; }
.crm-pick { flex: none; padding: 5px 14px; }

/* Подразделы форумной группы (Telegram topics): горизонтальная лента тем под шапкой диалога. */
.topic-bar { display: flex; gap: 6px; overflow-x: auto; padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--bg); flex: none; }
.topic-chip { flex: none; display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 5px 11px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.topic-chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.topic-cnt { background: var(--surface-soft); color: var(--muted); border-radius: 999px; padding: 1px 6px; font-size: 10.5px; font-weight: 700; }
.topic-chip.active .topic-cnt { background: var(--surface); color: var(--accent-strong); }

/* Автор в ГРУППЕ — фото + имя над его серией сообщений (в личных чатах не рисуется: собеседник один). */
.grp-author { align-self: flex-start; display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--accent-strong); margin: 6px 0 1px 2px; }
.grp-ava { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex: none; border: 1px solid var(--border); }
/* Инициалы, когда фото нет (приватность) — тот же приём, что в списке чатов. */
/* Ссылки в тексте сообщения: заметные, но не кричащие; ломаем длинные URL, чтобы не рвали пузырь. */
.msg-link { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; word-break: break-word; }
.msg.out .msg-link { color: inherit; text-decoration: underline; }
.grp-ava.ini { display: grid; place-items: center; background: var(--surface-soft); color: var(--accent-strong); font-size: 9px; font-weight: 700; }
.msg { max-width: 68%; padding: 9px 13px; border-radius: 14px; position: relative; box-shadow: var(--shadow-soft); }
.msg .txt { font-size: 14.5px; white-space: pre-wrap; word-wrap: break-word; }
.msg .foot { margin-top: 4px; font-size: 11px; display: flex; gap: 7px; align-items: center; }
.msg.in { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg.in .foot { color: var(--muted); }
.msg.out { align-self: flex-end; background: var(--accent-soft); border: 1px solid var(--accent-soft); border-bottom-right-radius: 5px; }
.msg.out .foot { color: var(--accent-strong); justify-content: flex-end; }
.msg .ch-tag { font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; font-size: 10px; }
.msg .ch-tag.telegram { color: var(--tg); } .msg .ch-tag.viber { color: var(--viber); } .msg .ch-tag.whatsapp { color: var(--wa); }

/* ── Пустое состояние / результаты поиска ── */
.empty { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; padding: 40px; }
.empty .big { font-size: 40px; margin-bottom: 10px; opacity: 0.6; }
.search-results { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 20px; }
.search-results h3 { margin: 0 0 12px; font-size: 15px; color: var(--muted); font-weight: 600; }
.hit { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 8px; cursor: pointer; }
.hit:hover { border-color: var(--accent); }
.hit .top { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.hit .snippet { font-size: 13.5px; color: var(--text); }
.hit mark { background: #fde68a; color: #111; border-radius: 3px; padding: 0 2px; }
.hit .kind { font-size: 10.5px; font-weight: 700; text-transform: uppercase; color: var(--muted); }

/* ── Модал мастера подключения ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 20, 17, 0.5); display: grid; place-items: center; z-index: 50; }
.modal { width: 440px; max-width: calc(100vw - 32px); background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.modal.wide { width: 900px; }
/* Подключения: один блок на сотрудника, внутри — его каналы, у каждого своя кнопка «отвязать» */
/* overflow-x: hidden — горизонтальной прокрутки быть не должно: длинные значения усекаются в самой ячейке (.conn-num) */
.conn-list { display: flex; flex-direction: column; gap: 4px; max-height: 62vh; overflow-y: auto; overflow-x: hidden; }
.conn-emp { padding: 8px 4px 10px; border-bottom: 1px solid var(--border); }
.conn-emp:last-child { border-bottom: none; }
.conn-emp-name { font-weight: 700; font-size: 14px; margin-bottom: 5px; }
.conn-chrow { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; font-size: 13px; min-width: 0; }
.conn-chrow:hover { background: var(--surface-soft); }
.conn-chrow.empty { color: var(--muted); font-style: italic; padding-left: 8px; }
.conn-chrow .conn-ch { white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.conn-chrow .conn-ch .ch-ico { width: 15px; height: 15px; }
.conn-chrow .conn-num { font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
.conn-chrow .conn-ch { flex: none; }
.conn-chrow .conn-sp { flex: 1 1 auto; }
.conn-st { font-weight: 600; white-space: nowrap; }
.conn-st.ok { color: #12a150; } .conn-st.bad { color: var(--danger); } .conn-st.warn { color: #b8860b; } .conn-st.off { color: var(--muted); }
.conn-unlink { flex: none; border: 1px solid var(--border-strong); background: var(--surface); color: var(--danger); border-radius: 8px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.conn-unlink:hover { background: var(--danger-soft); border-color: var(--danger); }
.conn-unlink:disabled { opacity: .6; cursor: default; }
.acc-links { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.acc-links .button-ghost { width: 100%; text-align: left; }
/* Редактор папки: название + пикер эмодзи */
.fedit-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.fedit-ico { flex: none; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; font-size: 24px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 11px; }
.fedit-row input { flex: 1; }
.fedit-label { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; max-height: 200px; overflow-y: auto; }
.emoji-cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 20px; border: 1px solid transparent; background: var(--surface-soft); border-radius: 9px; cursor: pointer; }
.emoji-cell:hover { background: var(--accent-soft); }
.emoji-cell.sel { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }
.fed-del { border: 1px solid var(--border-strong); background: var(--surface); color: var(--danger); border-radius: 9px; padding: 8px 14px; font-size: 13px; cursor: pointer; }
.fed-del:hover { background: var(--danger-soft); border-color: var(--danger); }
.modal .mhead { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal .mhead h3 { margin: 0; font-size: 17px; }
.modal .mbody { padding: 22px; }
.modal .steps { display: flex; gap: 6px; margin-bottom: 20px; }
.modal .steps .s { flex: 1; height: 4px; border-radius: 3px; background: var(--border); }
.modal .steps .s.done { background: var(--accent); }
.modal label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.modal input { width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 11px 12px; font-size: 16px; letter-spacing: 0.02em; }
.modal input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal .hint { font-size: 12.5px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
.modal .mactions { margin-top: 22px; display: flex; gap: 10px; justify-content: flex-end; }
.channel-pick { display: flex; gap: 10px; margin-bottom: 18px; }
.channel-pick .cp { flex: 1; border: 1.5px solid var(--border-strong); border-radius: var(--radius); padding: 14px 10px; text-align: center; font-weight: 600; font-size: 13px; }
.channel-pick .cp.sel { border-color: var(--accent); background: var(--accent-soft); }
.channel-pick .cp .dot { width: 26px; height: 26px; border-radius: 7px; margin: 0 auto 7px; }
.done-check { width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; font-size: 32px; margin: 0 auto 16px; }

/* ── Экран входа ── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 380px; max-width: 100%; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 30px; }
.login-card .brand { justify-content: center; margin-bottom: 4px; }
.login-card p.tag { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.login-card input { width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 11px 12px; font-size: 15px; }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card .button { width: 100%; margin-top: 20px; padding: 11px; font-size: 15px; }
.login-card .err { background: var(--danger-soft); color: var(--danger); border-radius: var(--radius); padding: 9px 12px; font-size: 13px; margin-top: 14px; }
.demo-accounts { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 16px; }
.demo-accounts .t { font-size: 12px; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.demo-accounts .a { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: var(--radius); cursor: pointer; font-size: 13.5px; }
.demo-accounts .a:hover { background: var(--surface-soft); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ── Непрочитанное (read-state в localStorage; гаснет при открытии чата) ── */
.dialog .name.unread { font-weight: 800; }
.dot-new { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); display: inline-block; flex: none; }
.badge.new { background: var(--accent-soft); color: var(--accent-strong); }

/* ── Значок мессенджера у чата в списке (компактный лейбл: TG/Viber/WA) ── */
.dialog .name .ch { font-size: 9.5px; padding: 1px 5px; }

/* ── Поле ответа внизу ленты — пока НЕактивно (отправка появится позже). Приглушённое, не кликается,
      с отступом от нижнего края экрана. ── */
.composer { flex: none; background: var(--bg); border-top: 1px solid var(--border); padding: 12px 22px 22px; }
.composer-inner { display: flex; align-items: flex-end; gap: 10px; opacity: 0.6; }
.composer-input { flex: 1; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-soft); color: var(--muted); padding: 11px 12px; font: inherit; font-size: 14px; line-height: 1.4; resize: none; min-height: 46px; max-height: 46px; cursor: not-allowed; }
.composer-input::placeholder { color: var(--muted); opacity: 1; }
.composer-send { flex: none; width: 46px; height: 46px; border: none; border-radius: var(--radius); background: var(--border-strong); color: var(--muted); font-size: 17px; cursor: not-allowed; display: grid; place-items: center; }

/* ── Реакции на сообщении (эмодзи + счётчик): «палец вверх» = согласие клиента ── */
/* ── Вложения в ленте: фото/видео/голос/аудио/документ ── */
.atts { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.att-img { display: block; max-width: 280px; max-height: 320px; width: auto; height: auto; border-radius: 10px; }
.att-video { max-width: 300px; max-height: 320px; border-radius: 10px; background: #000; }
/* Видео по требованию — постер-плеер (клик качает и играет инлайн), не файл-ссылка */
.att-video-poster { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 220px; height: 130px; border: none; border-radius: 10px; cursor: pointer; color: #fff; background: linear-gradient(135deg, #2b3440, #0f141a); box-shadow: var(--shadow-soft); font: inherit; }
.att-video-poster .vp-play { font-size: 26px; width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.16); display: flex; align-items: center; justify-content: center; }
.att-video-poster .vp-cap { font-size: 12px; opacity: .92; }
.att-video-poster:hover .vp-play { background: rgba(255,255,255,.28); }
.att-video-poster.err { background: linear-gradient(135deg, #4a2b2b, #1a0f0f); cursor: default; }
.att-video-poster .vp-play.spin { animation: vpspin 1s linear infinite; }
@keyframes vpspin { to { transform: rotate(360deg); } }
.att-audio { display: flex; align-items: center; gap: 8px; }
.att-audio audio { height: 34px; max-width: 240px; }
.att-audio .dur { flex: none; font-variant-numeric: tabular-nums; }
.att-doc { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); text-decoration: none; font-size: 13px; max-width: 300px; }
a.att-doc:hover { border-color: var(--accent); color: var(--accent-strong); }
.att-doc .di { flex: none; font-size: 17px; line-height: 1; }
.att-doc .dn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.att-req { flex: none; border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent-strong); border-radius: 999px; padding: 3px 11px; font-size: 12px; font-weight: 600; cursor: pointer; }
.att-req:hover { background: var(--accent); color: #fff; }
.att-req:disabled { opacity: .6; cursor: default; }
.att-bar { flex: none; width: 90px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.att-bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.att-err { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.att-pending { font-size: 13px; color: var(--muted); padding: 6px 10px; border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--surface-soft); display: inline-block; }
.msg.deleted .txt { color: var(--muted); }
.msg.deleted { opacity: .82; }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.react { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; line-height: 1.6; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; }
.msg.out .react { background: var(--surface); }
.msg .foot .ch-ico { width: 14px; height: 14px; } /* значок канала в футере (только при нескольких каналах) — компактный */

/* ── Закрепление чатов и сообщений (личное) ── */
.pin-dlg { flex: none; border: none; background: transparent; cursor: pointer; font-size: 13px; line-height: 1; padding: 2px; border-radius: 6px; opacity: 0; filter: grayscale(1); transition: opacity .12s; }
.dialog:hover .pin-dlg { opacity: .5; }
.pin-dlg:hover { opacity: 1 !important; background: var(--surface-soft); }
.pin-dlg.on { opacity: .95; filter: none; }
.dialog.pinned { background: linear-gradient(0deg, transparent, var(--accent-soft) 400%); }
.pin-mark { font-size: 11px; opacity: .85; }
/* Закреплённые: полоса МЕЖДУ шапкой и лентой (вне прокрутки — обновления не дёргают скролл). Свёрнуто видно
   последнее + счётчик; клик разворачивает список (класс .open) */
.pinned-box { flex: none; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-soft); overflow: hidden; }
.pinned-head { display: flex; align-items: center; gap: 7px; padding: 6px 8px; cursor: pointer; }
.pinned-head:hover { background: var(--surface-soft); }
.pinned-head .pin-hl { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.pinned-head .pin-cap { font-size: 11px; color: var(--accent-strong); font-weight: 700; display: flex; align-items: center; gap: 5px; }
.pinned-head .pin-count { background: var(--accent-soft); color: var(--accent-strong); border-radius: 999px; padding: 0 6px; font-size: 10px; }
.pinned-head .pin-snip { font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-toggle { flex: none; border: none; background: transparent; cursor: pointer; font-size: 13px; color: var(--muted); padding: 2px 4px; border-radius: 6px; transition: transform .15s; }
.pinned-box.open .pin-toggle { transform: rotate(180deg); }
.pin-toggle:hover { background: var(--surface-soft); color: var(--text); }
.pinned-list { display: none; border-top: 1px solid var(--border); max-height: 240px; overflow-y: auto; padding: 4px; }
.pinned-box.open .pinned-list { display: block; }
.pinned-item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text); cursor: pointer; padding: 4px 6px; border-radius: 7px; }
.pinned-item:hover { background: var(--surface-soft); }
.pinned-item .pin-snip { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pinned-head .pin-msg, .pinned-item .pin-msg { flex: none; opacity: .5; font-size: 12px; border: none; background: transparent; cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.pinned-head .pin-msg:hover, .pinned-item .pin-msg:hover { opacity: 1; background: var(--surface-soft); }
/* NB: БЕЗ свойства order — порядок под сообщением задаёт РАЗМЕТКА (канал -> 📌 -> время). Был order:-1: он тянул
   📌 в начало флекс-строки и перебивал разметку, из-за чего перестановка в client.ts не давала эффекта. */
.msg .pin-msg { flex: none; border: none; background: transparent; cursor: pointer; font-size: 11px; line-height: 1; padding: 1px 3px; border-radius: 5px; opacity: 0; filter: grayscale(1); }
.msg:hover .pin-msg { opacity: .5; }
.msg .pin-msg:hover { opacity: 1; background: var(--surface-soft); }
.msg .pin-msg.on { opacity: .9; filter: none; }
.msg.pinned { box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-soft); }
.msg.flash { animation: pinflash 1.2s ease-out; }
@keyframes pinflash { 0% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: var(--shadow-soft); } }
/* Галочки статуса исходящего: ✓ отправлено, ✓✓ доставлено, ✓✓ синие — прочитано */
.ticks { font-size: 11px; letter-spacing: -2px; margin-left: 1px; opacity: .75; }
.ticks.read { color: #34b7f1; opacity: 1; }

/* ── Тонкая ВИДИМАЯ полоса прокрутки (как в Telegram) — списку чатов и ленте, не невидимая ── */
.dialogs, .messages, .search-results, .pane { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.dialogs::-webkit-scrollbar, .messages::-webkit-scrollbar, .search-results::-webkit-scrollbar, .pane::-webkit-scrollbar { width: 10px; height: 10px; }
.dialogs::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb, .search-results::-webkit-scrollbar-thumb, .pane::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
.dialogs:hover::-webkit-scrollbar-thumb, .messages:hover::-webkit-scrollbar-thumb { background: var(--muted); background-clip: padding-box; }
.dialogs::-webkit-scrollbar-track, .messages::-webkit-scrollbar-track { background: transparent; }
