* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 18px;
    background: #f4f7f9;
    font-family: Arial, Helvetica, sans-serif;
    color: #1f2933;
}

.app { max-width: 1360px; margin: 0 auto; }

.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.title { font-size: 24px; font-weight: 700; margin: 0 0 6px; }
.subtitle { color: #6b7785; font-size: 14px; }
.user-box { background: #fff; border-radius: 12px; padding: 12px 16px; box-shadow: 0 2px 12px rgba(0,0,0,.06); font-size: 13px; min-width: 260px; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tab-btn { border: 0; background: #fff; color: #344054; padding: 10px 16px; border-radius: 10px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.05); font-weight: 600; }
.tab-btn.active { background: #1f7ae0; color: #fff; }
.tab { display: none; }
.tab.active { display: block; }

.card { background: #fff; border-radius: 14px; padding: 18px; box-shadow: 0 2px 14px rgba(0,0,0,.06); margin-bottom: 18px; }
.card-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
.card-title { font-size: 18px; font-weight: 700; }

.form-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
input, select, textarea { border: 1px solid #d0d7de; border-radius: 9px; padding: 10px 12px; font-size: 14px; min-height: 40px; }
input:not([type="checkbox"]):not([type="radio"]) { min-width: 220px; }
button { border: 0; border-radius: 9px; padding: 10px 14px; cursor: pointer; font-weight: 600; min-height: 40px; }
.btn-primary { background: #1f7ae0; color: white; }
.btn-gray { background: #edf2f7; color: #263238; }
.btn-danger { background: #e5484d; color: white; }
.btn-small { padding: 7px 10px; font-size: 12px; min-height: 32px; }

.notice { padding: 12px 14px; border-radius: 10px; background: #eef6ff; color: #184e77; margin-bottom: 12px; }
.error { background: #fee4e2; color: #b42318; }
.hidden { display: none !important; }
.muted { color: #667085; font-size: 12px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge { display: inline-block; padding: 4px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.badge-connected { background: #dcfae6; color: #067647; }
.badge-disabled { background: #f2f4f7; color: #667085; }
.badge-error { background: #fee4e2; color: #b42318; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid #eef1f4; padding: 10px 8px; text-align: left; vertical-align: top; }
th { background: #f8fafc; color: #667085; font-weight: 700; }

.chat-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; }
.chat-account-select { min-width: 280px; }
.messenger-layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 14px; min-height: 620px; }
.chat-list-panel, .chat-dialog-panel { background: #fff; border: 1px solid #eef1f4; border-radius: 14px; overflow: hidden; min-height: 620px; }
.chat-list-header { padding: 14px; border-bottom: 1px solid #eef1f4; display: flex; justify-content: space-between; align-items: center; }
.chat-list { max-height: 560px; overflow: auto; }
.chat-item { padding: 13px 14px; border-bottom: 1px solid #eef1f4; cursor: pointer; display: flex; gap: 10px; align-items: flex-start; }
.chat-item:hover, .chat-item.active { background: #eef6ff; }
.chat-avatar { width: 42px; height: 42px; border-radius: 50%; background: #ffad33; color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chat-main { min-width: 0; flex: 1; }
.chat-row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.chat-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-time { color: #667085; font-size: 12px; white-space: nowrap; }
.chat-preview { color: #667085; font-size: 13px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-meta { color: #98a2b3; font-size: 12px; margin-top: 4px; }
.chat-crm-link { min-height: 0; padding: 0; border-radius: 0; background: transparent; color: #1f7ae0; font-size: 12px; font-weight: 600; line-height: 1.2; }
.chat-crm-link:hover { text-decoration: underline; }

.dialog-empty { height: 100%; min-height: 620px; display: flex; align-items: center; justify-content: center; color: #667085; text-align: center; padding: 20px; }
.dialog-header { padding: 14px 16px; border-bottom: 1px solid #eef1f4; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.dialog-title { font-size: 18px; font-weight: 700; }
.dialog-subtitle { color: #667085; font-size: 13px; margin-top: 4px; }
.dialog-messages { height: 470px; overflow: auto; padding: 18px; background: #eaf5ff; }
.message-bubble { max-width: 72%; margin-bottom: 10px; padding: 10px 12px; border-radius: 14px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.06); white-space: pre-wrap; word-break: break-word; }
.message-bubble.own { margin-left: auto; background: #d9fdd3; }
.message-text { font-size: 14px; line-height: 1.35; }
.message-time { font-size: 11px; color: #667085; text-align: right; margin-top: 5px; }
.message-attach { display: flex; align-items: center; gap: 8px; margin-top: 7px; padding: 8px; border-radius: 8px; background: rgba(0,0,0,.05); color: #344054; font-size: 12px; text-decoration: none; }
.message-attach.image { display: block; padding: 0; overflow: hidden; background: rgba(255,255,255,.45); }
.message-attach.image img { display: block; max-width: 260px; max-height: 220px; object-fit: cover; }
.message-attach.image span { display: block; padding: 7px 8px; }
.message-attach-icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 28px; border-radius: 6px; background: #e7f0ff; color: #1f7ae0; font-size: 10px; font-weight: 700; flex: 0 0 auto; }
.message-attach-name { display: block; font-weight: 600; }
.message-attach-size { display: block; margin-top: 2px; color: #667085; font-size: 11px; }
.dialog-send { border-top: 1px solid #eef1f4; padding: 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.dialog-send textarea { width: 100%; resize: vertical; min-height: 48px; max-height: 140px; }

.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .65); display: flex; align-items: center; justify-content: center; z-index: 99999; }
.modal-box { background: #fff; border-radius: 18px; width: 100%; max-width: 460px; box-shadow: 0 25px 80px rgba(0,0,0,.25); overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid #eef2f6; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { border: 0; background: transparent; font-size: 22px; cursor: pointer; min-height: auto; padding: 0; line-height: 1; }
.modal-body { padding: 24px; text-align: center; }
.modal-text { font-size: 14px; color: #475467; line-height: 1.5; margin-bottom: 18px; white-space: pre-line; text-align: left; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 24px 24px; }
.qr-status { margin-bottom: 18px; font-size: 14px; color: #475467; }
.qr-image-container { min-height: 280px; display: flex; align-items: center; justify-content: center; }
.qr-image-container img { width: 280px; height: 280px; object-fit: contain; border-radius: 12px; border: 1px solid #e4e7ec; padding: 10px; background: #fff; }

.crm-binding-modal {
    max-width: 680px;
}

.crm-binding-modal .modal-body {
    min-height: 330px;
    padding: 18px 22px;
    text-align: left;
}

.crm-binding-search {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr) auto;
    gap: 8px;
    margin-bottom: 14px;
}

.crm-binding-search select,
.crm-binding-search input {
    width: 100%;
    min-width: 0;
}

.crm-binding-results {
    display: grid;
    gap: 7px;
    max-height: 350px;
    overflow: auto;
}

.crm-binding-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    min-height: 54px;
    padding: 9px 12px;
    border: 1px solid #e0e6ef;
    background: #fff;
    color: #27364b;
    text-align: left;
}

.crm-binding-result:hover,
.crm-binding-result.selected {
    border-color: #6ba6e8;
    background: #eef6ff;
}

.crm-binding-result > span:first-child {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.crm-binding-result strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-binding-result small {
    color: #718096;
    font-weight: 400;
}

.crm-binding-result > span:last-child {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 4px 8px;
    background: #edf2f7;
    color: #526173;
    font-size: 11px;
}

@media (max-width: 720px) {
    .crm-binding-search {
        grid-template-columns: 1fr;
    }
}

.admin-access {
    max-width: 560px;
}

.admin-access-users,
.admin-access-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-access-user,
.admin-access-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid #e5eaf3;
    border-radius: 8px;
    background: #fff;
}

.admin-access-user span,
.admin-access-result span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-access-remove {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    padding: 0 !important;
    border: 1px solid #fecaca !important;
    border-radius: 7px !important;
    background: #fee4e2;
    color: #b42318;
    font-family: Arial, sans-serif !important;
    font-size: 16px !important;
    line-height: 1 !important;
    font-weight: 700 !important;
    text-align: center !important;
    cursor: pointer;
    flex: 0 0 auto;
    appearance: none;
}

.admin-access-search {
    margin-top: 12px;
}

.admin-access-search input {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.admin-access-results {
    margin-top: 8px;
}

.admin-access-result .btn-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    min-width: 30px;
    height: 30px;
    padding: 0;
    font-size: 16px;
    line-height: 1;
}

@media (max-width: 900px) {
    .top { flex-direction: column; }
    .user-box { width: 100%; }
    .messenger-layout { grid-template-columns: 1fr; }
    .chat-list-panel, .chat-dialog-panel { min-height: auto; }
    .dialog-messages { height: 420px; }
}

/* === Исправление компактного отображения сообщений === */
.dialog-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dialog-message {
    display: flex;
    width: 100%;
}

.dialog-message.client {
    justify-content: flex-start;
}

.dialog-message.own {
    justify-content: flex-end;
}

.dialog-message-bubble {
    display: inline-block;
    width: auto;
    max-width: 68%;
    min-width: 40px;
    height: auto;
    min-height: 0;
    padding: 8px 11px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

.dialog-message.own .dialog-message-bubble {
    background: #d9fdd3;
}

.dialog-message-text {
    font-size: 14px;
    line-height: 1.35;
    white-space: pre-wrap;
    word-break: break-word;
}

.dialog-message-time {
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.2;
    color: #667085;
    text-align: right;
}

.chat-item.active {
    background: #dbeafe;
    border-left: 4px solid #1f7ae0;
    padding-left: 10px;
}

.chat-time {
    font-size: 11px;
    color: #667085;
}
/* /marketplace/TelegramMessenger/assets/css/lines_module.css */
.lines-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.line-card {
    border: 1px solid #eef1f4;
    border-radius: 14px;
    padding: 14px;
    background: #f8fafc;
}

.line-card.active {
    background: #ecfdf3;
    border-color: #abefc6;
}

.line-card.inactive {
    background: #f9fafb;
    color: #667085;
}

.line-card-title {
    font-weight: 700;
    margin-bottom: 6px;
}

.line-card-meta,
.line-card-bound {
    color: #667085;
    font-size: 13px;
    margin-top: 4px;
}

.line-invoice-modal {
    max-width: 760px;
}

.line-invoice-body {
    text-align: left;
}

.line-invoice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.line-invoice-grid .full,
.line-requisite-form.full {
    grid-column: 1 / -1;
}

.line-requisite-form {
    padding: 14px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #eef1f4;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-grid .full {
    grid-column: 1 / -1;
}

.line-renew-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow: auto;
    padding: 8px;
    border: 1px solid #eef1f4;
    border-radius: 12px;
    background: #f8fafc;
}

.line-renew-item {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border-radius: 10px;
    background: #fff;
}

.line-renew-item small {
    margin-left: auto;
    color: #667085;
}

.line-invoice-total {
    padding: 12px 14px;
    border-radius: 12px;
    background: #eef6ff;
    color: #184e77;
    font-weight: 700;
}

#lineInvoiceModal .modal-box {
    width: 620px !important;
    max-width: calc(100vw - 40px) !important;
    max-height: calc(100vh - 40px) !important;
    overflow: hidden !important;
}

#lineInvoiceModal .modal-body {
    max-height: calc(100vh - 190px) !important;
    overflow-y: auto !important;
    padding: 18px 24px !important;
}

#lineInvoiceModal .line-form-block {
    margin-bottom: 14px !important;
}

#lineInvoiceModal .line-form-block label {
    display: block !important;
    margin-bottom: 6px !important;
    font-weight: 600 !important;
    text-align: left !important;
}

#lineInvoiceModal .form-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
    align-items: center !important;
}

#lineInvoiceModal input,
#lineInvoiceModal select,
#lineInvoiceModal textarea {
    width: 100% !important;
    box-sizing: border-box !important;
}

#lineInvoiceModal #lineRequisiteSelect {
    width: 100% !important;
}

#lineInvoiceModal .line-requisite-form {
    padding: 14px !important;
    margin: 12px 0 !important;
    border-radius: 12px !important;
    background: #f7f9fc !important;
    border: 1px solid #e5eaf3 !important;
}

#lineInvoiceModal .line-requisite-form textarea {
    min-height: 76px !important;
    resize: vertical !important;
}

#lineInvoiceModal .line-total {
    text-align: right !important;
    font-size: 18px !important;
    font-weight: 700 !important;
}

.sync-settings {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    align-items: center;
    min-width: 220px;
}

.sync-check {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #26364d;
    white-space: nowrap;
}

.sync-check input {
    margin: 0;
}
.contact-form-settings-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 28px;
    align-items: start;
    margin-top: 20px;
}

.contact-form-settings-fields {
    min-width: 0;
}

.contact-form-switch {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px;
    margin-bottom: 12px;
    border: 1px solid #dfe5ec;
    border-radius: 12px;
    background: #f8fafc;
}

.contact-form-switch input,
.contact-form-options input {
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    accent-color: #1f7ae0;
}

.contact-form-switch span {
    display: grid;
    gap: 3px;
}

.contact-form-switch small,
.contact-form-full small {
    color: #6f7b8c;
    line-height: 1.4;
}

.contact-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.contact-form-grid label,
.contact-form-full {
    display: grid;
    gap: 7px;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
}

.contact-form-grid input,
.contact-form-full textarea,
.contact-form-full select {
    width: 100%;
    border: 1px solid #d7dee8;
    border-radius: 9px;
    padding: 10px 12px;
    background: #fff;
    color: #172033;
    font: inherit;
}

.contact-form-builder {
    border: 1px solid #dce4ef;
    border-radius: 12px;
    background: #f8fafc;
    padding: 16px;
}

.contact-form-builder-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 14px;
}

.contact-form-builder-head small {
    display: block;
    color: #69778b;
    margin-top: 4px;
}

.contact-form-fields-builder {
    display: grid;
    gap: 14px;
}

.contact-form-field-group {
    display: grid;
    gap: 10px;
}

.contact-form-field-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 28px;
    padding: 0 2px;
}

.contact-form-field-group-head strong {
    color: #172033;
    font-size: 14px;
}

.contact-form-field-group-head > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 27px;
    height: 27px;
    border-radius: 999px;
    background: #e8eef7;
    color: #4d5d73;
    font-size: 12px;
    font-weight: 700;
}

.contact-form-field-group-list {
    display: grid;
    gap: 10px;
}

.contact-form-field-empty {
    border: 1px dashed #cbd6e4;
    border-radius: 10px;
    padding: 18px;
    background: rgba(255, 255, 255, .65);
    color: #718096;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    transition:
        transform .18s ease,
        border-color .18s ease,
        background .18s ease,
        box-shadow .18s ease,
        color .18s ease;
}

.contact-form-field-empty:hover {
    transform: translateY(-2px) scale(1.015);
    border-color: #4f8df7;
    background: #f4f8ff;
    color: #3569b8;
    box-shadow: 0 8px 20px rgba(79, 141, 247, .14);
}

.contact-form-field-empty:active {
    transform: translateY(0) scale(.995);
    box-shadow: 0 3px 10px rgba(79, 141, 247, .12);
}

.contact-form-field-empty:focus-visible {
    outline: none;
    border-color: #4f8df7;
    box-shadow: 0 0 0 3px rgba(79, 141, 247, .18);
}

.contact-form-field-row {
    border: 1px solid #d9e1ec;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}

.contact-form-field-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 52px;
    padding: 8px 12px;
    background: #fff;
    cursor: pointer;
    transition: background .15s ease;
}

.contact-form-field-card-head:hover {
    background: #f8fafc;
}

.contact-form-field-row.is-editing {
    border-color: #a9c8ee;
    box-shadow: 0 0 0 2px rgba(31, 122, 224, .08);
}

.contact-form-field-row.is-editing .contact-form-field-card-head {
    border-bottom: 1px solid #e1e8f1;
    background: #f7faff;
}

.contact-form-field-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.contact-form-field-identity > div {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.contact-form-field-identity strong {
    overflow: hidden;
    color: #172033;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contact-form-field-identity small {
    color: #7a8798;
    font-size: 11px;
}

.contact-form-field-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: #edf3fc;
    color: #376aa8;
    font-size: 12px;
    font-weight: 800;
}

.contact-form-field-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 auto;
}

.contact-form-field-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #718096;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.contact-form-field-icon-btn:hover {
    background: #eaf2fc;
    color: #1f6fc5;
}

.contact-form-field-icon-btn.danger:hover {
    background: #fff0f0;
    color: #d83b3b;
}

.contact-form-field-editor {
    display: none;
    padding: 14px;
    background: #fff;
}

.contact-form-field-row.is-editing .contact-form-field-editor {
    display: block;
}

.contact-form-field-main {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(150px, 220px);
    gap: 10px;
    align-items: end;
}

.contact-form-field-row label span,
.contact-form-field-help span,
.contact-form-field-options span {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #536176;
    margin-bottom: 5px;
}

.contact-form-field-row input[type="text"],
.contact-form-field-row select,
.contact-form-field-row textarea {
    width: 100%;
    border: 1px solid #cfd8e5;
    border-radius: 8px;
    padding: 9px 10px;
    background: #fff;
    font: inherit;
}

.contact-form-field-check {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-size: 13px;
}

.contact-form-field-check input {
    margin: 0;
}

.contact-form-field-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 9px;
    background: #f5f7fa;
}

.contact-form-field-help,
.contact-form-field-options {
    display: block;
    margin-top: 10px;
}

.contact-form-mapping-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 10px;
}

.contact-form-mapping-details {
    margin-top: 12px;
    border: 1px solid #e1e7f0;
    border-radius: 9px;
    overflow: hidden;
}

.contact-form-mapping-details summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: #fbfcfe;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.contact-form-mapping-details summary::-webkit-details-marker {
    display: none;
}

.contact-form-mapping-details summary > span:first-child {
    display: grid;
    gap: 2px;
}

.contact-form-mapping-details summary strong {
    color: #334155;
    font-size: 13px;
}

.contact-form-mapping-details summary small {
    color: #77859a;
    font-size: 11px;
}

.contact-form-mapping-chevron {
    width: 9px;
    height: 9px;
    margin-right: 4px;
    border-right: 2px solid #7a8798;
    border-bottom: 2px solid #7a8798;
    transform: rotate(45deg);
    transition: transform .18s ease;
}

.contact-form-mapping-details[open] .contact-form-mapping-chevron {
    transform: rotate(225deg);
}

.contact-form-mapping-content {
    padding: 13px 14px 15px;
    border-top: 1px solid #edf1f6;
    background: #f8fafc;
}

.contact-form-field-editor-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.contact-form-system-badge {
    align-self: center;
    justify-self: end;
    border-radius: 999px;
    background: #eaf2ff;
    color: #2864b7;
    padding: 5px 9px;
    font-size: 11px;
    font-weight: 700;
}

.contact-form-preview-input-large {
    height: 58px;
}

@media (max-width: 1250px) {
    .contact-form-mapping-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}

@media (max-width: 720px) {
    .contact-form-builder-head {
        flex-direction: column;
    }

    .contact-form-field-main,
    .contact-form-mapping-grid {
        grid-template-columns: 1fr;
    }

    .contact-form-field-flags {
        align-items: flex-start;
        flex-direction: column;
    }

    .contact-form-system-badge {
        display: none;
    }

    .contact-form-field-identity small {
        max-width: 210px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

.contact-form-grid input[type="color"] {
    min-height: 42px;
    padding: 4px;
}

.contact-form-full {
    margin-top: 14px;
}

.contact-form-full textarea {
    resize: vertical;
    line-height: 1.45;
}

.contact-form-options {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin: 16px 0 4px;
}

.contact-form-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #334155;
    font-size: 14px;
}

.contact-form-system-note {
    margin-top: 18px;
    padding: 13px 14px;
    border: 1px solid #b8d5ff;
    border-radius: 10px;
    background: #eef6ff;
    color: #28527f;
    font-size: 13px;
    line-height: 1.5;
}

.contact-form-preview-wrap {
    position: sticky;
    top: 16px;
}

.contact-form-preview {
    --preview-primary: #1f7ae0;
    margin-top: 8px;
    padding: 24px 20px;
    border: 8px solid #172033;
    border-radius: 30px;
    background: #fff;
    box-shadow: 0 16px 36px rgba(28, 41, 61, .15);
    color: #172033;
    min-height: 590px;
}

.contact-form-preview-logo {
    display: block;
    max-width: 130px;
    max-height: 54px;
    margin: 0 auto 14px;
    object-fit: contain;
}

.contact-form-preview-company {
    color: #778296;
    font-size: 11px;
    text-align: center;
}

.contact-form-preview-title {
    margin: 5px 0 7px;
    font-size: 21px;
    font-weight: 750;
    text-align: center;
}

.contact-form-preview-description {
    min-height: 36px;
    margin-bottom: 20px;
    color: #687487;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
    white-space: pre-line;
}

.contact-form-preview label {
    display: block;
    margin: 0 0 5px;
    color: #344054;
    font-size: 11px;
    font-weight: 650;
}

.contact-form-preview-input {
    height: 38px;
    margin-bottom: 13px;
    border: 1px solid #d9e0e8;
    border-radius: 8px;
    background: #fff;
}

.contact-form-preview-consent {
    margin: 16px 0;
    color: #667085;
    font-size: 10px;
    line-height: 1.4;
}

.contact-form-preview-button {
    padding: 12px;
    border-radius: 9px;
    background: var(--preview-primary);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

.contact-form-preview-transfer {
    margin-top: 12px;
    color: #8490a1;
    font-size: 9px;
    text-align: center;
}

@media (max-width: 1050px) {
    .contact-form-settings-layout {
        grid-template-columns: 1fr;
    }

    .contact-form-preview-wrap {
        position: static;
        width: min(100%, 360px);
        margin: 0 auto;
    }
}

@media (max-width: 640px) {
    .contact-form-grid {
        grid-template-columns: 1fr;
    }

    .contact-form-options {
        display: grid;
        gap: 10px;
    }
}

/* Contact forms list-first interface */
.contact-forms-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.contact-form-list-item {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto 24px;
    gap: 14px;
    align-items: center;
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #dce4ef;
    border-radius: 12px;
    background: #fff;
    color: #172033;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.contact-form-list-item:hover {
    border-color: #a9c8ee;
    box-shadow: 0 6px 18px rgba(31, 55, 90, .08);
    transform: translateY(-1px);
}

.contact-form-list-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: #edf3fc;
    color: #376aa8;
    font-weight: 800;
}

.contact-form-list-main {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.contact-form-list-main strong {
    overflow: hidden;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contact-form-list-main small {
    color: #6f7b8c;
}

.contact-form-list-status {
    padding: 5px 9px;
    border-radius: 999px;
    background: #f1f3f6;
    color: #6f7b8c;
    font-size: 11px;
    font-weight: 700;
}

.contact-form-list-status.is-ready {
    background: #e8f7ef;
    color: #238451;
}

.contact-form-list-arrow {
    color: #8b98aa;
    font-size: 26px;
    line-height: 1;
}

.contact-forms-empty {
    display: grid;
    justify-items: center;
    gap: 10px;
    margin-top: 16px;
    padding: 38px 20px;
    border: 1px dashed #cbd6e4;
    border-radius: 12px;
    color: #6f7b8c;
    text-align: center;
}

.contact-forms-empty strong {
    color: #172033;
    font-size: 17px;
}

.contact-form-editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid #e7ecf2;
}

.contact-form-editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.btn-danger-text {
    color: #c43d4f;
}

@media (max-width: 720px) {
    .contact-form-list-item {
        grid-template-columns: 38px minmax(0, 1fr) 20px;
    }

    .contact-form-list-status {
        display: none;
    }

    .contact-form-editor-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .contact-form-editor-actions {
        justify-content: flex-start;
    }
}

/* Contact forms list details */
.contact-form-list-main .contact-form-list-accounts {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #53657d;
}

.contact-form-list-main .contact-form-list-meta {
    color: #8793a3;
    font-size: 11px;
}


/* Custom confirmation modal for unsaved contact form changes */
.contact-form-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.contact-form-modal.hidden {
    display: none;
}

.contact-form-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.58);
    backdrop-filter: blur(3px);
}

.contact-form-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(480px, 100%);
    padding: 28px;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 28px 70px rgba(15, 23, 42, 0.28);
    text-align: center;
}

.contact-form-modal__close {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: #f2f5f9;
    color: #64748b;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.contact-form-modal__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: #fff1f2;
    color: #e11d48;
    font-size: 30px;
    font-weight: 800;
}

.contact-form-modal__title {
    margin-bottom: 10px;
    color: #172033;
    font-size: 22px;
    font-weight: 800;
}

.contact-form-modal__text {
    margin: 0 auto;
    max-width: 360px;
    color: #64748b;
    font-size: 15px;
    line-height: 1.5;
}

.contact-form-modal__actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 24px;
}

.contact-form-modal__actions .btn {
    min-height: 42px;
}

.contact-form-modal-open {
    overflow: hidden;
}

@media (max-width: 560px) {
    .contact-form-modal__dialog {
        padding: 24px 18px 18px;
        border-radius: 18px;
    }

    .contact-form-modal__actions {
        flex-direction: column-reverse;
    }

    .contact-form-modal__actions .btn {
        width: 100%;
    }
}

.contact-form-mapping-status {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    margin-top: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
}

.contact-form-mapping-status.warning {
    background: #fef2f2;
    color: #dc2626;
}

.contact-form-mapping-status.ok {
    background: #ecfdf5;
    color: #15803d;
}

.contact-form-field-summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 3px;
}

.contact-form-field-crm-status {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
}

.contact-form-field-crm-status.warning {
    color: #dc2626;
}

.contact-form-field-crm-status.ok {
    color: #15803d;
}


/* Персональные локальные непрочитанные */
.chat-unread-tools {
    display:flex;
    align-items:center;
    gap:6px;
    margin-left:auto;
    white-space:nowrap;
}
.chat-unread-tools[hidden] { display:none !important; }
.chat-unread-label {
    color:#667085;
    font-size:11px;
}
.chat-unread-total {
    min-width:22px;
    height:22px;
    padding:0 6px;
    border-radius:999px;
    background:#16a34a;
    color:#fff;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    font-size:11px;
    font-weight:700;
    line-height:1;
}
.chat-time-wrap {
    display:flex;
    flex-direction:row;
    align-items:center;
    justify-content:flex-end;
    gap:6px;
    flex-shrink:0;
}
.chat-unread-badge {
    min-width:22px;
    height:22px;
    padding:0 6px;
    border-radius:999px;
    background:#16a34a;
    color:#fff;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    font-size:11px;
    font-weight:700;
    line-height:1;
    flex-shrink:0;
}
.chat-item.unread { background:#f0fdf4; }
.chat-item.unread .chat-title, .chat-item.unread .chat-preview { font-weight:700; color:#111827; }
.chat-tracking-off {
    display:inline-flex;
    align-items:center;
    margin-left:4px;
    color:#667085;
    font-size:12px;
    line-height:1;
    cursor:help;
}
@media (max-width:700px) {
    .chat-list-header { align-items:center; }
    .chat-unread-tools { gap:5px; }
    .chat-unread-label { display:none; }
    .chat-unread-tools .btn-small { padding:6px 8px; }
}

/* Telegram contact form: CRM enumeration mapping */
.contact-form-enum-map {
    grid-column: 1 / -1;
    margin: 4px 0 12px;
    padding: 12px;
    border: 1px solid #dce5ef;
    border-radius: 10px;
    background: #f8fafc;
}
.contact-form-enum-map > strong { display:block; margin-bottom:4px; }
.contact-form-enum-map > small { display:block; color:#6b7785; margin-bottom:10px; }
.contact-form-enum-row {
    display:grid;
    grid-template-columns:minmax(140px,1fr) minmax(180px,1.3fr);
    gap:10px;
    align-items:center;
    margin-top:8px;
}
.contact-form-enum-row > span { overflow-wrap:anywhere; }
@media (max-width:720px){.contact-form-enum-row{grid-template-columns:1fr;gap:5px}}


/* Локальный результат сохранения настроек строки Telegram-номера */
.inline-save-status {
    min-height: 17px;
    margin-top: 5px;
    font-size: 11px;
    line-height: 1.25;
    color: #667085;
}

.inline-save-status.success {
    color: #067647;
}

.inline-save-status.error {
    color: #b42318;
}

button.save-success {
    background: #dcfae6 !important;
    color: #067647 !important;
}

button.save-error {
    background: #fee4e2 !important;
    color: #b42318 !important;
}

button:disabled {
    cursor: default;
    opacity: .78;
}


/* Пагинация и optimistic send в чате */
.chat-history-loader {
    padding: 8px 12px;
    text-align: center;
    font-size: 11px;
    color: #667085;
}

.dialog-message-status {
    margin-top: 3px;
    font-size: 10px;
    line-height: 1.25;
}

.dialog-message-status.sending {
    color: #667085;
}

.dialog-message-status.success {
    color: #067647;
}

.dialog-message-status.error {
    color: #b42318;
}

.dialog-message.send-failed .dialog-message-bubble {
    outline: 1px solid rgba(180, 35, 24, .28);
}

.optimistic-message {
    opacity: .96;
}
