/* Global table and pagination theme for consistent list pages. */
html.theme-dark .table > :not(caption) > * > * {
    background-color: #0f172a;
    border-bottom-color: #1f2937;
    color: #e5e7eb;
}

html.theme-dark .table.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: #111b2e;
}

html.theme-dark .table.table-striped > tbody > tr:nth-of-type(even) > * {
    background-color: #0f172a;
}

html.theme-dark .table thead.table-light > tr > th,
html.theme-dark .table > thead > tr > th {
    background-color: #0b1223;
    color: #cbd5e1;
    border-bottom-color: #334155;
}

html.theme-dark .table-hover > tbody > tr:hover > *,
html.theme-dark .table-striped > tbody > tr:hover > * {
    background-color: #18243b;
}

html.theme-dark .pagination .page-link {
    background-color: transparent;
    border-color: #334155;
    color: #cbd5e1;
}

html.theme-dark .pagination .page-link:hover,
html.theme-dark .pagination .page-link:focus {
    background-color: #17233a;
    border-color: #3b4b63;
    color: #f1f5f9;
}

html.theme-dark .pagination .page-item.active .page-link {
    background-color: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

html.theme-dark .pagination .page-item.disabled .page-link {
    background-color: transparent;
    border-color: #334155;
    color: #64748b;
}

/* Tickets/open page-specific UI rules centralized here. */
body.route-tickets-open .content-topbar {
    display: none;
}

html.theme-dark body.route-tickets-open .table > :not(caption) > * > * {
    background-color: #111827;
    border-bottom-color: #1f2937;
    color: #e5e7eb;
}

html.theme-dark body.route-tickets-open .table thead.table-light > tr > th {
    background-color: #0f172a;
    color: #cbd5e1;
    border-bottom-color: #334155;
}

html.theme-dark body.route-tickets-open .table-hover > tbody > tr:hover > * {
    background-color: #1f2937;
}

body.route-tickets-open.mobile-shell .queue-mobile-title {
    font-size: 1.15rem;
    margin-bottom: 2px;
}

body.route-tickets-open.mobile-shell #queueContainer .card-body {
    max-height: calc(100dvh - 260px) !important;
}

body.route-tickets-open.mobile-shell #queueContainer .ticket-item {
    padding: .75rem !important;
}

body.route-tickets-open.mobile-shell .mobile-new-conversation-wrap {
    margin-bottom: .75rem;
}

body.route-tickets-open.mobile-shell .mobile-new-conversation-btn {
    width: 100%;
    font-weight: 600;
    padding: .7rem .85rem;
}

body.route-tickets-open.mobile-shell #queueContainer .btn-group .btn {
    font-size: .8rem;
}

/* Status users table footer/pagination (tickets/open). */
body.route-tickets-open #statusUsersContainer .status-users-footer {
    background-color: var(--card-bg);
    color: var(--app-text);
    border-top: 1px solid #e5e7eb;
}

body.route-tickets-open #statusUsersContainer .status-users-footer .text-muted {
    color: #6b7280 !important;
}

body.route-tickets-open #statusUsersContainer .status-users-pagination .page-link {
    background-color: var(--card-bg);
    color: var(--app-text);
    border-color: #cbd5e1;
}

body.route-tickets-open #statusUsersContainer .status-users-pagination .page-item.active .page-link {
    background-color: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

body.route-tickets-open #statusUsersContainer .status-users-pagination .page-item.disabled .page-link {
    background-color: var(--card-bg);
    color: #94a3b8;
    border-color: #cbd5e1;
}

html.theme-dark body.route-tickets-open #statusUsersContainer .status-users-footer {
    background-color: #0f172a;
    color: #e5e7eb;
    border-top-color: #1f2937;
}

html.theme-dark body.route-tickets-open #statusUsersContainer .status-users-footer .text-muted {
    color: #94a3b8 !important;
}

html.theme-dark body.route-tickets-open #statusUsersContainer .status-users-pagination .page-link {
    background-color: #0f172a;
    color: #cbd5e1;
    border-color: #334155;
}

html.theme-dark body.route-tickets-open #statusUsersContainer .status-users-pagination .page-item.disabled .page-link {
    background-color: #0f172a;
    color: #64748b;
    border-color: #334155;
}

/* Archived tickets footer (tickets/open) */
body.route-tickets-open .archive-tickets-footer {
    background-color: var(--card-bg);
    color: var(--app-text);
    border-top: 1px solid #e5e7eb;
}

html.theme-dark body.route-tickets-open .archive-tickets-footer {
    background-color: #0f172a;
    color: #e5e7eb;
    border-top-color: #1f2937;
}

/* Monitor page chart controls */
body.route-monitor-db .monitor-metrics-canvas {
    width: 100%;
    height: 180px;
    display: block;
}

body.route-monitor-db .monitor-chart-toggle {
    min-width: 104px;
}

/* App shell/layout styles migrated from sidebar layout. */
:root {
    --app-bg: #f3f6fb;
    --app-text: #0f172a;
    --sidebar-bg: #0f172a;
    --sidebar-bg2: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-hover-bg: rgba(99, 102, 241, 0.15);
    --sidebar-hover-text: #e2e8f0;
    --sidebar-active-bg: rgba(99, 102, 241, 0.22);
    --sidebar-active-text: #a5b4fc;
    --sidebar-active-border: #6366f1;
    --section-title: #64748b;
    --card-bg: #ffffff;
    --muted-bg: #f8fafc;
}

html.theme-dark {
    --app-bg: #0b1220;
    --app-text: #e5e7eb;
    --muted-text: #cbd5e1;
    --placeholder-text: #94a3b8;
    --sidebar-bg: #020617;
    --sidebar-bg2: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-hover-bg: rgba(99, 102, 241, 0.18);
    --sidebar-hover-text: #e2e8f0;
    --sidebar-active-bg: rgba(99, 102, 241, 0.25);
    --sidebar-active-text: #a5b4fc;
    --sidebar-active-border: #818cf8;
    --section-title: #475569;
    --card-bg: #111827;
    --muted-bg: #1f2937;
}

/* Inputs used for searches in integration page */
.integration-search-input {
    background-color: var(--card-bg);
    color: var(--app-text);
    border-color: #334155;
}

.integration-search-input::placeholder {
    color: var(--placeholder-text);
}



body {
    background: var(--app-bg);
    color: var(--app-text);
    margin: 0;
}

body.mobile-shell .content-area {
    margin-left: 0;
    width: 100%;
    padding: 56px 10px 84px;
}

body.mobile-shell .content-topbar {
    display: none;
}

body.mobile-shell .mobile-font-controls {
    position: fixed;
    right: 10px;
    top: calc(10px + env(safe-area-inset-top, 0px));
    z-index: 1080;
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 999px;
    box-shadow: 0 8px 20px rgba(2, 6, 23, 0.35);
    backdrop-filter: blur(4px);
}

body.mobile-shell .mobile-font-controls .btn {
    border-radius: 999px;
    width: 32px;
    height: 32px;
    padding: 0;
    line-height: 30px;
    font-size: .85rem;
    font-weight: 700;
}

body.mobile-shell .mobile-font-controls .mobile-font-reset {
    width: 40px;
    font-size: .74rem;
}

body.mobile-shell .mobile-font-controls .mobile-font-value {
    color: #e2e8f0;
    min-width: 38px;
    text-align: center;
    font-size: .72rem;
    font-weight: 600;
}

html.theme-dark body.mobile-shell .mobile-font-controls {
    background: rgba(2, 6, 23, 0.92);
    border-color: rgba(148, 163, 184, 0.35);
}

.app-sidebar {
    width: 64px;
    height: 100vh;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg2) 100%);
    border-right: 1px solid rgba(99, 102, 241, 0.12);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    color: #fff;
    transition: width .22s cubic-bezier(.4, 0, .2, 1);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1030;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.25) transparent;
}

.app-sidebar::-webkit-scrollbar {
    width: 4px;
}

.app-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.app-sidebar::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 999px;
}

.app-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.55);
}

.app-sidebar:hover,
.app-sidebar.is-open {
    width: 234px;
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.brand {
    font-weight: 700;
    font-size: 18px;
    padding: 18px 10px;
    text-align: center;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-pin-btn {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    transition: all .2s ease;
}

.sidebar-pin-btn:hover,
.sidebar-pin-btn:focus {
    background: rgba(99, 102, 241, 0.18);
    color: #a5b4fc;
    outline: none;
}

.sidebar-user {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    margin: 0 6px 2px;
    transition: opacity .2s ease, max-height .2s ease, margin .2s ease;
}

.app-sidebar:hover .sidebar-user,
.app-sidebar.is-open .sidebar-user {
    opacity: 1;
    max-height: 280px;
    overflow: visible;
    margin: 2px 6px 10px;
}

.sidebar-user-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 12px;
    text-decoration: none;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.15);
    color: #e2e8f0;
    text-align: center;
    transition: all .2s ease;
}

.sidebar-user-top {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.sidebar-user-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-user-theme-toggle .btn {
    color: #93c5fd;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.sidebar-user-link:hover {
    background: rgba(99, 102, 241, 0.18);
    border-color: rgba(99, 102, 241, 0.35);
    color: #ffffff;
}

.sidebar-avatar {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(99, 102, 241, 0.15);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(99, 102, 241, 0.4);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    transition: border-color .2s ease, box-shadow .2s ease;
}

.sidebar-user-link:hover .sidebar-avatar {
    border-color: rgba(99, 102, 241, 0.7);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.sidebar-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sidebar-avatar i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-user-name {
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.3;
    color: #a5b4fc;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    width: 100%;
}

.app-sidebar nav {
    flex: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: background .18s ease, color .18s ease, border-left-color .18s ease;
    border-radius: 10px;
    border-left: 3px solid transparent;
    position: relative;
    margin-bottom: 2px;
}

.menu-item:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-hover-text);
    border-left-color: rgba(99, 102, 241, 0.5);
}

.menu-item.active,
.menu-item[aria-current="page"] {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    border-left-color: var(--sidebar-active-border);
    font-weight: 600;
}

.menu-item i {
    font-size: 17px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.menu-text {
    white-space: nowrap;
    opacity: 0;
    transition: opacity .2s ease;
}

.app-sidebar:hover .menu-text,
.app-sidebar.is-open .menu-text {
    opacity: 1;
}

.menu-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--section-title);
    margin: 14px 8px 4px;
    padding: 0 6px 4px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity .2s ease;
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.menu-theme-toggle {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.menu-theme-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35);
}

.app-sidebar:hover .menu-section-title,
.app-sidebar.is-open .menu-section-title {
    opacity: 1;
}

.menu-item.text-danger {
    margin-top: auto;
    border-left-color: transparent !important;
}

.menu-item.text-danger:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5 !important;
    border-left-color: rgba(239, 68, 68, 0.5) !important;
}

.content-area {
    flex: 1;
    padding: 30px;
    margin-left: 64px;
    width: calc(100% - 64px);
    transition: margin-left .22s cubic-bezier(.4, 0, .2, 1), width .22s cubic-bezier(.4, 0, .2, 1);
}

.app-sidebar:hover ~ .content-area,
.app-sidebar.is-open ~ .content-area,
body.sidebar-pinned .content-area {
    margin-left: 234px;
    width: calc(100% - 234px);
}

.content-topbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 14px;
}

.user-menu-button {
    min-width: 220px;
    text-align: left;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.user-menu-button:hover,
.user-menu-button:focus,
.user-menu-button:active {
    border: 0 !important;
    box-shadow: none !important;
}

html.theme-dark .card,
html.theme-dark .table,
html.theme-dark .list-group-item,
html.theme-dark .dropdown-menu,
html.theme-dark .modal-content {
    background-color: var(--card-bg);
    color: var(--app-text);
}

html.theme-dark .bg-light,
html.theme-dark .bg-light-subtle {
    background-color: var(--muted-bg) !important;
    color: var(--app-text);
}

html.theme-dark .table {
    --bs-table-bg: var(--card-bg);
    --bs-table-color: var(--app-text);
    --bs-table-striped-bg: #0f172a;
    --bs-table-striped-color: var(--app-text);
}

html.theme-dark .form-control,
html.theme-dark .form-select,
html.theme-dark .form-control:focus,
html.theme-dark .form-select:focus {
    background-color: #0f172a;
    color: var(--app-text);
    border-color: #334155;
}

html.theme-dark .nav-tabs .nav-link {
    color: #cbd5e1;
}

html.theme-dark .nav-tabs .nav-link.active {
    background-color: var(--card-bg);
    color: var(--app-text);
    border-color: #334155 #334155 var(--card-bg);
}

html.theme-dark .text-muted,
html.theme-dark .text-body-secondary,
html.theme-dark small,
html.theme-dark .small {
    color: var(--muted-text) !important;
}

html.theme-dark .form-control::placeholder,
html.theme-dark textarea::placeholder {
    color: var(--placeholder-text);
    opacity: 1;
}

html.theme-dark .user-menu-button {
    color: #e5e7eb;
    border: 0 !important;
    background-color: transparent !important;
}

html.theme-dark .user-menu-button:hover,
html.theme-dark .user-menu-button:focus,
html.theme-dark .user-menu-button:active {
    color: #ffffff;
    border: 0 !important;
    background-color: #1e293b;
    box-shadow: none !important;
}

html.theme-dark .dropdown-menu {
    border: 1px solid #334155;
}

html.theme-dark .dropdown-item {
    color: #e5e7eb;
}

html.theme-dark .dropdown-item:hover,
html.theme-dark .dropdown-item:focus,
html.theme-dark .dropdown-item:active {
    color: #ffffff;
    background-color: #1e293b;
}

html.theme-dark .dropdown-divider {
    border-top-color: #334155;
}

/* Atendimento/new page styles. */
body.route-atendimento-new .new-atendimento-form {
    max-width: 600px;
}

body.route-atendimento-new .new-atendimento-form .form-label {
    color: var(--app-text);
}

body.route-atendimento-new .new-atendimento-form .form-text {
    color: #64748b;
}

body.route-atendimento-new .opening-message-preview {
    min-height: 90px;
    white-space: pre-wrap;
    background-color: var(--muted-bg);
    color: var(--app-text);
}

body.route-atendimento-new.mobile-shell .new-atendimento-form {
    max-width: 100% !important;
    padding: .25rem .15rem 1rem;
}

body.route-atendimento-new.mobile-shell .new-atendimento-title {
    font-size: 1.15rem;
    margin-bottom: .75rem !important;
}

body.route-atendimento-new.mobile-shell .new-atendimento-form .form-label {
    margin-bottom: .25rem;
    font-size: .86rem;
}

body.route-atendimento-new.mobile-shell .new-atendimento-form .form-text {
    font-size: .75rem;
}

body.route-atendimento-new.mobile-shell .new-atendimento-form .form-control,
body.route-atendimento-new.mobile-shell .new-atendimento-form .form-select {
    font-size: .95rem;
    min-height: 42px;
}

body.route-atendimento-new.mobile-shell .new-atendimento-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: .5rem;
}

body.route-atendimento-new.mobile-shell .new-atendimento-actions .btn {
    width: 100%;
}

html.theme-dark body.route-atendimento-new .new-atendimento-form .form-text {
    color: #cbd5e1;
}

html.theme-dark body.route-atendimento-new .new-atendimento-form .form-select,
html.theme-dark body.route-atendimento-new .new-atendimento-form .form-control {
    background-color: #0f172a;
    color: #e5e7eb;
    border-color: #334155;
}

html.theme-dark body.route-atendimento-new .new-atendimento-form .form-select option {
    background-color: #0f172a;
    color: #e5e7eb;
}

html.theme-dark body.route-atendimento-new .opening-message-preview {
    border-color: #334155;
}

/* Atendimento/show page styles. */
body.route-atendimento #atendimentoLayout .messages-scroll {
    max-height: calc(125vh - 720px);
    min-height: 420px;
}

body.route-atendimento #atendimentoLayout .related-scroll {
    max-height: calc(100vh - 210px);
}

@media (max-width: 1400px) {
    body.route-atendimento #atendimentoLayout .messages-scroll {
        max-height: calc(100vh - 340px);
    }

    body.route-atendimento #atendimentoLayout .related-scroll {
        max-height: 520px;
    }
}

@media (max-width: 992px) {
    body.route-atendimento #atendimentoLayout .messages-scroll,
    body.route-atendimento #atendimentoLayout .related-scroll {
        max-height: none;
        min-height: 0;
    }
}

@media (max-width: 576px) {
    body.route-atendimento #messages .audio-speed-controls {
        gap: .25rem !important;
    }

    body.route-atendimento #messages .audio-speed-controls .btn {
        padding: .15rem .35rem;
        font-size: .72rem;
        line-height: 1.5;
    }

    body.route-atendimento #messages .audio-speed-controls small {
        font-size: .72rem;
    }
}

body.route-atendimento .queue-toggle {
    cursor: pointer;
}

body.route-atendimento .queue-toggle-header {
    color: inherit;
    text-decoration: none;
}

body.route-atendimento .queue-toggle-header:hover,
body.route-atendimento .queue-toggle-header:focus {
    color: inherit;
    text-decoration: none;
}

body.route-atendimento .queue-toggle .queue-chevron {
    transition: transform .2s ease;
}

body.route-atendimento .queue-toggle[aria-expanded="true"] .queue-chevron {
    transform: rotate(180deg);
}

body.route-atendimento #atendimentoLayout .chat-attachment-pill {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .8rem;
}

body.route-atendimento #atendimentoLayout .quick-replies-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

/* === Modern chat bubbles === */

/* Encryption bar header */
body.route-atendimento #atendimentoChatColumn > .card > .card-header {
    background: linear-gradient(90deg, #064e3b 0%, #065f46 50%, #064e3b 100%) !important;
    border-bottom: 1px solid rgba(110, 231, 183, 0.12);
    padding: 7px 16px;
}
body.route-atendimento #atendimentoChatColumn > .card > .card-header h6,
body.route-atendimento #atendimentoChatColumn > .card > .card-header .h6 {
    color: #6ee7b7 !important;
    font-size: .8rem;
    font-weight: 500;
    letter-spacing: .02em;
}

/* Messages scroll area background */
body.route-atendimento #atendimentoLayout .messages-scroll {
    background: #edeef0;
    scroll-behavior: smooth;
}
html.theme-dark body.route-atendimento #atendimentoLayout .messages-scroll {
    background: #0d1520;
}

/* Load-older button row */
body.route-atendimento #atendimentoChatColumn .card-body > .border-bottom.bg-light {
    background: transparent !important;
    border-bottom-color: rgba(0,0,0,0.07) !important;
}
html.theme-dark body.route-atendimento #atendimentoChatColumn .card-body > .border-bottom.bg-light {
    background: transparent !important;
    border-bottom-color: rgba(148, 163, 184, 0.08) !important;
}
body.route-atendimento #loadOlderBtn {
    border-radius: 999px;
    font-size: .78rem;
    padding: .25rem .85rem;
    border-color: rgba(0,0,0,0.13);
    color: #64748b;
    background: rgba(255,255,255,0.8);
}
html.theme-dark body.route-atendimento #loadOlderBtn {
    border-color: rgba(148, 163, 184, 0.22);
    color: #94a3b8;
    background: rgba(255,255,255,0.04);
}

/* Author/timestamp label */
body.route-atendimento #messages .message-author {
    font-size: .73rem;
    opacity: .6;
    margin-bottom: 2px !important;
}
body.route-atendimento #messages .message-author strong {
    font-weight: 600;
}

/* Contact (incoming) bubble */
body.route-atendimento #messages .message-contact .message-bubble.bg-light {
    background: #ffffff !important;
    color: #1a202c !important;
    border-radius: 4px 18px 18px 18px !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.09), 0 0 0 1px rgba(0,0,0,0.03);
    border: none;
}
html.theme-dark body.route-atendimento #messages .message-contact .message-bubble.bg-light {
    background: #1e2d40 !important;
    color: #e2e8f0 !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Agent (outgoing normal) bubble */
body.route-atendimento #messages .message-agent .message-bubble.bg-primary {
    background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%) !important;
    border-radius: 18px 4px 18px 18px !important;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.38);
    border: none;
}

/* Internal message bubble */
body.route-atendimento #messages .message-agent .message-bubble.bg-dark {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%) !important;
    border-left: 3px solid #f59e0b !important;
    border-radius: 18px 4px 18px 18px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Reply preview inside agent bubble */
body.route-atendimento #messages .message-agent .message-bubble .reply-preview {
    background: rgba(255,255,255,0.10) !important;
    border-left: 3px solid rgba(255,255,255,0.45) !important;
    border-radius: 6px;
}

/* Reply preview inside contact bubble */
body.route-atendimento #messages .message-contact .message-bubble .reply-preview {
    background: rgba(0,0,0,0.04) !important;
    border-left: 3px solid rgba(0,0,0,0.18) !important;
    border-radius: 6px;
}
html.theme-dark body.route-atendimento #messages .message-contact .message-bubble .reply-preview {
    background: rgba(255,255,255,0.06) !important;
    border-left: 3px solid rgba(255,255,255,0.2) !important;
}

body.route-atendimento #atendimentoLayout .audio-recording-status {
    font-size: .8rem;
    color: #dc3545;
    font-weight: 600;
}

body.route-atendimento .content-topbar {
    display: none;
}

body.route-atendimento.mobile-shell #atendimentoLayout {
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-top: 0 !important;
}

body.route-atendimento.mobile-shell #atendimentoLayout .mobile-hidden {
    display: none !important;
}

body.route-atendimento.mobile-shell #queueSummaryCard,
body.route-atendimento.mobile-shell #atendimentoInfoColumn,
body.route-atendimento.mobile-shell #atendimentoRelatedColumn {
    display: none;
}

body.route-atendimento.mobile-shell #atendimentoChatColumn {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
}

body.route-atendimento.mobile-shell #atendimentoLayout .card {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
}

body.route-atendimento.mobile-shell #atendimentoChatColumn .card-header {
    display: none;
}

body.route-atendimento.mobile-shell #atendimentoChatColumn .card {
    margin-bottom: .5rem !important;
}

body.route-atendimento.mobile-shell #atendimentoChatColumn .card-body {
    padding: 0 !important;
}

body.route-atendimento.mobile-shell #messages.messages-scroll {
    max-height: calc(100dvh - 168px);
    min-height: calc(100dvh - 168px);
    padding: 10px 10px 16px !important;
}

body.route-atendimento.mobile-shell .chat-compose-card {
    position: sticky;
    bottom: 0;
    z-index: 25;
    margin-bottom: 0 !important;
    border-top: 1px solid #dbe4f1;
}

body.route-atendimento.mobile-shell .chat-compose-card .card-body {
    padding: .5rem .5rem calc(.5rem + env(safe-area-inset-bottom, 0px));
}

body.route-atendimento.mobile-shell #sendForm .input-group {
    align-items: stretch;
}

body.route-atendimento.mobile-shell #sendForm textarea {
    min-height: 40px;
    max-height: 92px;
    font-size: .95rem;
}

body.route-atendimento.mobile-shell #sendBtn {
    min-width: 74px;
    padding-left: .8rem;
    padding-right: .8rem;
}

body.route-atendimento.mobile-shell #sendForm .mobile-compose-actions {
    margin-bottom: .4rem !important;
}

body.route-atendimento.mobile-shell #sendForm .mobile-compose-actions .btn {
    font-size: .78rem;
    padding: .3rem .55rem;
}

body.route-atendimento.mobile-shell .mobile-back-to-queue {
    margin-top: .5rem;
}

/* Settings/zapi page styles. */
body.route-settings-zapi .zapi-page {
    max-width: 1320px;
}

body.route-settings-zapi .zapi-page .mono-code {
    word-break: break-all;
}

body.route-settings-zapi .zapi-page .card-title {
    font-weight: 600;
}

body.route-settings-zapi #companyScopeZapi {
    max-width: 320px;
}

/* Auth/login page styles. */
body.login-page,
body.login-page * {
    box-sizing: border-box;
}

body.login-page {
    font-family: Arial, Helvetica, sans-serif;
    background-image: url('/assets/images/login-background.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    min-height: 100vh;
}

body.login-page::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 0;
}

body.login-page .center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

body.login-page .card {
    background: #ffffff;
    padding: 28px;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(15, 15, 15, 0.15);
    width: 360px;
}

body.login-page h1 {
    margin: 0 0 12px;
    font-size: 20px;
    color: #1f2937;
}

body.login-page .field {
    margin-bottom: 12px;
}

body.login-page label {
    display: block;
    margin-bottom: 4px;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
}

body.login-page input[type="email"],
body.login-page input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #d9e1ef;
    border-radius: 4px;
    font-size: 14px;
}

body.login-page input[type="email"]:focus,
body.login-page input[type="password"]:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

body.login-page button {
    width: 100%;
    padding: 10px;
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: background .2s;
}

body.login-page button:hover {
    background: #1d4ed8;
}

body.login-page button:active {
    background: #1e40af;
}

body.login-page .error {
    background: #ffe6e6;
    color: #aa0000;
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 12px;
    font-size: 14px;
}

body.login-page .muted {
    font-size: 12px;
    color: #6b7280;
    margin-top: 10px;
    text-align: center;
}

body.login-page .muted-left {
    margin-top: 6px;
    text-align: left;
}

body.login-page .access-mode {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 6px;
    border-radius: 8px;
    background: #f3f6fb;
    border: 1px solid #d9e1ef;
}

body.login-page .access-mode-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

body.login-page .access-mode-label {
    margin: 0;
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid transparent;
    color: #334155;
    background: transparent;
    cursor: pointer;
    transition: all .18s ease;
    user-select: none;
}

body.login-page .access-mode-input:checked + .access-mode-label {
    color: #0f172a;
    background: #ffffff;
    border-color: #c7d2fe;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
    font-weight: 600;
}

body.login-page .access-mode-input:focus-visible + .access-mode-label {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
}

/* Queue order drag list — Settings > System */
html.theme-dark .queue-order-card {
    background-color: #0f172a !important;
}

html.theme-dark .queue-order-item {
    background-color: #1e293b;
    border-color: #334155 !important;
    color: #e5e7eb;
}

html.theme-dark .queue-order-item .queue-drag-handle {
    color: #64748b;
}

/* Service hours status card — Settings > System */
.service-hours-status-card {
    background-color: #f8f9fa;
    border-color: #dee2e6 !important;
}

html.theme-dark .service-hours-status-card {
    background-color: #1e293b;
    border-color: #334155 !important;
    color: #e5e7eb;
}
