* {
    box-sizing: border-box;
}

:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --sidebar: #172134;
    --sidebar-soft: #243047;
    --primary: #506ff5;
    --primary-dark: #3f5bd1;
    --text: #1d2636;
    --muted: #7a8496;
    --border: #e6eaf1;
    --success: #29b875;
    --danger: #d9534f;
    --shadow: 0 18px 50px rgba(29, 38, 54, 0.08);
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    color: var(--text);
    background: var(--bg);
}

button,
input {
    font: inherit;
}

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

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(
            circle at top left,
            rgba(80, 111, 245, 0.18),
            transparent 38%
        ),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 430px;
    padding: 42px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.auth-logo {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    margin-bottom: 28px;
    border-radius: 16px;
    background: var(--primary);
    color: #ffffff;
    font-weight: 800;
}

.auth-label,
.page-label {
    margin-bottom: 8px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.16em;
}

.auth-heading h1,
.dashboard-header h1 {
    margin: 0;
}

.auth-heading p,
.dashboard-header p,
.content-card p,
.stat-card p,
.step-item p {
    color: var(--muted);
}

.auth-form {
    display: grid;
    gap: 18px;
    margin-top: 30px;
}

.auth-form label {
    display: grid;
    gap: 8px;
}

.auth-form label span {
    font-size: 14px;
    font-weight: 700;
}

.auth-form input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    outline: none;
}

.auth-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(80, 111, 245, 0.1);
}

.auth-form button {
    padding: 15px 20px;
    border: 0;
    border-radius: 12px;
    background: var(--primary);
    color: #ffffff;
    cursor: pointer;
    font-weight: 800;
}

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

.alert {
    margin-top: 20px;
    padding: 13px 15px;
    border-radius: 10px;
}

.alert-error {
    background: rgba(217, 83, 79, 0.1);
    color: var(--danger);
}

/* Кабинет */

.dashboard-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 28px 20px;
    background: var(--sidebar);
    color: #ffffff;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 28px;
}

.sidebar-logo {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--primary);
    font-weight: 800;
}

.sidebar-brand strong,
.sidebar-brand span {
    display: block;
}

.sidebar-brand span {
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
}

.sidebar-nav a,
.logout-link {
    padding: 13px 14px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--sidebar-soft);
    color: #ffffff;
}

.logout-link {
    margin-top: auto;
}

.dashboard-content {
    min-width: 0;
    padding: 38px;
}

/* Фиксированный экран только для раздела диалогов */

.dashboard-page.dialogs-page-mode {
    height: 100vh;
    overflow: hidden;
}

.dashboard-page.dialogs-page-mode .sidebar {
    height: 100vh;
    min-height: 0;
}

.dashboard-page.dialogs-page-mode .dashboard-content {
    height: 100vh;
    min-height: 0;
    overflow: hidden;

    display: flex;
    flex-direction: column;
}

.dashboard-page.dialogs-page-mode .dialogs-layout {
    flex: 1;
    min-height: 0;
}

.dashboard-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: var(--surface);
    font-size: 13px;
    font-weight: 700;
}

.status-badge span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-top: 34px;
}

.stat-card,
.content-card {
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 24px;
    border-radius: 18px;
}

.stat-card > span {
    color: var(--muted);
    font-size: 14px;
}

.stat-card strong {
    display: block;
    margin-top: 18px;
    font-size: 32px;
}

.stat-card p {
    margin: 8px 0 0;
    font-size: 13px;
}

.content-card {
    margin-top: 22px;
    padding: 28px;
    border-radius: 20px;
}

.content-card h2 {
    margin: 0;
}

.steps-list {
    display: grid;
    gap: 12px;
    margin-top: 26px;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.step-item > span {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 12px;
    background: var(--bg);
    font-weight: 800;
}

.step-item.completed > span {
    background: rgba(41, 184, 117, 0.12);
    color: var(--success);
}

.step-item p {
    margin: 4px 0 0;
    font-size: 13px;
}

@media (max-width: 1000px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .dashboard-page {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;
    }

    .dashboard-content {
        padding: 24px 18px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-header {
        flex-direction: column;
    }
}

/* Пользователи */

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.card-header h2 {
    margin: 0;
}

.card-header p {
    margin: 7px 0 0;
}

.table-search {
    width: min(100%, 320px);
}

.table-search input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    outline: none;
}

.table-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(80, 111, 245, 0.1);
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 820px;
}

.users-table th,
.users-table td {
    padding: 16px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.users-table th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.users-table tbody tr {
    transition:
        background 0.2s ease,
        transform 0.2s ease;
}

.users-table tbody tr:hover {
    background: rgba(80, 111, 245, 0.035);
}

.users-table tbody tr:last-child td {
    border-bottom: 0;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 13px;
    background: rgba(80, 111, 245, 0.12);
    color: var(--primary);
    font-weight: 800;
}

.user-cell strong,
.user-cell span {
    display: block;
}

.user-cell span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.user-id {
    color: var(--muted);
    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;
    font-size: 13px;
}

.tasks-count {
    min-width: 34px;
    display: inline-grid;
    place-items: center;
    padding: 6px 10px;
    border-radius: 9px;
    background: var(--bg);
    font-weight: 800;
}

.user-status {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 800;
}

.user-status-active {
    background: rgba(41, 184, 117, 0.12);
    color: var(--success);
}

.user-status-new {
    background: rgba(80, 111, 245, 0.12);
    color: var(--primary);
}

.table-action {
    display: inline-flex;
    padding: 9px 12px;
    border-radius: 9px;
    background: rgba(80, 111, 245, 0.1);
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
}

.table-action:hover {
    background: var(--primary);
    color: #ffffff;
}

@media (max-width: 760px) {
    .card-header {
        flex-direction: column;
    }

    .table-search {
        width: 100%;
    }
}

.users-total {
    display: inline-grid;
    place-items: center;
    min-width: 34px;
    min-height: 28px;
    margin-left: 8px;
    padding: 4px 9px;
    border-radius: 9px;
    background: rgba(80, 111, 245, 0.12);
    color: var(--primary);
    font-size: 14px;
    vertical-align: middle;
}

.table-search {
    position: relative;
}

.table-search input {
    padding-right: 44px;
}

.search-reset {
    position: absolute;
    top: 50%;
    right: 14px;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--muted);
    text-decoration: none;
    font-size: 22px;
    line-height: 1;
    transform: translateY(-50%);
}

.search-reset:hover {
    background: rgba(80, 111, 245, 0.1);
    color: var(--primary);
}

.empty-table {
    padding: 46px 20px;
    text-align: center;
}

.empty-table strong {
    display: block;
    font-size: 18px;
}

.empty-table p {
    margin: 8px 0 18px;
    color: var(--muted);
}

.empty-table a {
    display: inline-flex;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(80, 111, 245, 0.1);
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
}

.empty-table a:hover {
    background: var(--primary);
    color: #ffffff;
}

/* Карточка пользователя */

.back-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 16px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
    transition:
        border-color 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}

.back-button:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.user-profile-grid {
    display: grid;
    grid-template-columns:
        minmax(280px, 1.5fr)
        repeat(3, minmax(170px, 1fr));
    gap: 18px;
    margin-top: 34px;
}

.profile-card {
    min-width: 0;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.profile-main-card {
    display: flex;
    align-items: center;
    gap: 18px;
}

.profile-avatar {
    width: 68px;
    height: 68px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 20px;
    background: rgba(80, 111, 245, 0.12);
    color: var(--primary);
    font-size: 25px;
    font-weight: 800;
}

.profile-main-info {
    min-width: 0;
}

.profile-main-info h2 {
    margin: 0;
}

.profile-main-info p {
    margin: 6px 0 12px;
    color: var(--muted);
    font-size: 13px;
}

.profile-card-label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.profile-card-value {
    display: block;
    margin-top: 16px;
    overflow-wrap: anywhere;
    font-size: 17px;
}

.profile-id {
    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;
    font-size: 14px;
}

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

.profile-stat-card {
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.profile-stat-card > span {
    color: var(--muted);
    font-size: 13px;
}

.profile-stat-card strong {
    display: block;
    margin-top: 12px;
    font-size: 30px;
}

.profile-stat-card p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.profile-list {
    display: grid;
    gap: 12px;
}

.profile-list-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}

.profile-list-main {
    min-width: 0;
}

.profile-list-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
}

.profile-list-number {
    padding: 4px 8px;
    border-radius: 7px;
    background: var(--bg);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.profile-list-item p {
    margin: 9px 0 0;
    line-height: 1.55;
}

.profile-list-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 13px;
    color: var(--muted);
    font-size: 12px;
}

.task-status,
.request-status {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    padding: 7px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 800;
}

.task-status {
    background: rgba(80, 111, 245, 0.12);
    color: var(--primary);
}

.request-status-open {
    background: rgba(41, 184, 117, 0.12);
    color: var(--success);
}

.request-status-closed {
    background: var(--bg);
    color: var(--muted);
}

.empty-profile-section {
    padding: 42px 20px;
    border: 1px dashed var(--border);
    border-radius: 14px;
    text-align: center;
}

.empty-profile-section p {
    margin: 8px 0 0;
}

@media (max-width: 1180px) {
    .user-profile-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .profile-main-card {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .user-profile-grid,
    .profile-stats-grid {
        grid-template-columns: 1fr;
    }

    .profile-main-card {
        grid-column: auto;
    }

    .profile-list-item {
        flex-direction: column;
    }
}

/* Карточка пользователя */

.user-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.primary-button,
.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    border-radius: 11px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 800;
}

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

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

.secondary-button {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.secondary-button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-top: 34px;
}

.profile-stat-card {
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.profile-stat-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.profile-stat-card strong {
    display: block;
    margin-top: 13px;
    overflow-wrap: anywhere;
    font-size: 18px;
}

.profile-list {
    display: grid;
    gap: 14px;
}

.profile-list-item {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 15px;
}

.profile-list-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.profile-list-item p {
    margin: 12px 0;
    white-space: pre-wrap;
}

.profile-list-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 12px;
}

.item-number {
    color: var(--muted);
    font-size: 13px;
}

.request-status {
    display: inline-flex;
    padding: 7px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 800;
}

.request-status-open {
    background: rgba(41, 184, 117, 0.12);
    color: var(--success);
}

.request-status-closed {
    background: var(--bg);
    color: var(--muted);
}

.empty-section,
.empty-chat {
    padding: 44px 20px;
    text-align: center;
}

.empty-section p,
.empty-chat p {
    color: var(--muted);
}

/* Чат */

.chat-page {
    max-width: 1100px;
    margin: 0 auto;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.chat-user-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.chat-user-info h1 {
    margin: 0;
    font-size: 24px;
}

.chat-user-info p {
    margin: 5px 0 0;
    color: var(--muted);
}

.chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 16px;
}

.chat-window {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.chat-messages {
    min-height: 560px;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
    padding: 28px;
    background:
        radial-gradient(
            circle at top right,
            rgba(80, 111, 245, 0.05),
            transparent 34%
        ),
        var(--bg);
}

.chat-system-message {
    width: fit-content;
    margin: 16px auto;
    padding: 7px 11px;
    border-radius: 100px;
    background: rgba(23, 33, 52, 0.08);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.chat-row {
    display: flex;
    margin: 10px 0;
}

.chat-row-user {
    justify-content: flex-start;
}

.chat-row-admin {
    justify-content: flex-end;
}

.chat-bubble {
    max-width: min(72%, 650px);
    padding: 13px 15px;
    border-radius: 16px;
    line-height: 1.5;
    white-space: normal;
    overflow-wrap: anywhere;
}

.chat-bubble-user {
    border-bottom-left-radius: 5px;
    background: var(--surface);
}

.chat-bubble-admin {
    border-bottom-right-radius: 5px;
    background: var(--primary);
    color: #ffffff;
}

.chat-bubble-bot {
    border-bottom-right-radius: 5px;
    background: var(--sidebar-soft);
    color: #ffffff;
}

.chat-sender {
    display: block;
    margin-bottom: 5px;
    font-size: 11px;
    font-weight: 800;
    opacity: 0.7;
}

.chat-bubble time {
    display: block;
    margin-top: 7px;
    font-size: 10px;
    opacity: 0.55;
}

.chat-attachment {
    margin-top: 10px;
    padding: 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.14);
    font-size: 13px;
}

.chat-compose {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.chat-compose-notice {
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 12px;
}

.chat-compose-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
}

.chat-compose textarea {
    min-height: 48px;
    max-height: 130px;
    resize: vertical;
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font: inherit;
}

.attachment-button,
.send-button {
    border: 0;
    border-radius: 12px;
    font: inherit;
    font-weight: 800;
}

.attachment-button {
    width: 48px;
}

.send-button {
    padding: 0 18px;
    background: var(--primary);
    color: #ffffff;
}

.chat-compose button:disabled,
.chat-compose textarea:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

@media (max-width: 900px) {
    .profile-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .chat-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .profile-stats-grid {
        grid-template-columns: 1fr;
    }

    .chat-messages {
        padding: 18px 12px;
    }

    .chat-bubble {
        max-width: 88%;
    }

    .chat-compose-row {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .send-button {
        grid-column: 1 / -1;
        min-height: 46px;
    }
}

/* Общий раздел диалогов */

.dialogs-summary {
    display: flex;
    gap: 12px;
}

.dialogs-summary-item {
    min-width: 105px;
    padding: 13px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.dialogs-summary-item span,
.dialogs-summary-item strong {
    display: block;
}

.dialogs-summary-item span {
    color: var(--muted);
    font-size: 12px;
}

.dialogs-summary-item strong {
    margin-top: 5px;
    font-size: 21px;
}

.dialogs-layout {
    flex: 1;
    display: grid;
    grid-template-columns:
        340px
        minmax(420px, 1fr)
        290px;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.dialogs-sidebar{

    display:flex;
    flex-direction:column;

    overflow:hidden;

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

.dialogs-sidebar-header {
    padding: 22px 22px 12px;
}

.dialogs-sidebar-header h2,
.dialogs-sidebar-header p {
    margin: 0;
}

.dialogs-sidebar-header p {
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
}

.dialogs-search {
    position: relative;
    padding: 0 16px 14px;
}

.dialogs-search input {
    width: 100%;
    padding: 12px 40px 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    outline: none;
}

.dialogs-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(80, 111, 245, 0.1);
}

.dialogs-search-reset {
    position: absolute;
    top: 8px;
    right: 28px;
    color: var(--muted);
    text-decoration: none;
    font-size: 25px;
    line-height: 1;
}

.dialogs-list{

    flex:1;

    overflow-y:auto;

    min-height:0;
}

.dialog-list-item {
    display: flex;
    gap: 12px;
    padding: 15px 16px;
    border-top: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    transition:
        background 0.2s ease,
        border-color 0.2s ease;
}

.dialog-list-item:hover {
    background: rgba(80, 111, 245, 0.04);
}

.dialog-list-item.active {
    background: rgba(80, 111, 245, 0.1);
    box-shadow: inset 3px 0 0 var(--primary);
}

.dialog-list-avatar {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 14px;
    background: rgba(80, 111, 245, 0.12);
    color: var(--primary);
    font-weight: 800;
}

.dialog-list-content {
    min-width: 0;
    flex: 1;
}

.dialog-list-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.dialog-list-top strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dialog-list-top time {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 10px;
}

.dialog-list-username {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.dialog-list-preview {
    margin-top: 8px;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-role {
    color: var(--primary);
    font-weight: 800;
}

.dialog-list-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 9px;
}

.dialog-status {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 100px;
    font-size: 10px;
    font-weight: 800;
}

.dialog-status-open {
    background: rgba(41, 184, 117, 0.12);
    color: var(--success);
}

.dialog-status-closed {
    background: var(--bg);
    color: var(--muted);
}

.dialog-messages-count {
    color: var(--muted);
    font-size: 10px;
}

.dialogs-empty-list {
    padding: 42px 24px;
    text-align: center;
}

.dialogs-empty-list p {
    color: var(--muted);
}

.dialogs-empty-list a {
    color: var(--primary);
    font-weight: 700;
}

.dialog-chat-panel{

    display:flex;
    flex-direction:column;

    overflow:hidden;

    min-width:0;
}
.dialog-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.dialog-chat-user {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
}

.dialog-chat-avatar {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 15px;
    background: rgba(80, 111, 245, 0.12);
    color: var(--primary);
    font-weight: 800;
}

.dialog-chat-user h2,
.dialog-chat-user p {
    margin: 0;
}

.dialog-chat-user h2 {
    font-size: 18px;
}

.dialog-chat-user p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

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

.dialog-chat-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    padding: 10px 22px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 11px;
}

.dialog-chat-messages{

    flex:1;

    overflow-y:auto;

    min-height:0;

    padding:26px;
}

.dialog-chat-compose {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.dialog-placeholder {
    margin: auto;
    padding: 30px;
    text-align: center;
}

.dialog-placeholder-icon {
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
    margin: 0 auto 18px;
    border-radius: 22px;
    background: rgba(80, 111, 245, 0.12);
    font-size: 30px;
}

.dialog-placeholder h2,
.dialog-placeholder p {
    margin: 0;
}

.dialog-placeholder p {
    margin-top: 8px;
    color: var(--muted);
}

/* Правая карточка пользователя */

.dialog-user-panel {
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid var(--border);
    background: var(--surface);
}

.dialog-user-panel-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 22px 18px;
}

.dialog-user-profile {
    padding: 8px 4px 22px;
    text-align: center;
}

.dialog-user-large-avatar {
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
    margin: 0 auto 14px;
    border-radius: 23px;
    background: rgba(80, 111, 245, 0.12);
    color: var(--primary);
    font-size: 27px;
    font-weight: 800;
}

.dialog-user-profile h3 {
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 18px;
}

.dialog-user-profile p {
    margin: 6px 0 12px;
    overflow-wrap: anywhere;
    color: var(--muted);
    font-size: 13px;
}

.dialog-user-online-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border-radius: 100px;
    background: rgba(41, 184, 117, 0.1);
    color: var(--success);
    font-size: 11px;
    font-weight: 800;
}

.dialog-user-online-status i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.dialog-user-section {
    padding: 18px 0;
    border-top: 1px solid var(--border);
}

.dialog-user-section-title {
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dialog-user-info-list {
    display: grid;
    gap: 13px;
}

.dialog-user-info-row {
    display: grid;
    gap: 5px;
}

.dialog-user-info-row span {
    color: var(--muted);
    font-size: 11px;
}

.dialog-user-info-row strong {
    overflow-wrap: anywhere;
    font-size: 13px;
    line-height: 1.4;
}

.dialog-user-mono {
    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;
}

.dialog-user-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.dialog-user-stat {
    min-width: 0;
    padding: 12px 6px;
    border-radius: 12px;
    background: var(--bg);
    text-align: center;
}

.dialog-user-stat strong,
.dialog-user-stat span {
    display: block;
}

.dialog-user-stat strong {
    font-size: 19px;
}

.dialog-user-stat span {
    margin-top: 5px;
    color: var(--muted);
    font-size: 9px;
}

.dialog-user-actions {
    display: grid;
    gap: 10px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.dialog-user-primary-action,
.dialog-user-secondary-action {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 11px;
    text-align: center;
    text-decoration: none;
    font-size: 12px;
    font-weight: 800;
}

.dialog-user-primary-action {
    background: var(--primary);
    color: #ffffff;
}

.dialog-user-primary-action:hover {
    background: var(--primary-dark);
}

.dialog-user-secondary-action {
    border: 1px solid var(--border);
    color: var(--text);
}

.dialog-user-secondary-action:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.dialog-user-placeholder {
    margin: auto;
    padding: 24px;
    text-align: center;
}

.dialog-user-placeholder > div {
    margin-bottom: 12px;
    font-size: 30px;
}

.dialog-user-placeholder strong {
    display: block;
}

.dialog-user-placeholder p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 1400px) {
    .dialogs-layout {
        grid-template-columns:
            310px
            minmax(390px, 1fr)
            260px;
    }
}

@media (max-width: 1180px) {
    .dialogs-layout {
        grid-template-columns:
            300px
            minmax(0, 1fr);
    }

    .dialog-user-panel {
        display: none;
    }
}

@media (max-width: 850px) {
    .dialogs-layout {
        height: auto;
        grid-template-columns: 1fr;
        overflow: visible;
    }

    .dialogs-sidebar {
        max-height: 520px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .dialog-chat-panel {
        min-height: 650px;
    }

    .dialog-user-panel {
        display: none;
    }

    .dialogs-summary {
        width: 100%;
    }

    .dialogs-summary-item {
        flex: 1;
    }
}

@media (max-width: 600px) {
    .dialog-chat-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .dialog-chat-actions {
        width: 100%;
        justify-content: space-between;
    }

    .dialog-chat-messages {
        padding: 18px 12px;
    }
}

/* Отправка сообщения из диалога */

.dialog-chat-compose textarea {
    width: 100%;
    min-height: 46px;
    max-height: 130px;
    resize: vertical;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    outline: none;
}

.dialog-chat-compose textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(80, 111, 245, 0.1);
}

.dialog-chat-compose .send-button {
    min-height: 46px;
    padding: 0 18px;
    border: 0;
    border-radius: 11px;
    background: var(--primary);
    color: #ffffff;
    cursor: pointer;
    font-weight: 800;
}

.dialog-chat-compose .send-button:hover {
    background: var(--primary-dark);
}

.chat-send-alert {
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
}

.chat-send-success {
    background: rgba(41, 184, 117, 0.12);
    color: var(--success);
}

.chat-send-error {
    background: rgba(217, 83, 79, 0.1);
    color: var(--danger);
}

/* ==================================================
   Компактные сообщения в личном чате
================================================== */

.direct-chat-messages {
    display: block !important;
}

.direct-chat-messages .chat-row {
    display: flex !important;
    flex: 0 0 auto !important;

    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;

    margin: 10px 0 !important;
}

.direct-chat-messages .chat-row-admin {
    align-items: flex-start !important;
    justify-content: flex-end !important;
}

.direct-chat-messages .chat-row-user {
    align-items: flex-start !important;
    justify-content: flex-start !important;
}

.direct-chat-messages .chat-bubble {
    display: inline-block !important;
    flex: 0 0 auto !important;

    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: min(72%, 650px) !important;
    max-height: none !important;

    padding: 13px 15px !important;

    align-self: flex-start !important;

    line-height: 1.5 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
}

.direct-chat-messages .chat-bubble > div:not(.chat-attachment) {
    display: block !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    white-space: pre-line !important;
}

.direct-chat-messages .chat-sender {
    display: block !important;
    margin: 0 0 5px !important;
}

.direct-chat-messages .chat-bubble time {
    display: block !important;
    margin: 7px 0 0 !important;
}

/* Финальный размер пузырей в личном чате */

.direct-chat-messages .chat-bubble {
    display: inline-block !important;
    width: max-content !important;
    min-width: 0 !important;
    max-width: min(70%, 520px) !important;
    height: auto !important;
    padding: 12px 15px !important;
    text-align: left !important;
}

.direct-chat-messages .chat-message-text,
.direct-chat-messages .chat-bubble > div:not(.chat-attachment) {
    display: block !important;
    width: auto !important;
    max-width: 100% !important;
    margin: 0 !important;
    white-space: pre-line !important;
    overflow-wrap: anywhere !important;
    text-align: left !important;
}

.direct-chat-messages .chat-row-admin .chat-bubble {
    margin-left: auto !important;
    margin-right: 0 !important;
}

.direct-chat-messages .chat-row-user .chat-bubble {
    margin-left: 0 !important;
    margin-right: auto !important;
}

/* ==================================================
   Страница настроек
================================================== */

.settings-page {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
}

.settings-header {
    margin-bottom: 30px;
}

.settings-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.settings-summary-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.settings-summary-icon,
.settings-card-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: rgba(80, 111, 245, 0.1);
}

.settings-summary-icon {
    width: 45px;
    height: 45px;
    border-radius: 14px;
    font-size: 20px;
}

.settings-summary-card > div:nth-child(2) {
    min-width: 0;
}

.settings-summary-card span,
.settings-summary-card strong {
    display: block;
}

.settings-summary-card > div:nth-child(2) > span {
    color: var(--muted);
    font-size: 12px;
}

.settings-summary-card > div:nth-child(2) > strong {
    margin-top: 5px;
    font-size: 16px;
}

.settings-state {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 7px 10px;
    border-radius: 100px;
    font-size: 10px;
    font-weight: 800;
    white-space: nowrap;
}

.settings-state-success {
    background: rgba(41, 184, 117, 0.12);
    color: var(--success);
}

.settings-state-error {
    background: rgba(217, 83, 79, 0.1);
    color: var(--danger);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: 20px;
    padding-bottom: 38px;
}

.settings-card {
    min-width: 0;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.settings-card-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.settings-card-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    font-size: 20px;
}

.settings-card-header h2,
.settings-card-header p {
    margin: 0;
}

.settings-card-header h2 {
    font-size: 18px;
}

.settings-card-header p {
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.settings-list {
    display: grid;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 72px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.settings-row:last-child {
    border-bottom: 0;
}

.settings-row-column {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
}

.settings-label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 11px;
}

.settings-row strong {
    display: block;
    font-size: 14px;
}

.settings-code,
.settings-path {
    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;
}

.settings-path {
    display: block;
    width: 100%;
    padding: 10px 12px;
    overflow-x: auto;
    border-radius: 9px;
    background: var(--bg);
    color: var(--text);
    font-size: 11px;
    white-space: nowrap;
}

.settings-value-muted {
    color: var(--muted);
    font-size: 12px;
    text-align: right;
}

.settings-indicator {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border-radius: 100px;
    font-size: 10px;
    font-weight: 800;
    white-space: nowrap;
}

.settings-indicator i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.settings-indicator-online {
    background: rgba(41, 184, 117, 0.1);
    color: var(--success);
}

.settings-indicator-offline {
    background: rgba(217, 83, 79, 0.1);
    color: var(--danger);
}

.settings-notice {
    margin-top: 16px;
    padding: 13px 14px;
    border-radius: 11px;
    background: rgba(80, 111, 245, 0.08);
    color: var(--primary-dark);
    font-size: 11px;
    line-height: 1.55;
}

.settings-notice-warning {
    background: rgba(217, 160, 79, 0.12);
    color: #9a6421;
}

.settings-button {
    width: 100%;
    min-height: 44px;
    margin-top: 18px;
    padding: 11px 15px;
    border: 0;
    border-radius: 11px;
    font-weight: 800;
}

.settings-button-disabled {
    cursor: not-allowed;
    background: var(--bg);
    color: var(--muted);
}

.settings-button-caption {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 10px;
    text-align: center;
}

.settings-options {
    display: grid;
}

.settings-option {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 15px 0;
    border-bottom: 1px solid var(--border);
}

.settings-option:last-child {
    border-bottom: 0;
}

.settings-option strong,
.settings-option small {
    display: block;
}

.settings-option strong {
    font-size: 14px;
}

.settings-option small {
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
}

.settings-option input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.settings-option-disabled {
    opacity: 0.55;
}

.settings-switch {
    width: 42px;
    height: 24px;
    position: relative;
    flex: 0 0 auto;
    border-radius: 100px;
    background: var(--border);
}

.settings-switch i {
    width: 18px;
    height: 18px;
    position: absolute;
    top: 3px;
    left: 3px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 2px 6px rgba(29, 38, 54, 0.2);
}

.settings-switch-disabled {
    opacity: 0.65;
}

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

    .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .settings-summary-card {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .settings-state {
        grid-column: 1 / -1;
        width: fit-content;
        margin-left: 59px;
    }

    .settings-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .settings-value-muted {
        text-align: left;
    }
}

/* Проверка Telegram */

.settings-button-primary {
    cursor: pointer;
    background: var(--primary);
    color: #ffffff;
    transition:
        background 0.2s ease,
        transform 0.2s ease;
}

.settings-button-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.settings-alert {
    display: grid;
    gap: 5px;
    margin-bottom: 20px;
    padding: 15px 17px;
    border-radius: 13px;
    font-size: 13px;
    line-height: 1.5;
}

.settings-alert strong,
.settings-alert span {
    display: block;
}

.settings-alert-success {
    border: 1px solid rgba(41, 184, 117, 0.2);
    background: rgba(41, 184, 117, 0.1);
    color: #198754;
}

.settings-alert-error {
    border: 1px solid rgba(217, 83, 79, 0.2);
    background: rgba(217, 83, 79, 0.09);
    color: var(--danger);
}

.settings-download-button {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    padding: 11px 15px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
    transition:
        border-color 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}

.settings-download-button:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

/* Управление статусом обращения */

.dialog-status-form {
    margin: 0;
}

.dialog-close-button,
.dialog-reopen-button {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 13px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    transition:
        background 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}

.dialog-close-button {
    background: rgba(217, 83, 79, 0.1);
    color: var(--danger);
}

.dialog-close-button:hover {
    background: var(--danger);
    color: #ffffff;
    transform: translateY(-1px);
}

.dialog-reopen-button {
    background: rgba(80, 111, 245, 0.12);
    color: var(--primary);
}

.dialog-reopen-button:hover {
    background: var(--primary);
    color: #ffffff;
    transform: translateY(-1px);
}

.closed-dialog-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
}

.closed-dialog-notice strong,
.closed-dialog-notice span {
    display: block;
}

.closed-dialog-notice span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 760px) {
    .dialog-chat-actions {
        flex-wrap: wrap;
    }

    .closed-dialog-notice {
        align-items: flex-start;
        flex-direction: column;
    }

    .closed-dialog-notice form,
    .closed-dialog-notice button {
        width: 100%;
    }
}

/* ==================================================
   Адаптивная шапка выбранного диалога
================================================== */

.dialog-chat-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
}

.dialog-chat-user {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 13px;
}

.dialog-chat-user-info {
    min-width: 0;
}

.dialog-chat-user-title {
    min-width: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.dialog-chat-user-title h2 {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 18px;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dialog-chat-user-info p {
    margin: 5px 0 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dialog-chat-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 9px;
}

.dialog-status-form {
    display: flex;
    margin: 0;
}

.dialog-chat-actions .secondary-button,
.dialog-chat-actions .dialog-close-button,
.dialog-chat-actions .dialog-reopen-button {
    min-height: 40px;
    padding: 9px 13px;
    white-space: nowrap;
}

.dialog-close-button,
.dialog-reopen-button {
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
}

.dialog-close-button {
    background: rgba(217, 83, 79, 0.1);
    color: var(--danger);
}

.dialog-close-button:hover {
    background: var(--danger);
    color: #ffffff;
}

.dialog-reopen-button {
    background: rgba(41, 184, 117, 0.12);
    color: var(--success);
}

.dialog-reopen-button:hover {
    background: var(--success);
    color: #ffffff;
}

.closed-dialog-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.closed-dialog-notice-text {
    min-width: 0;
}

.closed-dialog-notice strong,
.closed-dialog-notice span {
    display: block;
}

.closed-dialog-notice span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

/* Средняя ширина */

@media (max-width: 1400px) {

    .dialog-chat-header {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .dialog-chat-actions {
        width: 100%;
        justify-content: flex-start;
        padding-left: 59px;
    }

}

/* Узкое окно */

@media (max-width: 1180px) {

    .dialog-chat-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding-left: 0;
    }

    .dialog-chat-actions .secondary-button,
    .dialog-chat-actions .dialog-status-form,
    .dialog-chat-actions .dialog-close-button,
    .dialog-chat-actions .dialog-reopen-button {
        width: 100%;
    }

    .dialog-chat-actions .secondary-button,
    .dialog-chat-actions button {
        text-align: center;
    }

}

/* Планшет и телефон */

@media (max-width: 850px) {

    .dialog-chat-header {
        padding: 16px;
    }

    .dialog-chat-user {
        align-items: flex-start;
    }

    .dialog-chat-user-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .dialog-chat-user-title h2,
    .dialog-chat-user-info p {
        overflow: visible;
        text-overflow: clip;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .dialog-chat-actions {
        grid-template-columns: 1fr;
    }

    .closed-dialog-notice {
        align-items: stretch;
        flex-direction: column;
    }

    .closed-dialog-notice form,
    .closed-dialog-notice .dialog-reopen-button {
        width: 100%;
    }

}

/* Совсем узкий экран */

@media (max-width: 520px) {

    .dialog-chat-avatar {
        width: 42px;
        height: 42px;
        border-radius: 13px;
    }

    .dialog-chat-user-title h2 {
        font-size: 16px;
    }

    .dialog-chat-actions .secondary-button,
    .dialog-chat-actions .dialog-close-button,
    .dialog-chat-actions .dialog-reopen-button {
        min-height: 44px;
        padding: 10px 12px;
        font-size: 12px;
    }

}

/* Менеджеры в настройках */

.settings-card-wide {
    grid-column: 1 / -1;
}

.settings-managers-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    padding: 16px;
    border-radius: 14px;
    background: var(--bg);
}

.settings-managers-header span,
.settings-managers-header strong {
    display: block;
}

.settings-managers-header span {
    color: var(--muted);
    font-size: 12px;
}

.settings-managers-header strong {
    margin-top: 5px;
    font-size: 24px;
}

.settings-managers-list {
    display: grid;
    gap: 10px;
}

.settings-manager-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.settings-manager-avatar {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: rgba(80, 111, 245, 0.12);
    color: var(--primary);
    font-weight: 800;
}

.settings-manager-main {
    min-width: 0;
}

.settings-manager-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.manager-role {
    display: inline-flex;
    padding: 5px 8px;
    border-radius: 100px;
    background: var(--bg);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
}

.manager-role-owner {
    background: rgba(80, 111, 245, 0.12);
    color: var(--primary);
}

.settings-manager-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-top: 7px;
    color: var(--muted);
    font-size: 11px;
}

.settings-manager-meta b {
    color: var(--text);
    font-weight: 700;
}

.settings-empty-managers {
    padding: 32px 20px;
    border: 1px dashed var(--border);
    border-radius: 14px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 760px) {
    .settings-managers-header {
        align-items: stretch;
        flex-direction: column;
    }

    .settings-managers-header .settings-button {
        width: 100%;
    }

    .settings-manager-item {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .settings-manager-item > .settings-indicator {
        grid-column: 1 / -1;
        width: fit-content;
        margin-left: 58px;
    }

    .settings-manager-meta {
        flex-direction: column;
        gap: 5px;
    }
}

/* Форма добавления менеджера */

.settings-manager-form {
    display: none;
    margin-bottom: 18px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg);
}

.settings-manager-form.is-visible {
    display: block;
}

.settings-manager-form-grid {
    display: grid;
    grid-template-columns:
        minmax(180px, 0.8fr)
        minmax(220px, 1.2fr)
        auto;
    align-items: end;
    gap: 12px;
}

.settings-manager-form label {
    display: grid;
    gap: 7px;
}

.settings-manager-form label > span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.settings-manager-form input {
    width: 100%;
    min-height: 44px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    outline: none;
}

.settings-manager-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(80, 111, 245, 0.1);
}

.settings-manager-form-grid .settings-button {
    min-height: 44px;
}

.settings-manager-form > p {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 11px;
}

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

    .settings-manager-form-grid .settings-button {
        width: 100%;
    }
}

/* Управление менеджерами */

.settings-manager-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 auto;
    gap: 12px;
}

.settings-manager-controls form {
    margin: 0;
}

.settings-manager-delete-button {
    min-height: 36px;
    padding: 8px 13px;
    border: 1px solid rgba(217, 83, 79, 0.2);
    border-radius: 10px;
    background: rgba(217, 83, 79, 0.08);
    color: var(--danger);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease;
}

.settings-manager-delete-button:hover {
    border-color: var(--danger);
    background: var(--danger);
    color: #ffffff;
}

@media (max-width: 760px) {
    .settings-manager-item {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .settings-manager-controls {
        width: 100%;
        justify-content: space-between;
        padding-top: 12px;
        border-top: 1px solid var(--border);
    }
}

/* ==================================================
   Переключатель темы
================================================== */

.settings-theme-option {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    text-align: left;
    cursor: pointer;
    font: inherit;
    transition:
        border-color 0.2s ease,
        background 0.2s ease,
        transform 0.2s ease;
}

.settings-theme-option:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.settings-theme-description {
    display: grid;
    gap: 5px;
}

.settings-theme-description strong {
    color: var(--text);
}

.settings-theme-description small {
    color: var(--muted);
}

.settings-theme-switch {
    position: relative;
    width: 50px;
    height: 28px;
    display: block;
    flex: 0 0 auto;
    border-radius: 100px;
    background: #d9deea;
    transition: background 0.25s ease;
}

.settings-theme-switch i {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 3px 9px rgba(29, 38, 54, 0.2);
    transition: transform 0.25s ease;
}

.settings-theme-switch.is-active {
    background: var(--primary);
}

.settings-theme-switch.is-active i {
    transform: translateX(22px);
}

/* ==================================================
   Тёмная тема
================================================== */

body[data-theme="dark"] {
    --bg: #0f1623;
    --surface: #182131;
    --sidebar: #0b111c;
    --sidebar-soft: #202c40;
    --primary: #7189ff;
    --primary-dark: #5e75e8;
    --text: #edf1f8;
    --muted: #9ca7b8;
    --border: #2a3547;
    --success: #48cf91;
    --danger: #ff7872;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.24);

    color-scheme: dark;
}

body[data-theme="dark"],
body[data-theme="dark"] .dashboard-content {
    background: var(--bg);
    color: var(--text);
}

body[data-theme="dark"] .auth-page {
    background:
        radial-gradient(
            circle at top left,
            rgba(113, 137, 255, 0.18),
            transparent 38%
        ),
        var(--bg);
}

body[data-theme="dark"] .auth-card,
body[data-theme="dark"] .content-card,
body[data-theme="dark"] .stat-card,
body[data-theme="dark"] .profile-card,
body[data-theme="dark"] .profile-stat-card,
body[data-theme="dark"] .chat-window,
body[data-theme="dark"] .dialogs-layout,
body[data-theme="dark"] .settings-card,
body[data-theme="dark"] .settings-summary-card {
    background: var(--surface);
    border-color: var(--border);
}

body[data-theme="dark"] input,
body[data-theme="dark"] textarea,
body[data-theme="dark"] .table-search input,
body[data-theme="dark"] .dialogs-search input,
body[data-theme="dark"] .dialog-chat-compose textarea {
    background: #121b29;
    color: var(--text);
    border-color: var(--border);
}

body[data-theme="dark"] input::placeholder,
body[data-theme="dark"] textarea::placeholder {
    color: #778397;
}

body[data-theme="dark"] .chat-messages,
body[data-theme="dark"] .dialog-chat-messages {
    background:
        radial-gradient(
            circle at top right,
            rgba(113, 137, 255, 0.08),
            transparent 34%
        ),
        var(--bg);
}

body[data-theme="dark"] .chat-bubble-user {
    background: #202b3d;
    color: var(--text);
}

body[data-theme="dark"] .chat-system-message {
    background: rgba(255, 255, 255, 0.08);
}

body[data-theme="dark"] .secondary-button,
body[data-theme="dark"] .back-button {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

body[data-theme="dark"] .settings-option,
body[data-theme="dark"] .settings-theme-option,
body[data-theme="dark"] .settings-row,
body[data-theme="dark"] .settings-manager-item {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}

body[data-theme="dark"] .settings-path,
body[data-theme="dark"] .settings-code,
body[data-theme="dark"] .dialog-user-stat,
body[data-theme="dark"] .tasks-count {
    background: #111a28;
    color: var(--text);
}

body[data-theme="dark"] .users-table tbody tr:hover,
body[data-theme="dark"] .dialog-list-item:hover {
    background: rgba(113, 137, 255, 0.08);
}

body[data-theme="dark"] .dialog-list-item.active {
    background: rgba(113, 137, 255, 0.15);
}

body[data-theme="dark"] .settings-notice {
    background: rgba(113, 137, 255, 0.09);
}

body[data-theme="dark"] .settings-notice-warning {
    background: rgba(217, 148, 88, 0.12);
}

@media (max-width: 600px) {
    .settings-theme-option {
        gap: 14px;
    }

    .settings-theme-description {
        min-width: 0;
    }
}

/* ==================================================
   Закрепление обращений за менеджерами
================================================== */

.dialog-take-button,
.dialog-release-button {
    min-height: 42px;
    padding: 10px 14px;
    border: 0;
    border-radius: 11px;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.dialog-take-button {
    background: var(--success);
    color: #ffffff;
}

.dialog-take-button:hover {
    filter: brightness(0.94);
}

.dialog-release-button {
    background: rgba(217, 83, 79, 0.12);
    color: var(--danger);
}

.dialog-release-button:hover {
    background: var(--danger);
    color: #ffffff;
}

.dialog-assigned-badge {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 9px 13px;
    border-radius: 11px;
    background: rgba(80, 111, 245, 0.1);
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
}

.dialog-assignment-meta {
    color: var(--text);
}

.dialog-assignment-meta strong {
    color: var(--primary);
}

.dialog-assignment-free {
    color: var(--success);
    font-weight: 800;
}

body[data-theme="dark"] .dialog-release-button {
    background: rgba(255, 120, 114, 0.12);
}

body[data-theme="dark"] .dialog-assigned-badge {
    background: rgba(113, 137, 255, 0.14);
}

@media (max-width: 760px) {
    .dialog-take-button,
    .dialog-release-button,
    .dialog-assigned-badge {
        width: 100%;
        justify-content: center;
    }

    .dialog-status-form {
        width: 100%;
    }
}

/* ==================================================
   Ответственный в списке диалогов
================================================== */

.dialog-owner {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    max-width: 140px;
    padding: 5px 8px;
    border-radius: 100px;
    background: rgba(80, 111, 245, 0.1);
    color: var(--primary);
    font-size: 10px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dialog-owner-current {
    background: rgba(41, 184, 117, 0.12);
    color: var(--success);
}

.dialog-owner-free {
    background: var(--bg);
    color: var(--muted);
}

.dialog-list-footer {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

.dialog-messages-count {
    margin-left: auto;
}

body[data-theme="dark"] .dialog-owner {
    background: rgba(113, 137, 255, 0.14);
}

body[data-theme="dark"] .dialog-owner-current {
    background: rgba(72, 207, 145, 0.12);
}

@media (max-width: 600px) {
    .dialog-owner {
        max-width: 120px;
    }
}

/* ==================================================
   Фильтры диалогов
================================================== */

.dialogs-filters {
    display: flex;
    gap: 7px;
    padding: 0 16px 14px;
    overflow-x: auto;
    scrollbar-width: none;
}

.dialogs-filters::-webkit-scrollbar {
    display: none;
}

.dialogs-filter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-height: 32px;
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: var(--surface);
    color: var(--muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 800;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease;
}

.dialogs-filter:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.dialogs-filter.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
}

body[data-theme="dark"] .dialogs-filter {
    background: #121b29;
}

body[data-theme="dark"] .dialogs-filter.active {
    background: var(--primary);
    color: #ffffff;
}

@media (max-width: 600px) {
    .dialogs-filters {
        padding-right: 12px;
        padding-left: 12px;
    }
}