/* CRM 2.0. The underlying workflow and component IDs stay shared. */
:root {
  --bg: #f1f5f4;
  --ink: #182827;
  --muted: #49605e;
  --line: #d6e1df;
  --line2: #e8efed;
  --accent: #09685e;
  --accent-2: #def2ec;
  --nav: #17282b;
  --nav-ink: #d7e6e4;
  --red: #a52c36;
  --green: #216b4b;
  --amber: #805500;
  --shadow: 0 1px 2px rgb(16 50 45 / 7%);
}

.nav-section { margin: 14px 10px 4px; color: #a8bfbb; font-size: 11px; font-weight: 650; }
.nav-section:has(+ #nav-mail.hidden + #nav-messages.hidden + #nav-wazzup.hidden + #nav-max.hidden) { display: none; }
.nav .brand small, .nav-foot .muted, .me small { color: #a8bfbb; }
.nav .brand { padding-inline: 8px; }
.brand-mark { display: block; width: 107px; height: auto; }
.brand .brand-mark { width: 102px; }
.brand small { align-self: end; padding-bottom: 3px; }
.nav-search { background: #263b3e; color: #dae8e6; }
.nav-item:hover { background: #22383a; }
.nav-item.active { background: #285953; box-shadow: inset 3px 0 #a2d573; }
.main { padding: 20px clamp(12px, 2vw, 28px) 32px; }
.preview-caption { margin: 0 0 12px; padding: 6px 10px; border-left: 3px solid var(--accent); background: #e5efec; color: var(--muted); font-size: 12px; }
.view > .toolbar > h2 { font-size: clamp(20px, 2vw, 27px); font-weight: 700; letter-spacing: -.025em; }
.btn, .seg button, .source-filter select { min-height: 34px; }
.btn.small { min-height: 30px; }
.btn:focus-visible, .icon:focus-visible, summary:focus-visible, .chip:focus-visible, .stagebar button:focus-visible, .max-chat-select:focus-visible { outline: 2px solid #09685e; outline-offset: 2px; }
.panel, .composer { border: 1px solid var(--line); box-shadow: var(--shadow); }

#view-board > .toolbar { padding-bottom: 13px; border-bottom: 1px solid var(--line); }
#view-board .pipeline-select { font-size: 19px; }
#view-board #board-owner { max-width: min(190px, 100%); }
#view-board .quickbar { align-items: center; gap: 9px 14px; }
#view-board #quick-filters { padding-block: 2px; }
#view-board .chip { min-height: 30px; }
#view-board .col { background: #e5edeb; width: clamp(250px, 23vw, 294px); border-color: var(--line); border-top-color: var(--stage, #8caea7); }
#view-board .col-name { font-size: 14px; font-weight: 680; }
#view-board .col-name { white-space: normal; overflow-wrap: anywhere; }
#view-board .col-title { align-items: flex-start; }
#view-board .col-count { margin-top: 2px; flex: 0 0 auto; }
#view-board .col-tools { opacity: 1; }
#view-board .card { border-color: var(--line); border-left-color: transparent; box-shadow: var(--shadow); }
#view-board .card.rot { border-left-color: var(--red); }
#view-board .card .t { font-size: 15px; line-height: 1.35; }
#view-board .card:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#view-board .card .card-created { font-size: 12px; color: var(--muted); }
[data-context-pending] { visibility: hidden; }
.table th { color: #314d49; }
.table tbody tr:hover td { background: #f7fbfa; }
.contact-heading { font-size: 19px; color: var(--ink); text-transform: none; letter-spacing: 0; overflow-wrap: anywhere; }
.contact-deals { border-top: 1px solid var(--line); padding-top: 10px; }
.contact-deal { display: grid; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--line2); }
.contact-deal .btn { justify-self: start; white-space: normal; text-align: left; overflow-wrap: anywhere; }
.search-bar { display: flex; align-items: center; padding-right: 10px; gap: 8px; }
.search-bar .btn { flex-shrink: 0; }
button.sr { width: 100%; border: 0; background: transparent; font: inherit; color: var(--ink); text-align: left; overflow-wrap: anywhere; }
button.sr:hover, button.sr.sel { background: var(--accent-2); }
button.sr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.manager-header { padding: 16px 20px 10px; border-color: var(--line); }
.manager-header .dh-title { font-size: clamp(17px, 2vw, 23px); letter-spacing: -.02em; }
.manager-header .stagebar button { padding-inline: 10px; font-size: 12px; }
.manager-deal.dgrid { grid-template-columns: minmax(290px, .86fr) minmax(0, 1.2fr); gap: 16px; }
.manager-deal .plan { margin-bottom: 14px; }
.manager-deal .plan h3 { margin-bottom: 0; }
.manager-deal .plan:empty { display: none; }
.manager-deal .planned, .manager-deal .nudge { padding: 10px 12px; }
.manager-deal .panel h3, .conversation-heading { font-size: 15px; font-weight: 680; text-transform: none; letter-spacing: 0; color: var(--ink); }
.manager-deal .fields { gap: 5px; }
.manager-deal .fld { grid-template-columns: minmax(83px, 112px) minmax(0, 1fr); }
.manager-deal .fld input, .manager-deal .fld select { min-height: 32px; }
.manager-deal .contact-actions { margin-top: 10px; }
.manager-deal #client-time .badge { white-space: normal; overflow-wrap: anywhere; }

.avito-chat .ac-list, #max-messages, .telegram-conversation-history {
  background: #eaf2ef;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.ac-msg, .max-bubble { max-width: min(90%, 64ch); border: 1px solid rgb(22 56 51 / 8%); line-height: 1.48; }
.ac-msg.in, .max-bubble-in { background: #fff; }
.ac-msg.out, .max-bubble-out { background: var(--accent-2); }
.ac-msg img { max-width: 100%; height: auto; }
.avito-photo-picker { position: relative; }
.avito-photo-picker input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.avito-photo-picker:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
#ac-file { overflow-wrap: anywhere; }
.telegram-conversation-history { display: flex; flex-direction: column; gap: 8px; max-height: 330px; overflow: auto; margin-bottom: 10px; }
.telegram-conversation-history .ac-msg.in { background: #fff; }
.telegram-conversation-history .ac-msg.out { background: var(--accent-2); }
.conversation-bar, .conversation-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.conversation-bar { justify-content: space-between; margin-bottom: 12px; }
.conversation-bar h3 { margin: 0; overflow-wrap: anywhere; }
.conversation-actions + [role="status"]:empty { display: none; }
.max-layout { grid-template-columns: minmax(208px, 275px) minmax(0, 1fr); }
.max-conversation { display: grid; grid-template-rows: auto minmax(6rem, 1fr) auto; max-height: calc(100dvh - 112px); }
.max-conversation:has(#max-messages:empty) { grid-template-rows: auto auto; max-height: none; }
.max-chat-select { min-height: 40px; overflow-wrap: anywhere; }
.max-chat-select strong { display: block; font-weight: 650; }
.max-chat-excerpt { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; font-size: 12px; color: var(--muted); }
.max-chat-select[aria-pressed="true"] { background: var(--accent-2); color: var(--accent); box-shadow: inset 3px 0 var(--accent); font-weight: 650; }
.max-chat-row { flex-wrap: wrap; }
#max-messages:empty { display: none; }
#max-messages { min-height: 0; max-height: none; }
#max-send-form label { font-weight: 550; }
#wazzup-body iframe { background: var(--panel); border: 1px solid var(--line) !important; border-radius: 10px; }
.wazzup-compose { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.wazzup-compose summary { cursor: pointer; font-weight: 650; padding: 12px 16px; color: var(--accent); }
.wazzup-compose #wazzup-first-form { border: 0; box-shadow: none; margin-bottom: 0; padding-top: 4px; }
.wazzup-compose #wazzup-first-form h3 { display: none; }
#wazzup-first-form { display: grid; gap: 8px; max-width: 780px; }
#wazzup-first-form h3, #wazzup-first-form p { margin: 0; }
#wazzup-first-form > .btn { justify-self: start; }

@media (max-width: 900px) {
  .nav-section { display: none; }
  .main { padding-top: 14px; }
  .manager-deal.dgrid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
}
@media (max-width: 760px) {
  .max-layout { grid-template-columns: minmax(0, 1fr); }
  .max-conversation { max-height: none; }
  #max-messages { max-height: 40dvh; }
}
@media (max-width: 520px) {
  #view-board .pipeline-select { font-size: 16px; }
  #view-board .col { width: min(285px, 82vw); }
  .manager-header { padding: 12px; }
  .manager-deal.dgrid { padding: 10px 12px 28px; }
  .manager-deal .fld { grid-template-columns: minmax(72px, 94px) minmax(0, 1fr); }
  .contact-form { grid-template-columns: minmax(0, 1fr); }
  .btn, .seg button, .chip, .max-chat-select { min-height: 40px; }
  .btn.small { min-height: 34px; }
}
.chat-file-picker { padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; background: var(--bg); }
.chat-file-picker input { max-width: 100%; min-width: 0; }
.chat-attachment-link { display: block; overflow-wrap: anywhere; padding: 8px 0; font-weight: 600; color: var(--accent); }
.max-bubble > p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.max-bubble > small { display: block; margin-top: 6px; text-align: right; }
