/* ==========================================================================
   «Чат команды» (Нури 16.09.2026) — переписка сотрудников внутри CRM.
   Разметку строит team-chat.js (window.TC). Неймспейс .tc-*: панель .tc справа под шапкой,
   всплывашки о новых сообщениях .tc-pop, лайтбокс .tc-lightbox — все в <body> и получают
   токены через .tc-scope. Тёмная тема — body[data-theme="dark"].
   Пузыри нарочно синие, а не зелёные, как у клиентского WhatsApp-чата: внутренний разговор
   не спутать с перепиской с клиентом.
   ========================================================================== */

.tc-scope {
    --tc-accent: #0b5cad;
    --tc-accent-2: #074783;
    --tc-accent-soft: rgba(11, 92, 173, .08);
    --tc-accent-soft-2: rgba(11, 92, 173, .14);
    --tc-accent-line: rgba(11, 92, 173, .32);
    --tc-mine: #0b5cad;
    --tc-mine-2: #0a4f95;
    --tc-mine-text: #ffffff;
    --tc-mine-muted: rgba(255, 255, 255, .72);
    --tc-theirs: #ffffff;
    --tc-theirs-text: #0f1c2e;
    --tc-surface: #ffffff;
    --tc-surface-2: #f4f6fa;
    --tc-surface-3: #e9edf4;
    --tc-chat-bg: #eef2f8;
    --tc-line: #e1e6ee;
    --tc-line-soft: #edf0f5;
    --tc-text: #0f1c2e;
    --tc-text-2: #4a5872;
    --tc-text-3: #8591a6;
    --tc-online: #16a34a;
    --tc-danger: #d93025;
    --tc-danger-soft: rgba(217, 48, 37, .08);
    --tc-badge: #e5484d;
    --tc-org: #7c3aed;
    --tc-org-soft: rgba(124, 58, 237, .08);
    --tc-quote: #0d9488;
    --tc-quote-soft: rgba(13, 148, 136, .08);
    --tc-shadow: 0 1px 2px rgba(15, 28, 46, .05), 0 1px 3px rgba(15, 28, 46, .06);
    --tc-shadow-md: 0 10px 28px rgba(15, 28, 46, .12), 0 2px 6px rgba(15, 28, 46, .05);
    --tc-shadow-lg: 0 24px 64px rgba(15, 28, 46, .22), 0 4px 14px rgba(15, 28, 46, .08);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body[data-theme="dark"] .tc-scope {
    --tc-accent: #5aa7ff;
    --tc-accent-2: #86c0ff;
    --tc-accent-soft: rgba(90, 167, 255, .10);
    --tc-accent-soft-2: rgba(90, 167, 255, .18);
    --tc-accent-line: rgba(90, 167, 255, .40);
    --tc-mine: #1f64b8;
    --tc-mine-2: #1a579f;
    --tc-mine-text: #f2f7ff;
    --tc-mine-muted: rgba(242, 247, 255, .66);
    --tc-theirs: #1b2536;
    --tc-theirs-text: #e7ecf4;
    --tc-surface: #141d2b;
    --tc-surface-2: #182233;
    --tc-surface-3: #212d40;
    --tc-chat-bg: #0f1724;
    --tc-line: #253247;
    --tc-line-soft: #1e2a3b;
    --tc-text: #e7ecf4;
    --tc-text-2: #a9b4c7;
    --tc-text-3: #76839b;
    --tc-online: #34d399;
    --tc-danger: #f87171;
    --tc-danger-soft: rgba(248, 113, 113, .12);
    --tc-badge: #f0555a;
    --tc-org: #b69dfb;
    --tc-org-soft: rgba(167, 139, 250, .14);
    --tc-quote: #4fd1c5;
    --tc-quote-soft: rgba(79, 209, 197, .12);
    --tc-shadow: 0 1px 2px rgba(0, 0, 0, .35);
    --tc-shadow-md: 0 12px 30px rgba(0, 0, 0, .42);
    --tc-shadow-lg: 0 28px 72px rgba(0, 0, 0, .6);
}

.tc-scope *, .tc-scope *::before, .tc-scope *::after { box-sizing: border-box; }
.tc-scope button { font-family: inherit; }
.tc-scope [hidden] { display: none !important; }
.tc-ic { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; line-height: 0; }
.tc-ic svg { width: 100%; height: 100%; display: block; }

/* ------------------------------------------------------------ кнопка в шапке CRM */
/* Кнопки входа видны только сотрудникам — TC.init() ставит body.tc-enabled */
.tc-hbtn { display: none; }
body.tc-enabled .tc-hbtn { display: inline-flex; }
.tc-hbtn {
    position: relative;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 32px;
    border: 1px solid var(--border-color);
    background: var(--bg-color, #f3f4f6);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.tc-hbtn:hover { color: var(--text-color); }
.tc-hbtn.is-open {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
    box-shadow: 0 1px 4px rgba(7, 71, 131, .25);
}
.tc-hbtn .tc-ic { width: 18px; height: 18px; }
.tc-hbtn-badge {
    position: absolute;
    top: -7px;
    right: -8px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #e5484d;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    border: 2px solid var(--header-bg, #fff);
    box-sizing: content-box;
    pointer-events: none;
}
.tc-hbtn-badge.pulse { animation: tc-badge-pop .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes tc-badge-pop { 0% { transform: scale(.4); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* Та же кнопка в полосе «Продаж», когда шапка CRM свёрнута */
#salesTab .adv-subtab.tc-sales-btn { display: none; position: relative; align-items: center; gap: 6px; }
body.tc-enabled.sales-hdr-collapsed #salesTab .adv-subtab.tc-sales-btn { display: inline-flex; }
.adv-subtab.tc-sales-btn .tc-ic { width: 16px; height: 16px; }
.adv-subtab.tc-sales-btn .tc-hbtn-badge { position: static; border: none; box-sizing: border-box; }

/* ------------------------------------------------------------ панель */
.tc {
    position: fixed;
    top: 56px;
    right: 12px;
    bottom: 12px;
    width: 404px;
    max-width: calc(100vw - 24px);
    z-index: 9000;
    display: flex;
    flex-direction: column;
    background: var(--tc-surface);
    color: var(--tc-text);
    border: 1px solid var(--tc-line);
    border-radius: 16px;
    box-shadow: var(--tc-shadow-lg);
    overflow: hidden;
    font-size: 14px;
    line-height: 1.45;
    transform-origin: top right;
    animation: tc-in .2s cubic-bezier(.2, .9, .3, 1);
}
.tc[hidden] { display: none !important; }
body.sales-hdr-collapsed .tc { top: 10px; }
.tc.is-wide { width: 900px; }
.tc.is-closing { animation: tc-out .14s ease forwards; }
@keyframes tc-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes tc-out { to { opacity: 0; transform: translateY(-6px) scale(.98); } }

.tc-body { flex: 1; min-height: 0; display: flex; position: relative; }
.tc-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--tc-surface); }
.tc-list-pane { flex: 1; }
.tc-conv-pane { flex: 1; display: none; }
.tc.show-conv .tc-list-pane { display: none; }
.tc.show-conv .tc-conv-pane { display: flex; animation: tc-slide .18s ease; }
@keyframes tc-slide { from { opacity: .4; transform: translateX(14px); } to { opacity: 1; transform: none; } }

.tc.is-wide .tc-list-pane { display: flex; flex: 0 0 312px; border-right: 1px solid var(--tc-line); }
.tc.is-wide .tc-conv-pane { display: flex; animation: none; }
.tc.is-wide .tc-back,
.tc.is-wide .tc-chead-acts { display: none; }

/* ------------------------------------------------------------ шапки */
.tc-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px 10px 16px;
    min-height: 60px;
    border-bottom: 1px solid var(--tc-line-soft);
}
.tc-head-title { flex: 1; min-width: 0; }
.tc-head-title b { display: block; font-size: 15px; font-weight: 700; letter-spacing: -.1px; }
.tc-head-title span { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--tc-text-3); }
.tc-head-title span i { width: 7px; height: 7px; border-radius: 50%; background: var(--tc-online); display: inline-block; }

.tc-iconbtn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--tc-text-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}
.tc-iconbtn:hover { background: var(--tc-surface-3); color: var(--tc-text); }
.tc-iconbtn:disabled { opacity: .45; cursor: default; background: transparent; }
.tc-iconbtn .tc-ic { width: 19px; height: 19px; }
.tc-iconbtn.is-on { color: var(--tc-accent); background: var(--tc-accent-soft); }

.tc-search {
    margin: 10px 12px 6px;
    position: relative;
}
.tc-search .tc-ic { position: absolute; left: 11px; top: 50%; width: 17px; height: 17px; margin-top: -8.5px; color: var(--tc-text-3); pointer-events: none; }
.tc-search input {
    width: 100%;
    height: 38px;
    border-radius: 11px;
    border: 1px solid transparent;
    background: var(--tc-surface-2);
    color: var(--tc-text);
    padding: 0 12px 0 36px;
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.tc-search input::placeholder { color: var(--tc-text-3); }
.tc-search input:focus { border-color: var(--tc-accent-line); background: var(--tc-surface); box-shadow: 0 0 0 3px var(--tc-accent-soft); }

/* Баннер «обсудить клиента — выберите коллегу» */
.tc-ctx {
    margin: 6px 12px 4px;
    padding: 10px 10px 10px 12px;
    border-radius: 12px;
    background: var(--tc-org-soft);
    border: 1px solid color-mix(in srgb, var(--tc-org) 26%, transparent);
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 12.5px;
    color: var(--tc-text-2);
    animation: tc-in .18s ease;
}
.tc-ctx > .tc-ic { width: 18px; height: 18px; color: var(--tc-org); margin-top: 1px; }
.tc-ctx-main { flex: 1; min-width: 0; }
.tc-ctx-main b { color: var(--tc-text); font-weight: 600; }
.tc-ctx-main div + div { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-ctx .tc-iconbtn { width: 26px; height: 26px; border-radius: 8px; }
.tc-ctx .tc-iconbtn .tc-ic { width: 15px; height: 15px; }

/* ------------------------------------------------------------ список коллег */
.tc-list { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 6px 10px; scrollbar-width: thin; }
.tc-sec {
    padding: 12px 10px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: var(--tc-text-3);
}
.tc-row {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    transition: background .12s;
    user-select: none;
}
.tc-row:hover { background: var(--tc-surface-2); }
.tc-row.is-active { background: var(--tc-accent-soft-2); }
.tc-row.is-kbd { box-shadow: inset 0 0 0 2px var(--tc-accent-line); }
.tc-row-main { flex: 1; min-width: 0; }
.tc-row-top { display: flex; align-items: baseline; gap: 8px; }
.tc-row-name { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; color: var(--tc-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-row-time { font-size: 11.5px; color: var(--tc-text-3); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.tc-row.has-unread .tc-row-time { color: var(--tc-accent); font-weight: 600; }
.tc-row-bottom { display: flex; align-items: center; gap: 8px; margin-top: 1px; }
.tc-row-prev { flex: 1; min-width: 0; font-size: 13px; color: var(--tc-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-row-prev em { font-style: normal; color: var(--tc-text-3); }
.tc-row-prev .tc-typing-txt { color: var(--tc-accent); }
.tc-row-prev .tc-ic { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; display: inline-flex; }
.tc-row.has-unread .tc-row-prev { color: var(--tc-text); }
.tc-row-role { font-size: 12.5px; color: var(--tc-text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-unread {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--tc-accent);
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    flex-shrink: 0;
}
body[data-theme="dark"] .tc-unread { color: #06121f; }
.tc-row-off { opacity: .6; }
.tc-empty-list { padding: 30px 20px; text-align: center; color: var(--tc-text-3); font-size: 13px; }

/* аватар */
.tc-ava {
    position: relative;
    flex-shrink: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    letter-spacing: .2px;
    background: var(--ava, #64748b);
    background-image: linear-gradient(145deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, 0) 60%);
}
.tc-ava i {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 30%;
    height: 30%;
    min-width: 10px;
    min-height: 10px;
    border-radius: 50%;
    background: var(--tc-online);
    border: 2px solid var(--tc-surface);
}
.tc-row:hover .tc-ava i { border-color: var(--tc-surface-2); }
.tc-row.is-active .tc-ava i { border-color: color-mix(in srgb, var(--tc-accent) 14%, var(--tc-surface)); }

/* ------------------------------------------------------------ диалог */
.tc-chead {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px 10px 8px;
    min-height: 60px;
    border-bottom: 1px solid var(--tc-line-soft);
    background: var(--tc-surface);
}
.tc.is-wide .tc-chead { padding-left: 16px; }
.tc-chead-who { flex: 1; min-width: 0; }
.tc-chead-name { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-chead-status { font-size: 12px; color: var(--tc-text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-chead-status.is-online { color: var(--tc-online); }
.tc-chead-status.is-typing { color: var(--tc-accent); }

.tc-msgs-wrap { flex: 1; min-height: 0; position: relative; background: var(--tc-chat-bg); }
.tc-msgs {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    padding: 12px 14px 8px;
    scrollbar-width: thin;
    overscroll-behavior: contain;
}
.tc-older { text-align: center; padding: 4px 0 10px; font-size: 12px; color: var(--tc-text-3); }
.tc-day { display: flex; justify-content: center; margin: 12px 0 8px; pointer-events: none; }
.tc-day span {
    padding: 3px 11px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--tc-surface) 88%, transparent);
    backdrop-filter: blur(6px);
    color: var(--tc-text-2);
    font-size: 11.5px;
    font-weight: 600;
    box-shadow: var(--tc-shadow);
}
.tc-unread-sep { display: flex; align-items: center; gap: 10px; margin: 12px 0 10px; color: var(--tc-accent); font-size: 11.5px; font-weight: 700; letter-spacing: .3px; }
.tc-unread-sep::before, .tc-unread-sep::after { content: ''; flex: 1; height: 1px; background: var(--tc-accent-line); }

.tc-m { display: flex; align-items: flex-end; gap: 6px; margin-top: 8px; position: relative; }
.tc-m.is-cont { margin-top: 2px; }
.tc-m.me { justify-content: flex-end; }
.tc-m.is-flash .tc-b { animation: tc-flash 1.4s ease; }
@keyframes tc-flash { 0%, 40% { box-shadow: 0 0 0 3px var(--tc-accent-line); } 100% { box-shadow: none; } }

.tc-b {
    position: relative;
    max-width: min(78%, 520px);
    padding: 7px 10px 6px;
    border-radius: 16px;
    background: var(--tc-theirs);
    color: var(--tc-theirs-text);
    box-shadow: var(--tc-shadow);
    word-wrap: break-word;
    overflow-wrap: anywhere;
    min-width: 64px;
}
.tc-m:not(.me) .tc-b { border-bottom-left-radius: 5px; }
.tc-m:not(.me).is-cont-next .tc-b { border-bottom-left-radius: 16px; }
.tc-m:not(.me).is-cont .tc-b { border-top-left-radius: 5px; }
.tc-m.me .tc-b {
    background: linear-gradient(180deg, var(--tc-mine), var(--tc-mine-2));
    color: var(--tc-mine-text);
    border-bottom-right-radius: 5px;
}
.tc-m.me.is-cont-next .tc-b { border-bottom-right-radius: 16px; }
.tc-m.me.is-cont .tc-b { border-top-right-radius: 5px; }
.tc-b.is-media-only { padding: 3px 3px 4px; }
/* Картинки и видео тянутся на ширину пузыря — задаём её явно, иначе он сжимается до min-width */
.tc-b.has-imgs, .tc-b.has-media { width: min(78%, 340px); }
.tc-b.is-pending { opacity: .78; }
.tc-b.is-failed { box-shadow: 0 0 0 2px var(--tc-danger); }

.tc-b-text { white-space: pre-wrap; font-size: 14px; line-height: 1.42; }
.tc-b-text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.tc-m:not(.me) .tc-b-text a { color: var(--tc-accent); }
.tc-b-text .tc-emoji-big { font-size: 30px; line-height: 1.2; }
.tc-b-meta {
    float: right;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin: 6px 0 -3px 10px;
    font-size: 11px;
    line-height: 1;
    color: var(--tc-text-3);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    user-select: none;
}
.tc-m.me .tc-b-meta { color: var(--tc-mine-muted); }
.tc-b-meta .tc-ic { width: 16px; height: 16px; }
.tc-b-meta .tc-tick-read { color: #7dd3fc; }
.tc-m:not(.me) .tc-b-meta .tc-tick-read { color: var(--tc-accent); }
.tc-b::after { content: ''; display: block; clear: both; }
.tc-b.is-media-only .tc-b-meta {
    position: absolute;
    right: 8px;
    bottom: 8px;
    margin: 0;
    padding: 3px 7px;
    border-radius: 10px;
    background: rgba(8, 15, 26, .55);
    color: #fff;
}
.tc-b.is-deleted { background: transparent; box-shadow: inset 0 0 0 1px var(--tc-line); color: var(--tc-text-3); }
.tc-m.me .tc-b.is-deleted { background: transparent; color: var(--tc-text-3); }
.tc-m.me .tc-b.is-deleted .tc-b-meta { color: var(--tc-text-3); }
.tc-b.is-deleted .tc-b-text { font-style: italic; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.tc-b.is-deleted .tc-b-text .tc-ic { width: 15px; height: 15px; }
.tc-edited { font-style: italic; margin-right: 2px; }

/* цитата ответа */
.tc-b-reply {
    display: block;
    margin: 1px 0 6px;
    padding: 5px 9px 5px 9px;
    border-radius: 9px;
    border-left: 3px solid var(--tc-accent);
    background: var(--tc-accent-soft);
    cursor: pointer;
    font-size: 12.5px;
    max-width: 100%;
    text-align: left;
    width: 100%;
    color: inherit;
    border-top: 0; border-right: 0; border-bottom: 0;
}
.tc-m.me .tc-b-reply { background: rgba(255, 255, 255, .14); border-left-color: rgba(255, 255, 255, .8); }
.tc-b-reply b { display: block; font-weight: 600; color: var(--tc-accent); font-size: 12px; }
.tc-m.me .tc-b-reply b { color: #fff; }
.tc-b-reply span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }

/* карточка клиента в сообщении — под текстом, как превью ссылки */
.tc-org {
    margin: 7px 0 3px;
    padding: 9px 9px 8px 10px;
    border-radius: 12px;
    background: var(--tc-surface-2);
    border: 1px solid var(--tc-line);
    color: var(--tc-text);
    min-width: 236px;
}
.tc-b-text + .tc-org { margin-top: 7px; }
.tc-m.me .tc-org { background: rgba(255, 255, 255, .97); border-color: transparent; color: #0f1c2e; }
body[data-theme="dark"] .tc-m.me .tc-org { background: rgba(8, 18, 32, .42); color: #e7ecf4; }
.tc-org-top { display: flex; align-items: flex-start; gap: 10px; }
.tc-org-ico {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--tc-org-soft);
    color: var(--tc-org);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tc-m.me .tc-org-ico { background: rgba(124, 58, 237, .1); color: #7c3aed; }
body[data-theme="dark"] .tc-m.me .tc-org-ico { background: rgba(167, 139, 250, .16); color: #c4b5fd; }
.tc-org-ico .tc-ic { width: 19px; height: 19px; }
.tc-org-main { flex: 1; min-width: 0; }
.tc-org-cap { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--tc-org); line-height: 1.3; }
.tc-m.me .tc-org-cap { color: #7c3aed; }
body[data-theme="dark"] .tc-m.me .tc-org-cap { color: #c4b5fd; }
.tc-org-name { font-weight: 650; font-size: 13.5px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.tc-org-inn { font-size: 12px; opacity: .72; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.tc-org-inn em { font-style: normal; color: var(--tc-danger); opacity: 1; }
.tc-org-acts { display: flex; gap: 6px; margin-top: 8px; }
.tc-org-btn {
    flex: 1;
    height: 28px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--tc-line);
    background: var(--tc-surface);
    color: var(--tc-text-2);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    transition: background .12s, color .12s, border-color .12s;
}
.tc-org-btn .tc-ic { width: 15px; height: 15px; }
.tc-org-btn:hover { color: var(--tc-accent); border-color: var(--tc-accent-line); background: var(--tc-accent-soft); }
.tc-m.me .tc-org-btn { background: #f4f6fa; color: #334155; border-color: #e2e8f0; }
.tc-m.me .tc-org-btn:hover { color: #0b5cad; border-color: rgba(11, 92, 173, .32); background: rgba(11, 92, 173, .08); }
body[data-theme="dark"] .tc-m.me .tc-org-btn { background: rgba(255, 255, 255, .06); color: #cbd5e1; border-color: rgba(255, 255, 255, .12); }

/* цитата сообщения клиента */
.tc-cq {
    display: block;
    margin: 2px 0 6px;
    padding: 7px 10px 8px;
    border-radius: 11px;
    background: var(--tc-quote-soft);
    border-left: 3px solid var(--tc-quote);
    cursor: pointer;
    color: inherit;
    text-align: left;
    width: 100%;
    border-top: 0; border-right: 0; border-bottom: 0;
    font: inherit;
}
.tc-m.me .tc-cq { background: rgba(255, 255, 255, .15); border-left-color: #99f6e4; }
.tc-cq-cap { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; color: var(--tc-quote); letter-spacing: .2px; }
.tc-m.me .tc-cq-cap { color: #ccfbf1; }
.tc-cq-cap .tc-ic { width: 13px; height: 13px; }
.tc-cq-text { font-size: 13px; line-height: 1.4; white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; margin-top: 2px; }
.tc-cq-sub { font-size: 11px; opacity: .7; margin-top: 3px; }

/* вложения */
.tc-imgs { display: grid; gap: 3px; margin: 0 0 4px; border-radius: 13px; overflow: hidden; }
.tc-imgs.n1 { grid-template-columns: 1fr; }
.tc-imgs.n2, .tc-imgs.n4 { grid-template-columns: 1fr 1fr; }
.tc-imgs.n3, .tc-imgs.nmany { grid-template-columns: 1fr 1fr 1fr; }
.tc-img {
    display: block;
    border: 0;
    padding: 0;
    background: var(--tc-surface-3);
    cursor: zoom-in;
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
}
.tc-imgs.n1 .tc-img { aspect-ratio: auto; max-height: 300px; min-height: 90px; }
.tc-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tc-imgs.n1 .tc-img img { max-height: 300px; object-fit: contain; background: var(--tc-surface-3); }
.tc-files { display: flex; flex-direction: column; gap: 4px; margin: 1px 0 4px; }
.tc-file {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px 7px 7px;
    border-radius: 11px;
    background: var(--tc-surface-2);
    color: inherit;
    text-decoration: none;
    min-width: 200px;
    transition: background .12s;
}
.tc-file:hover { background: var(--tc-surface-3); }
.tc-m.me .tc-file { background: rgba(255, 255, 255, .14); }
.tc-m.me .tc-file:hover { background: rgba(255, 255, 255, .22); }
.tc-file-ico {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: var(--tc-accent-soft-2);
    color: var(--tc-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: .3px;
}
.tc-m.me .tc-file-ico { background: rgba(255, 255, 255, .92); color: var(--tc-mine); }
.tc-file-main { flex: 1; min-width: 0; }
.tc-file-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-file-size { font-size: 11.5px; opacity: .7; }
.tc-file > .tc-ic { width: 18px; height: 18px; opacity: .7; }
.tc-media { display: block; max-width: 100%; border-radius: 10px; margin: 2px 0 4px; }
audio.tc-media { width: 260px; height: 36px; }

/* повтор неотправленного */
.tc-fail { display: flex; justify-content: flex-end; gap: 10px; margin: 3px 2px 0; font-size: 12px; color: var(--tc-danger); }
.tc-fail button { border: 0; background: none; color: var(--tc-accent); font-weight: 600; cursor: pointer; padding: 0; font-size: 12px; }

/* действия у сообщения */
.tc-tools {
    display: flex;
    align-items: center;
    gap: 1px;
    padding: 2px;
    border-radius: 10px;
    background: var(--tc-surface);
    box-shadow: var(--tc-shadow-md);
    border: 1px solid var(--tc-line-soft);
    opacity: 0;
    pointer-events: none;
    transform: translateY(2px);
    transition: opacity .12s, transform .12s;
    align-self: center;
}
.tc-m:hover .tc-tools, .tc-tools:focus-within { opacity: 1; pointer-events: auto; transform: none; }
.tc-m.me .tc-tools { order: -1; }
.tc-tools button {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--tc-text-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.tc-tools button:hover { background: var(--tc-surface-3); color: var(--tc-text); }
.tc-tools button.is-danger:hover { background: var(--tc-danger-soft); color: var(--tc-danger); }
.tc-tools .tc-ic { width: 16px; height: 16px; }

/* «печатает…» */
.tc-typing { display: flex; align-items: center; gap: 8px; margin: 8px 0 2px; font-size: 12px; color: var(--tc-text-3); }
.tc-typing-dots { display: inline-flex; gap: 3px; padding: 9px 11px; border-radius: 14px; border-bottom-left-radius: 5px; background: var(--tc-theirs); box-shadow: var(--tc-shadow); }
.tc-typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--tc-text-3); animation: tc-dot 1.2s infinite ease-in-out; }
.tc-typing-dots i:nth-child(2) { animation-delay: .15s; }
.tc-typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes tc-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }

/* пустые состояния */
.tc-void {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 30px 34px;
    color: var(--tc-text-3);
    gap: 10px;
    font-size: 13px;
}
.tc-void-ico {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: var(--tc-surface);
    color: var(--tc-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--tc-shadow-md);
    margin-bottom: 4px;
}
.tc-void-ico .tc-ic { width: 30px; height: 30px; }
.tc-void b { color: var(--tc-text); font-size: 14.5px; font-weight: 700; }
.tc-void-tips { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; text-align: left; }
.tc-void-tips div { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--tc-text-2); }
.tc-void-tips .tc-ic { width: 16px; height: 16px; color: var(--tc-accent); }

.tc-down {
    position: absolute;
    right: 14px;
    bottom: 12px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--tc-line);
    background: var(--tc-surface);
    color: var(--tc-text-2);
    box-shadow: var(--tc-shadow-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3;
    animation: tc-in .15s ease;
}
.tc-down .tc-ic { width: 18px; height: 18px; }
.tc-down b {
    position: absolute;
    top: -6px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--tc-accent);
    color: #fff;
    font-size: 10.5px;
    line-height: 18px;
    text-align: center;
}

.tc-drop {
    position: absolute;
    inset: 8px;
    border-radius: 14px;
    border: 2px dashed var(--tc-accent);
    background: color-mix(in srgb, var(--tc-surface) 86%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    color: var(--tc-accent);
    font-weight: 600;
    z-index: 5;
    pointer-events: none;
}
.tc-drop .tc-ic { width: 32px; height: 32px; }

/* ------------------------------------------------------------ композер */
.tc-comp { border-top: 1px solid var(--tc-line-soft); background: var(--tc-surface); padding: 8px 10px 10px; position: relative; }
.tc-bar {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 2px 8px;
    padding: 6px 6px 6px 10px;
    border-radius: 10px;
    background: var(--tc-surface-2);
    border-left: 3px solid var(--tc-accent);
    animation: tc-in .14s ease;
}
.tc-bar > .tc-ic { width: 17px; height: 17px; color: var(--tc-accent); }
.tc-bar-main { flex: 1; min-width: 0; font-size: 12.5px; }
.tc-bar-main b { display: block; color: var(--tc-accent); font-weight: 600; font-size: 12px; }
.tc-bar-main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tc-text-2); }
.tc-bar .tc-iconbtn { width: 26px; height: 26px; border-radius: 8px; }
.tc-bar .tc-iconbtn .tc-ic { width: 15px; height: 15px; }

.tc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 2px 8px; }
.tc-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 100%;
    height: 32px;
    padding: 0 4px 0 9px;
    border-radius: 10px;
    background: var(--tc-surface-2);
    border: 1px solid var(--tc-line);
    font-size: 12.5px;
    color: var(--tc-text);
    animation: tc-in .14s ease;
}
.tc-chip > .tc-ic { width: 16px; height: 16px; color: var(--tc-text-2); }
.tc-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 230px; }
.tc-chip small { color: var(--tc-text-3); font-size: 11.5px; white-space: nowrap; }
.tc-chip button { width: 24px; height: 24px; border: 0; border-radius: 7px; background: transparent; color: var(--tc-text-3); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.tc-chip button:hover { background: var(--tc-surface-3); color: var(--tc-text); }
.tc-chip button .tc-ic { width: 14px; height: 14px; }
.tc-chip.is-org { background: var(--tc-org-soft); border-color: color-mix(in srgb, var(--tc-org) 28%, transparent); }
.tc-chip.is-org > .tc-ic { color: var(--tc-org); }
.tc-chip.is-quote { background: var(--tc-quote-soft); border-color: color-mix(in srgb, var(--tc-quote) 30%, transparent); }
.tc-chip.is-quote > .tc-ic { color: var(--tc-quote); }
.tc-chip.is-img { padding-left: 3px; }
.tc-chip.is-img img { width: 26px; height: 26px; border-radius: 7px; object-fit: cover; }
.tc-chip.is-error { border-color: var(--tc-danger); background: var(--tc-danger-soft); }
.tc-chip.is-error small { color: var(--tc-danger); }
.tc-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--tc-accent-soft-2); border-top-color: var(--tc-accent); animation: tc-rot .8s linear infinite; flex-shrink: 0; }
@keyframes tc-rot { to { transform: rotate(360deg); } }

.tc-comp-row {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    padding: 4px 4px 4px 4px;
    border-radius: 14px;
    border: 1px solid var(--tc-line);
    background: var(--tc-surface-2);
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.tc-comp-row:focus-within { border-color: var(--tc-accent-line); background: var(--tc-surface); box-shadow: 0 0 0 3px var(--tc-accent-soft); }
.tc-comp-row .tc-iconbtn { width: 34px; height: 34px; color: var(--tc-text-3); }
.tc-comp-row .tc-iconbtn:hover { color: var(--tc-accent); background: var(--tc-accent-soft); }
.tc-input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    resize: none;
    background: transparent;
    color: var(--tc-text);
    font: inherit;
    font-size: 14px;
    line-height: 20px;
    padding: 7px 6px;
    max-height: 168px;
    min-height: 34px;
    scrollbar-width: thin;
}
.tc-input::placeholder { color: var(--tc-text-3); }
.tc-send {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    border: 0;
    background: var(--tc-accent);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform .1s, opacity .15s, background .15s;
}
body[data-theme="dark"] .tc-send { color: #06121f; }
.tc-send:hover { background: var(--tc-accent-2); }
.tc-send:active { transform: scale(.92); }
.tc-send:disabled { opacity: .35; cursor: default; transform: none; background: var(--tc-accent); }
.tc-send .tc-ic { width: 18px; height: 18px; }
.tc-comp-hint { margin: 6px 4px 0; font-size: 11px; color: var(--tc-text-3); display: flex; justify-content: space-between; gap: 8px; }
.tc-comp-hint kbd { font-family: inherit; font-size: 10.5px; padding: 0 4px; border-radius: 4px; border: 1px solid var(--tc-line); background: var(--tc-surface-2); }
.tc-comp-off { padding: 12px; text-align: center; font-size: 13px; color: var(--tc-text-3); }

/* ------------------------------------------------------------ выбор клиента */
.tc-pick {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: calc(100% + 6px);
    max-height: 360px;
    display: flex;
    flex-direction: column;
    background: var(--tc-surface);
    border: 1px solid var(--tc-line);
    border-radius: 14px;
    box-shadow: var(--tc-shadow-lg);
    overflow: hidden;
    z-index: 10;
    animation: tc-in .15s ease;
}
.tc-pick-head { padding: 10px 10px 6px; }
.tc-pick-head .tc-search { margin: 0; }
.tc-pick-cap { padding: 6px 14px 2px; font-size: 10.5px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--tc-text-3); }
.tc-pick-list { overflow-y: auto; padding: 2px 6px 8px; scrollbar-width: thin; }
.tc-pick-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--tc-text);
    cursor: pointer;
    text-align: left;
}
.tc-pick-row:hover, .tc-pick-row.is-kbd { background: var(--tc-surface-2); }
.tc-pick-row .tc-org-ico { width: 30px; height: 30px; border-radius: 9px; }
.tc-pick-row .tc-org-ico .tc-ic { width: 16px; height: 16px; }
.tc-pick-main { flex: 1; min-width: 0; }
.tc-pick-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-pick-sub { font-size: 12px; color: var(--tc-text-3); font-variant-numeric: tabular-nums; }
.tc-pick-sub em { font-style: normal; color: var(--tc-danger); }
.tc-pick-empty { padding: 18px 14px 20px; text-align: center; font-size: 12.5px; color: var(--tc-text-3); }

/* ------------------------------------------------------------ всплывашка о новом сообщении */
.tc-pops {
    position: fixed;
    top: 58px;
    right: 14px;
    z-index: 9500;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 340px;
    max-width: calc(100vw - 28px);
    pointer-events: none;
}
body.sales-hdr-collapsed .tc-pops { top: 12px; }
.tc-pop {
    pointer-events: auto;
    display: flex;
    gap: 11px;
    padding: 12px 10px 12px 12px;
    border-radius: 14px;
    background: var(--tc-surface);
    color: var(--tc-text);
    border: 1px solid var(--tc-line);
    box-shadow: var(--tc-shadow-lg);
    cursor: pointer;
    animation: tc-pop-in .28s cubic-bezier(.2, 1.2, .4, 1);
    position: relative;
    overflow: hidden;
}
.tc-pop::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--tc-accent); }
.tc-pop.is-out { animation: tc-pop-out .2s ease forwards; }
@keyframes tc-pop-in { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
@keyframes tc-pop-out { to { opacity: 0; transform: translateX(30px); } }
.tc-pop-main { flex: 1; min-width: 0; }
.tc-pop-top { display: flex; align-items: baseline; gap: 6px; }
.tc-pop-top b { flex: 1; min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-pop-top small { font-size: 11px; color: var(--tc-text-3); flex-shrink: 0; }
.tc-pop-cap { font-size: 11px; color: var(--tc-text-3); margin-top: -1px; }
.tc-pop-text { font-size: 13px; color: var(--tc-text-2); margin-top: 3px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; white-space: pre-wrap; word-break: break-word; }
.tc-pop-org { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; padding: 2px 8px 2px 6px; border-radius: 8px; background: var(--tc-org-soft); color: var(--tc-org); font-size: 11.5px; font-weight: 600; max-width: 100%; }
.tc-pop-org .tc-ic { width: 13px; height: 13px; }
.tc-pop-org span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-pop-acts { display: flex; gap: 6px; margin-top: 9px; }
.tc-pop-btn { height: 28px; padding: 0 12px; border-radius: 8px; border: 0; background: var(--tc-accent); color: #fff; font-size: 12.5px; font-weight: 600; cursor: pointer; }
body[data-theme="dark"] .tc-pop-btn { color: #06121f; }
.tc-pop-btn.is-ghost { background: var(--tc-surface-2); color: var(--tc-text-2); }
.tc-pop .tc-iconbtn { width: 26px; height: 26px; border-radius: 8px; margin: -4px -2px 0 0; }
.tc-pop .tc-iconbtn .tc-ic { width: 14px; height: 14px; }

/* ------------------------------------------------------------ лайтбокс */
.tc-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9800;
    background: rgba(6, 12, 22, .86);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 56px 24px 24px;
    animation: tc-in .15s ease;
    cursor: zoom-out;
}
.tc-lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); cursor: default; }
.tc-lightbox-bar { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; }
.tc-lightbox-bar a, .tc-lightbox-bar button {
    height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    border: 0;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
}
.tc-lightbox-bar a:hover, .tc-lightbox-bar button:hover { background: rgba(255, 255, 255, .22); }
.tc-lightbox-bar .tc-ic { width: 17px; height: 17px; }

/* ------------------------------------------------------------ вход из чата клиента и карточки */
.chat-bubble-discuss {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
    margin-right: 5px;
    line-height: 0;
    cursor: pointer;
    vertical-align: middle;
    opacity: 0;
    color: var(--wa-muted, #667781);
    transition: opacity .15s, color .15s, transform .1s;
}
.chat-bubble:hover .chat-bubble-discuss { opacity: .55; }
.chat-bubble-discuss:hover { opacity: 1 !important; color: #0b5cad; }
.chat-bubble-discuss:active { transform: scale(.82); }
.chat-bubble-discuss svg { width: 14px; height: 14px; display: block; }
body[data-theme="dark"] .chat-bubble-discuss { color: rgba(233, 237, 239, .6); }
body[data-theme="dark"] .chat-bubble-discuss:hover { color: #5aa7ff; }
/* Кнопка «Обсудить с коллегой» в шапке клиентского чата: на экранах уже 1600px шапка и так
   тесная — там остаются кнопки у пузырей и подсказка «Открыт сейчас» в выборе клиента */
@media (max-width: 1599px) { .chat-header-tools .tc-chat-discuss { display: none; } }
.btn-audit-edit.tc-audit-btn { display: none; align-items: center; gap: 6px; }
body.tc-enabled .btn-audit-edit.tc-audit-btn { display: inline-flex; }
.btn-audit-edit.tc-audit-btn svg { width: 16px; height: 16px; }

@media (max-width: 720px) {
    .tc, .tc.is-wide { left: 8px; right: 8px; width: auto; top: 54px; bottom: 8px; }
    .tc.is-wide .tc-list-pane { display: none; }
    .tc.is-wide:not(.show-conv) .tc-list-pane { display: flex; flex: 1; border-right: 0; }
    .tc.is-wide:not(.show-conv) .tc-conv-pane { display: none; }
    .tc.is-wide .tc-back { display: inline-flex; }
    .tc-pops { top: auto; bottom: 12px; }
}
