/* Задача №786. Единый вид сообщений чата (ПК и мобильный кабинет) */
.cu-thread {
    --cu-bg: #f6f8fb; --cu-card: #ffffff; --cu-line: #e2e8f0; --cu-ink: #1f2937; --cu-soft: #6b7280;
    --cu-mine: #e3efff; --cu-mine-line: #bcd4f7; --cu-accent: #2563eb; --cu-danger: #dc2626; --cu-ok: #15803d;
    --cu-warn-bg: #fff7e0; --cu-warn-line: #f2d98a;
    overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px; scroll-behavior: auto;
    -webkit-overflow-scrolling: touch; color: var(--cu-ink);
}
.cu-panel, .cu-compose-tools, .cu-tools, .cu-broadcast {
    --cu-bg: #f6f8fb; --cu-card: #ffffff; --cu-line: #e2e8f0; --cu-ink: #1f2937; --cu-soft: #6b7280;
    --cu-accent: #2563eb; --cu-danger: #dc2626; --cu-ok: #15803d;
}
@media (prefers-color-scheme: dark) {
    body[data-mode="auto"] .cu-thread, body[data-mode="dark"] .cu-thread {
        --cu-bg: #0b1220; --cu-card: #162033; --cu-line: #263349; --cu-ink: #e5e7eb; --cu-soft: #94a3b8;
        --cu-mine: #1e3a8a; --cu-mine-line: #2b4fa8; --cu-warn-bg: #3a2f10; --cu-warn-line: #6b5a1d; --cu-ok: #4ade80;
    }
}
body[data-mode="dark"] .cu-thread {
    --cu-bg: #0b1220; --cu-card: #162033; --cu-line: #263349; --cu-ink: #e5e7eb; --cu-soft: #94a3b8;
    --cu-mine: #1e3a8a; --cu-mine-line: #2b4fa8; --cu-warn-bg: #3a2f10; --cu-warn-line: #6b5a1d; --cu-ok: #4ade80;
}

.cu-day, .cu-newline { display: flex; align-items: center; justify-content: center; margin: 4px 0; font-size: 12px; color: var(--cu-soft); }
.cu-day span { background: rgba(148,163,184,.18); border-radius: 999px; padding: 2px 12px; }
.cu-newline { color: var(--cu-danger); }
.cu-newline::before, .cu-newline::after { content: ''; flex: 1 1 auto; height: 1px; background: currentColor; opacity: .35; margin: 0 10px; }
.cu-newline span { font-weight: 600; }

.cu-row { position: relative; display: flex; gap: 8px; align-items: flex-end; max-width: 86%; align-self: flex-start; }
.cu-row.mine { align-self: flex-end; flex-direction: row-reverse; }
.cu-row.unread .cu-bubble { border-color: var(--cu-warn-line); background: var(--cu-warn-bg); }
.cu-row.cu-flash .cu-bubble { box-shadow: 0 0 0 3px rgba(37,99,235,.45); transition: box-shadow .3s; }
.cu-row.sending { opacity: .65; }
.cu-row.failed .cu-bubble { border-color: var(--cu-danger); background: rgba(220,38,38,.08); }

.cu-ava {
    flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; color: #fff; background: #64748b; margin-bottom: 2px;
}
.cu-ava.r-admin { background: #7c3aed; } .cu-ava.r-leader { background: #0d9488; } .cu-ava.r-manager { background: #2563eb; }
.cu-ava.r-quality { background: #d97706; } .cu-ava.r-executor { background: #16a34a; } .cu-ava.r-user { background: #64748b; }

.cu-bubble {
    position: relative; min-width: 0; background: var(--cu-card); border: 1px solid var(--cu-line); border-radius: 14px; padding: 7px 34px 7px 11px;
    font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; box-shadow: 0 1px 2px rgba(15,23,42,.05);
}
.cu-row.mine .cu-bubble { background: var(--cu-mine); border-color: var(--cu-mine-line); border-bottom-right-radius: 4px; }
.cu-row:not(.mine) .cu-bubble { border-bottom-left-radius: 4px; }

.cu-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: 12px; margin-bottom: 2px; }
.cu-author { font-weight: 700; }
.cu-role { font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 0 7px; line-height: 16px; color: #fff; background: #64748b; }
.cu-role.r-admin { background: #7c3aed; } .cu-role.r-leader { background: #0d9488; } .cu-role.r-manager { background: #2563eb; }
.cu-role.r-quality { background: #d97706; } .cu-role.r-executor { background: #16a34a; }
.cu-time { color: var(--cu-soft); font-size: 11.5px; margin-left: auto; }
.cu-pin { font-size: 11px; }

.cu-quote {
    border-left: 3px solid var(--cu-accent); background: rgba(37,99,235,.08); border-radius: 6px; padding: 3px 8px; margin: 2px 0 4px;
    font-size: 12.5px; cursor: pointer; display: flex; flex-direction: column; min-width: 0;
}
.cu-quote b { color: var(--cu-accent); } .cu-quote span { color: var(--cu-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cu-body { white-space: normal; }
.cu-body a { color: var(--cu-accent); text-decoration: underline; }
.cu-mention { background: rgba(37,99,235,.15); color: var(--cu-accent); border-radius: 4px; padding: 0 3px; font-weight: 600; }
.cu-deleted { color: var(--cu-soft); }
.cu-file { display: flex; align-items: center; gap: 8px; margin-top: 6px; text-decoration: none !important; color: var(--cu-ink) !important; }
.cu-file.cu-img { flex-direction: column; align-items: flex-start; gap: 3px; }
.cu-file.cu-img img { max-width: 260px; max-height: 170px; border-radius: 8px; border: 1px solid var(--cu-line); object-fit: cover; background: #fff; }
.cu-file.cu-img span { font-size: 11.5px; color: var(--cu-soft); }
.cu-file.cu-doc { border: 1px solid var(--cu-line); border-radius: 10px; padding: 6px 10px; background: rgba(148,163,184,.12); }
.cu-file.cu-doc b { font-size: 11px; background: #dc2626; color: #fff; border-radius: 4px; padding: 1px 5px; }

.cu-reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.cu-react { border: 1px solid var(--cu-line); background: var(--cu-card); border-radius: 999px; padding: 0 8px; font-size: 13px; line-height: 22px; cursor: pointer; color: var(--cu-ink); }
.cu-react.mine { border-color: var(--cu-accent); background: rgba(37,99,235,.12); }
.cu-react span { font-size: 12px; font-weight: 600; }

.cu-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; font-size: 11px; color: var(--cu-soft); margin-top: 3px; }
.cu-status.read { color: var(--cu-ok); font-weight: 600; }
.cu-edited { font-style: italic; }

.cu-menu-btn {
    position: absolute; right: 4px; top: 4px; width: 26px; height: 26px; border: 0; border-radius: 50%; background: transparent; color: var(--cu-soft);
    font-size: 18px; line-height: 20px; cursor: pointer; opacity: 0;
}
.cu-row:hover .cu-menu-btn, .cu-row.menu-open .cu-menu-btn, .cu-menu-btn:focus { opacity: 1; }
@media (hover: none) { .cu-menu-btn { opacity: .7; } }
.cu-menu {
    display: none; position: absolute; z-index: 30; right: 4px; top: 30px; min-width: 190px; background: var(--cu-card); border: 1px solid var(--cu-line);
    border-radius: 12px; box-shadow: 0 8px 28px rgba(15,23,42,.22); padding: 6px;
}
.cu-row.menu-open .cu-menu { display: block; }
.cu-row:last-of-type .cu-menu { top: auto; bottom: 30px; }
.cu-menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 10px; border-radius: 8px; font-size: 13px; cursor: pointer; color: var(--cu-ink); }
.cu-menu button:hover { background: rgba(148,163,184,.18); }
.cu-menu button.danger { color: var(--cu-danger); }
.cu-menu-react { display: flex; gap: 2px; padding-bottom: 4px; margin-bottom: 4px; border-bottom: 1px solid var(--cu-line); }
.cu-menu-react button { width: auto; flex: 1 1 0; text-align: center; font-size: 17px; padding: 4px 0; }

.cu-edit { display: flex; flex-direction: column; gap: 6px; margin: 4px 0; }
.cu-edit textarea { width: 100%; border: 1px solid var(--cu-line); border-radius: 8px; padding: 6px 8px; font: inherit; background: var(--cu-card); color: var(--cu-ink); }
.cu-edit .cu-btn { align-self: flex-start; }
.cu-confirm { margin-top: 6px; font-size: 12.5px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.cu-btn { border: 1px solid var(--cu-line); background: var(--cu-card); color: var(--cu-ink); border-radius: 8px; padding: 3px 11px; font-size: 12.5px; cursor: pointer; }
.cu-btn-primary { background: var(--cu-accent); border-color: var(--cu-accent); color: #fff; }
.cu-btn-danger { background: var(--cu-danger); border-color: var(--cu-danger); color: #fff; }

.cu-typing { align-self: flex-start; font-size: 12.5px; color: var(--cu-soft); display: flex; align-items: center; gap: 6px; padding: 0 6px; }
.cu-dots { display: inline-flex; gap: 3px; }
.cu-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--cu-soft); animation: cuBlink 1.2s infinite ease-in-out; opacity: .35; }
.cu-dots i:nth-child(2) { animation-delay: .2s; } .cu-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes cuBlink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.cu-more {
    position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 20; border: 0; border-radius: 999px; background: var(--cu-accent, #2563eb);
    color: #fff; font-size: 12.5px; font-weight: 600; padding: 6px 14px; cursor: pointer; box-shadow: 0 4px 14px rgba(37,99,235,.4);
}

.cu-empty { margin: auto; max-width: 360px; text-align: center; color: var(--cu-soft); padding: 24px 12px; }
.cu-empty-ico { font-size: 34px; margin-bottom: 6px; }
.cu-empty-title { font-weight: 700; color: var(--cu-ink); font-size: 15px; margin-bottom: 4px; }
.cu-empty-text { font-size: 13px; margin-bottom: 10px; }
.cu-phrases { display: flex; flex-direction: column; gap: 6px; }
.cu-phrase { border: 1px solid var(--cu-line); background: var(--cu-card); color: var(--cu-ink); border-radius: 10px; padding: 7px 10px; font-size: 13px; cursor: pointer; text-align: left; }
.cu-phrase:hover { border-color: var(--cu-accent); }

/* Полоски над и под перепиской */
.cu-pinbar {
    display: flex; align-items: center; gap: 8px; background: #fff7e0; border: 1px solid #f2d98a; border-radius: 10px; padding: 5px 10px;
    margin-bottom: 6px; font-size: 12.5px; cursor: pointer; color: #5c4a0a;
}
.cu-pinbar b { flex: 0 0 auto; } .cu-pinbar span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cu-pinbar em { font-style: normal; color: #8a7420; font-size: 11.5px; }
.cu-replybar {
    display: flex; align-items: center; gap: 8px; border-left: 3px solid #2563eb; background: rgba(37,99,235,.08); border-radius: 6px;
    padding: 4px 8px; font-size: 12.5px; margin-bottom: 6px;
}
.cu-replybar div { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.cu-replybar b { color: #2563eb; } .cu-replybar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .8; }
.cu-replybar button { border: 0; background: transparent; font-size: 18px; line-height: 1; cursor: pointer; opacity: .6; }
.cu-attach {
    display: inline-flex; align-items: center; gap: 8px; border: 1px solid #cbd5e1; border-radius: 10px; padding: 3px 6px 3px 8px; font-size: 12.5px;
    background: rgba(148,163,184,.14); margin-bottom: 6px; max-width: 100%;
}
.cu-attach img { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; }
.cu-attach span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.cu-attach button { border: 0; background: transparent; font-size: 17px; line-height: 1; cursor: pointer; opacity: .6; }
.cu-dropping { outline: 2px dashed #2563eb; outline-offset: -4px; }

@media (max-width: 600px) {
    .cu-row { max-width: 94%; }
    .cu-file.cu-img img { max-width: 200px; }
}

/* сообщения прижаты к низу окна, когда их мало */
.cu-thread > :first-child { margin-top: auto; }

/* Выбор файла в окне чата: своя русская кнопка вместо системной («Choose File» зависит от языка браузера) */
#chatsModal .cu-file-native { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
#chatsModal .cu-file-btn {
  border: 1px solid #cbd5e1; background: #fff; color: #334155; border-radius: 8px;
  padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
}
#chatsModal .cu-file-btn:hover { background: #f1f5f9; border-color: #94a3b8; }
#chatsModal .cu-file-name { margin: 0 12px 0 8px; font-size: 12px; color: #64748b; max-width: 200px; display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }

/* Пометка «Важно» в общих лентах исполнителей и копирайтеров */
.cu-important-badge { font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 0 7px; line-height: 16px; color: #fff; background: #dc2626; }

/* Задача №893: состояние связи, отправленное сообщение, ошибка загрузки */
.cu-row.sent { opacity: .85; }
.cu-row.sent .cu-bubble::after { content: "отправлено"; display: block; font-size: 11px; color: #16a34a; margin-top: 2px; }
#chatsModal .message.sent { opacity: .85; }
.chats-status { margin: 0; padding: 8px 14px; font-size: 13px; line-height: 1.35; border-bottom: 1px solid transparent; }
.chats-status--loading { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.chats-status--warn { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.chats-status--error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.chats-status a.chats-status-retry { font-weight: 600; margin-left: 6px; text-decoration: underline; }
.cu-empty--error .cu-empty-title { color: #991b1b; }
.cu-empty--error .cu-retry { margin-top: 10px; }

/* =====================================================================================================
   Задача №893. Новый облик чата: стопки сообщений, пузыри с галочками, панель действий при наведении,
   поле ввода как в мессенджерах, список диалогов с превью, кнопка «вниз», просмотр картинок.
   ===================================================================================================== */

#chatsModal, .cu-thread { --cu-bubble-mine: #2f6fed; --cu-bubble-mine-ink: #fff; --cu-wall: #eaeff6; }
#chatsModal { --cu-accent: #2f6fed; }

/* ---------- переписка ---------- */
#chatsModal .cu-thread, .cu-thread {
    gap: 2px; padding: 14px 18px 10px; background: var(--cu-wall, #eaeff6);
    background-image: radial-gradient(circle at 20% 0%, rgba(255,255,255,.55), transparent 45%), radial-gradient(circle at 100% 100%, rgba(47,111,237,.06), transparent 40%);
}
#ordersChatsContent .chat .messages.cu-thread,
#executorsChatContent .chat .messages.cu-thread,
#personalChatContent .chat .messages.cu-thread,
#groupChatContent .chat .messages.cu-thread {
    border: 0; border-radius: 16px; padding: 14px 18px 10px; gap: 2px;
}

.cu-row { max-width: 74%; gap: 8px; align-items: flex-end; margin-top: 0; }
.cu-row.cu-first { margin-top: 10px; }
.cu-row.cu-first:first-child { margin-top: 0; }

.cu-ava { width: 34px; height: 34px; font-size: 14px; margin-bottom: 0; box-shadow: 0 1px 3px rgba(15,23,42,.18); }
.cu-row:not(.cu-last) .cu-ava { visibility: hidden; }

.cu-bubble {
    padding: 6px 11px 5px; border: 0; border-radius: 16px; box-shadow: 0 1px 1.5px rgba(15,23,42,.12);
    background: #fff; font-size: 14.5px; line-height: 1.42; min-width: 64px;
}
.cu-row:not(.mine) .cu-bubble { border-bottom-left-radius: 16px; border-top-left-radius: 16px; }
.cu-row:not(.mine).cu-last .cu-bubble { border-bottom-left-radius: 5px; }
.cu-row:not(.mine):not(.cu-first) .cu-bubble { border-top-left-radius: 6px; }
.cu-row.mine .cu-bubble { background: var(--cu-bubble-mine, #2f6fed); color: var(--cu-bubble-mine-ink, #fff); border: 0; border-bottom-right-radius: 16px; }
.cu-row.mine.cu-last .cu-bubble { border-bottom-right-radius: 5px; }
.cu-row.mine:not(.cu-first) .cu-bubble { border-top-right-radius: 6px; }
.cu-row.unread .cu-bubble { box-shadow: 0 0 0 2px rgba(245,158,11,.55), 0 1px 1.5px rgba(15,23,42,.12); background: #fff; }
.cu-row.sent .cu-bubble::after { display: none; }
.cu-row.sending .cu-bubble { opacity: .7; }
.cu-row.failed .cu-bubble { background: #fff1f2; box-shadow: 0 0 0 2px rgba(220,38,38,.5); color: #7f1d1d; }

.cu-row:not(.cu-first) .cu-head { display: none; }
.cu-head { margin-bottom: 1px; gap: 6px; }
.cu-author { font-size: 13px; font-weight: 700; }
.cu-role { background: rgba(100,116,139,.14) !important; color: #475569 !important; font-weight: 600; font-size: 10.5px; line-height: 15px; padding: 0 6px; }
.cu-row.mine .cu-head { margin-bottom: 0; }

.cu-body { font-size: 14.5px; }
.cu-row.mine .cu-body a, .cu-row.mine .cu-body a:visited { color: #fff; text-decoration: underline; }
.cu-row.mine .cu-mention { background: rgba(255,255,255,.22); color: #fff; }
.cu-row.mine .cu-quote { background: rgba(255,255,255,.18); border-left-color: #fff; }
.cu-row.mine .cu-quote b, .cu-row.mine .cu-quote span { color: #fff; }
.cu-row.mine .cu-file.cu-doc { border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.14); }
.cu-row.mine .cu-file { color: #fff !important; }
.cu-row.mine .cu-file.cu-img span { color: rgba(255,255,255,.8); }

/* время и галочки — внутри пузыря, справа внизу */
.cu-meta { display: flex; justify-content: flex-end; align-items: center; gap: 5px; margin-top: 1px; font-size: 11px; color: var(--cu-soft); line-height: 14px; user-select: none; }
.cu-meta .cu-time { margin: 0; font-size: 11px; }
.cu-row.mine .cu-meta { color: rgba(255,255,255,.78); }
.cu-ticks { font-size: 12px; letter-spacing: -2px; margin-left: 1px; }
.cu-ticks.read { color: #bfe3ff; font-weight: 700; }
.cu-row:not(.mine) .cu-ticks { color: var(--cu-soft); }
.cu-edited { font-style: normal; opacity: .85; }
.cu-row.mine .cu-foot { display: none; }
.cu-foot { margin-top: 0; }

.cu-reacts { margin-top: 4px; }
.cu-react { padding: 0 7px; line-height: 20px; font-size: 13px; border-color: rgba(148,163,184,.4); background: rgba(255,255,255,.85); }
.cu-row.mine .cu-react { color: #1e3a8a; }
.cu-react.mine { border-color: var(--cu-accent); background: #dbe7ff; }

/* ---------- панель действий при наведении ---------- */
.cu-tools-bar {
    position: absolute; top: -14px; right: 6px; display: none; gap: 1px; padding: 2px; background: #fff; border: 1px solid #dbe2ec;
    border-radius: 10px; box-shadow: 0 4px 14px rgba(15,23,42,.16); z-index: 8;
}
.cu-row.mine .cu-tools-bar { right: auto; left: 6px; }
.cu-row:hover .cu-tools-bar, .cu-row.menu-open .cu-tools-bar { display: flex; }
.cu-tools-bar button {
    position: static; opacity: 1; width: 28px; height: 26px; border: 0; background: transparent; border-radius: 7px; color: #475569;
    font-size: 15px; line-height: 26px; cursor: pointer; padding: 0;
}
.cu-tools-bar button:hover { background: #eef2f7; color: #1d4ed8; }
/* на сенсорных экранах панель наведения не нужна: остаётся только «⋯» в углу пузыря */
@media (hover: none) {
    .cu-tools-bar { display: flex; position: absolute; top: 0; right: 2px; background: transparent; border: 0; box-shadow: none; padding: 0; }
    .cu-tools-bar button:not(.cu-menu-btn) { display: none; }
    .cu-tools-bar .cu-menu-btn { width: 26px; height: 24px; opacity: .55; }
    .cu-row.mine .cu-tools-bar { left: auto; right: 2px; }
    .cu-bubble { padding-right: 26px; }
}
.cu-menu { top: 14px; right: 6px; }
.cu-row.mine .cu-menu { right: auto; left: 6px; }
.cu-row:last-of-type .cu-menu { top: auto; bottom: 14px; }

/* ---------- дата и «новые сообщения» ---------- */
.cu-day { position: sticky; top: 4px; z-index: 5; margin: 10px 0 6px; }
.cu-day span { background: rgba(71,85,105,.62); color: #fff; font-weight: 600; font-size: 12px; padding: 3px 12px; backdrop-filter: blur(4px); }
.cu-newline { margin: 10px 0 4px; }

/* ---------- кнопка «вниз» ---------- */
.cu-fab {
    position: absolute; right: 22px; bottom: 16px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: #fff; color: #334155;
    font-size: 20px; line-height: 40px; cursor: pointer; box-shadow: 0 4px 16px rgba(15,23,42,.28); z-index: 21;
    opacity: 0; transform: translateY(8px) scale(.9); pointer-events: none; transition: opacity .15s, transform .15s;
}
.cu-fab.on { opacity: 1; transform: none; pointer-events: auto; }
.cu-fab:hover { color: var(--cu-accent); }
.cu-fab i { position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; line-height: 20px; padding: 0 5px; border-radius: 999px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; font-style: normal; text-align: center; }
.cu-more { bottom: 62px; }

/* ---------- просмотр картинки ---------- */
.cu-file.cu-img img { max-width: 320px; max-height: 240px; cursor: zoom-in; border: 0; border-radius: 10px; }
.cu-lightbox {
    position: fixed; inset: 0; z-index: 99990; background: rgba(2,6,23,.86); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out;
}
.cu-lightbox img { max-width: 94vw; max-height: 80vh; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.5); background: #fff; cursor: default; }
.cu-lightbox-x { position: absolute; top: 14px; right: 20px; border: 0; background: transparent; color: #fff; font-size: 38px; line-height: 1; cursor: pointer; }
.cu-lightbox-cap { margin-top: 10px; color: #e2e8f0; font-size: 13px; }
.cu-lightbox-open { margin-top: 6px; color: #93c5fd; font-size: 13px; }
.cu-toast { position: fixed; left: 50%; bottom: 36px; transform: translate(-50%, 10px); background: #0f172a; color: #fff; padding: 8px 16px; border-radius: 999px; font-size: 13px; z-index: 99991; opacity: 0; transition: .2s; }
.cu-toast.on { opacity: .95; transform: translate(-50%, 0); }

/* ---------- поле ввода ---------- */
#chatsModal .chat form.cu-composer { padding: 8px 0 0; margin: 0; border: 0; background: transparent; }
.cu-composer .cu-hide-legacy, .cu-composer .cu-hide-legacy-label { display: none !important; }
.cu-composer .cu-hide-legacy-label .help-block { display: none; }
.cu-cbar { display: flex; align-items: flex-end; gap: 8px; }
.cu-cinput {
    position: relative; flex: 1 1 auto; min-width: 0; display: flex; align-items: flex-end; background: #fff; border: 1px solid #d6deea; border-radius: 22px; padding: 2px 6px 2px 14px;
    transition: border-color .15s, box-shadow .15s;
}
.cu-cinput:focus-within { border-color: var(--cu-accent); box-shadow: 0 0 0 3px rgba(47,111,237,.15); }
.cu-cinput textarea.cu-ta {
    flex: 1 1 auto; min-width: 0; border: 0 !important; outline: 0 !important; box-shadow: none !important; background: transparent !important; resize: none; padding: 9px 0 !important;
    max-height: 140px; font-size: 14.5px; line-height: 1.35; height: 38px;
}
.cu-cbtn {
    flex: 0 0 auto; width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: #64748b; display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 22px; line-height: 1; padding: 0;
}
.cu-cbtn:hover { background: #eef2f7; color: var(--cu-accent); }
.cu-cinput .cu-cbtn { width: 34px; height: 34px; margin-bottom: 1px; }
.cu-composer .cu-send, #chatsModal .chat form.cu-composer .sendButton.cu-send {
    flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50% !important; padding: 0 !important; display: inline-flex; align-items: center; justify-content: center;
    background: var(--cu-accent); border: 0; color: #fff; box-shadow: 0 3px 10px rgba(47,111,237,.38); transition: transform .1s;
}
.cu-composer .cu-send:hover { transform: scale(1.06); background: #1f5fe0; }
.cu-composer .cu-send svg { transform: translateX(1px); }
.cu-composer .cu-cerr { margin: 0 4px 4px 56px; font-size: 12.5px; color: #dc2626; }
.cu-composer .cu-cerr:empty { display: none; }
.cu-composer .cu-attach-box { margin: 0 0 6px 48px; }
.cu-composer .cu-replybar { margin: 0 0 6px 48px; border-radius: 12px; background: #fff; border: 1px solid #dbe5f7; border-left: 3px solid var(--cu-accent); }
.cu-composer .cu-compose-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px 0; }
.cu-composer .cu-compose-tools .cu-tool { border-radius: 999px; padding: 4px 12px; background: #fff; border: 1px solid #d6deea; font-size: 12.5px; color: #334155; }
.cu-composer .cu-compose-tools .cu-tool:hover { border-color: var(--cu-accent); color: var(--cu-accent); }
.cu-emoji {
    position: absolute; right: 0; bottom: 46px; width: 300px; display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; padding: 8px; background: #fff;
    border: 1px solid #dbe2ec; border-radius: 14px; box-shadow: 0 10px 34px rgba(15,23,42,.24); z-index: 40;
}
.cu-emoji.d-none { display: none; }
.cu-emoji button { border: 0; background: transparent; font-size: 20px; line-height: 28px; border-radius: 6px; cursor: pointer; padding: 0; }
.cu-emoji button:hover { background: #eef2f7; }

/* перетаскивание файла */
#chatsModal .chat.cu-dropping::after {
    content: 'Отпустите файл, чтобы прикрепить'; position: absolute; inset: 8px; border: 2px dashed var(--cu-accent); border-radius: 16px; background: rgba(47,111,237,.1); color: var(--cu-accent);
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; z-index: 50; pointer-events: none;
}

/* ---------- заголовок переписки ---------- */
#chatsModal .chat .header { align-items: center; margin-bottom: 8px; padding: 2px 4px; gap: 10px; }
#chatsModal .chat .header .title { font-size: 16px; font-weight: 700; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#chatsModal .chat .header .cu-tools { display: flex; gap: 6px; }
#chatsModal .chat .header .cu-tool, #chatsModal .chat .header .cu-search-btn {
    border: 1px solid #d6deea; background: #fff; border-radius: 999px; padding: 4px 12px; font-size: 12.5px; color: #334155; cursor: pointer; line-height: 20px;
}
#chatsModal .chat .header .cu-tool:hover, #chatsModal .chat .header .cu-search-btn:hover { border-color: var(--cu-accent); color: var(--cu-accent); }
#chatsModal .chat .header .cu-search-btn { padding: 4px 9px; }

/* ---------- списки диалогов (заказы, личные, группа) ---------- */
#ordersChatsContent .orders { width: 272px; padding: 8px 6px; background: #fff; }
#ordersChatsContent .orders li[data-id] {
    display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; grid-template-areas: "ava title when" "ava sub count"; column-gap: 11px; row-gap: 1px;
    align-items: center; padding: 9px 10px; margin: 1px 2px; border-radius: 12px; cursor: pointer; text-wrap: wrap;
}
#ordersChatsContent .orders li[data-id] .ava { grid-area: ava; width: 46px; height: 46px; border-radius: 50%; font-size: 16px; }
#ordersChatsContent .orders li[data-id] .title { grid-area: title; font-size: 14px; }
#ordersChatsContent .orders li[data-id] .when { grid-area: when; position: static; font-size: 11.5px; color: #94a3b8; white-space: nowrap; }
#ordersChatsContent .orders li[data-id] .sub { grid-area: sub; font-size: 13px; color: #64748b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#ordersChatsContent .orders li[data-id] .counter { grid-area: count; justify-self: end; margin: 0; }
#ordersChatsContent .orders li[data-id] .star { position: absolute; right: 8px; top: 8px; opacity: 0; transition: opacity .15s; }
#ordersChatsContent .orders li[data-id]:hover .star, #ordersChatsContent .orders li[data-id] .star.on { opacity: 1; }
#ordersChatsContent .orders li[data-id] { position: relative; }
#ordersChatsContent .orders li.selected { background: #e8f0ff; }
#ordersChatsContent .orders li.search input { border-radius: 999px; background: #f1f5f9; border-color: transparent; padding: 8px 14px; }
#ordersChatsContent .orders li.search input:focus { background: #fff; border-color: var(--cu-accent); }
#ordersChatsContent .chats { width: 190px; background: #fbfcfe; }
#ordersChatsContent .chats li.search input { border-radius: 999px; background: #f1f5f9; border-color: transparent; padding: 8px 14px; }

#personalChatContent .pc-chats li[data-id], #groupChatContent .pc-chats li[data-id] { border-radius: 12px; margin: 1px 2px; }
#groupChatContent .pc-views button, #personalChatContent .pc-views button { border-radius: 999px; }

/* чипы-фильтры над списком */
.cu-chips { display: flex; gap: 6px; padding: 2px 6px 8px; flex-wrap: wrap; }
.cu-chips button { border: 0; background: #eef2f7; color: #475569; border-radius: 999px; padding: 4px 11px; font-size: 12px; font-weight: 600; cursor: pointer; }
.cu-chips button.on { background: #dbe7ff; color: #1d4ed8; }
#ordersChatsContent .orders.cu-only-unread li[data-id]:not(:has(.counter)) { display: none; }
#ordersChatsContent .orders.cu-only-star li[data-id]:not(:has(.star.on)) { display: none; }

/* ---------- состояние связи и тёмная тема ---------- */
body[data-mode="dark"] #chatsModal { --cu-wall: #0b1220; }
body[data-mode="dark"] .cu-bubble, body[data-mode="dark"] .cu-cinput, body[data-mode="dark"] .cu-tools-bar, body[data-mode="dark"] .cu-emoji { background: #162033; border-color: #263349; color: #e5e7eb; }
body[data-mode="dark"] .cu-row.mine .cu-bubble { background: #1e3a8a; }

/* колонка заказов с фильтрами */
#ordersChatsContent .cu-orders-col { flex: 0 0 272px; width: 272px; display: flex; flex-direction: column; min-height: 0; background: #fff; border-right: 1px solid #eef0f3; }
#ordersChatsContent .cu-orders-col .orders { width: 100%; border-right: 0; flex: 1 1 auto; min-height: 0; }
@media screen and (max-width: 991px) { #ordersChatsContent .cu-orders-col { display: none; } }
@media screen and (max-width: 1280px) {
    #ordersChatsContent .cu-orders-col, #ordersChatsContent .orders { width: 250px; flex-basis: 250px; }
    #ordersChatsContent .chats { width: 190px; }
}

/* ---------- вкладка «Группа»: создание поста и сообщения ---------- */
#groupChatContent { position: relative; }
#groupChatContent .cg-actions { display: flex; flex-direction: column; gap: 6px; padding: 10px 10px 4px; }
#groupChatContent .cg-actions .btn { border-radius: 999px; font-weight: 600; text-align: center; }
.cg-create { position: absolute; inset: 0; z-index: 60; background: rgba(15,23,42,.45); display: flex; align-items: flex-start; justify-content: center; padding: 28px 16px; }
.cg-create.d-none { display: none; }
.cg-create-card { width: 100%; max-width: 640px; max-height: 100%; background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(2,6,23,.4); padding: 16px 18px; display: flex; flex-direction: column; min-height: 0; }
.cg-create-head { display: flex; justify-content: space-between; align-items: center; font-size: 17px; margin-bottom: 4px; }
.cg-x { border: 0; background: transparent; font-size: 26px; line-height: 1; color: #64748b; cursor: pointer; }
.cg-create-note { font-size: 12.5px; color: #64748b; margin: 0 0 10px; }
.cg-create-q { border-radius: 999px; background: #f1f5f9; border-color: transparent; padding: 8px 14px; margin-bottom: 8px; }
.cg-create-list { overflow-y: auto; min-height: 120px; display: flex; flex-direction: column; gap: 6px; }
.cg-create-empty { color: #64748b; text-align: center; padding: 26px 8px; font-size: 13px; }
.cg-cand { display: flex; align-items: center; gap: 12px; border: 1px solid #e2e8f0; border-radius: 12px; padding: 9px 12px; }
.cg-cand:hover { border-color: #93b4f5; background: #f8faff; }
.cg-cand-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cg-cand-main b { font-size: 14px; }
.cg-cand-main span { font-size: 12px; color: #64748b; }
.cg-cand-main em { font-size: 11.5px; color: #b45309; font-style: normal; }
.cg-cand-act { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
.cg-cand-act input { width: 64px; text-align: center; }
.cg-create-err { margin-top: 8px; font-size: 13px; }

/* панель переписки во вкладках «Личные» и «Группа»: поле ввода не уезжает за край окна */
#personalChatContent .chat, #groupChatContent .chat { min-height: 0; }
#personalChatContent .chat .messages, #groupChatContent .chat .messages { flex: 1 1 0; min-height: 0; height: auto; }
#personalChatContent .chat form, #groupChatContent .chat form { flex: 0 0 auto; }
#personalChatContent .chat .header, #groupChatContent .chat .header { flex: 0 0 auto; }

/* список постов группы: аватар, название, превью, время */
#groupChatContent .pc-chats li[data-id] { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; column-gap: 11px; align-items: center; padding: 9px 10px; cursor: pointer; position: relative; }
#groupChatContent .pc-chats li[data-id] .cg-ava { grid-row: 1 / span 3; width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 16px; }
#groupChatContent .pc-chats li[data-id] .pc-name { grid-column: 2; font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#groupChatContent .pc-chats li[data-id] .pc-login { grid-column: 2; font-size: 11.5px; color: #94a3b8; }
#groupChatContent .pc-chats li[data-id] .pc-last { grid-column: 2; font-size: 12.5px; color: #64748b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#groupChatContent .pc-chats li[data-id] .counter { grid-column: 3; grid-row: 1 / span 3; align-self: center; position: static; margin: 0; }

.cu-row.mine .cu-meta .cu-time, .cu-row.mine .cu-meta .cu-edited { color: rgba(255,255,255,.82); }
.cu-row.mine .cu-ticks { color: rgba(255,255,255,.82); }
#groupChatContent .pc-chats li.selected, #personalChatContent .pc-chats li.selected { background: #e8f0ff; }
#groupChatContent .pc-chats li[data-id]:hover, #personalChatContent .pc-chats li[data-id]:hover { background: #f1f5fb; }
#personalChatContent .chat .messages:empty::before {
    content: '💬  Выберите диалог слева или найдите исполнителя в поиске'; margin: auto; color: #64748b; font-size: 14px; text-align: center; padding: 20px;
}
.cu-chips button { padding: 4px 10px; }
#ordersChatsContent .orders li.cu-f-hide { display: none !important; }
