:root {
    color-scheme: light;

    --page-bg: #e9edf3;
    --panel-bg: #ffffff;
    --border: #dde3ea;

    --text: #17202a;
    --muted: #7a8594;

    --primary: #3978f6;
    --primary-dark: #2865dc;
    --primary-soft: #edf4ff;

    --incoming: #ffffff;
    --outgoing: #dff1ff;

    --shadow: 0 16px 40px rgba(25, 35, 50, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body,
#app {
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
}

body {
    overflow: hidden;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Arial,
        sans-serif;

    color: var(--text);
    background: var(--page-bg);
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

/*
|--------------------------------------------------------------------------
| Основной каркас
|--------------------------------------------------------------------------
*/

#app {
    padding: 20px;
}

.messenger {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);

    width: 100%;
    height: 100%;
    min-height: 0;

    overflow: hidden;

    border: 1px solid var(--border);
    border-radius: 22px;

    background: var(--panel-bg);
    box-shadow: var(--shadow);
}

/*
|--------------------------------------------------------------------------
| Левая панель
|--------------------------------------------------------------------------
*/

.messenger-sidebar {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;

    overflow: hidden;

    border-right: 1px solid var(--border);
    background: #ffffff;
}

.sidebar-header {
    display: flex;
    min-height: 88px;
    align-items: center;
    justify-content: space-between;

    padding: 18px 20px 14px;
}

.sidebar-label {
    display: block;

    margin-bottom: 3px;

    color: var(--primary);

    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-header h1 {
    margin: 0;

    font-size: 25px;
    line-height: 1.15;
}

.icon-button {
    display: grid;
    width: 42px;
    height: 42px;
    padding: 0;

    place-items: center;

    border: 0;
    border-radius: 14px;

    color: #ffffff;
    background: var(--primary);

    font-size: 27px;
    line-height: 1;
}

.icon-button:hover {
    background: var(--primary-dark);
}

.sidebar-search {
    padding: 0 16px 14px;
}

.sidebar-search input {
    width: 100%;
    height: 44px;
    padding: 0 15px;

    border: 1px solid transparent;
    border-radius: 14px;
    outline: none;

    color: var(--text);
    background: #f1f4f8;
}

.sidebar-search input:focus {
    border-color: #aac6ff;
    background: #ffffff;
}

.chat-list {
    min-height: 0;
    flex: 1 1 auto;

    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;

    padding: 0 8px 12px;
}

.chat-list-item {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 12px;

    padding: 12px;

    border: 0;
    border-radius: 16px;

    text-align: left;
    color: inherit;
    background: transparent;
}

.chat-list-item:hover {
    background: #f4f6f9;
}

.chat-list-item--active,
.chat-list-item--active:hover {
    background: var(--primary-soft);
}

.chat-avatar {
    display: grid;
    width: 48px;
    min-width: 48px;
    height: 48px;

    place-items: center;

    border-radius: 50%;

    color: #ffffff;
    background: linear-gradient(145deg, #5892ff, #3069db);

    font-size: 14px;
    font-weight: 800;
}

.chat-list-content {
    display: block;
    min-width: 0;
    flex: 1;
}

.chat-list-row {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.chat-list-row + .chat-list-row {
    margin-top: 5px;
}

.chat-list-row strong {
    min-width: 0;

    overflow: hidden;

    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-list-row time {
    color: var(--muted);

    font-size: 12px;
    white-space: nowrap;
}

.chat-preview {
    min-width: 0;

    overflow: hidden;

    color: var(--muted);

    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.unread-badge {
    display: grid;
    min-width: 21px;
    height: 21px;
    padding: 0 6px;

    place-items: center;

    border-radius: 999px;

    color: #ffffff;
    background: var(--primary);

    font-size: 11px;
    font-weight: 800;
}

/*
|--------------------------------------------------------------------------
| Диалог
|--------------------------------------------------------------------------
*/

.conversation {
    display: grid;
    min-width: 0;
    min-height: 0;

    grid-template-rows: auto minmax(0, 1fr) auto;

    overflow: hidden;

    background:
        radial-gradient(
            circle at 20% 20%,
            rgba(255, 255, 255, 0.85),
            transparent 30%
        ),
        #eef2f6;
}

.conversation-header {
    display: flex;
    min-width: 0;
    min-height: 76px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    padding: 12px 20px;

    border-bottom: 1px solid var(--border);

    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
}

.conversation-user {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
}

.conversation-user .chat-avatar {
    width: 46px;
    min-width: 46px;
    height: 46px;
}

.conversation-user div {
    min-width: 0;
}

.conversation-user strong,
.conversation-user span {
    display: block;

    overflow: hidden;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-user strong {
    font-size: 16px;
}

.conversation-user span {
    margin-top: 4px;

    color: var(--muted);

    font-size: 12px;
}

.header-button {
    min-height: 40px;
    padding: 0 15px;

    border: 1px solid var(--border);
    border-radius: 12px;

    color: var(--text);
    background: #ffffff;

    font-weight: 700;
}

.header-button:hover {
    background: #f4f6f9;
}

/*
|--------------------------------------------------------------------------
| Лента сообщений
|--------------------------------------------------------------------------
*/

.messages {
    display: flex;
    min-height: 0;
    flex-direction: column;

    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;

    padding: 20px 18px 24px;
	position: relative;

    z-index: 1;
}

.messages-empty {
    display: grid;
    min-height: 100%;

    place-items: center;

    padding: 30px;

    color: var(--muted);

    text-align: center;
}

.messages-date {
    position: sticky;
    top: 8px;
    z-index: 2;

    align-self: center;

    margin: 10px 0;
    padding: 5px 10px;

    border-radius: 999px;

    color: #ffffff;
    background: rgba(75, 89, 110, 0.68);

    font-size: 11px;
    font-weight: 700;
    line-height: 1.1;

    backdrop-filter: blur(8px);
}

/*
|--------------------------------------------------------------------------
| Пузырь сообщения
|--------------------------------------------------------------------------
*/

.message {
    position: relative;

    display: block;
    width: fit-content;
    min-width: 0;
    max-width: min(72%, 560px);

    margin: 3px 0;
    padding: 0;

    border-radius: 15px;

    box-shadow: 0 3px 12px rgba(31, 44, 63, 0.07);

    transform-origin: bottom left;
}

.message--incoming {
    align-self: flex-start;

    border-bottom-left-radius: 5px;

    background: var(--incoming);
}

.message--outgoing {
    align-self: flex-end;

    border-bottom-right-radius: 5px;

    background: var(--outgoing);

    transform-origin: bottom right;
}

.message-body {
    display: flex;
    width: auto;
    min-width: 0;
    max-width: 100%;

    align-items: flex-end;
    gap: 6px;

    padding: 7px 9px 6px;
}

.message-content {
    min-width: 0;
}

.message-content p {
    margin: 0;

    font-size: 14px;
    line-height: 1.32;

    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.message-time {
    flex: 0 0 auto;
    align-self: flex-end;

    margin-bottom: 1px;

    color: #718096;

    font-size: 10px;
    line-height: 1;
    white-space: nowrap;

    user-select: none;
}

.message--outgoing .message-time {
    color: #66829a;
}

/*
|--------------------------------------------------------------------------
| Вложения
|--------------------------------------------------------------------------
*/

.message-photo {
    display: block;
    max-width: 360px;

    overflow: hidden;

    border-radius: 11px;

    background: #e9edf3;
}

.message-photo img {
    display: block;
    width: 100%;
    max-height: 420px;

    object-fit: cover;
}

.message-file {
    display: block;
    max-width: 320px;

    padding: 9px 11px;

    border-radius: 10px;

    color: inherit;
    background: rgba(80, 110, 150, 0.1);

    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

/*
|--------------------------------------------------------------------------
| Анимация сообщений
|--------------------------------------------------------------------------
*/

.message--new,
.message--appear {
    animation: messageAppear 180ms ease-out;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(7px) scale(0.985);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/*
|--------------------------------------------------------------------------
| Поле отправки
|--------------------------------------------------------------------------
*/

.composer {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: end;
    gap: 10px;

    padding: 12px 18px 16px;

    border-top: 1px solid var(--border);

    background: rgba(255, 255, 255, 0.96);
}

.composer textarea {
    width: 100%;
    min-height: 44px;
    max-height: 140px;

    resize: none;
    overflow-y: auto;

    padding: 11px 14px;

    border: 1px solid var(--border);
    border-radius: 15px;
    outline: none;

    color: var(--text);
    background: #f7f8fa;

    line-height: 1.4;
}

.composer textarea:focus {
    border-color: #aac6ff;
    background: #ffffff;
}

.composer-attach {
    width: 44px;
    height: 44px;
    padding: 0;

    border: 1px solid var(--border);
    border-radius: 14px;

    color: var(--primary);
    background: #ffffff;

    font-size: 25px;
}

.composer-send {
    min-height: 44px;
    padding: 0 18px;

    border: 0;
    border-radius: 14px;

    color: #ffffff;
    background: var(--primary);

    font-weight: 800;
}

.composer-send:hover {
    background: var(--primary-dark);
}

.composer-send:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/*
|--------------------------------------------------------------------------
| Мобильная версия
|--------------------------------------------------------------------------
*/

@media (max-width: 760px) {
    #app {
        padding: 0;
    }

    .messenger {
        grid-template-columns: 1fr;

        border: 0;
        border-radius: 0;
    }

   

    .conversation-header {
        min-height: 68px;
        padding: 10px 12px;
	position: relative;

    z-index: 100;

}
    }

    .header-button {
        padding: 0 10px;

        font-size: 12px;
    }

    .messages {
        padding: 14px 9px 18px;
    }

    .message {
        max-width: 88%;
    }

    .message-body {
        padding: 7px 9px 6px;
    }

    .composer {
        padding: 9px 10px;
    }

    .composer-send {
        padding: 0 13px;

        font-size: 13px;
    }
}

.mobile-back {
    display: none;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    padding: 0;

    place-items: center;

    border: 0;
    border-radius: 50%;

    color: var(--text);
    background: transparent;

    font-size: 24px;
    line-height: 1;
}

.mobile-back:hover {
    background: rgba(0, 0, 0, 0.05);
}

@media (max-width: 760px) {
    .messenger-sidebar {
        display: flex;
    }

    .conversation {
        display: none;
    }

    .messenger-sidebar--hidden-mobile {
        display: none;
    }

    .conversation--visible-mobile {
        display: grid;
    }

    .mobile-back {
        display: grid;
    }

    .conversation-user {
        flex: 1;
    }
}

.message-context-menu {
    position: fixed;
    z-index: 10000;

    min-width: 160px;
    padding: 6px;

    border: 1px solid rgba(31, 44, 63, 0.12);
    border-radius: 12px;

    background: #ffffff;
    box-shadow: 0 12px 32px rgba(31, 44, 63, 0.2);
}

.message-context-menu[hidden] {
    display: none;
}

.message-context-menu button {
    display: block;
    width: 100%;
    padding: 10px 12px;

    border: 0;
    border-radius: 8px;

    color: var(--text);
    background: transparent;

    font: inherit;
    text-align: left;
    cursor: pointer;
}

.message-context-menu button:hover {
    background: #f1f4f8;
}

.composer-reply {
    grid-column: 1 / -1;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    margin-bottom: 2px;
    padding: 8px 10px;

    border-left: 3px solid var(--primary);
    border-radius: 9px;

    background: #f1f5fb;
}

.composer-reply[hidden] {
    display: none;
}

.composer-reply__content {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}

.composer-reply__content strong {
    color: var(--primary);
    font-size: 12px;
}

.composer-reply__text {
    overflow: hidden;

    color: #526174;

    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.composer-reply__close {
    flex: 0 0 auto;

    border: 0;
    background: transparent;

    color: #718096;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.message {
    -webkit-touch-callout: none;
}
.message,

.message * {

    -webkit-user-select: none;

    user-select: none;

    -webkit-touch-callout: none;

}

.message img,

.message video,

.message audio,

.message a,

.message button {

    -webkit-user-drag: none;

}

.message-reply {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;

    margin-bottom: 6px;
    padding: 5px 8px;

    border-left: 3px solid var(--primary);
    border-radius: 7px;

    background: rgba(80, 110, 150, 0.1);
}

.message-reply strong {
    color: var(--primary);
    font-size: 11px;
}

.message-reply span {
    overflow: hidden;

    color: #526174;

    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-reply {
    cursor: pointer;
}

.message--reply-highlight {
    animation: messageReplyHighlight 1.6s ease;
}

@keyframes messageReplyHighlight {
    0%,
    100% {
        box-shadow:
            0 3px 12px rgba(31, 44, 63, 0.07);
    }

    30%,
    65% {
        box-shadow:
            0 0 0 4px rgba(56, 132, 255, 0.35),
            0 3px 12px rgba(31, 44, 63, 0.07);
    }
}

.forward-modal {
    position: fixed;
    inset: 0;
    z-index: 12000;
}

.forward-modal[hidden] {
    display: none;
}

.forward-modal__backdrop {
    position: absolute;
    inset: 0;

    background: rgba(15, 23, 42, 0.42);
}

.forward-modal__panel {
    position: absolute;
    top: 50%;
    left: 50%;

    display: flex;
    width: min(420px, calc(100vw - 24px));
    max-height: min(620px, calc(100vh - 40px));
    flex-direction: column;

    padding: 14px;

    border-radius: 18px;

    background: #ffffff;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);

    transform: translate(-50%, -50%);
}

.forward-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 12px;
}

.forward-modal__close {
    width: 36px;
    height: 36px;

    border: 0;
    border-radius: 50%;

    background: transparent;

    font-size: 26px;
    cursor: pointer;
}

.forward-modal__search {
    width: 100%;
    margin-bottom: 10px;
    padding: 11px 13px;

    border: 1px solid var(--border);
    border-radius: 12px;
    outline: none;

    background: #f7f8fa;
}

.forward-modal__chats {
    display: flex;
    min-height: 100px;
    flex-direction: column;
    gap: 4px;

    overflow-y: auto;
}

.forward-chat {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 10px;

    padding: 9px;

    border: 0;
    border-radius: 12px;

    background: transparent;

    text-align: left;
    cursor: pointer;
}

.forward-chat:hover {
    background: #f1f4f8;
}

.forward-chat:disabled {
    opacity: 0.55;
    cursor: wait;
}

.forward-chat__avatar {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;

    place-items: center;

    border-radius: 50%;

    color: #ffffff;
    background: var(--primary);

    font-size: 13px;
    font-weight: 700;
}

.forward-chat__info {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}

.forward-chat__info strong,
.forward-chat__info small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.forward-chat__info small {
    color: #718096;
}

.forward-modal__empty {
    padding: 30px 10px;

    color: #718096;
    text-align: center;
}

.conversation-search {
    position: absolute;
    top: 68px;
    right: 12px;
    z-index: 5000;

    width: min(420px, calc(100% - 24px));
    max-height: min(520px, calc(100vh - 100px));

    padding: 10px;

    border: 1px solid var(--border);
    border-radius: 14px;

    background: #ffffff;
    box-shadow: 0 14px 40px rgba(31, 44, 63, 0.22);
 isolation: isolate;
}

.conversation-search[hidden] {
    display: none;
}

.conversation-search > input {
    width: calc(100% - 42px);
    min-height: 40px;

    padding: 9px 12px;

    border: 1px solid var(--border);
    border-radius: 11px;
    outline: none;

    background: #f7f8fa;
}

#conversation-search-close {
    width: 36px;
    height: 36px;
    margin-left: 4px;

    border: 0;
    border-radius: 50%;

    color: #718096;
    background: transparent;

    font-size: 20px;
    cursor: pointer;
}

.conversation-search-results {
    display: flex;
    max-height: 390px;
    margin-top: 8px;
    flex-direction: column;
    gap: 3px;

    overflow-y: auto;
}

.conversation-search-result {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    width: 100%;

    padding: 10px;

    border: 0;
    border-radius: 10px;

    color: var(--text);
    background: transparent;

    text-align: left;
    cursor: pointer;
}

.conversation-search-result:hover {
    background: #f1f4f8;
}

.conversation-search-result__text {
    overflow: hidden;

    font-size: 13px;
    line-height: 1.35;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-search-result__date {
    color: #718096;

    font-size: 11px;
    white-space: nowrap;
}

.conversation-search-empty {
    padding: 24px 10px;

    color: #718096;

    font-size: 13px;
    text-align: center;
}

.conversation {
    position: relative;
}

@media (max-width: 760px) {
    .conversation-search {
        top: 68px;
        right: 8px;
        left: 8px;

        width: auto;
        max-height: calc(100vh - 90px);
    }

    .conversation-search-results {
        max-height: calc(100vh - 165px);
    }
}

.sidebar-groups {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;

    padding: 0 12px 10px;
}

.sidebar-group {
    min-height: 34px;
    padding: 6px 10px;

    border: 1px solid var(--border);
    border-radius: 10px;

    color: #667085;
    background: #ffffff;

    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.sidebar-group:hover {
    background: #f3f6fa;
}

.sidebar-group--active {
    border-color: var(--primary);

    color: #ffffff;
    background: var(--primary);
}

.sidebar-group--active:hover {
    background: var(--primary);
}

/*
|--------------------------------------------------------------------------
| Цвета групп 700 и 800
|--------------------------------------------------------------------------
*/

/* ------------------------------------------------------------------
   700 — песочный
------------------------------------------------------------------- */

.sidebar-group[data-sidebar-group="700"] {
    border-color: #d7bd91;
    color: #80643a;
    background: #f8eedc;
}

.sidebar-group[data-sidebar-group="700"]:hover {
    background: #f2e2c6;
}

.sidebar-group[data-sidebar-group="700"].sidebar-group--active {
    border-color: #b9965f;
    color: #4f3c20;
    background: #dfc79f;
}

.chat-list-item--group-700 .chat-avatar {
    background: #d8bf91;
    color: #5b4523;
}


/* ------------------------------------------------------------------
   800 — бетонный серый
------------------------------------------------------------------- */

.sidebar-group[data-sidebar-group="800"] {
    border-color: #aeb3b8;
    color: #555d64;
    background: #eceeef;
}

.sidebar-group[data-sidebar-group="800"]:hover {
    background: #dfe2e4;
}

.sidebar-group[data-sidebar-group="800"].sidebar-group--active {
    border-color: #858c92;
    color: #30363b;
    background: #c8cccf;
}

.chat-list-item--group-800 .chat-avatar {
    background: #b9bec3;
    color: #2f3438;
}


/* ------------------------------------------------------------------
   Все
------------------------------------------------------------------- */

.sidebar-group[data-sidebar-group="all"] {
    border-color: var(--border);
    color: #667085;
    background: #ffffff;
}

.sidebar-group[data-sidebar-group="all"]:hover {
    background: #f3f6fa;
}

.sidebar-group[data-sidebar-group="all"].sidebar-group--active {
    border-color: var(--primary);
    color: #ffffff;
    background: var(--primary);
}

/*
|--------------------------------------------------------------------------
| Управление источниками и группами — только ПК
|--------------------------------------------------------------------------
*/

.sidebar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.desktop-management-button {
    display: grid;
}

.management-modal {
    position: fixed;
    inset: 0;
    z-index: 15000;
}

.management-modal[hidden] {
    display: none;
}

.management-modal__backdrop {
    position: absolute;
    inset: 0;

    background: rgba(15, 23, 42, 0.46);
    backdrop-filter: blur(2px);
}

.management-window {
    position: absolute;
    top: 50%;
    left: 50%;

    width: min(920px, calc(100vw - 48px));
    height: min(680px, calc(100vh - 48px));

    overflow: hidden;

    border-radius: 20px;
    background: #ffffff;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.32);

    transform: translate(-50%, -50%);
}

.management-header {
    display: flex;
    min-height: 66px;
    align-items: center;
    justify-content: space-between;

    padding: 0 20px;

    border-bottom: 1px solid var(--border);
}

.management-header strong {
    font-size: 18px;
}

.management-close {
    width: 38px;
    height: 38px;
    padding: 0;

    border: 0;
    border-radius: 50%;

    color: #667085;
    background: transparent;

    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.management-close:hover {
    background: #f2f4f7;
}

.management-body {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    height: calc(100% - 66px);
}

.management-sidebar {
    display: flex;
    flex-direction: column;
    gap: 6px;

    padding: 16px;

    border-right: 1px solid var(--border);
    background: #f8f9fb;
}

.management-tab {
    width: 100%;
    padding: 11px 13px;

    border: 0;
    border-radius: 11px;

    color: #475467;
    background: transparent;

    font-size: 14px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.management-tab:hover {
    background: #eef2f6;
}

.management-tab--active {
    color: #ffffff;
    background: var(--primary);
}

.management-content {
    min-width: 0;
    overflow-y: auto;

    padding: 22px;

    background: #ffffff;
}

@media (max-width: 760px) {
    .desktop-management-button,
    .management-modal {
        display: none !important;
    }
}

/*
|--------------------------------------------------------------------------
| Содержимое окна управления
|--------------------------------------------------------------------------
*/

.management-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;

    margin-bottom: 20px;
}

.management-section-head h2 {
    margin: 0 0 5px;

    font-size: 22px;
    line-height: 1.2;
}

.management-section-head p {
    margin: 0;

    color: #667085;

    font-size: 14px;
    line-height: 1.45;
}

.management-primary-button,
.management-secondary-button {
    min-height: 38px;
    padding: 8px 13px;

    border-radius: 10px;

    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.management-primary-button {
    border: 1px solid var(--primary);

    color: #ffffff;
    background: var(--primary);
}

.management-primary-button:hover {
    background: var(--primary-dark);
}

.management-secondary-button {
    border: 1px solid var(--border);

    color: #475467;
    background: #ffffff;
}

.management-secondary-button:hover {
    background: #f2f4f7;
}

.management-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.management-source-card,
.management-group-card {
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    padding: 14px 16px;

    border: 1px solid var(--border);
    border-radius: 14px;

    background: #ffffff;
    box-shadow: 0 3px 12px rgba(31, 44, 63, 0.05);
}

.management-source-card:hover,
.management-group-card:hover {
    border-color: #c8d2df;
    box-shadow: 0 5px 18px rgba(31, 44, 63, 0.08);
}

.management-source-card__main,
.management-group-card__main {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
}

.management-source-card__main > div,
.management-group-card__main > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
}

.management-source-card__main strong,
.management-group-card__main strong {
    overflow: hidden;

    color: #1f2937;

    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.management-source-card__main small,
.management-group-card__main small {
    overflow: hidden;

    color: #667085;

    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.management-status {
    width: 11px;
    height: 11px;
    flex: 0 0 auto;

    border-radius: 50%;
}

.management-status--online {
    background: #2fb36f;
    box-shadow: 0 0 0 4px rgba(47, 179, 111, 0.13);
}

.management-status--disabled {
    background: #98a2b3;
    box-shadow: 0 0 0 4px rgba(152, 162, 179, 0.13);
}

.management-group-color {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;

    border-radius: 11px;

    border: 1px solid rgba(15, 23, 42, 0.08);
}

.management-group-color--sand {
    background: #d8bf91;
}

.management-group-color--concrete {
    background: #b9bec3;
}

.management-loading,
.management-error {
    padding: 40px 20px;

    color: #667085;

    text-align: center;
}

.management-error {
    color: #b42318;
    background: #fff1f0;

    border: 1px solid #fecdca;
    border-radius: 12px;
}

/*
|--------------------------------------------------------------------------
| Двухколоночное управление источниками
|--------------------------------------------------------------------------
*/

.management-split {
    display: grid;
    grid-template-columns: minmax(230px, 0.8fr) minmax(320px, 1.2fr);
    min-height: 420px;

    border: 1px solid var(--border);
    border-radius: 16px;

    overflow: hidden;
    background: #ffffff;
}

.management-source-list {
    display: flex;
    flex-direction: column;
    gap: 6px;

    padding: 12px;

    border-right: 1px solid var(--border);
    background: #f8f9fb;
}

.management-source-item {
    display: flex;
    width: 100%;
    min-width: 0;
    align-items: center;
    gap: 11px;

    padding: 11px 12px;

    border: 1px solid transparent;
    border-radius: 12px;

    color: #344054;
    background: transparent;

    text-align: left;
    cursor: pointer;
}

.management-source-item:hover {
    border-color: #d7dee8;
    background: #ffffff;
}

.management-source-item--active {
    border-color: #b9cae6;
    background: #ffffff;
    box-shadow: 0 4px 14px rgba(31, 44, 63, 0.07);
}

.management-source-item__info {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
}

.management-source-item__info strong {
    overflow: hidden;

    font-size: 14px;
    line-height: 1.25;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.management-source-item__info small {
    overflow: hidden;

    color: #667085;

    font-size: 12px;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.management-editor {
    min-width: 0;
    padding: 20px;

    background: #ffffff;
}

.management-source-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.management-editor-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;

    padding-bottom: 16px;

    border-bottom: 1px solid var(--border);
}

.management-editor-head h3 {
    margin: 0 0 4px;

    font-size: 18px;
    line-height: 1.2;
}

.management-editor-head p {
    margin: 0;

    color: #667085;

    font-size: 12px;
}

.management-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.management-field > span {
    color: #344054;

    font-size: 13px;
    font-weight: 700;
}

.management-field input,
.management-field select {
    width: 100%;
    min-height: 42px;

    padding: 9px 11px;

    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;

    color: #1f2937;
    background: #ffffff;

    font: inherit;
}

.management-field input:focus,
.management-field select:focus {
    border-color: #a9c2eb;
    box-shadow: 0 0 0 3px rgba(100, 149, 237, 0.12);
}

.management-field input:disabled {
    color: #667085;
    background: #f2f4f7;
}

.management-switch {
    display: flex;
    align-items: center;
    gap: 9px;

    color: #344054;

    font-size: 13px;
    font-weight: 700;

    cursor: pointer;
}

.management-switch input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.management-form-actions {
    display: flex;
    min-height: 40px;
    align-items: center;
    gap: 12px;

    padding-top: 4px;
}

.management-save-status {
    color: #667085;

    font-size: 12px;
}

.management-empty {
    display: grid;
    min-height: 160px;
    place-items: center;

    padding: 20px;

    color: #667085;

    font-size: 13px;
    text-align: center;
}

.management-primary-button:disabled,
.management-secondary-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.management-danger-button {
    min-height: 38px;
    padding: 8px 13px;

    border: 1px solid #f04438;
    border-radius: 10px;

    color: #b42318;
    background: #fff5f4;

    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.management-danger-button:hover {
    background: #fee4e2;
}

.management-danger-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/*
|--------------------------------------------------------------------------
| Динамические цвета групп
|--------------------------------------------------------------------------
*/

/* Песочная тема */

.chat-list-item--theme-sand .chat-avatar {
    color: #5b4523;
    background: #d8bf91;
}

/* Бетонная тема */

.chat-list-item--theme-concrete .chat-avatar {
    color: #2f3438;
    background: #b9bec3;
}

/* Динамические цвета вкладок */

.sidebar-group[data-group-theme="sand"] {
    border-color: #d7bd91;
    color: #80643a;
    background: #f8eedc;
}

.sidebar-group[data-group-theme="sand"]:hover {
    background: #f2e2c6;
}

.sidebar-group[data-group-theme="sand"].sidebar-group--active {
    border-color: #b9965f;
    color: #4f3c20;
    background: #dfc79f;
}

.sidebar-group[data-group-theme="concrete"] {
    border-color: #aeb3b8;
    color: #555d64;
    background: #eceeef;
}

.sidebar-group[data-group-theme="concrete"]:hover {
    background: #dfe2e4;
}

.sidebar-group[data-group-theme="concrete"].sidebar-group--active {
    border-color: #858c92;
    color: #30363b;
    background: #c8cccf;
}

.chat-list-item--theme-sand .chat-avatar {
    color: #5b4523;
    background: #d8bf91;
}

.chat-list-item--theme-concrete .chat-avatar {
    color: #2f3438;
    background: #b9bec3;
}

.sidebar-group[data-group-theme="sand"] {
    border-color: #d7bd91;
    color: #80643a;
    background: #f8eedc;
}

.sidebar-group[data-group-theme="sand"].sidebar-group--active {
    border-color: #b9965f;
    color: #4f3c20;
    background: #dfc79f;
}

.sidebar-group[data-group-theme="concrete"] {
    border-color: #aeb3b8;
    color: #555d64;
    background: #eceeef;
}

.sidebar-group[data-group-theme="concrete"].sidebar-group--active {
    border-color: #858c92;
    color: #30363b;
    background: #c8cccf;
}

/*
|--------------------------------------------------------------------------
| Авторизация MAX
|--------------------------------------------------------------------------
*/

.management-auth-panel {
    padding: 16px;

    border: 1px solid #cdd9eb;
    border-radius: 14px;

    background: #f8fbff;
}

.management-auth-panel[hidden] {
    display: none;
}

.management-auth-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;

    margin-bottom: 16px;
}

.management-auth-head > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.management-auth-head strong {
    color: #1f2937;

    font-size: 15px;
}

.management-auth-head span {
    color: #667085;

    font-size: 12px;
    line-height: 1.4;
}

.management-auth-close {
    width: 30px;
    height: 30px;
    padding: 0;

    border: 0;
    border-radius: 50%;

    color: #667085;
    background: transparent;

    font-size: 22px;
    cursor: pointer;
}

.management-auth-close:hover {
    background: #e8eef7;
}

.management-auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.management-auth-waiting,
.management-auth-success {
    display: flex;
    align-items: center;
    gap: 12px;
}

.management-auth-waiting > div,
.management-auth-success > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.management-auth-waiting span,
.management-auth-success small {
    color: #667085;

    font-size: 12px;
}

.management-auth-spinner {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;

    border: 3px solid #d8e2f0;
    border-top-color: var(--primary);
    border-radius: 50%;

    animation: managementSpinner 700ms linear infinite;
}

.management-auth-success > span {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;

    place-items: center;

    border-radius: 50%;

    color: #ffffff;
    background: #2fb36f;

    font-size: 20px;
    font-weight: 800;
}

.management-auth-error {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 9px;

    color: #b42318;
}

.management-auth-error span {
    font-size: 12px;
    line-height: 1.45;
}

@keyframes managementSpinner {
    to {
        transform: rotate(360deg);
    }
}

/*
|--------------------------------------------------------------------------
| Новый диалог
|--------------------------------------------------------------------------
*/

.new-chat-modal {
    position: fixed;
    z-index: 1200;
    inset: 0;
}

.new-chat-modal[hidden] {
    display: none;
}

.new-chat-modal__backdrop {
    position: absolute;
    inset: 0;

    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(2px);
}

.new-chat-modal__panel {
    position: relative;
    z-index: 1;

    width: min(460px, calc(100vw - 40px));
    margin: 90px auto 0;
    padding: 20px;

    border: 1px solid #dbe3ec;
    border-radius: 20px;

    background: #ffffff;
    box-shadow:
        0 24px 70px rgba(15, 23, 42, 0.22);
}

.new-chat-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    margin-bottom: 18px;
}

.new-chat-modal__header strong {
    color: #1f2937;

    font-size: 20px;
    line-height: 1.2;
}

#new-chat-close {
    display: grid;
    width: 34px;
    height: 34px;
    padding: 0;

    place-items: center;

    border: 0;
    border-radius: 50%;

    color: #667085;
    background: transparent;

    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

#new-chat-close:hover {
    background: #f1f4f8;
}

#new-chat-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.new-chat-result {
    margin-top: 16px;
}

.new-chat-result:empty {
    display: none;
}

.new-chat-result__contact {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 12px;

    padding: 12px;

    border: 1px solid #dbe3ec;
    border-radius: 14px;

    color: inherit;
    background: #f8fafc;

    text-align: left;
    cursor: pointer;
}

.new-chat-result__contact:hover {
    border-color: #b8c6d8;
    background: #f1f5f9;
}

.new-chat-result__contact img,
.new-chat-result__contact > span {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;

    border-radius: 50%;
}

.new-chat-result__contact img {
    object-fit: cover;
}

.new-chat-result__contact > span {
    display: grid;

    place-items: center;

    color: #ffffff;
    background: var(--primary);

    font-size: 18px;
    font-weight: 800;
}

.new-chat-result__contact > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 4px;
}

.new-chat-result__contact strong {
    overflow: hidden;

    color: #1f2937;

    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.new-chat-result__contact small {
    color: #667085;

    font-size: 12px;
}

@media (max-width: 760px) {
    .new-chat-modal {
        display: none !important;
    }
}

.chat-list-item .chat-avatar {
    position: relative;
    overflow: visible;
}

.chat-provider-badge {
    position: absolute;
    right: -3px;
    bottom: -3px;

    width: 19px;
    height: 19px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 2px solid #fff;
    border-radius: 50%;
    background: #fff;

    box-sizing: border-box;
    pointer-events: none;
}

.chat-provider-badge img {
    display: block;

    width: 100%;
    height: 100%;

    border-radius: 50%;
    object-fit: contain;
}