/* messenger.css — чат с клиентами (Telegram + MAX) */
#mx-root { --mx-tg: #229ED9; --mx-max: #7B4DFF; --mx-line: #e5e7eb; --mx-muted: #6b7280; }
#mx-root .mx-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
#mx-root .mx-tab { padding: 8px 16px; border-radius: 10px; border: 1px solid var(--mx-line); background: #fff; font-size: 14px; font-weight: 500; color: #374151; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
#mx-root .mx-tab.is-active { background: #111827; color: #fff; border-color: #111827; }
#mx-root .mx-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
#mx-root .mx-card { background: #fff; border: 1px solid var(--mx-line); border-radius: 14px; }

/* layout */
#mx-root .mx-chat { display: grid; grid-template-columns: 340px 1fr; gap: 16px; height: calc(100vh - 210px); min-height: 520px; }
#mx-root .mx-list { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
#mx-root .mx-list-head { padding: 14px; border-bottom: 1px solid var(--mx-line); }
#mx-root .mx-search { width: 100%; padding: 9px 12px; border: 1px solid var(--mx-line); border-radius: 10px; font-size: 14px; outline: none; }
#mx-root .mx-search:focus { border-color: #9ca3af; }
#mx-root .mx-filters { display: flex; gap: 6px; margin-top: 10px; }
#mx-root .mx-chip { padding: 4px 10px; border-radius: 999px; font-size: 12px; border: 1px solid var(--mx-line); background: #fff; color: #374151; cursor: pointer; }
#mx-root .mx-chip.is-active { background: #111827; color: #fff; border-color: #111827; }
#mx-root .mx-items { overflow-y: auto; flex: 1; }
#mx-root .mx-item { display: flex; gap: 10px; padding: 12px 14px; cursor: pointer; border-bottom: 1px solid #f3f4f6; align-items: center; }
#mx-root .mx-item:hover { background: #f9fafb; }
#mx-root .mx-item.is-active { background: #f3f4f6; }
#mx-root .mx-ava { position: relative; width: 42px; height: 42px; border-radius: 50%; background: #e5e7eb; color: #374151; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex-shrink: 0; }
#mx-root .mx-ava .mx-pl { position: absolute; right: -2px; bottom: -2px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; font-size: 8px; font-weight: 700; color: #fff; display: flex; align-items: center; justify-content: center; }
#mx-root .mx-pl.tg, #mx-root .mx-pill.tg { background: var(--mx-tg); }
#mx-root .mx-pl.max, #mx-root .mx-pill.max { background: var(--mx-max); }
#mx-root .mx-item-main { flex: 1; min-width: 0; }
#mx-root .mx-item-top { display: flex; justify-content: space-between; gap: 6px; }
#mx-root .mx-item-name { font-weight: 600; font-size: 14px; color: #111827; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mx-root .mx-item-time { font-size: 11px; color: var(--mx-muted); flex-shrink: 0; }
#mx-root .mx-item-bottom { display: flex; justify-content: space-between; gap: 6px; margin-top: 2px; align-items: center; }
#mx-root .mx-item-text { font-size: 13px; color: var(--mx-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mx-root .mx-empty { padding: 40px 20px; text-align: center; color: var(--mx-muted); font-size: 14px; }

/* dialog */
#mx-root .mx-dialog { display: flex; flex-direction: column; min-height: 0; overflow: hidden; position: relative; }
#mx-root .mx-dlg-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--mx-line); }
#mx-root .mx-dlg-title { font-weight: 600; color: #111827; font-size: 15px; }
#mx-root .mx-dlg-sub { font-size: 12px; color: var(--mx-muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
#mx-root .mx-pill { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; color: #fff; font-size: 11px; font-weight: 600; }
#mx-root .mx-tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; background: #f3f4f6; color: #374151; font-size: 11px; }
#mx-root .mx-tag.ok { background: #dcfce7; color: #166534; }
#mx-root .mx-tag.warn { background: #fef3c7; color: #92400e; }
#mx-root .mx-tag.bad { background: #fee2e2; color: #991b1b; }
#mx-root .mx-icon-btn { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--mx-line); background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: #374151; }
#mx-root .mx-icon-btn:hover { background: #f9fafb; }
#mx-root .mx-msgs { flex: 1; overflow-y: auto; padding: 16px; background: #f8fafc; }
#mx-root .mx-day { text-align: center; margin: 12px 0; }
#mx-root .mx-day span { font-size: 11px; color: var(--mx-muted); background: #eef2f7; padding: 3px 10px; border-radius: 999px; }
#mx-root .mx-row { display: flex; margin: 4px 0; }
#mx-root .mx-row.out { justify-content: flex-end; }
#mx-root .mx-row.sys { justify-content: center; }
#mx-root .mx-bubble { max-width: min(72%, 560px); padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(0,0,0,.04); }
#mx-root .mx-row.in .mx-bubble { background: #fff; border: 1px solid var(--mx-line); border-bottom-left-radius: 4px; color: #111827; }
#mx-root .mx-row.out.op .mx-bubble { background: #111827; color: #fff; border-bottom-right-radius: 4px; }
#mx-root .mx-row.out.bot .mx-bubble { background: #e8f1ff; color: #1e3a5f; border-bottom-right-radius: 4px; }
#mx-root .mx-row.sys .mx-bubble { background: transparent; box-shadow: none; color: var(--mx-muted); font-size: 12px; padding: 2px 8px; }
#mx-root .mx-meta { font-size: 10.5px; opacity: .65; margin-top: 3px; text-align: right; }
#mx-root .mx-who { font-size: 11px; font-weight: 600; opacity: .7; margin-bottom: 2px; }
#mx-root .mx-btns { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
#mx-root .mx-btns span { font-size: 11.5px; padding: 3px 8px; border-radius: 8px; background: rgba(255,255,255,.75); border: 1px solid rgba(30,58,95,.15); }
#mx-root .mx-failed { color: #dc2626; font-size: 11px; margin-top: 3px; }
#mx-root .mx-img { display: block; max-width: 260px; max-height: 260px; border-radius: 10px; margin-bottom: 4px; background: #e5e7eb; min-width: 120px; min-height: 80px; object-fit: cover; cursor: pointer; }
#mx-root .mx-file { display: inline-flex; align-items: center; gap: 6px; text-decoration: underline; cursor: pointer; }
#mx-root .mx-more { text-align: center; margin-bottom: 8px; }
#mx-root .mx-more button { font-size: 12px; color: #374151; background: #fff; border: 1px solid var(--mx-line); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
#mx-root .mx-composer { border-top: 1px solid var(--mx-line); padding: 12px; display: flex; gap: 8px; align-items: flex-end; background: #fff; }
#mx-root .mx-input { flex: 1; resize: none; border: 1px solid var(--mx-line); border-radius: 12px; padding: 10px 12px; font-size: 14px; line-height: 1.4; max-height: 160px; outline: none; font-family: inherit; }
#mx-root .mx-input:focus { border-color: #9ca3af; }
#mx-root .mx-send { height: 42px; padding: 0 16px; border-radius: 12px; background: #111827; color: #fff; border: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; }
#mx-root .mx-send:disabled { opacity: .5; cursor: default; }
#mx-root .mx-warn { padding: 8px 16px; background: #fef3c7; color: #92400e; font-size: 12.5px; border-top: 1px solid #fde68a; }
#mx-root .mx-info { position: absolute; top: 0; right: 0; bottom: 0; width: 300px; background: #fff; border-left: 1px solid var(--mx-line); padding: 16px; overflow-y: auto; box-shadow: -8px 0 24px rgba(0,0,0,.06); z-index: 2; }
#mx-root .mx-info dt { font-size: 11px; color: var(--mx-muted); margin-top: 10px; }
#mx-root .mx-info dd { font-size: 14px; color: #111827; margin: 2px 0 0; word-break: break-word; }
#mx-root .mx-back { display: none; }

/* settings */
#mx-root .mx-set { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
#mx-root .mx-set .mx-full { grid-column: 1 / -1; }
#mx-root .mx-sec { padding: 20px; }
#mx-root .mx-sec h3 { font-size: 16px; font-weight: 600; color: #111827; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
#mx-root .mx-sec .mx-hint { font-size: 13px; color: var(--mx-muted); margin: 0 0 14px; }
#mx-root .mx-label { display: block; font-size: 12.5px; font-weight: 500; color: #374151; margin: 12px 0 4px; }
#mx-root .mx-field, #mx-root .mx-area, #mx-root .mx-select { width: 100%; border: 1px solid var(--mx-line); border-radius: 10px; padding: 9px 12px; font-size: 14px; outline: none; font-family: inherit; background: #fff; }
#mx-root .mx-area { min-height: 76px; resize: vertical; }
#mx-root .mx-field:focus, #mx-root .mx-area:focus, #mx-root .mx-select:focus { border-color: #9ca3af; }
#mx-root .mx-btn { padding: 9px 14px; border-radius: 10px; border: 1px solid var(--mx-line); background: #fff; color: #111827; font-size: 13.5px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
#mx-root .mx-btn:hover { background: #f9fafb; }
#mx-root .mx-btn.primary { background: #111827; color: #fff; border-color: #111827; }
#mx-root .mx-btn.primary:hover { background: #1f2937; }
#mx-root .mx-btn.danger { color: #b91c1c; }
#mx-root .mx-btn:disabled { opacity: .5; cursor: default; }
#mx-root .mx-bot-logo { width: 36px; height: 36px; border-radius: 10px; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
#mx-root .mx-status { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: #f9fafb; font-size: 13.5px; margin-bottom: 12px; }
#mx-root .mx-dot { width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; flex-shrink: 0; }
#mx-root .mx-dot.on { background: #22c55e; }
#mx-root .mx-dot.err { background: #ef4444; }
#mx-root .mx-steps { font-size: 13px; color: #4b5563; padding-left: 18px; margin: 0 0 8px; list-style: decimal; }
#mx-root .mx-steps li { margin: 2px 0; }
#mx-root .mx-row-flex { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
#mx-root .mx-switch { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; margin: 10px 0; }
#mx-root .mx-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
#mx-root .mx-switch .mx-sw { width: 38px; height: 22px; border-radius: 999px; background: #d1d5db; position: relative; flex-shrink: 0; transition: background .15s; margin-top: 1px; }
#mx-root .mx-switch .mx-sw::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
#mx-root .mx-switch input:checked + .mx-sw { background: #111827; }
#mx-root .mx-switch input:checked + .mx-sw::after { left: 19px; }
#mx-root .mx-switch input:focus-visible + .mx-sw { outline: 2px solid #93c5fd; outline-offset: 2px; }
#mx-root .mx-switch b { font-size: 14px; font-weight: 500; color: #111827; display: block; }
#mx-root .mx-switch small { font-size: 12.5px; color: var(--mx-muted); }
#mx-root .mx-sub { margin-left: 48px; padding-left: 12px; border-left: 2px solid #f3f4f6; }
#mx-root .mx-btn-edit { border: 1px solid var(--mx-line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: #fcfcfd; }
#mx-root .mx-btn-edit-top { display: grid; grid-template-columns: minmax(0,1fr) 160px auto; gap: 8px; align-items: center; }
#mx-root .mx-set > * { min-width: 0; }
#mx-root .mx-preview { background: #eef2f7; border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 8px; min-height: 200px; }
#mx-root .mx-preview .mx-pv-msg { background: #fff; border-radius: 12px; padding: 8px 12px; font-size: 13px; max-width: 90%; white-space: pre-wrap; }
#mx-root .mx-preview .mx-pv-kb { display: grid; gap: 4px; max-width: 90%; }
#mx-root .mx-preview .mx-pv-kb span { background: rgba(255,255,255,.85); border-radius: 8px; padding: 6px; font-size: 12.5px; text-align: center; color: #1f2937; }
#mx-root .mx-savebar { position: sticky; bottom: 0; background: rgba(255,255,255,.95); border-top: 1px solid var(--mx-line); padding: 12px 20px; display: flex; justify-content: flex-end; gap: 10px; border-radius: 0 0 14px 14px; }

@media (max-width: 1024px) {
  #mx-root .mx-set { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  #mx-root .mx-chat { grid-template-columns: 1fr; height: calc(100vh - 180px); }
  #mx-root .mx-chat.show-dialog .mx-list { display: none; }
  #mx-root .mx-chat:not(.show-dialog) .mx-dialog { display: none; }
  #mx-root .mx-back { display: inline-flex; }
  #mx-root .mx-bubble { max-width: 86%; }
  #mx-root .mx-info { width: 100%; }
  #mx-root .mx-btn-edit-top { grid-template-columns: 1fr; }
}
