/* ARS-X 2.6 — «Коммуникации»: сообщения, каналы, звонки, отчёты с объекта */
.nav button.nav-item .nav-count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 11.5px; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; }

/* входящие */
.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; height: calc(100vh - 150px); min-height: 480px; }
.inbox-list { display: flex; flex-direction: column; gap: 4px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 10px; }
.inbox-filters { display: grid; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; position: sticky; top: -10px; background: var(--surface); z-index: 1; }
.inbox-filters .chip-filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.inbox-filters select { min-height: 32px; padding: 4px 8px; }
.inbox-row { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 9px 8px; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.inbox-row:hover { background: var(--surface-2); }
.inbox-row.active { background: var(--accent-soft); }
.inbox-row.unread b { font-weight: 750; }
.inbox-main { flex: 1; min-width: 0; display: grid; }
.inbox-main small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }
.inbox-side { display: grid; justify-items: end; gap: 4px; color: var(--muted); font-size: 11.5px; }
.inbox-chat { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; display: flex; }
.inbox-chat > .chat { flex: 1; }
.inbox-empty { margin: auto; display: grid; justify-items: center; gap: 8px; color: var(--muted); }
.inbox-empty .ico { width: 32px; height: 32px; }

.chat-kind { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; background: var(--surface-2); color: var(--muted); }
.chat-kind.kind-telegram { background: color-mix(in srgb, #229ED9 14%, transparent); color: #229ED9; }
.chat-kind.kind-max { background: color-mix(in srgb, #6A4CFF 14%, transparent); color: #6A4CFF; }
.chat-kind.kind-avito { background: color-mix(in srgb, #00AAFF 14%, transparent); color: #0097E6; }
.chat-kind.kind-imap { background: color-mix(in srgb, #F59E0B 16%, transparent); color: #C27803; }
.chat-kind.kind-mango, .chat-kind.kind-calls { background: color-mix(in srgb, #16A34A 14%, transparent); color: #16A34A; }

.chat { display: flex; flex-direction: column; min-height: 0; width: 100%; }
.chat.compact { height: min(70vh, 640px); }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-who { display: grid; flex: 1; min-width: 0; }
.chat-who small { color: var(--muted); font-size: 12.5px; }
.chat-links { display: flex; gap: 6px; flex-wrap: wrap; }
.chat-body { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.bubble { max-width: min(78%, 560px); padding: 8px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); align-self: flex-start; display: grid; gap: 4px; }
.bubble.out { align-self: flex-end; background: var(--accent-soft); border-color: var(--accent-line); }
.bubble.failed { border-color: var(--danger, #d92d20); }
.bubble-text { white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.bubble-meta { font-size: 11.5px; color: var(--muted); }
.bubble-file { display: grid; gap: 4px; }
.bubble-voice { display: grid; gap: 4px; }
.bubble-voice q { font-style: italic; color: var(--text); }
.bubble-voice audio { max-width: 260px; height: 36px; }
.chat-photo { max-width: 240px; max-height: 240px; border-radius: 10px; display: block; object-fit: cover; }
.chat-photo.placeholder { width: 120px; height: 90px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--muted); }
.chat-reply { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); align-items: flex-end; }
.chat-reply textarea { flex: 1; resize: vertical; min-height: 44px; }
.chat-readonly { padding: 12px 14px; border-top: 1px solid var(--line); }
.deal-chats .doc-row.unread b, .deal-chats .doc-row.unread span { font-weight: 650; }

/* каналы */
.channels-screen { display: grid; gap: 14px; }
.channels-screen .screen-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.channels-intro { max-width: 880px; margin: 0; }
.channel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; align-items: start; }
.channel-card { display: grid; gap: 6px; }
.channel-head { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; }
.channel-head > div { flex: 1; min-width: 0; display: grid; }
.channel-head small { color: var(--muted); font-size: 12.5px; }
.channel-add { display: grid; justify-items: start; gap: 4px; text-align: left; border-style: dashed; cursor: pointer; color: var(--text); font: inherit; min-height: 110px; }
.channel-add:hover { border-color: var(--accent-line); background: var(--accent-softer); }
.channel-add .ico { color: var(--brand); }
.channel-add small { color: var(--muted); }
.help-text { color: var(--muted); line-height: 1.5; }
.help-text code { font-size: 12px; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; word-break: break-all; }
.help-text ul { padding-left: 18px; margin: 6px 0; }
.ext-map { display: grid; gap: 6px; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.ext-row { display: grid; grid-template-columns: 1fr 110px; gap: 10px; align-items: center; font-size: 13.5px; }
.ext-row input { min-height: 32px; padding: 4px 8px; }
.my-bots { display: grid; gap: 10px; }
.my-bot { display: grid; gap: 6px; }
.my-bot-head { display: flex; align-items: center; gap: 8px; }
.my-bot-head b { flex: 1; }

/* источники */
.lead-sources { display: grid; gap: 12px; }
.lead-sources .screen-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.source-totals { display: flex; gap: 16px; color: var(--muted); font-size: 13.5px; flex-wrap: wrap; }
.source-totals b { color: var(--text); }
.source-bar { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.source-bar span { height: 8px; border-radius: 4px; background: var(--brand); opacity: .75; min-width: 4px; }

/* звонок */
.call-popup { position: fixed; right: 20px; bottom: 20px; z-index: 1200; display: flex; gap: 12px; align-items: center; padding: 14px 14px 14px 16px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: 0 18px 50px rgba(15, 23, 42, .22); max-width: 420px; animation: call-in .25s ease-out; }
.call-popup-icon { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: color-mix(in srgb, #16A34A 16%, transparent); color: #16A34A; flex: none; animation: call-pulse 1.4s ease-in-out infinite; }
.call-popup-main { display: grid; min-width: 0; flex: 1; }
.call-popup-main small { color: var(--muted); }
@keyframes call-in { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes call-pulse { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, #16A34A 12%, transparent); } }

/* отчёты с объекта */
.project-reports { display: grid; gap: 12px; }
.project-reports .card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.project-reports h3 { display: flex; align-items: center; gap: 8px; margin: 0; }
.project-reports h3 .ico { color: var(--brand); }
.report-list { display: grid; gap: 10px; }
.report-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 8px; background: var(--surface); }
.report-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.report-head .icon-btn { margin-left: auto; }
.report-summary { margin: 0; }
.report-block { display: grid; gap: 2px; }
.report-block ul { margin: 0; padding-left: 18px; }
.report-label { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.report-photos { display: flex; gap: 6px; flex-wrap: wrap; }
.report-photo { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; display: block; background: var(--surface-3); }
.report-quote { margin: 0; padding: 8px 12px; border-left: 3px solid var(--accent-line); background: var(--surface-2); border-radius: 0 8px 8px 0; white-space: pre-wrap; font-size: 13.5px; }
.muted-row td { color: var(--muted); }

@media (max-width: 900px) {
  .inbox { grid-template-columns: 1fr; height: auto; }
  .inbox-list { max-height: 50vh; }
  .inbox-chat { min-height: 60vh; }
  .call-popup { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}
.bubble-voice .btn { justify-self: start; }
.deal-chats .doc-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; }
.deal-chats .doc-row > span:not(.count-pill) { flex: 1; min-width: 0; display: grid; }
.deal-chats .doc-row small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.deal-chats .doc-row .count-pill { flex: none; width: auto; }
