/* CRM. Цвета, шрифты, кнопки, фильтры и логотип — общие файлы Мидаса в web/midas/ (источник: projects/midas/design). */

html, body { height: 100%; }
body { font-size: 14px; line-height: 1.45; }
.sprite { position: absolute; }
.logo { display: grid; gap: 4px; }
.logo-name, .chat-title strong, .card-head h2, .avatar { font-variant-numeric: lining-nums; }
.error { margin: 0; color: var(--danger); font-size: 13px; }

/* круглая кнопка-значок без обводки */
.round.quiet { width: 38px; height: 38px; box-shadow: none; color: var(--soft); }
.round.quiet:hover { background: var(--surface); color: var(--graphite); }

/* поля */
.field input, .field textarea { width: 100%; height: 46px; padding: 0 14px; border: 0; border-radius: var(--r-field); background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); font-size: 14px; color: var(--ink); transition: box-shadow .2s; }
.field textarea { height: auto; padding: 12px 14px; line-height: 1.5; resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--graphite); }
input::placeholder, textarea::placeholder { color: var(--placeholder); }

/* вход */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); display: grid; gap: 18px; padding: 44px 32px 32px; border-radius: var(--r-panel); background: var(--paper); box-shadow: inset 0 0 0 1px var(--line), 0 40px 80px -50px rgba(29, 29, 31, .35); }
.login-card .logo { justify-items: center; margin-bottom: 10px; text-align: center; }
.login-card .logo-name { font-size: 40px; }

/* раскладка */
.app { height: 100%; display: grid; grid-template-columns: 350px minmax(0, 1fr) auto; }
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--paper); border-right: 1px solid var(--line); }
.chat { position: relative; display: flex; min-width: 0; min-height: 0; background: var(--bg); }
.card { width: 320px; min-height: 0; overflow-y: auto; background: var(--paper); border-left: 1px solid var(--line); }

/* список диалогов */
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 14px 14px 22px; }
.head-actions { display: flex; gap: 2px; }
.channels { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 22px 14px; }
.channel-state { display: inline-flex; align-items: center; gap: 7px; height: 24px; padding: 0 10px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line); font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--soft); cursor: default; }
.channel-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.channel-state.ok::before { background: var(--ok); }
.channel-state.error { color: var(--danger); background: var(--danger-bg); box-shadow: none; }
.channel-state.error::before { background: var(--danger); }
.channel-state.starting::before { background: #c9a14a; }
.channel-state.off { opacity: .6; }
.search { display: flex; align-items: center; gap: 10px; height: 44px; margin: 0 14px; padding: 0 14px; border-radius: var(--r-field); background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); transition: box-shadow .2s; }
.search:focus-within { box-shadow: inset 0 0 0 1.5px var(--graphite); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none; color: var(--ink); }
.filters { display: flex; gap: 6px; padding: 12px 14px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.filters::-webkit-scrollbar { display: none; }
.filters .pill { height: 32px; padding: 0 14px; font-size: 12px; }
.list { flex: 1; min-height: 0; margin: 0; padding: 8px 8px 14px; list-style: none; overflow-y: auto; }
.list-empty { margin: 0; padding: 24px 22px; text-align: center; font: italic 400 19px/1.35 var(--serif); }
.item { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 3px 12px; align-items: center; padding: 10px 12px; border-radius: var(--r-img); cursor: pointer; transition: background .2s var(--ease); }
.item:hover { background: var(--bg); }
.item.active { background: var(--accent); }
.item .avatar { grid-row: span 2; }
.item-name { display: flex; align-items: center; gap: 7px; min-width: 0; font-weight: 600; color: var(--ink); }
.item-name span:first-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.item-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.item-text { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; color: var(--soft); }
.item.waiting .item-time { color: var(--accent-deep); font-weight: 600; }
.unread { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--graphite); color: #fff; font-size: 11px; font-weight: 600; line-height: 20px; text-align: center; }

/* метка канала: точка цвета мессенджера и короткое название */
.badge { flex: none; display: inline-flex; align-items: center; gap: 4px; height: 17px; padding: 0 6px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line); color: var(--soft); font-size: 9px; font-weight: 600; letter-spacing: .08em; line-height: 1; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.vk::before { background: var(--vk); }
.badge.telegram::before { background: var(--telegram); }
.badge.max::before { background: var(--max); }
.badge.site::before { background: var(--accent-deep); }
.item.active .badge { box-shadow: inset 0 0 0 1px rgba(42, 42, 45, .14); }
.avatar { position: relative; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; background: var(--surface); color: var(--graphite); font: 500 18px/1 var(--serif); letter-spacing: .02em; }
.item.active .avatar { background: var(--paper); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* переписка */
.chat-empty { margin: auto; display: grid; justify-items: center; gap: 12px; padding: 24px; text-align: center; }
.chat-empty .logo-name { font-size: 44px; }
.hint { margin: 0; font: italic 400 22px var(--serif); color: var(--muted); }
.chat-body { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 12px 14px 12px 22px; background: var(--paper); border-bottom: 1px solid var(--line); }
.chat-head .avatar { width: 42px; height: 42px; font-size: 17px; }
.chat-title { flex: 1; min-width: 0; display: grid; gap: 4px; }
.chat-title strong, .chat-title span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-title strong { font: 500 24px/1.05 var(--serif); color: var(--ink); }
.chat-title span { font-size: 12px; letter-spacing: .02em; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 20px max(20px, 6%) 12px; display: flex; flex-direction: column; gap: 6px; }
.more { align-self: center; height: 32px; margin-bottom: 8px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; box-shadow: inset 0 0 0 1px var(--line); color: var(--soft); font-size: 12px; font-weight: 500; cursor: pointer; }
.more:hover { color: var(--graphite); box-shadow: inset 0 0 0 1px var(--graphite); }
.day { align-self: stretch; display: flex; align-items: center; gap: 14px; margin: 14px 0 8px; font-size: 10px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.bubble { max-width: min(560px, 78%); padding: 9px 14px 6px; border-radius: 18px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); line-height: 1.5; overflow-wrap: anywhere; }
.bubble.in { align-self: flex-start; border-bottom-left-radius: 6px; }
.bubble.out { align-self: flex-end; background: var(--graphite); color: #fff; box-shadow: none; border-bottom-right-radius: 6px; }
.bubble a { text-decoration: underline; text-underline-offset: 2px; }
.bubble.failed { background: var(--danger-bg); color: var(--ink); box-shadow: inset 0 0 0 1px #ecc9c0; }
.bubble .text { white-space: pre-wrap; }
.meta { display: block; margin-top: 3px; font-size: 11px; text-align: right; opacity: .55; font-variant-numeric: tabular-nums; }
.bubble.failed .meta { color: var(--danger); opacity: 1; }
.attachment { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.attachment img { display: block; max-width: 100%; max-height: 320px; border-radius: 12px; cursor: zoom-in; }
.attachment.sticker img { max-height: 140px; }
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; width: min(420px, 100%); margin: 4px 0; }
.gallery .attachment { margin: 0; }
.gallery .attachment a { display: block; width: 100%; }
.gallery img { width: 100%; max-height: none; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.gallery .attachment:nth-child(odd):last-child { grid-column: 1 / -1; }
.gallery .attachment:nth-child(odd):last-child img { aspect-ratio: 2; }
.attachment audio { max-width: 100%; }
.quote { margin: 4px 0; padding-left: 10px; border-left: 2px solid var(--accent-deep); opacity: .85; white-space: pre-wrap; }
.bubble.out .quote { border-color: var(--accent); }

.composer { padding: 10px 16px 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); background: var(--bg); }
.composer-note { margin: 0 0 10px; padding: 10px 14px; border-radius: var(--r-field); background: var(--danger-bg); color: var(--danger); font-size: 13px; }
.composer-note.info { background: var(--surface); color: var(--soft); }
.composer-note a { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
.composer-hint { margin: 0 0 8px; padding: 0 4px; font-size: 12px; color: var(--danger); }
.composer-row { display: flex; align-items: flex-end; gap: 10px; }
.attach { flex: none; display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%; background: var(--paper); color: var(--soft); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; transition: color .2s, box-shadow .2s; }
.attach:hover { color: var(--graphite); box-shadow: inset 0 0 0 1px var(--graphite); }
.attach:disabled { opacity: .45; cursor: not-allowed; }
.attach svg { width: 21px; height: 21px; }
.attachments { display: flex; gap: 8px; margin: 0 0 10px; padding: 2px; overflow-x: auto; scrollbar-width: none; }
.attachments::-webkit-scrollbar { display: none; }
.thumb { position: relative; flex: none; width: 76px; height: 76px; overflow: hidden; border-radius: var(--r-field); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.loading { background: linear-gradient(100deg, var(--surface) 30%, var(--paper) 50%, var(--surface) 70%) 0 0 / 300% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }
.thumb-remove { position: absolute; top: 4px; right: 4px; display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; background: rgba(29, 29, 31, .72); color: #fff; cursor: pointer; }
.thumb-remove svg { width: 14px; height: 14px; stroke-width: 2; }
.thumb-progress { position: absolute; left: 8px; right: 8px; bottom: 8px; height: 4px; overflow: hidden; border-radius: 2px; background: rgba(255, 255, 255, .75); }
.thumb-progress i { display: block; height: 100%; background: var(--graphite); transform: scaleX(0); transform-origin: left; transition: transform .2s; }
.chat-body.dropping .messages { outline: 1.5px dashed var(--graphite); outline-offset: -12px; border-radius: var(--r-panel); }
.composer textarea { flex: 1; min-height: 48px; max-height: 180px; padding: 13px 18px; border: 0; border-radius: 24px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); line-height: 1.5; resize: none; outline: none; transition: box-shadow .2s; }
.composer textarea:focus { box-shadow: inset 0 0 0 1.5px var(--graphite); }
.send { display: grid; place-items: center; width: 48px; height: 48px; border: 0; border-radius: 50%; background: var(--graphite); color: #fff; cursor: pointer; transition: background .25s, transform .2s var(--ease); }
.send:hover { background: var(--ink); }
.send:active { transform: scale(.96); }
.send:disabled, .composer textarea:disabled { opacity: .45; cursor: not-allowed; }

/* просмотр фото на весь экран */
.viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(20, 20, 22, .95); overflow: hidden; }
.viewer[open] { display: grid; place-items: center; }
.viewer::backdrop { background: transparent; }
.viewer img { max-width: calc(100vw - 24px); max-height: calc(100dvh - 128px); object-fit: contain; border-radius: 6px; }
.viewer-bar { position: fixed; top: max(14px, env(safe-area-inset-top)); right: 14px; display: flex; gap: 8px; }
.viewer-btn, .viewer-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; box-shadow: none; }
.viewer-btn:hover { background: rgba(255, 255, 255, .22); }

/* карточка клиента */
.card-head { display: flex; align-items: center; justify-content: space-between; min-height: 72px; padding: 12px 14px 12px 24px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; font: 500 26px/1 var(--serif); }
.card-form { display: grid; gap: 14px; padding: 20px 24px 0; }
.saved { margin: -6px 0 0; font-size: 12px; }
.facts { margin: 8px 24px 24px; padding-top: 18px; border-top: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; font-size: 13px; }
.facts dt { align-self: center; font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts a { text-decoration: underline; text-underline-offset: 2px; }

.only-mobile { display: none; }

@media (max-width: 1100px) {
  .app { position: relative; }
  .card { position: absolute; top: 0; right: 0; bottom: 0; z-index: 5; box-shadow: -20px 0 50px -30px rgba(29, 29, 31, .35); }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar, .chat { grid-column: 1; grid-row: 1; }
  .sidebar { border-right: 0; }
  .app.show-chat .sidebar { display: none; }
  .app:not(.show-chat) .chat { display: none; }
  .only-mobile { display: grid; }
  .side-head { padding: 14px 10px 12px 18px; }
  .channels { padding: 0 18px 12px; }
  .chat-head { min-height: 62px; padding: 8px 8px 8px 6px; gap: 8px; }
  .chat-title strong { font-size: 21px; }
  .messages { padding: 16px 12px 8px; }
  .composer { padding-inline: 10px; }
  .composer-row { gap: 8px; }
  .attach, .send { width: 44px; height: 44px; }
  .composer textarea { min-height: 44px; padding: 11px 16px; }
  .viewer img { max-width: 100vw; border-radius: 0; }
  .card { width: 100%; border-left: 0; box-shadow: none; }
  .bubble { max-width: 88%; }
}
