/* =========================================================
   Base / tokens
   ========================================================= */
:root {
    color-scheme: dark;
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
    font-size: 13px;
    letter-spacing: 0;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    background: #1f2635;
}

h1:focus {
    outline: none;
}

button,
input,
select,
texTarea,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.material-symbols-rounded {
    direction: ltr;
    display: inline-flex;
    font-family: "Material Symbols Rounded";
    font-feature-settings: "liga";
    font-size: 20px;
    font-style: normal;
    font-weight: 500;
    letter-spacing: 0;
    line-height: 1;
    text-rendering: optimizeLegibility;
    text-transform: none;
    white-space: nowrap;
    word-wrap: normal;
}

/* =========================================================
   Shell / layout principal
   ========================================================= */
.app-shell {
    --topbar: #202738;
    --sidebar: #263143;
    --sidebar-panel: #303a4e;
    --main: #293241;
    --main-2: #242c3b;
    --panel: #30394d;
    --panel-soft: #384257;
    --line: rgba(255, 255, 255, 0.11);
    --text: #f6f8fc;
    --muted: #b7bfce;
    --muted-2: #8e98aa;
    --accent: #9ccbff;
    --accent-strong: #87c4ff;
    --green: #25d366;
    --danger: #ef4444;
    --bubble-in: #4d586e;
    --bubble-out: #08736d;
    background: var(--main);
    color: var(--text);
    display: grid;
    grid-template-columns: 282px minmax(0, 1fr);
    grid-template-rows: 62px minmax(0, 1fr);
    height: 100vh;
    width: 100vw;
}

    .app-shell.theme-light {
        --topbar: #dfe6ee;
        --sidebar: #d8e1eb;
        --sidebar-panel: #e8eef5;
        --main: #dfe7ef;
        --main-2: #e5ebf3;
        --panel: #edf2f7;
        --panel-soft: #d8e1ea;
        --line: rgba(15, 23, 42, 0.16);
        --text: #1f2937;
        --muted: #465569;
        --muted-2: #66758a;
        --accent: #2563eb;
        --accent-strong: #1d4ed8;
        --bubble-in: #d5dee9;
        --bubble-out: #c9ece3;
        color-scheme: light;
    }

.theme-light .brand-mark {
    background: #cfd8e3;
    color: #142033;
}

.theme-light .chat-header,
.theme-light .tag-strip,
.theme-light .search-toolbar input,
.theme-light .composer input {
    background: #d8e1eb;
}

.theme-light .filter-chip,
.theme-light .tag-chip,
.theme-light .status-pill {
    background: #53657c;
    border-color: #44566c;
    color: #f8fafc;
}

    .theme-light .filter-chip.active,
    .theme-light .status-pill.connected {
        background: #3f648d;
        border-color: #2d5f8a;
        color: #ffffff;
    }

    .theme-light .status-pill.pending {
        background: #f6c453;
        border-color: #d99a14;
        color: #3f2a05;
    }

    .theme-light .status-pill.soft {
        background: #53657c;
        border-color: #44566c;
        color: #ffffff;
    }

.theme-light .secondary-button,
.theme-light .wide-card-action {
    background: #63738a;
    color: #ffffff;
}

.theme-light code {
    background: #d5deea;
    border-color: #aab8ca;
    color: #12345f;
}

.app-shell.sidebar-collapsed {
    grid-template-columns: 82px minmax(0, 1fr);
}

/* =========================================================
   Topbar / navegación lateral
   ========================================================= */
.topbar {
    align-items: center;
    background: var(--topbar);
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.26);
    display: flex;
    gap: 12px;
    grid-column: 1 / -1;
    min-width: 0;
    padding: 0 22px;
    z-index: 4;
}

    .topbar form {
        margin: 0;
    }

.brand {
    align-items: center;
    color: var(--text);
    display: inline-flex;
    gap: 10px;
    min-width: 0;
    text-decoration: none;
}

.brand-mark {
    align-items: center;
    background: linear-gradient(135deg, var(--accent), #25d366);
    border-radius: 8px;
    color: #202738;
    display: inline-flex;
    height: 38px;
    justify-content: center;
    line-height: 1;
    width: 38px;
}

    .brand-mark .material-symbols-rounded {
        color: #10233b;
        font-size: 24px;
        font-variation-settings: "FILL" 1, "wght" 700, "GRAD" 0, "opsz" 24;
    }

.brand-text {
    font-size: 24px;
    font-weight: 800;
}

.topbar-spacer {
    flex: 1 1 auto;
}

.icon-button,
.small-icon-button {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: var(--text);
    display: inline-flex;
    height: 36px;
    justify-content: center;
    padding: 0;
    position: relative;
    width: 36px;
}

.visually-hidden-file {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    left: -10000px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    position: absolute;
    top: auto;
    white-space: nowrap;
    width: 1px;
}

.small-icon-button {
    height: 30px;
    width: 30px;
}

    .icon-button:hover,
    .small-icon-button:hover {
        background: rgba(255, 255, 255, 0.08);
    }

    .icon-button:disabled,
    .small-icon-button:disabled,
    .small-icon-button.disabled {
        cursor: not-allowed;
        opacity: 0.45;
        pointer-events: none;
    }

.notification-badge {
    align-items: center;
    background: var(--danger);
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    font-size: 11px;
    font-weight: 700;
    height: 17px;
    justify-content: center;
    position: absolute;
    right: 0;
    top: 4px;
    width: 17px;
}

.notification-host {
    position: relative;
}

.notification-button[aria-expanded="true"],
.unread-filter-button.active {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    color: var(--accent);
}

.notification-popover {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 22px 54px rgba(0, 0, 0, 0.38);
    color: var(--text);
    min-width: 340px;
    padding: 10px;
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    width: min(380px, calc(100vw - 28px));
    z-index: 32;
}

.notification-popover header {
    align-items: center;
    display: flex;
    justify-content: space-between;
    padding: 4px 4px 10px;
}

.notification-popover header span,
.notification-count {
    align-items: center;
    background: var(--danger);
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    font-size: 11px;
    font-weight: 800;
    justify-content: center;
    min-width: 20px;
    padding: 2px 6px;
}

.notification-list {
    display: grid;
    gap: 6px;
    max-height: 390px;
    overflow: auto;
}

.notification-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px 5px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

.sla-notification-list + .notification-group-title {
    border-top: 1px solid var(--line);
}

.sla-notification .notification-avatar {
    display: grid;
    place-items: center;
    color: #b45309;
    background: #fef3c7;
}

.sla-notification.breach .notification-avatar {
    color: #b91c1c;
    background: #fee2e2;
}

.sla-notification.acknowledged {
    opacity: 0.72;
}

.notification-count.acknowledged {
    color: #15803d;
    background: #dcfce7;
}

.settings-sla-panel {
    margin-top: 16px;
}

.sla-settings-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(150px, 1fr)) minmax(180px, 1fr);
    gap: 12px;
    align-items: end;
}

.sla-settings-grid > label:not(.inline-check) {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.sla-settings-grid input[type="number"] {
    width: 100%;
}

.sla-working-hours-toggle {
    min-height: 42px;
    align-items: center;
}

@media (max-width: 900px) {
    .sla-settings-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .sla-settings-grid {
        grid-template-columns: 1fr;
    }
}

.notification-item {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text);
    display: grid;
    gap: 10px;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    min-width: 0;
    padding: 8px;
    text-align: left;
}

.notification-item:hover {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    border-color: color-mix(in srgb, var(--accent) 28%, transparent);
}

.notification-avatar {
    align-items: center;
    background: #3b465c;
    border-radius: 999px;
    color: var(--text);
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    height: 34px;
    justify-content: center;
    text-transform: uppercase;
    width: 34px;
}

.notification-content {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.notification-title {
    align-items: center;
    display: flex;
    gap: 8px;
    min-width: 0;
}

.notification-title strong,
.notification-preview,
.notification-line {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-title strong {
    flex: 1 1 auto;
    min-width: 0;
}

.notification-title small,
.notification-line {
    color: var(--muted);
    font-size: 11px;
}

.notification-preview {
    color: var(--text);
    font-size: 12px;
}

.notification-empty {
    color: var(--muted);
    padding: 12px 4px 6px;
}

.sidebar {
    background: var(--sidebar);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    padding: 10px 12px 14px;
}

.nav-panel,
.sidebar-footer {
    background: var(--sidebar-panel);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
}

.nav-panel {
    flex: 1 1 auto;
    overflow-y: auto;
}

.nav-entry {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: var(--text);
    display: flex;
    gap: 11px;
    min-height: 39px;
    min-width: 0;
    padding: 0 10px;
    position: relative;
    text-align: left;
    text-decoration: none;
    width: 100%;
}

    .nav-entry:hover,
    .nav-entry.active {
        background: #48576f;
    }

.theme-light .nav-entry:hover,
.theme-light .nav-entry.active {
    background: #dce7f5;
}

.nav-icon {
    flex: 0 0 auto;
}

.nav-label {
    font-size: 14px;
    font-weight: 700;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-alert {
    background: var(--danger);
    border-radius: 999px;
    height: 8px;
    width: 8px;
}

.account-avatar,
.avatar {
    align-items: center;
    background: linear-gradient(135deg, #ffe3a1, #f472b6);
    border-radius: 999px;
    color: #1f2937;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 800;
    height: 36px;
    justify-content: center;
    width: 36px;
}

.account-avatar {
    background: #8d96a5;
    color: #263143;
    height: 28px;
    width: 28px;
}

    .account-avatar.big {
        font-size: 24px;
        height: 78px;
        width: 78px;
    }

.avatar.large {
    height: 46px;
    width: 46px;
}

.contact-avatar {
    overflow: hidden;
    position: relative;
}

.contact-avatar-initials {
    align-items: center;
    display: inline-flex;
    height: 100%;
    justify-content: center;
    width: 100%;
}

.contact-avatar-image {
    border-radius: inherit;
    height: 100%;
    inset: 0;
    object-fit: cover;
    position: absolute;
    width: 100%;
}

.switch-track {
    align-items: center;
    background: #6b7280;
    border-radius: 999px;
    display: inline-flex;
    flex: 0 0 auto;
    height: 20px;
    margin-left: auto;
    padding: 2px;
    transition: background 0.16s ease;
    width: 36px;
}

    .switch-track.on {
        background: #93c9ff;
    }

.switch-thumb {
    background: #fff;
    border-radius: 999px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    height: 16px;
    transform: translateX(0);
    transition: transform 0.16s ease;
    width: 16px;
}

.switch-track.on .switch-thumb {
    transform: translateX(16px);
}

.sidebar-collapsed .brand-text,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .nav-alert,
.sidebar-collapsed .switch-track {
    display: none;
}

.sidebar-collapsed .sidebar {
    padding-left: 10px;
    padding-right: 10px;
}

.sidebar-collapsed .nav-entry {
    justify-content: center;
    padding: 0;
}

.main-stage {
    background: var(--main);
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

/* =========================================================
   Login
   ========================================================= */
.login-stage {
    --main-2: #ffffff;
    --panel: #ffffff;
    --line: #e4e9f1;
    --text: #172033;
    --muted: #62708a;
    --accent: #ff6b00;
    --accent-strong: #e95d00;
    align-items: center;
    background: linear-gradient(135deg, #073b78 0%, #0b4b92 42%, #f4f7fb 42%, #ffffff 100%);
    color: var(--text);
    display: grid;
    height: 100%;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

.login-shell {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 100%;
    min-width: 0;
    padding: 28px;
    width: 100%;
}

.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1fr);
    max-width: 390px;
    min-width: 0;
    padding: 28px;
    width: min(100%, 390px);
}

.login-brand {
    align-items: center;
    display: flex;
    gap: 12px;
    margin-bottom: 4px;
}

    .login-brand h1 {
        font-size: 25px;
        line-height: 1;
        margin: 0 0 4px;
    }

    .login-brand p {
        color: var(--muted);
        font-weight: 800;
        margin: 0;
    }

.login-panel label {
    color: var(--muted);
    display: grid;
    font-weight: 800;
    gap: 7px;
}

.login-panel input {
    background: var(--main-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    min-height: 40px;
    min-width: 0;
    outline: 0;
    padding: 9px 11px;
    width: 100%;
}

.login-button {
    justify-content: center;
    margin-top: 4px;
    width: 100%;
}

.login-close-button {
    justify-content: center;
    width: 100%;
}

.login-close-button .material-symbols-rounded {
    font-size: 19px;
}

.login-close-message {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
    margin: -4px 0 0;
    text-align: center;
}

@media (max-width: 380px) {
    .login-shell {
        padding: 8px;
    }

    .login-panel {
        padding: 22px;
    }

    .login-brand {
        gap: 8px;
    }

    .login-brand .aicon-logo-mark {
        height: 40px;
        width: 40px;
    }

    .login-brand .aicon-wordmark-image {
        height: 24px;
    }

    .login-brand .logo-chat {
        font-size: 22px;
    }

    .login-brand p {
        font-size: 11px;
    }
}

/* =========================================================
   Startup splash and login transition
   ========================================================= */
html:not(.aicon-startup-ready) .login-panel {
    visibility: hidden;
}

.aicon-startup {
    color: #ffffff;
    padding: max(16px, env(safe-area-inset-top))
        max(16px, env(safe-area-inset-right))
        max(16px, env(safe-area-inset-bottom))
        max(16px, env(safe-area-inset-left));
}

.aicon-startup-white {
    will-change: transform;
}

.aicon-startup.is-finishing .aicon-startup-white {
    animation: aicon-startup-diagonal-in 760ms cubic-bezier(0.22, 0.8, 0.24, 1) both;
}

.aicon-startup-mark {
    animation: aicon-startup-mark-in 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
    filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.22));
    will-change: opacity, transform;
}

.aicon-startup.is-finishing .aicon-startup-mark {
    animation: aicon-startup-mark-out 360ms ease-out both;
}

.aicon-startup-error {
    align-items: center;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.25);
    color: #172033;
    display: none;
    flex-direction: column;
    gap: 14px;
    max-width: min(330px, calc(100vw - 32px));
    padding: 22px 24px;
    position: relative;
    text-align: center;
    z-index: 2;
}

.aicon-startup.has-error .aicon-startup-mark,
.aicon-startup.has-error .aicon-startup-white {
    opacity: 0;
}

.aicon-startup.has-error .aicon-startup-error {
    display: flex;
}

.aicon-startup-error button {
    background: #ff6b00;
    border: 0;
    border-radius: 999px;
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    min-height: 44px;
    padding: 10px 22px;
}

html.aicon-startup-ready .login-panel {
    animation: aicon-login-card-in 420ms cubic-bezier(0.2, 0.76, 0.25, 1) both;
    will-change: opacity, transform;
}

html.aicon-startup-ready .login-panel .login-brand {
    animation: aicon-login-field-in 340ms ease-out 110ms both;
}

html.aicon-startup-ready .login-panel > label:nth-of-type(1) {
    animation: aicon-login-field-in 340ms ease-out 170ms both;
}

html.aicon-startup-ready .login-panel > label:nth-of-type(2) {
    animation: aicon-login-field-in 340ms ease-out 220ms both;
}

html.aicon-startup-ready .login-panel .login-button,
html.aicon-startup-ready .login-panel .login-close-button {
    animation: aicon-login-field-in 340ms ease-out 270ms both;
}

.login-button {
    align-items: center;
    display: inline-flex;
    gap: 8px;
    min-height: 44px;
}

.topbar-logout-form {
    display: contents;
}

.login-button-progress {
    animation: aicon-login-spinner 760ms linear infinite;
    border: 2px solid currentColor;
    border-left-color: transparent;
    border-radius: 50%;
    display: none;
    height: 15px;
    width: 15px;
}

.login-button.is-validating,
.login-panel.is-submitting .login-button {
    cursor: wait;
}

.login-panel.is-submitting .login-button-progress {
    display: inline-block;
}

.login-auth-error .form-error {
    animation: aicon-login-shake 180ms ease-out 450ms both;
}

.login-stage,
.login-shell {
    min-height: 100dvh;
}

@keyframes aicon-startup-mark-in {
    from {
        opacity: 0;
        transform: scale(0.78) translateY(8px);
    }

    72% {
        opacity: 1;
        transform: scale(1.04) translateY(0);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes aicon-startup-mark-out {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.94) translateY(-4px);
    }
}

@keyframes aicon-startup-diagonal-in {
    from {
        transform: translate(68%, 68%);
    }

    to {
        transform: translate(0, 0);
    }
}

@keyframes aicon-login-card-in {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes aicon-login-field-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes aicon-login-spinner {
    to {
        transform: rotate(360deg);
    }
}

@keyframes aicon-login-shake {
    0%, 100% {
        transform: translateX(0);
    }

    45% {
        transform: translateX(-3px);
    }

    75% {
        transform: translateX(2px);
    }
}

@media (max-width: 860px) {
    .login-stage {
        padding: 0;
    }

    .login-shell {
        padding: max(22px, env(safe-area-inset-top))
            max(16px, env(safe-area-inset-right))
            max(22px, env(safe-area-inset-bottom))
            max(16px, env(safe-area-inset-left));
    }

    .login-panel input {
        font-size: 16px;
        min-height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .aicon-startup-mark,
    html.aicon-startup-ready .login-panel,
    html.aicon-startup-ready .login-panel .login-brand,
    html.aicon-startup-ready .login-panel > label:nth-of-type(1),
    html.aicon-startup-ready .login-panel > label:nth-of-type(2),
    html.aicon-startup-ready .login-panel .login-button,
    html.aicon-startup-ready .login-panel .login-close-button,
    .login-auth-error .form-error {
        animation-duration: 120ms;
        animation-delay: 0ms;
        animation-name: aicon-startup-fade-only;
    }

    .aicon-startup.is-finishing .aicon-startup-white,
    .aicon-startup.is-finishing .aicon-startup-mark {
        animation: aicon-startup-fade-out 120ms ease-out both;
    }

    .login-button-progress {
        animation: none;
    }
}

@keyframes aicon-startup-fade-only {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes aicon-startup-fade-out {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* =========================================================
   Chats: layout, lista, cabecera, mensajes
   ========================================================= */
.workspace {
    height: 100%;
    min-height: 0;
    min-width: 0;
}

.chat-workspace {
    display: grid;
    grid-template-columns: 390px minmax(0, 1fr);
    height: 100%;
    min-width: 0;
}

.conversation-panel {
    background: var(--main-2);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    font-size: 12.5px;
    min-height: 0;
    padding: 10px;
    position: relative;
}

.search-toolbar {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 6px;
    padding: 8px 6px;
}

    .search-toolbar input,
    .composer input {
        background: #3b465b;
        border: 0;
        border-radius: 24px;
        color: var(--text);
        flex: 1 1 auto;
        min-width: 0;
        outline: 0;
        padding: 9px 14px;
    }

.filter-row {
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 6px;
    padding: 8px 8px 9px;
}

.filter-panel-header {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.filter-panel-header strong {
    font-size: 0.82rem;
}

.filter-panel-actions {
    display: flex;
    gap: 6px;
}

.default-chat-view-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.default-chat-view-actions .secondary-button {
    flex: 1 1 150px;
    justify-content: center;
    min-width: 0;
}

.default-chat-view-actions .default-chat-view-remove:not(:disabled) {
    color: #d9485f;
}

.default-chat-view-hint {
    align-items: flex-start;
    color: var(--muted);
    display: flex;
    font-size: 11px;
    gap: 6px;
    line-height: 1.35;
}

.default-chat-view-hint .material-symbols-rounded {
    color: var(--accent);
    flex: 0 0 auto;
    font-size: 16px;
}

.status-filter-combo {
    position: relative;
}

.status-filter-trigger,
.status-filter-option {
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    display: flex;
    font-size: 11.5px;
    font-weight: 800;
    gap: 8px;
    min-height: 30px;
    min-width: 0;
    padding: 5px 8px;
    text-align: left;
    width: 100%;
}

.status-filter-trigger {
    justify-content: space-between;
}

    .status-filter-trigger > span:first-child,
    .status-filter-option > span:first-child {
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .status-filter-trigger .material-symbols-rounded {
        flex: 0 0 auto;
        font-size: 18px;
    }

.status-filter-menu {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.35);
    display: grid;
    gap: 4px;
    left: 0;
    padding: 5px;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 12;
}

.status-filter-option {
    border-color: transparent;
    border-radius: 6px;
}

    .status-filter-option:hover,
    .status-filter-option.selected {
        background: #46556e;
        border-color: color-mix(in srgb, var(--accent) 40%, transparent);
    }

.filter-select-grid {
    display: grid;
    gap: 6px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.filter-chip,
.tag-chip,
.status-pill {
    align-items: center;
    background: #3b465c;
    border: 0;
    border-radius: 999px;
    color: var(--text);
    display: inline-flex;
    font-size: 11.5px;
    font-weight: 700;
    gap: 6px;
    justify-content: space-between;
    min-height: 26px;
    min-width: 0;
    padding: 0 9px;
    white-space: nowrap;
}

    .filter-chip.active {
        background: #5977a4;
    }

    .filter-count,
    .filter-chip span,
    .unread-badge {
        align-items: center;
        background: #65d765;
        border-radius: 999px;
        color: #102716;
        display: inline-flex;
        font-size: 10.5px;
        font-weight: 800;
        height: 18px;
        justify-content: center;
        min-width: 18px;
        padding: 0 5px;
    }

.filter-count {
    flex: 0 0 auto;
}

.conversation-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.conversation-item-container {
    position: relative;
}

.conversation-context-trigger {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--text);
    display: inline-flex;
    height: 24px;
    justify-content: center;
    padding: 0;
    position: absolute;
    right: 6px;
    top: 5px;
    width: 24px;
    z-index: 4;
}

    .conversation-context-trigger:hover,
    .conversation-context-trigger[aria-expanded="true"] {
        background: rgba(255, 255, 255, 0.12);
    }

    .conversation-context-trigger .material-symbols-rounded {
        font-size: 18px;
    }

.conversation-context-menu {
    background: #273143;
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
    display: grid;
    gap: 2px;
    min-width: 234px;
    padding: 14px 12px;
    position: absolute;
    right: 0;
    top: 31px;
    z-index: 24;
}

.header-context-menu-shell {
    display: inline-flex;
    position: relative;
}

.header-context-menu {
    max-height: min(520px, calc(100dvh - 150px));
    min-width: 270px;
    overflow-y: auto;
    right: 0;
    scrollbar-gutter: stable;
    top: 42px;
}

.header-menu-section-label {
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 800;
    padding: 7px 8px 3px;
}

.header-menu-section-label:first-child {
    padding-top: 2px;
}

.header-menu-divider {
    border-top: 1px solid var(--line);
    margin: 6px 8px;
}

.conversation-context-menu button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

    .conversation-context-menu button:disabled:hover {
        background: transparent;
    }

.conversation-context-menu button {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: #f4f7fb;
    display: grid;
    font-size: 14px;
    font-weight: 700;
    gap: 12px;
    grid-template-columns: 24px minmax(0, 1fr);
    min-height: 36px;
    padding: 5px 8px;
    text-align: left;
    width: 100%;
}

    .conversation-context-menu button:hover {
        background: rgba(255, 255, 255, 0.09);
    }

    .conversation-context-menu button.danger,
    .conversation-context-menu button.danger .material-symbols-rounded {
        color: #ff4d4f;
    }

.conversation-context-menu .material-symbols-rounded {
    color: #f4f7fb;
    font-size: 22px;
}

.conversation-item {
    align-items: center;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    display: grid;
    gap: 9px;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    min-height: 58px;
    padding: 6px 34px 6px 8px;
    text-align: left;
    width: 100%;
}

    .conversation-item:hover,
    .conversation-item.selected {
        background: #46556e;
    }

.theme-light .conversation-item:hover,
.theme-light .conversation-item.selected {
    background: #536a87;
    color: #ffffff;
}

    .theme-light .conversation-item:hover .conversation-preview,
    .theme-light .conversation-item.selected .conversation-preview,
    .theme-light .conversation-item:hover .conversation-meta,
    .theme-light .conversation-item.selected .conversation-meta,
    .theme-light .conversation-item:hover .conversation-icons,
    .theme-light .conversation-item.selected .conversation-icons {
        color: #f8fafc;
    }

    .theme-light .conversation-item:hover .branch-chip,
    .theme-light .conversation-item.selected .branch-chip,
    .theme-light .conversation-item:hover .agent-chip,
    .theme-light .conversation-item.selected .agent-chip {
        background: rgba(255, 255, 255, 0.16);
        border-color: rgba(255, 255, 255, 0.42);
        color: #f8fafc;
    }

        .theme-light .conversation-item:hover .agent-chip .material-symbols-rounded,
        .theme-light .conversation-item.selected .agent-chip .material-symbols-rounded {
            color: #f8fafc;
        }

.conversation-main,
.conversation-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.conversation-badges {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.conversation-title {
    font-size: 13px;
    font-weight: 800;
}

.conversation-preview {
    color: var(--text);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-meta {
    align-items: flex-end;
    color: #cfe2ff;
    font-size: 12px;
    font-weight: 700;
}

.theme-light .conversation-meta {
    color: #2b5b91;
}

.conversation-icons {
    align-items: center;
    color: var(--text);
    display: flex;
    gap: 5px;
}

    .conversation-icons .material-symbols-rounded {
        font-size: 17px;
    }

.whatsapp-icon,
.whatsapp-large {
    color: var(--green);
}


.chat-panel {
    display: grid;
    grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
    min-height: 0;
}

.chat-header {
    align-items: center;
    background: #3c465b;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 10px;
    min-height: 74px;
    padding: 9px 22px;
}

    .chat-header h1 {
        align-items: center;
        display: flex;
        font-size: 15.5px;
        gap: 4px;
        margin: 0 0 3px;
    }

    .chat-header p {
        color: var(--muted);
        font-size: 12.5px;
        margin: 1px 0;
    }

.sync-status {
    color: var(--muted);
    font-size: 0.76rem;
    margin-top: 2px;
}

    .sync-status .material-symbols-rounded {
        font-size: 16px;
        vertical-align: -3px;
    }

.wa-line {
    align-items: center;
    display: flex;
    gap: 6px;
}

.title-link {
    font-size: 16px;
}

.chat-header-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.primary-pill,
.secondary-button {
    align-items: center;
    background: #9bd0ff;
    border: 0;
    border-radius: 999px;
    color: #10233b;
    display: inline-flex;
    font-weight: 800;
    gap: 7px;
    min-height: 36px;
    padding: 0 16px;
}

.primary-pill.icon-only {
    align-items: center;
    border-radius: 999px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.16);
    justify-content: center;
    min-width: 38px;
    padding: 0 9px;
}

.refresh-pill {
    justify-content: center;
    min-width: 38px;
    padding: 0 9px;
}

.chat-header-actions .primary-pill:hover {
    background: #aad8ff;
}

.chat-header-actions .primary-pill:active {
    background: #8bc8f8;
}

.secondary-button {
    background: #59667d;
    color: var(--text);
}

.tag-strip {
    align-items: center;
    background: #2a3344;
    color: var(--muted);
    display: flex;
    gap: 7px;
    min-height: 36px;
    padding: 0 20px;
}

.theme-light .tag-strip {
    background: #d5deea;
}

.routing-strip {
    align-items: end;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 12px;
    grid-template-columns: 170px 150px auto;
    justify-content: start;
    min-height: 66px;
    padding: 10px 22px 12px;
}

.routing-field {
    display: grid;
    gap: 5px;
    min-width: 0;
}

    /* Estado */
    .routing-field:nth-child(1) {
        max-width: 170px;
    }

    /* Prioridad */
    .routing-field:nth-child(2) {
        max-width: 150px;
    }

    .routing-field > span {
        color: var(--muted);
        font-size: 11px;
        font-weight: 800;
        line-height: 1;
    }

    .routing-field .routing-select,
    .routing-field .priority-select {
        width: 100%;
    }

/* Anchos específicos de la barra de ruteo */
.routing-strip .routing-field:nth-child(1) .routing-select {
    width: 170px;
}

.routing-strip .routing-field:nth-child(2) .priority-select {
    width: 150px;
}

.routing-transfer-button {
    align-self: end;
    justify-content: center;
    min-height: 38px;
    min-width: 190px;
    white-space: nowrap;
}

    .routing-transfer-button .material-symbols-rounded {
        font-size: 18px;
    }

.contact-insight-strip {
    align-items: stretch;
    background: var(--main-2);
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(170px, 1.1fr) minmax(170px, 1fr) minmax(150px, .7fr) auto;
    min-height: 58px;
    padding: 8px 22px;
}

.contact-insight-card {
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 9px;
    grid-template-columns: auto minmax(0, 1fr);
    min-width: 0;
    padding: 8px 10px;
}

    .contact-insight-card > .material-symbols-rounded {
        color: var(--accent);
        font-size: 20px;
    }

    .contact-insight-card small,
    .contact-insight-card span {
        color: var(--muted);
        display: block;
        font-size: 11px;
        font-weight: 800;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .contact-insight-card strong {
        color: var(--text);
        display: block;
        font-size: 12.5px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .contact-insight-card.sla.ok > .material-symbols-rounded,
    .contact-insight-card.sla.ok strong {
        color: #22c55e;
    }

    .contact-insight-card.sla.warning > .material-symbols-rounded,
    .contact-insight-card.sla.warning strong {
        color: #f59e0b;
    }

    .contact-insight-card.sla.overdue > .material-symbols-rounded,
    .contact-insight-card.sla.overdue strong {
        color: #ef4444;
    }

.contact-insight-status {
    align-items: center;
    color: var(--muted);
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    min-width: 0;
}

.conversation-trace-panel {
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 7px;
    padding: 8px 22px 9px;
}

.conversation-trace-header {
    align-items: center;
    color: var(--muted);
    display: flex;
    gap: 7px;
    min-width: 0;
}

    .conversation-trace-header .material-symbols-rounded {
        color: var(--accent);
        font-size: 18px;
    }

    .conversation-trace-header strong {
        color: var(--text);
        font-size: 12px;
    }

    .conversation-trace-header span:last-child {
        font-size: 11px;
        font-weight: 800;
    }

.conversation-trace-list {
    display: flex;
    gap: 8px;
    min-width: 0;
    overflow-x: auto;
    padding-bottom: 2px;
}

.conversation-trace-item {
    align-items: center;
    background: var(--main-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    flex: 0 0 258px;
    gap: 8px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    min-height: 52px;
    min-width: 0;
    padding: 7px 9px;
}

    .conversation-trace-item > .material-symbols-rounded {
        color: var(--accent);
        font-size: 20px;
    }

    .conversation-trace-item div {
        display: grid;
        gap: 1px;
        min-width: 0;
    }

    .conversation-trace-item strong,
    .conversation-trace-item span,
    .conversation-trace-item small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .conversation-trace-item strong {
        color: var(--text);
        font-size: 12px;
    }

    .conversation-trace-item span,
    .conversation-trace-item small,
    .conversation-trace-item time {
        color: var(--muted);
        font-size: 10.5px;
        font-weight: 800;
    }

    .conversation-trace-item time {
        white-space: nowrap;
    }

    .conversation-trace-item.transfer > .material-symbols-rounded {
        color: #f97316;
    }

    .conversation-trace-item.assignment > .material-symbols-rounded,
    .conversation-trace-item.status > .material-symbols-rounded,
    .conversation-trace-item.message > .material-symbols-rounded {
        color: #0ea5e9;
    }

    .conversation-trace-item.ok > .material-symbols-rounded {
        color: #22c55e;
    }

    .conversation-trace-item.warning > .material-symbols-rounded {
        color: #f59e0b;
    }

    .conversation-trace-item.overdue > .material-symbols-rounded,
    .conversation-trace-item.danger > .material-symbols-rounded {
        color: #ef4444;
    }

    .conversation-trace-item.note > .material-symbols-rounded {
        color: #8b5cf6;
    }

.sla-chip {
    align-items: center;
    background: rgba(245, 158, 11, .16);
    border: 1px solid rgba(245, 158, 11, .35);
    border-radius: 999px;
    color: #fbbf24;
    display: inline-flex;
    font-size: 10.5px;
    font-weight: 900;
    min-height: 20px;
    padding: 0 7px;
}

    .sla-chip.overdue {
        background: rgba(239, 68, 68, .16);
        border-color: rgba(239, 68, 68, .4);
        color: #f87171;
    }

.message-search-toolbar {
    align-items: center;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 8px;
    grid-template-columns: auto minmax(0, 1fr) auto auto auto auto auto;
    min-height: 44px;
    padding: 6px 22px;
}

.message-tools-slot {
    min-height: 0;
}

.message-tools-close {
    border: 1px solid var(--line);
    flex: 0 0 30px;
}

    .message-search-toolbar .material-symbols-rounded {
        color: var(--muted);
        font-size: 19px;
    }

    .message-search-toolbar input {
        background: var(--main-2);
        border: 1px solid var(--line);
        border-radius: 999px;
        color: var(--text);
        min-height: 30px;
        min-width: 0;
        outline: 0;
        padding: 5px 12px;
    }

.message-search-count {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.history-search-toolbar {
    border: 1px solid var(--line);
    border-radius: 8px;
    flex: 0 0 auto;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    min-height: 38px;
    padding: 5px 8px;
}

.export-csv-button {
    align-items: center;
    display: inline-flex;
    gap: 5px;
    min-height: 30px;
    white-space: nowrap;
}

    .export-csv-button .material-symbols-rounded {
        font-size: 18px;
    }

.export-status {
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 800;
    white-space: nowrap;
}

.history-export-toolbar {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 7px 8px;
}

    .history-export-toolbar label {
        align-items: center;
        color: var(--muted);
        display: inline-flex;
        font-size: 12px;
        font-weight: 800;
        gap: 6px;
    }

    .history-export-toolbar input {
        background: var(--main-2);
        border: 1px solid var(--line);
        border-radius: 7px;
        color: var(--text);
        min-height: 30px;
        padding: 4px 8px;
    }

.message-search-empty {
    align-self: center;
    background: rgba(8, 47, 73, 0.4);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-weight: 800;
    margin: 18px 0;
    padding: 10px 16px;
}

.tag-chip {
    --tag-color: #53617a;
    background: color-mix(in srgb, var(--tag-color) 24%, #303a4f);
    border: 1px solid color-mix(in srgb, var(--tag-color) 48%, transparent);
    color: var(--text);
    font-size: 11px;
    min-height: 21px;
    padding: 0 8px;
}

    .tag-chip.compact {
        margin: 2px 4px 2px 0;
    }

.message-surface {
    background-color: #202838;
    background-image: radial-gradient(circle at 20px 20px, rgba(255, 255, 255, 0.05) 0 1px, transparent 2px), radial-gradient(circle at 70px 50px, rgba(255, 255, 255, 0.035) 0 1px, transparent 2px);
    background-size: 96px 96px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 22px 18px 12px;
    scrollbar-gutter: stable;
}

.theme-light .message-surface {
    background-color: #dce5ee;
    background-image: radial-gradient(circle at 18px 18px, rgba(47, 72, 103, 0.16) 0 1px, transparent 2px), radial-gradient(circle at 62px 46px, rgba(47, 72, 103, 0.11) 0 1px, transparent 2px);
    background-size: 88px 88px;
}

.day-separator {
    align-self: center;
    background: rgba(8, 47, 73, 0.4);
    border-radius: 8px;
    color: var(--muted);
    font-weight: 700;
    padding: 8px 42px;
}

.message-bubble {
    border-radius: 6px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.18);
    max-width: min(480px, 72%);
    min-width: 120px;
    padding: 8px 10px 5px;
    position: relative;
}

    .message-bubble.inbound {
        align-self: flex-start;
        background: var(--bubble-in);
    }

    .message-bubble.outbound {
        align-self: flex-end;
        background: var(--bubble-out);
    }

    .message-bubble.internal-note {
        background: #374151;
        border: 1px solid rgba(250, 204, 21, 0.38);
    }

    .message-bubble.select-mode {
        padding-left: 42px;
    }

    .message-bubble.selected {
        border: 1px solid rgba(156, 203, 255, 0.75);
        box-shadow: 0 0 0 2px rgba(156, 203, 255, 0.16);
    }

.message-bubble p {
    font-weight: 700;
    font-size: 12.5px;
    line-height: 1.3;
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.crm-state-badge { border-radius:999px; padding:.2rem .55rem; font-weight:700; font-size:.75rem; }
.crm-state-badge.open { background:#fff3cd; color:#7a4b00; }
.crm-state-badge.final { background:#dff5e5; color:#146c2e; }
.crm-detail-panel { width:min(780px,calc(100vw - 2rem)); max-height:90dvh; overflow:auto; }
.crm-detail-content { min-width:0; }
.crm-detail-title { overflow-wrap:anywhere; }
.crm-case-overview { background:#f7f9fc; border:1px solid var(--line); border-radius:10px; display:grid; gap:.55rem .8rem; grid-template-columns:repeat(2,minmax(0,1fr)); padding:.7rem; }
.crm-case-overview > div { display:grid; gap:.12rem; min-width:0; }
.crm-case-overview span { color:var(--muted); font-size:.7rem; font-weight:700; letter-spacing:.02em; text-transform:uppercase; }
.crm-case-overview strong { font-size:.84rem; overflow-wrap:anywhere; }
.crm-intervention-detail { border:1px solid #dce4ee; border-radius:10px; padding:.75rem; display:grid; gap:.65rem; min-width:0; }
.crm-intervention-detail > strong { overflow-wrap:anywhere; }
.crm-intervention-meta { display:grid; gap:.55rem .8rem; grid-template-columns:repeat(2,minmax(0,1fr)); }
.crm-intervention-meta > div { display:grid; gap:.12rem; min-width:0; }
.crm-intervention-meta span { color:var(--muted); font-size:.7rem; font-weight:700; letter-spacing:.02em; text-transform:uppercase; }
.crm-intervention-meta strong { font-size:.82rem; line-height:1.35; overflow-wrap:anywhere; }
.crm-intervention-meta-wide { grid-column:1 / -1; }
.crm-intervention-detail p { border-top:1px solid var(--line); white-space:pre-wrap; overflow-wrap:anywhere; margin:.1rem 0 0; padding-top:.6rem; }
.crm-detail-attachments { border:1px solid var(--line); border-radius:10px; display:grid; gap:.55rem; min-width:0; padding:.7rem; }
.crm-detail-attachments legend { font-weight:700; padding:0 .3rem; }
.crm-detail-attachment-list { display:flex; flex-wrap:wrap; gap:.45rem; min-width:0; }
.crm-detail-attachment-list button { max-width:100%; overflow-wrap:anywhere; }
.crm-detail-empty { color:var(--muted); }
.crm-config-card { max-width:980px; display:grid; gap:1rem; }

.crm-request-panel {
    margin: 0 14px 8px;
    padding: 8px 12px;
    border: 1px solid #cbd9e5;
    border-radius: 8px;
    background: #f5f9fc;
    font-size: 12px;
}
.crm-request-panel summary { cursor: pointer; font-weight: 600; }
.crm-request-item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid #dce5ed; }
.crm-request-item small { flex-basis: 100%; color: #536477; }
.crm-case-interventions { display: grid; flex-basis: 100%; gap: 4px; }
.crm-case-interventions small { display: block; }
.crm-unlinked-heading { margin-top: 8px; padding-top: 8px; border-top: 1px solid #dce5ed; font-weight: 600; }
.crm-customer-validation { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.crm-select-button {
    border-color: #0f766e;
    color: #0f766e;
}

.crm-usage-badge {
    align-items: center;
    background: #ccfbf1;
    border: 1px solid #5eead4;
    border-radius: 999px;
    color: #115e59;
    display: inline-flex;
    font-size: .7rem;
    font-weight: 700;
    gap: .15rem;
    margin-bottom: .25rem;
    padding: .1rem .4rem;
}

.crm-usage-badge .material-symbols-rounded {
    font-size: .9rem;
}

.modal-panel.crm-case-modal {
    box-sizing: border-box;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    max-height: min(92dvh, 900px);
    max-width: 940px;
    overflow: hidden;
    width: min(94vw, 940px);
}

.crm-case-modal > header {
    position: relative;
    top: auto;
    z-index: 2;
}

.crm-case-modal > .crm-case-form {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    overscroll-behavior: contain;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-gutter: stable;
}

.crm-wizard-status {
    display: grid;
    gap: .6rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.crm-wizard-status-item {
    align-items: center;
    background: #fff8e8;
    border: 1px solid #f4d58b;
    border-radius: .65rem;
    color: #7a4b00;
    display: flex;
    gap: .55rem;
    min-width: 0;
    padding: .6rem .7rem;
}

.crm-wizard-status-item.complete {
    background: #edf9f0;
    border-color: #b8e2c2;
    color: #146c2e;
}

.crm-wizard-status-item > span:last-child {
    display: grid;
    min-width: 0;
}

.crm-wizard-status-item strong,
.crm-wizard-status-item small {
    overflow-wrap: anywhere;
}

.crm-wizard-status-item .material-symbols-rounded {
    flex: 0 0 auto;
    font-size: 1.15rem;
}

.crm-case-form fieldset {
    border: 1px solid var(--border-color, #d7dee8);
    border-radius: .65rem;
    padding: .8rem;
}

.crm-case-form legend {
    font-weight: 700;
    padding: 0 .35rem;
}

.crm-section-intro {
    color: var(--muted);
    display: block;
    line-height: 1.35;
    margin: -.15rem 0 .7rem;
}

.crm-validation-status {
    color: var(--muted);
    line-height: 1.35;
}

.crm-summary-action {
    align-items: flex-start;
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
    margin-top: .65rem;
}

.crm-summary-action small {
    flex: 1 1 320px;
}

.crm-form-grid {
    display: grid;
    gap: .75rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.crm-form-full {
    grid-column: 1 / -1;
}

.crm-attachments {
    display: grid;
    gap: .45rem;
}

.crm-attachments .inline-check {
    align-items: center;
    display: flex;
    gap: .55rem;
}

.crm-attachments small {
    color: var(--muted-color, #64748b);
    display: block;
}

.crm-case-modal > footer {
    align-items: center;
    bottom: auto;
    display: flex;
    justify-content: space-between;
    position: relative;
    z-index: 2;
}

.crm-case-modal footer > div {
    display: flex;
    gap: .5rem;
}

.crm-footer-note {
    color: var(--muted-color, #64748b);
    font-size: .78rem;
}

@media (max-width: 700px) {
    .crm-form-grid { grid-template-columns: 1fr; }
    .crm-wizard-status { grid-template-columns: 1fr; }
    .modal-panel.crm-case-modal { height:calc(100dvh - 16px); max-height:calc(100dvh - 16px); width:calc(100vw - 16px); }
    .crm-case-modal .crm-case-form { padding-left:.8rem; padding-right:.8rem; }
    .crm-case-modal header,
    .crm-case-modal footer { padding-left:.8rem; padding-right:.8rem; }
    .crm-case-modal footer { align-items: stretch; flex-direction: column; gap: .65rem; }
    .crm-case-modal footer > div { justify-content: stretch; width:100%; }
    .crm-case-modal footer > div > button { flex:1 1 0; justify-content:center; }
    .crm-case-form fieldset { padding:.7rem; }
    .crm-customer-validation > button { width:100%; }
    .crm-summary-action .secondary-button { width:100%; }
    .crm-detail-panel { height:calc(100dvh - 16px); max-height:calc(100dvh - 16px); width:calc(100vw - 16px); }
    .crm-detail-panel .modal-form { padding-left:.8rem; padding-right:.8rem; }
    .crm-detail-panel header,
    .crm-detail-panel footer { padding-left:.8rem; padding-right:.8rem; }
    .crm-intervention-meta { grid-template-columns:1fr; }
    .crm-case-overview { grid-template-columns:1fr; }
    .crm-intervention-meta-wide { grid-column:auto; }
    .crm-detail-attachment-list { display:grid; grid-template-columns:minmax(0,1fr); }
    .crm-detail-attachment-list button { justify-content:flex-start; width:100%; }
}

@media (max-width: 420px) {
    .crm-case-modal .crm-case-form { padding-left:.5rem; padding-right:.5rem; }
    .crm-case-modal header,
    .crm-case-modal footer { padding-left:.65rem; padding-right:.65rem; }
    .crm-case-form fieldset { border-left:0; border-right:0; border-radius:0; padding-left:.25rem; padding-right:.25rem; }
    .crm-case-modal footer > div { flex-direction:column-reverse; }
    .crm-case-modal footer > div > button { width:100%; }
    .crm-intervention-detail { padding:.65rem; }
    .crm-detail-panel footer .secondary-button,
    .crm-detail-panel footer .primary-pill { flex:1 1 0; justify-content:center; }
}

.message-bubble p.message-text {
    white-space: pre-wrap;
}

.reply-snippet span {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.message-bubble time {
    align-items: center;
    color: #c8d1df;
        display: flex;
        font-size: 10.5px;
        gap: 3px;
        justify-content: flex-end;
        margin-top: 5px;
    }


.message-context-menu {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, .32);
    display: grid;
    gap: 4px;
    min-width: 170px;
    padding: 6px;
    position: absolute;
    top: 34px;
    z-index: 80;
}

    .message-context-menu.inbound-menu {
        left: calc(100% + 8px);
        right: auto;
        top: 0;
    }

    .message-context-menu.outbound-menu {
        left: auto;
        right: calc(100% + 8px);
        top: 0;
    }

    .message-context-menu button {
        align-items: center;
        background: transparent;
        border: 0;
        border-radius: 8px;
        color: var(--text);
        cursor: pointer;
        display: flex;
        gap: 10px;
        padding: 9px 10px;
        text-align: left;
        width: 100%;
    }

        .message-context-menu button:hover {
            background: var(--hover);
        }

    .message-context-menu .material-symbols-rounded {
        font-size: 19px;
    }

.theme-light .message-bubble {
    border: 1px solid rgba(78, 98, 124, 0.2);
    box-shadow: 0 2px 5px rgba(44, 62, 82, 0.14);
}

    .theme-light .message-bubble.inbound {
        background: #eef3f8;
    }

    .theme-light .message-bubble.outbound {
        background: #bfe9dd;
    }

    .theme-light .message-bubble.internal-note {
        background: #f4ead0;
        border-color: rgba(161, 98, 7, 0.34);
    }

    .theme-light .message-bubble time {
        color: #5b6b7f;
        font-weight: 800;
    }

        .theme-light .message-bubble time .material-symbols-rounded {
            color: #8ba0b8;
        }

.reply-snippet {
    background: rgba(0, 0, 0, 0.18);
    border-left: 4px solid #8ee6ff;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 6px;
    padding: 7px;
}

.attachment-pill {
    align-items: center;
    background: rgba(255, 255, 255, 0.14);
    border-radius: 6px;
    display: flex;
    gap: 5px;
    margin-top: 7px;
    padding: 7px;
}

.composer {
    align-items: center;
    background: #4a556b;
    display: flex;
    gap: 7px;
    min-height: 56px;
    padding: 8px 14px;
}

.composer-input-host {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
}

.composer-input-host input,
.composer-input-host textarea {
    width: 100%;
}

/*
   El campo de mensaje crece solo con lo escrito (o pegado) hasta ~6 renglones y
   despues scrollea adentro; el boton de ampliar lo lleva a media pantalla para
   escribir o leer largo comodo (20/08/2026). field-sizing es CSS puro: cero JS
   de medicion. En un navegador viejo queda de un renglon con scroll interno,
   que es lo mismo que habia.
*/
.composer-input-host textarea {
    field-sizing: content;
    line-height: 1.45;
    max-height: 168px;
    overflow-y: auto;
    resize: none;
}

.composer-input-host.composer-host-expanded textarea {
    max-height: 48dvh;
    min-height: 32dvh;
}

.clipboard-attachment-backdrop {
    align-items: center;
    background: rgba(2, 18, 39, 0.58);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 20px;
    position: fixed;
    z-index: 1400;
}

.clipboard-attachment-preview {
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(2, 18, 39, 0.28);
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: min(82dvh, 720px);
    max-width: 560px;
    padding: 18px;
    width: min(92vw, 560px);
}

.clipboard-attachment-preview > header,
.clipboard-attachment-preview > footer {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.clipboard-attachment-preview > footer {
    justify-content: flex-end;
}

.clipboard-attachment-preview img {
    background: #f4f6f9;
    border-radius: 10px;
    max-height: 48dvh;
    max-width: 100%;
    object-fit: contain;
}

.clipboard-attachment-preview > small {
    color: #667085;
}

.clipboard-attachment-file {
    align-items: center;
    background: #f4f6f9;
    border-radius: 10px;
    display: flex;
    gap: 10px;
    min-height: 96px;
    overflow-wrap: anywhere;
    padding: 16px;
}

.clipboard-attachment-file .material-symbols-rounded {
    color: #073b78;
    font-size: 38px;
}

.clipboard-attachment-caption {
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    font: inherit;
    min-height: 68px;
    padding: 10px 12px;
    resize: vertical;
    width: 100%;
}

.clipboard-attachment-preview .primary-action,
.clipboard-attachment-preview .secondary-action {
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 700;
    padding: 9px 18px;
}

.clipboard-attachment-preview .primary-action {
    background: #ff6500;
    color: #ffffff;
}

.clipboard-attachment-preview .secondary-action {
    background: #edf2f7;
    color: #17365d;
}

.clipboard-attachment-preview button:disabled {
    cursor: wait;
    opacity: 0.65;
}

/* =========================================================
   Páginas administrativas / módulos
   ========================================================= */
.module-page {
    height: 100%;
    overflow-y: auto;
    padding: 22px min(5vw, 72px);
}

.page-heading {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
}

    .page-heading h1 {
        color: var(--accent);
        font-size: 22px;
        font-weight: 600;
        margin: 0;
    }

.eyebrow {
    color: var(--muted-2);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    margin: 0 0 6px;
    text-transform: uppercase;
}

.connection-grid,
.tag-grid,
.campaign-grid,
.metrics-grid,
.subscription-grid,
.support-grid,
.ai-board,
.account-page,
.docs-layout {
    display: grid;
    gap: 18px;
}

.connection-grid {
    grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
}

.connection-card,
.mini-card,
.campaign-card,
.metric-card,
.plan-card,
.support-card,
.ai-panel,
.prompt-panel,
.profile-card,
.theme-card,
.chart-card,
.docs-layout article {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.22);
    min-width: 0;
    padding: 18px;
    position: relative;
}

.connection-card {
    display: flex;
    flex-direction: column;
    min-height: 150px;
}

.connection-card .card-menu {
    background: color-mix(in srgb, var(--panel) 88%, #000 12%);
    border: 1px solid var(--line);
}

.card-menu {
    position: absolute;
    right: 14px;
    top: 14px;
}

.connection-title {
    align-items: flex-start;
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
    min-width: 0;
    padding-right: 36px;
}

    .connection-title h2,
    .mini-card h2,
    .campaign-card h2,
    .support-card h2,
    .plan-card h2,
    .ai-panel h2,
    .profile-card h2,
    .theme-card h2,
    .chart-card h2,
    .docs-layout h2,
    .setting-row h2 {
        font-size: 16px;
        margin: 0 0 4px;
    }

    .connection-title p,
    .campaign-card p,
    .support-card p,
    .plan-card p,
    .ai-panel p,
    .profile-card p,
    .setting-row p,
    .docs-layout p {
        color: var(--muted);
        margin: 0;
    }

    .connection-title div {
        min-width: 0;
    }

    .connection-title h2 {
        font-size: 14.5px;
        line-height: 1.2;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .connection-title p {
        font-size: 12px;
        line-height: 1.2;
    }

.whatsapp-large {
    font-size: 29px;
}

.status-pill {
    border: 1px solid rgba(76, 211, 116, 0.72);
    color: #67d87a;
    font-size: 12px;
    align-self: flex-start;
    margin-bottom: 14px;
    min-height: 27px;
}

    .status-pill.pending {
        border-color: #facc15;
        color: #facc15;
    }

    .status-pill.disconnected {
        border-color: #f87171;
        color: #f87171;
    }

    .status-pill.soft {
        border-color: var(--line);
        color: var(--text);
        margin: 0;
    }

.connection-meta-grid {
    display: grid;
    gap: 8px;
    margin: 0 0 14px;
}

    .connection-meta-grid div {
        min-width: 0;
    }

    .connection-meta-grid dt {
        color: var(--muted);
        font-size: 11px;
        font-weight: 800;
        margin: 0 0 3px;
        text-transform: uppercase;
    }

    .connection-meta-grid dd {
        color: var(--text);
        font-family: Consolas, "Courier New", monospace;
        font-size: 12px;
        margin: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

.managed-note {
    align-items: center;
    border-top: 1px solid var(--line);
    color: var(--muted);
    display: flex;
    font-size: 12px;
    font-weight: 800;
    gap: 8px;
    margin-top: auto;
    padding-top: 12px;
}

    .managed-note .material-symbols-rounded {
        color: var(--accent);
        font-size: 18px;
    }

.connection-usage {
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 2px;
    padding-top: 12px;
}

.connection-usage-header {
    align-items: baseline;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.connection-usage-header span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.connection-usage-header strong {
    font-size: 14px;
    font-weight: 800;
    white-space: nowrap;
}

.connection-usage-meter {
    background: color-mix(in srgb, var(--panel) 72%, #000 28%);
    border: 1px solid var(--line);
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
}

.connection-usage-meter span {
    border-radius: inherit;
    display: block;
    height: 100%;
    transition: width 0.2s ease;
}

.connection-usage small {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.3;
}

.wide-card-action {
    align-items: center;
    background: #747c8e;
    border: 0;
    border-radius: 6px;
    color: #fff;
    display: flex;
    font-size: 12.5px;
    font-weight: 800;
    justify-content: space-between;
    margin-top: auto;
    min-height: 34px;
    padding: 0 16px;
    position: static;
    width: 100%;
}

.table-card {
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: auto;
}

.section-block {
    display: grid;
    gap: 14px;
    margin-top: 24px;
}

.section-header {
    align-items: flex-end;
    display: flex;
    justify-content: space-between;
}

    .section-header h2 {
        font-size: 17px;
        margin: 0 0 4px;
    }

    .section-header p {
        color: var(--muted);
        margin: 0;
    }

.request-status {
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    margin: 0;
    padding: 5px 9px;
    white-space: nowrap;
}

    .request-status.received {
        border-color: #93c5fd;
        color: #93c5fd;
    }

    .request-status.progress {
        border-color: #facc15;
        color: #facc15;
    }

    .request-status.approved {
        border-color: #67d87a;
        color: #67d87a;
    }

    .request-status.rejected {
        border-color: #f87171;
        color: #f87171;
    }

    .request-status.observed {
        border-color: #a78bfa;
        color: #a78bfa;
    }

    .request-status.cancelled {
        border-color: #fb923c;
        color: #fb923c;
    }

    .request-status.closed {
        border-color: #94a3b8;
        color: #94a3b8;
    }

table {
    border-collapse: collapse;
    min-width: 720px;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 11px 14px;
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--text);
    font-weight: 800;
}

td {
    color: var(--text);
}

    td span {
        color: var(--muted);
        display: block;
        margin-top: 3px;
    }

.row-actions {
    align-items: center;
    display: flex;
    gap: 11px;
    justify-content: flex-end;
}

    .row-actions .material-symbols-rounded {
        color: var(--text);
    }

td.row-actions {
    display: table-cell;
    text-align: right;
    white-space: nowrap;
}

    td.row-actions .material-symbols-rounded {
        color: var(--text);
        display: inline-flex;
        font-size: 18px;
        margin-left: 12px;
        margin-top: 0;
        vertical-align: middle;
    }

.row-icon-button {
    align-items: center;
    background: transparent;
    border: 0;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    height: 30px;
    justify-content: center;
    margin-left: 8px;
    padding: 0;
    width: 30px;
}

    .row-icon-button .material-symbols-rounded {
        margin-left: 0;
    }

    .row-icon-button:hover {
        color: var(--accent);
    }

    .row-icon-button.danger:hover {
        color: #f87171;
    }

    .row-icon-button:disabled {
        cursor: not-allowed;
        opacity: 0.42;
    }

td .tag-chip {
    display: inline-flex;
}

.tag-color-preview {
    --tag-color: #53617a;
    background: var(--tag-color);
    border-radius: 999px;
    display: inline-flex;
    height: 14px;
    margin-right: 8px;
    vertical-align: middle;
    width: 56px;
}

.tag-color-code {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 800;
    vertical-align: middle;
}

code {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--accent);
    display: inline-flex;
    margin: 3px 6px 3px 0;
    padding: 5px 7px;
}

.tag-grid {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.color-dot,
.dept-color {
    border-radius: 4px;
    display: inline-flex;
    height: 16px;
    width: 36px;
}

.branch-chip,
.unit-type {
    align-self: flex-start;
    background: rgba(147, 197, 253, 0.13);
    border: 1px solid rgba(147, 197, 253, 0.35);
    border-radius: 6px;
    color: var(--accent);
    display: inline-flex;
    font-size: 0.74rem;
    font-weight: 800;
    line-height: 1;
    padding: 5px 7px;
}

.agent-icon {
    font-size: 13px;
}

.agent-chip {
    align-items: center;
    background: rgba(156, 203, 255, .15);
    border: 1px solid rgba(156, 203, 255, .45);
    border-radius: 6px;
    color: var(--accent);
    display: inline-flex;
    gap: 4px;
    font-size: .74rem;
    font-weight: 800;
    line-height: 1;
    min-height: 22px;
    padding: 4px 7px;
}

.priority-chip {
    --priority-color: #60a5fa;
    align-items: center;
    background: color-mix(in srgb, var(--priority-color) 18%, transparent);
    border: 1px solid color-mix(in srgb, var(--priority-color) 70%, transparent);
    border-radius: 6px;
    color: var(--text);
    display: inline-flex;
    font-size: 0.74rem;
    font-weight: 800;
    line-height: 1;
    min-height: 25px;
    padding: 5px 8px;
}

.status-chip {
    --status-color: #38bdf8;
    align-items: center;
    background: color-mix(in srgb, var(--status-color) 18%, transparent);
    border: 1px solid color-mix(in srgb, var(--status-color) 70%, transparent);
    border-radius: 6px;
    color: var(--text);
    display: inline-flex;
    font-size: 0.74rem;
    font-weight: 800;
    line-height: 1;
    min-height: 25px;
    padding: 5px 8px;
}

.priority-chip.compact {
    min-height: 22px;
    padding: 4px 7px;
}

.status-chip.compact {
    min-height: 22px;
    padding: 4px 7px;
}

.priority-select,
.routing-select {
    --priority-color: #60a5fa;
    background: color-mix(in srgb, var(--priority-color) 18%, var(--panel));
    border: 1px solid color-mix(in srgb, var(--priority-color) 70%, var(--line));
    border-radius: 8px;
    color: var(--text);
    font-weight: 800;
    min-height: 28px;
    outline: 0;
    padding: 4px 8px;
}

.routing-select {
    background: var(--panel);
    border-color: var(--line);
    max-width: none;
}

    .routing-select[style*="--status-color"] {
        background: color-mix(in srgb, var(--status-color) 16%, var(--panel));
        border-color: color-mix(in srgb, var(--status-color) 62%, var(--line));
    }

    .routing-select.wide {
        max-width: none;
    }

.scope-select,
.unit-toolbar input,
.unit-toolbar select {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font-weight: 800;
    min-height: 34px;
    outline: 0;
    padding: 6px 9px;
}

.filter-select-grid .scope-select {
    font-size: 11.5px;
    min-height: 30px;
    min-width: 0;
    padding: 5px 8px;
    width: 100%;
}

.filter-select-grid .unit-filter,
.filter-select-grid .line-filter {
    grid-column: 1 / -1;
}

.unit-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    margin-bottom: 12px;
}

    .unit-toolbar label {
        align-items: center;
        color: var(--muted);
        display: flex;
        font-weight: 800;
        gap: 8px;
    }

.contact-toolbar {
    align-items: end;
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(280px, 1fr) auto auto;
}

.contact-toolbar-main,
.contact-toolbar-config {
    align-items: end;
    display: flex;
    gap: 10px;
}

.contact-search-field input {
    min-width: min(420px, 42vw);
}

.contact-company-search-field input {
    min-width: min(560px, 52vw);
}

.contact-import-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.contact-grid-shell {
    min-width: 0;
    position: relative;
}

.data-grid-shell {
    min-width: 0;
    position: relative;
}

.contact-grid-scroll-top {
    background: var(--main-2);
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 5px 12px rgba(15, 36, 66, .08);
    height: 18px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    position: sticky;
    scrollbar-color: #6f7d91 #e8edf4;
    top: 0;
    z-index: 8;
}

.data-grid-scroll-top {
    background: var(--main-2);
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 5px 12px rgba(15, 36, 66, .08);
    height: 18px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    position: sticky;
    scrollbar-color: #6f7d91 #e8edf4;
    top: 0;
    z-index: 8;
}

.contact-grid-scroll-top.is-hidden {
    display: none;
}

.data-grid-scroll-top.is-hidden {
    display: none;
}

.contact-grid-scroll-spacer {
    height: 1px;
}

.table-pager {
    align-items: center;
    display: flex;
    gap: 14px;
    justify-content: center;
    padding: 12px 0 2px;
}

.table-pager-label {
    color: #6f7d91;
    font-size: 13px;
}

.data-grid-scroll-spacer {
    height: 1px;
}

.contact-grid-scroll-top:not(.is-hidden) + .contact-table-card {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.data-grid-scroll-top:not(.is-hidden) + .data-grid-table-card {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.contact-grid-scroll-top::-webkit-scrollbar,
.contact-table-card::-webkit-scrollbar,
.data-grid-scroll-top::-webkit-scrollbar,
.data-grid-table-card::-webkit-scrollbar {
    height: 14px;
    width: 14px;
}

.contact-grid-scroll-top::-webkit-scrollbar-track,
.contact-table-card::-webkit-scrollbar-track,
.data-grid-scroll-top::-webkit-scrollbar-track,
.data-grid-table-card::-webkit-scrollbar-track {
    background: #e8edf4;
}

.contact-grid-scroll-top::-webkit-scrollbar-thumb,
.contact-table-card::-webkit-scrollbar-thumb,
.data-grid-scroll-top::-webkit-scrollbar-thumb,
.data-grid-table-card::-webkit-scrollbar-thumb {
    background: #6f7d91;
    border: 3px solid #e8edf4;
    border-radius: 8px;
}

.contact-grid-scroll-top::-webkit-scrollbar-thumb:hover,
.contact-table-card::-webkit-scrollbar-thumb:hover,
.data-grid-scroll-top::-webkit-scrollbar-thumb:hover,
.data-grid-table-card::-webkit-scrollbar-thumb:hover {
    background: #40516a;
}

.contact-company-table-card {
    max-height: max(320px, calc(100dvh - 235px));
    scrollbar-color: #6f7d91 #e8edf4;
}

.table-card.contact-company-table-card table {
    min-width: 1260px;
    table-layout: fixed;
    width: 100%;
}

.contact-company-name-column {
    width: 240px;
}

.contact-company-business-column {
    width: 270px;
}

.contact-company-tax-column {
    width: 150px;
}

.contact-company-address-column {
    width: 330px;
}

.contact-company-phone-column {
    width: 170px;
}

.contact-company-actions-column {
    width: 100px;
}

.table-card.catalog-table-card table {
    min-width: 100%;
    table-layout: fixed;
    width: 100%;
}

.table-card.catalog-table-card {
    scrollbar-gutter: auto;
}

.catalog-table-card th,
.catalog-table-card td {
    overflow-wrap: anywhere;
}

.catalog-table-card td.row-actions {
    white-space: nowrap;
}

.quick-reply-table-card {
    max-height: max(320px, calc(100dvh - 235px));
    scrollbar-color: #6f7d91 #e8edf4;
}

.table-card.quick-reply-table-card table {
    min-width: 1160px;
    table-layout: fixed;
    width: 100%;
}

.quick-reply-shortcut-column {
    width: 130px;
}

.quick-reply-title-column {
    width: 220px;
}

.quick-reply-message-column {
    width: 430px;
}

.quick-reply-departments-column {
    width: 290px;
}

.quick-reply-actions-column {
    width: 90px;
}

.quick-reply-table-card th,
.quick-reply-table-card td {
    overflow-wrap: anywhere;
    vertical-align: top;
}

.quick-reply-table-card td.row-actions {
    white-space: nowrap;
}

.quick-reply-scope-text {
    color: var(--muted);
    display: block;
    line-height: 1.35;
}

.team-toolbar {
    align-items: end;
    justify-content: space-between;
}

.team-table-card {
    max-height: max(320px, calc(100dvh - 235px));
    scrollbar-color: #6f7d91 #e8edf4;
}

.table-card.team-table-card table {
    min-width: 100%;
    /* Reparte el 100% del ancho disponible: nada de scroll horizontal en PC.
       Antes: table-layout auto + width max-content + minimos que sumaban ~1170px
       (20/08/2026). Lo largo (correos, nombres) envuelve linea, no empuja ancho. */
    table-layout: fixed;
    min-width: 0;
    width: 100%;
}

.team-table-card th,
.team-table-card td {
    overflow-wrap: anywhere;
    vertical-align: top;
}

.team-user-column {
    width: 21%;
}

.team-name-column {
    width: 21%;
}

.team-role-column {
    width: 17%;
}

.team-admin-column,
.team-chats-column {
    width: 62px;
}

.team-access-column {
    width: 112px;
}

.team-status-column {
    width: 92px;
}

.team-actions-column {
    /* 2 botones de 30px + gap 11 + padding 20 = 91: con 88 el ultimo se recorta. */
    width: 100px;
}

.team-table-card td.row-actions {
    white-space: nowrap;
}

/* CONTACTOS (20/08/2026): mismas reglas que Equipo — el 100% repartido, sin scroll
   horizontal. Las columnas son configurables (picker), asi que los anchos van por
   th: con table-layout fijo el th define su columna y los td heredan. */
.table-card.contact-table-card table {
    table-layout: fixed;
    min-width: 0;
    width: 100%;
}

.contact-table-card th,
.contact-table-card td {
    overflow-wrap: anywhere;
    vertical-align: top;
}

.contact-col-name {
    width: 24%;
}

.contact-col-phone {
    width: 128px;
}

.contact-col-last {
    width: 106px;
}

.contact-col-actions {
    /* 3 botones (editar/fusionar/desactivar) = 3x30 + 2 gaps de 11 + padding 20 = 132.
       Con 88 el tercero desbordaba la tabla y aparecia el scroll horizontal. */
    width: 132px;
}

/* correo, empresa, etiquetas y observaciones se reparten lo que sobra */

.contact-table-card td.row-actions {
    white-space: nowrap;
}

.department-toolbar {
    align-items: end;
    justify-content: space-between;
}

.department-toolbar-filters {
    align-items: end;
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
}

.department-search-field {
    flex: 1 1 360px;
    min-width: 260px;
}

.department-search-field input {
    min-width: 0;
    width: 100%;
}

.department-table-card {
    max-height: max(320px, calc(100dvh - 235px));
    scrollbar-color: #6f7d91 #e8edf4;
}

.table-card.department-table-card table {
    /* Antes tenia un piso clavado de 1540px: scroll horizontal en casi cualquier
       pantalla (20/08/2026). Ahora reparte el 100%; los textos largos envuelven. */
    min-width: 0;
    table-layout: fixed;
    width: 100%;
}

.department-table-card th,
.department-table-card td {
    overflow-wrap: anywhere;
    vertical-align: top;
}

.department-root-column {
    width: 105px;
}

.department-area-column {
    width: 130px;
}

.department-subarea-column {
    width: 115px;
}

.department-type-column {
    width: 86px;
}

.department-color-column {
    width: 56px;
}

/* Mensaje inicial y Criterio de atencion quedan SIN ancho: con table-layout fijo
   se reparten el espacio que sobra, y el texto largo envuelve en vez de empujar. */

.department-assignment-column {
    /* Esta columna no tenia regla: quedaba al ancho que quisiera el contenido. */
    width: 150px;
}

.department-actions-column {
    /* 2 botones = 91px reales: con 84 el eliminar quedaba tapado por la barra. */
    width: 100px;
}

.department-table-card td.row-actions {
    white-space: nowrap;
}

@media (max-width: 980px) {
    .contact-toolbar {
        grid-template-columns: 1fr;
    }

    .contact-toolbar-main,
    .contact-toolbar-config,
    .contact-import-actions {
        justify-content: flex-start;
    }

    .contact-search-field input,
    .contact-company-search-field input {
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 860px) {
    .contact-grid-scroll-top,
    .data-grid-scroll-top {
        display: none;
    }

    .contact-company-table-card {
        max-height: none;
    }

    .quick-reply-table-card {
        max-height: none;
    }

    .team-table-card {
        max-height: none;
    }

    .department-table-card {
        max-height: none;
    }

    .table-card.team-table-card table {
        min-width: 0;
        width: 100%;
    }

    .table-card.team-table-card table {
        table-layout: auto;
    }

    .team-table-card .team-user-column,
    .team-table-card .team-name-column,
    .team-table-card .team-role-column,
    .team-table-card .team-admin-column,
    .team-table-card .team-chats-column,
    .team-table-card .team-access-column,
    .team-table-card .team-status-column,
    .team-table-card .team-actions-column {
        min-width: 0;
        width: auto;
    }

    .table-card.contact-table-card table {
        table-layout: auto;
    }

    .contact-col-name,
    .contact-col-phone,
    .contact-col-last,
    .contact-col-actions {
        width: auto;
    }

    .table-card.department-table-card table {
        min-width: 0;
        table-layout: auto;
        width: 100%;
    }

    .department-table-card colgroup {
        display: none;
    }

    .department-table-card tbody,
    .department-table-card tr {
        width: 100%;
    }

    .department-table-card .department-root-column,
    .department-table-card .department-area-column,
    .department-table-card .department-subarea-column,
    .department-table-card .department-type-column,
    .department-table-card .department-color-column,
    .department-table-card .department-greeting-column,
    .department-table-card .department-behavior-column,
    .department-table-card .department-actions-column {
        width: auto;
    }

    .table-card.quick-reply-table-card table {
        min-width: 0;
        table-layout: auto;
        width: 100%;
    }

    .quick-reply-table-card colgroup {
        display: none;
    }

    .quick-reply-table-card tbody,
    .quick-reply-table-card tr {
        width: 100%;
    }

    .table-card.catalog-table-card table {
        min-width: 0;
        table-layout: auto;
        width: 100%;
    }
}

.quick-reply-scope-fieldset {
    background: #f8fafc;
    border: 1px solid #d5deea;
    border-radius: 8px;
    display: grid;
    gap: 8px;
    margin: 0;
    min-width: 0;
    padding: 10px;
}

.quick-reply-scope-fieldset legend {
    color: #263b5d;
    font-size: 13px;
    font-weight: 800;
    padding: 0 5px;
}

.modal-form .quick-reply-scope-option {
    align-items: center;
    background: #ffffff;
    border: 1px solid #dbe4ef;
    border-radius: 7px;
    color: #172033;
    cursor: pointer;
    display: grid;
    font-weight: 600;
    gap: 9px;
    grid-template-columns: 18px minmax(0, 1fr);
    padding: 8px 10px;
}

.modal-form .quick-reply-scope-option input {
    accent-color: #ff6500;
    height: 18px;
    margin: 0;
    width: 18px;
}

.quick-reply-scope-option span {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.quick-reply-scope-option strong {
    overflow-wrap: anywhere;
}

.quick-reply-scope-option small {
    color: #62708a;
    font-size: 11px;
    font-weight: 600;
}

.quick-reply-scope-all {
    border-color: #ffc39d !important;
}

.quick-reply-scope-list {
    display: grid;
    gap: 7px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 210px;
    overflow-y: auto;
    padding-right: 3px;
    scrollbar-color: #6f7d91 #e8edf4;
}

.quick-reply-scope-list[aria-disabled="true"] {
    opacity: .55;
}

@media (max-width: 620px) {
    .quick-reply-scope-list {
        grid-template-columns: 1fr;
    }
}

.secondary-button.icon-only {
    width: 38px;
}

.contact-column-picker {
    position: relative;
}

.contact-column-menu {
    background: #263145;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 16px 35px rgba(0, 0, 0, .34);
    display: grid;
    gap: 4px;
    min-width: 220px;
    padding: 10px;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 12;
}

    .contact-column-menu label {
        align-items: center;
        border-radius: 6px;
        color: var(--text);
        display: flex;
        font-size: .78rem;
        font-weight: 800;
        gap: 9px;
        min-height: 30px;
        padding: 5px 7px;
        white-space: nowrap;
    }

        .contact-column-menu label:hover {
            background: rgba(255, 255, 255, .06);
        }

        .contact-column-menu label.locked {
            color: var(--muted);
            opacity: .72;
        }

    .contact-column-menu input {
        accent-color: var(--accent);
        height: 14px;
        width: 14px;
    }

.file-action-button {
    align-items: center;
    cursor: pointer;
    display: inline-flex;
    gap: 6px;
    justify-content: center;
    margin: 0;
}

    .file-action-button.disabled {
        cursor: not-allowed;
        opacity: .48;
        pointer-events: none;
    }

.contact-import-status {
    background: rgba(147, 197, 253, 0.12);
    border: 1px solid rgba(147, 197, 253, 0.3);
    border-radius: 8px;
    color: var(--accent);
    font-size: .82rem;
    font-weight: 800;
    margin: 0 0 12px;
    padding: 9px 11px;
}

.contact-import-help {
    background: #ffffff;
    border: 1px solid #dbe4f0;
    border-radius: 12px;
    color: #172033;
    margin: -2px 0 12px;
    overflow: hidden;
}

    .contact-import-help summary {
        align-items: center;
        cursor: pointer;
        display: inline-flex;
        gap: 8px;
        font-size: .84rem;
        font-weight: 900;
        list-style: none;
        padding: 11px 13px;
        user-select: none;
    }

        .contact-import-help summary::-webkit-details-marker {
            display: none;
        }

        .contact-import-help summary .material-symbols-rounded {
            color: #ff6b00;
            font-size: 20px;
        }

.contact-import-help-body {
    border-top: 1px solid #e4e9f1;
    display: grid;
    gap: 9px;
    padding: 12px 14px 14px;
}

    .contact-import-help-body p {
        color: #42526b;
        font-size: .84rem;
        font-weight: 700;
        line-height: 1.45;
        margin: 0;
    }

    .contact-import-help-body ul {
        color: #42526b;
        font-size: .84rem;
        font-weight: 700;
        line-height: 1.5;
        margin: 0;
        padding-left: 20px;
    }

    .contact-import-help-body code {
        background: #f3f6fb;
        border: 1px solid #dbe4f0;
        border-radius: 6px;
        color: #0f2442;
        font-family: Consolas, monospace;
        font-size: .8rem;
        padding: 2px 5px;
    }

.contact-import-example {
    background: #f8fafc;
    border: 1px solid #dbe4f0;
    border-radius: 10px;
    display: grid;
    gap: 7px;
    padding: 10px;
}

    .contact-import-example span {
        color: #172033;
        font-size: .82rem;
        font-weight: 900;
    }

    .contact-import-example code {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

.contact-import-help-note {
    color: #62708a !important;
}

.contact-duplicate-row {
    background: rgba(245, 158, 11, 0.12);
    outline: 1px solid rgba(245, 158, 11, 0.52);
    outline-offset: -1px;
}

.contact-name-cell {
    align-items: center;
    display: inline-flex;
    gap: 10px;
    min-width: 0;
}

.contact-name-text {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.duplicate-chip {
    background: rgba(245, 158, 11, 0.18);
    border: 1px solid rgba(245, 158, 11, 0.62);
    border-radius: 999px;
    color: #fbbf24;
    display: inline-flex;
    font-size: .7rem;
    font-weight: 900;
    line-height: 1;
    margin: 5px 0 0;
    padding: 4px 7px;
    width: fit-content;
}

.form-error {
    background: rgba(248, 113, 113, 0.13);
    border: 1px solid rgba(248, 113, 113, 0.4);
    border-radius: 8px;
    color: #fecaca;
    font-weight: 800;
    padding: 10px;
    white-space: pre-line;
}

.error-page {
    min-height: calc(100vh - 72px);
    display: grid;
    place-items: center;
    padding: 32px;
}

.error-card {
    width: min(520px, 100%);
    background: rgba(31, 42, 59, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 22px;
    padding: 32px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
    color: #f8fafc;
}

.error-icon {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: rgba(248, 113, 113, 0.16);
    color: #f87171;
    margin-bottom: 18px;
}

    .error-icon .material-symbols-rounded {
        font-size: 32px;
    }

.error-card h1 {
    margin: 0 0 12px;
    font-size: 26px;
    font-weight: 800;
}

.error-message {
    margin: 0;
    color: #cbd5e1;
    line-height: 1.55;
}

.error-request {
    margin-top: 22px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.18);
}

    .error-request span {
        display: block;
        margin-bottom: 6px;
        color: #94a3b8;
        font-size: 12px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .error-request code {
        color: #93c5fd;
        word-break: break-all;
    }

.error-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.form-info {
    align-items: center;
    background: rgba(96, 165, 250, 0.13);
    border: 1px solid rgba(96, 165, 250, 0.38);
    border-radius: 8px;
    color: #bfdbfe;
    display: flex;
    font-weight: 800;
    gap: 8px;
    padding: 10px;
}

    .form-info .material-symbols-rounded {
        font-size: 20px;
    }

.permission-session-notice {
    margin-bottom: 14px;
}

.permission-page {
    display: grid;
    gap: 12px;
}

.permission-toolbar {
    align-items: end;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(280px, 1fr) minmax(150px, 190px) minmax(190px, 240px);
    padding: 12px;
}

    .permission-toolbar label {
        color: var(--muted);
        display: grid;
        font-size: 11px;
        font-weight: 800;
        gap: 5px;
        min-width: 0;
        text-transform: uppercase;
    }

    .permission-toolbar input,
    .permission-toolbar select {
        background: var(--panel-soft);
        border: 1px solid var(--line);
        border-radius: 8px;
        color: var(--text);
        font-weight: 800;
        min-height: 34px;
        outline: 0;
        padding: 7px 10px;
        width: 100%;
    }

.permission-tabs {
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    display: inline-flex;
    gap: 4px;
    justify-self: start;
    padding: 4px;
}

    .permission-tabs button {
        background: transparent;
        border: 0;
        border-radius: 8px;
        color: var(--muted);
        cursor: pointer;
        font-weight: 900;
        min-height: 34px;
        padding: 0 14px;
    }

        .permission-tabs button.active {
            background: var(--accent);
            color: #ffffff;
        }

.permission-admin-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
}

.permission-layout {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.permission-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.permission-panel-header {
    align-items: flex-start;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 14px;
    flex: 0 0 auto;
}

    .permission-panel-header h2 {
        font-size: 15px;
        margin: 0 0 4px;
    }

    .permission-panel-header p {
        color: var(--muted);
        margin: 0;
    }


.permission-header-filter {
    align-items: flex-start;
    color: var(--muted);
    display: grid;
    font-size: 11px;
    font-weight: 700;
    gap: 4px;
    min-width: 180px;
    text-transform: uppercase;
}

    .permission-header-filter select {
        background: var(--panel-soft);
        border: 1px solid var(--line);
        border-radius: 999px;
        color: var(--text);
        font-size: 12px;
        font-weight: 700;
        min-height: 30px;
        padding: 4px 28px 4px 12px;
    }

.permission-table {
    min-width: 560px;
}

.permission-table-scroll {
    flex: 1 1 auto;
    max-height: min(66vh, 650px);
    overflow: auto;
}

    .permission-table-scroll.catalog {
        max-height: min(44vh, 420px);
    }

    .permission-table-scroll.audit {
        max-height: min(66vh, 620px);
    }

    .permission-table-scroll thead th {
        background: var(--panel);
        position: sticky;
        top: 0;
        z-index: 1;
    }

.compact-table {
    min-width: 0;
}

.permission-table td,
.permission-table th {
    padding: 9px 12px;
}

.permission-table input[type="checkbox"] {
    height: 17px;
    width: 17px;
}

.permission-mode {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font-weight: 800;
    min-height: 30px;
    outline: 0;
    padding: 5px 8px;
    width: 120px;
}

.permission-form-grid {
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    padding: 12px 14px;
}

    .permission-form-grid.task-form {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .permission-form-grid label {
        color: var(--muted);
        display: grid;
        font-size: 11.5px;
        font-weight: 800;
        gap: 5px;
    }

    .permission-form-grid input {
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 8px;
        color: var(--text);
        font-weight: 800;
        min-height: 32px;
        outline: 0;
        padding: 6px 9px;
        width: 100%;
    }

    .permission-form-grid .wide-field {
        grid-column: span 2;
    }

.primary-pill.compact,
.secondary-button.compact {
    align-self: end;
    min-height: 32px;
    padding: 0 14px;
    white-space: nowrap;
}

.denied-panel {
    min-height: 360px;
}

.mini-card .color-dot {
    border-radius: 999px;
    height: 14px;
    margin-bottom: 9px;
    width: 14px;
}

.support-grid,
.subscription-grid,
.metrics-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.support-card .material-symbols-rounded,
.ai-panel .material-symbols-rounded {
    color: var(--accent);
    font-size: 34px;
    margin-bottom: 10px;
}

.support-card {
    display: flex;
    flex-direction: column;
    min-height: 174px;
}

    .support-card p {
        flex: 1 1 auto;
        line-height: 1.32;
        margin-bottom: 14px;
    }

    .support-card .secondary-button {
        align-self: flex-start;
        flex: 0 0 auto;
    }

.ai-board,
.account-page,
.docs-layout {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
}

.docs-layout {
    gap: 22px;
}

    .docs-layout article {
        padding: 24px;
    }

    .docs-layout h2 {
        margin-bottom: 10px;
    }

    .docs-layout p {
        line-height: 1.42;
        margin-bottom: 14px;
    }

    .docs-layout code {
        margin: 0 8px 10px 0;
    }

.modal-form texTarea,
.modal-form textarea {
    min-height: 130px;
    resize: vertical;
}

.prompt-panel texTarea,
.prompt-panel textarea {
    height: 128px;
    max-height: 128px;
    min-height: 128px;
    overflow-y: auto;
    resize: none;
    width: 100%;
}

.prompt-panel label,
.theme-card label,
.modal-form label {
    color: var(--muted);
    display: flex;
    flex-direction: column;
    font-weight: 700;
    gap: 6px;
}

    .modal-form label.inline-check {
        align-items: center;
        flex-direction: row;
        gap: 9px;
    }

        .modal-form label.inline-check input {
            width: auto;
        }

.agent-area-default {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 8px;
    padding-top: 8px;
}

    .agent-area-default:first-of-type {
        border-top: 0;
        padding-top: 0;
    }

.agent-area-default-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-left: 22px;
}

.agent-state-permissions {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
}

.agent-line-access {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 8px;
    padding: 10px;
}

.agent-line-access-title {
    color: var(--text);
    font-weight: 800;
}

.agent-line-access-hint {
    color: var(--muted);
    font-size: .82rem;
    font-weight: 700;
    line-height: 1.35;
}

.agent-line-list {
    display: grid;
    gap: 6px;
    max-height: 190px;
    overflow: auto;
    padding-right: 4px;
}

.agent-line-item {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 9px;
    grid-template-columns: auto minmax(0, 1fr);
    padding: 8px 10px;
}

    .agent-line-item input {
        width: auto;
    }

    .agent-line-item > span {
        display: grid;
        gap: 2px;
        min-width: 0;
    }

    .agent-line-item strong,
    .agent-line-item small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .agent-line-item small {
        color: var(--muted);
        font-size: .78rem;
        font-weight: 700;
    }

    .agent-line-item.from-area {
        background: rgba(96, 165, 250, 0.08);
    }

        .agent-line-item.from-area strong {
            color: var(--accent);
        }

.agent-state-matrix {
    align-items: start;
    display: grid;
    gap: 8px 10px;
    grid-template-columns: minmax(120px, 0.8fr) 56px minmax(220px, 2fr);
}

.agent-priority-permissions {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
}

.agent-priority-matrix {
    align-items: center;
    display: grid;
    gap: 8px 10px;
    grid-template-columns: minmax(120px, 1fr) 72px 120px;
}

.agent-priority-matrix-head {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
}

.agent-priority-name {
    font-weight: 600;
    line-height: 1.35;
}

.agent-priority-check {
    align-items: center;
    display: inline-flex;
    justify-content: center;
}

.agent-state-matrix-head {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
}

.agent-state-name {
    font-weight: 600;
    line-height: 1.35;
}

.agent-state-view {
    justify-content: center;
}

.agent-state-targets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
}

.agent-state-targets label {
    align-items: center;
    display: inline-flex;
    flex-direction: row;
    font-size: 0.86rem;
    gap: 4px;
    min-height: 24px;
}

.prompt-panel texTarea,
.prompt-panel textarea,
.theme-card select,
.modal-form input,
.modal-form select,
.modal-form texTarea,
.modal-form textarea {
    background: var(--main-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    outline: 0;
    padding: 10px;
}

.campaign-stats,
.plan-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

    .plan-card.highlighted {
        border-color: rgba(155, 208, 255, 0.7);
    }

.metric-card h2 {
    font-size: 24px;
    margin: 8px 0;
}

.metric-card p,
.metric-card span {
    color: var(--muted);
    margin: 0;
}

.metric-progress {
    background: rgba(255, 255, 255, 0.11);
    border-radius: 999px;
    height: 9px;
    margin-top: 14px;
    overflow: hidden;
}

    .metric-progress span {
        background: linear-gradient(90deg, var(--accent), #25d366);
        display: block;
        height: 100%;
    }

.bar-chart {
    align-items: end;
    display: flex;
    gap: 9px;
    height: 210px;
    padding-top: 20px;
}

    .bar-chart span {
        background: linear-gradient(180deg, var(--accent), #08736d);
        border-radius: 8px 8px 0 0;
        flex: 1 1 0;
        min-width: 14px;
    }

.reports-shell {
    display: grid;
    gap: 16px;
}

.reports-header {
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    padding: 16px 18px;
}

    .reports-header h1 {
        color: var(--accent);
        font-size: 1.25rem;
        margin: 0 0 4px;
    }

    .reports-header span {
        color: var(--muted);
        font-size: .82rem;
        font-weight: 800;
    }

.report-working-hours {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-size: .78rem;
    font-weight: 800;
    gap: 8px;
    white-space: nowrap;
}

.reports-filter-bar {
    align-items: end;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    padding: 14px 16px;
}

    .reports-filter-bar label {
        color: var(--muted);
        display: grid;
        font-size: .72rem;
        font-weight: 800;
        gap: 5px;
        min-width: 0;
    }

    .reports-filter-bar input,
    .reports-filter-bar select {
        background: #364154;
        border: 1px solid #65718a;
        border-radius: 7px;
        color: var(--text);
        font-weight: 800;
        min-height: 36px;
        min-width: 0;
        padding: 0 10px;
        width: 100%;
    }

.report-clear-button {
    min-height: 36px;
}

.report-tabs {
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 10px;
    padding: 0 16px;
}

    .report-tabs button {
        background: transparent;
        border: 0;
        border-bottom: 2px solid transparent;
        color: var(--muted);
        cursor: pointer;
        font-size: .78rem;
        font-weight: 900;
        min-height: 44px;
        padding: 0 4px;
    }

        .report-tabs button.active {
            border-bottom-color: var(--accent);
            color: var(--accent);
        }

.report-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 16px;
    min-width: 0;
    padding: 18px;
}

    .report-card header {
        align-items: center;
        display: flex;
        justify-content: space-between;
        min-width: 0;
    }

    .report-card h2 {
        color: var(--accent);
        font-size: .92rem;
        margin: 0;
    }

.report-empty {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-weight: 800;
    justify-content: center;
    min-height: 180px;
}

.report-empty.compact {
    min-height: 86px;
}

.diagnostics-shell {
    display: grid;
    gap: 16px;
}

.diagnostics-header {
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    min-width: 0;
    padding: 16px 18px;
}

    .diagnostics-header > div {
        align-items: center;
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        min-width: 0;
    }

    .diagnostics-header strong {
        color: var(--text);
        font-size: .9rem;
    }

    .diagnostics-header small,
    .diagnostics-header span:not(.diagnostic-status):not(.material-symbols-rounded) {
        color: var(--muted);
        font-size: .78rem;
        font-weight: 800;
    }

.diagnostic-status {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    display: inline-flex;
    font-size: .76rem;
    font-weight: 900;
    gap: 6px;
    min-height: 30px;
    padding: 0 10px;
    white-space: nowrap;
}

    .diagnostic-status .material-symbols-rounded {
        font-size: 18px;
    }

    .diagnostic-status.ok,
    .diagnostic-check-card.ok {
        border-color: rgba(74, 222, 128, .58);
        color: #4ade80;
    }

    .diagnostic-status.warning,
    .diagnostic-check-card.warning {
        border-color: rgba(250, 204, 21, .62);
        color: #facc15;
    }

    .diagnostic-status.error,
    .diagnostic-check-card.error {
        border-color: rgba(248, 113, 113, .66);
        color: #f87171;
    }

.diagnostic-error {
    align-items: center;
    background: rgba(248, 113, 113, .08);
    border: 1px solid rgba(248, 113, 113, .4);
    border-radius: 8px;
    color: #fecaca;
    display: flex;
    font-weight: 800;
    gap: 10px;
    padding: 12px 14px;
}

.diagnostic-api-filter-bar {
    margin-bottom: 12px;
}

.diagnostic-api-filter-bar + .diagnostic-error,
.diagnostic-api-filter-bar + .report-empty,
.diagnostic-error + .report-empty,
.diagnostic-error + .table-card {
    margin-top: 12px;
}

.diagnostic-check-grid,
.diagnostic-metric-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.diagnostic-check-card,
.diagnostic-metric-grid article {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    min-width: 0;
    padding: 14px;
}

.diagnostic-check-card {
    align-items: flex-start;
    display: flex;
    gap: 10px;
}

    .diagnostic-check-card > .material-symbols-rounded {
        flex: 0 0 auto;
        font-size: 24px;
    }

    .diagnostic-check-card strong,
    .diagnostic-flow-list strong {
        color: var(--text);
        display: block;
        font-size: .86rem;
        margin-bottom: 5px;
    }

    .diagnostic-check-card small,
    .diagnostic-flow-list small,
    .diagnostic-flow-list em {
        color: var(--muted);
        display: block;
        font-size: .76rem;
        font-style: normal;
        font-weight: 800;
        line-height: 1.35;
    }

.diagnostic-metric-grid article {
    border-left: 4px solid var(--accent);
}

    .diagnostic-metric-grid article.ok {
        border-left-color: #4ade80;
    }

    .diagnostic-metric-grid article.warning {
        border-left-color: #facc15;
    }

    .diagnostic-metric-grid article.error {
        border-left-color: #f87171;
    }

    .diagnostic-metric-grid strong {
        color: var(--accent);
        display: block;
        font-size: 1.45rem;
        line-height: 1;
        margin-bottom: 8px;
    }

    .diagnostic-metric-grid span {
        color: var(--muted);
        font-size: .78rem;
        font-weight: 900;
    }

.diagnostic-two-columns {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr);
}

.diagnostic-service-list,
.diagnostic-flow-list {
    display: grid;
    gap: 12px;
}

    .diagnostic-service-list article,
    .diagnostic-flow-list article {
        border: 1px solid var(--line);
        border-radius: 8px;
        min-width: 0;
        padding: 14px;
    }

    .diagnostic-service-list dl {
        display: grid;
        gap: 10px;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        margin: 12px 0 0;
    }

    .diagnostic-service-list dt {
        color: var(--muted);
        font-size: .68rem;
        font-weight: 900;
        margin-bottom: 3px;
        text-transform: uppercase;
    }

    .diagnostic-service-list dd {
        color: var(--text);
        font-size: .78rem;
        font-weight: 800;
        margin: 0;
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .diagnostic-flow-list article {
        align-items: flex-start;
        display: flex;
        gap: 12px;
    }

    .diagnostic-flow-list > article > .material-symbols-rounded {
        color: var(--accent);
        flex: 0 0 auto;
        font-size: 24px;
    }

.diagnostic-alert-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    padding: 14px;
}

    .diagnostic-alert-panel > header,
    .report-card > header {
        align-items: center;
        display: flex;
        gap: 12px;
        justify-content: space-between;
    }

    .diagnostic-alert-panel h2 {
        color: var(--text);
        font-size: .92rem;
        margin: 0;
    }

    .diagnostic-alert-panel header small {
        color: var(--muted);
        font-size: .74rem;
        font-weight: 800;
    }

.diagnostic-alert-list {
    display: grid;
    gap: 8px;
}

    .diagnostic-alert-list article {
        align-items: flex-start;
        border-left: 4px solid var(--line);
        display: grid;
        gap: 10px;
        grid-template-columns: auto minmax(0, 1fr) auto;
        min-width: 0;
        padding: 10px 12px;
    }

    .diagnostic-alert-list article.warning {
        background: rgba(250, 204, 21, .06);
        border-left-color: #facc15;
    }

    .diagnostic-alert-list article.error {
        background: rgba(248, 113, 113, .07);
        border-left-color: #f87171;
    }

    .diagnostic-alert-list .material-symbols-rounded {
        color: currentColor;
        font-size: 21px;
    }

    .diagnostic-alert-list strong,
    .diagnostic-issue-list strong {
        color: var(--text);
        display: block;
        font-size: .8rem;
    }

    .diagnostic-alert-list small,
    .diagnostic-alert-list em,
    .diagnostic-issue-list small,
    .diagnostic-issue-list em {
        color: var(--muted);
        display: block;
        font-size: .72rem;
        font-style: normal;
        font-weight: 750;
        line-height: 1.4;
        overflow-wrap: anywhere;
    }

    .diagnostic-alert-list em {
        margin-top: 3px;
    }

    .diagnostic-alert-list > article > b,
    .diagnostic-issue-list > article > b {
        color: var(--text);
        font-size: 1rem;
    }

.diagnostic-operation-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.diagnostic-stat-list,
.diagnostic-dispatcher-list {
    display: grid;
    gap: 1px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0;
    overflow: hidden;
}

    .diagnostic-stat-list > div,
    .diagnostic-dispatcher-list > div {
        background: rgba(255, 255, 255, .025);
        min-width: 0;
        padding: 10px;
    }

    .diagnostic-stat-list dt,
    .diagnostic-dispatcher-list dt {
        color: var(--muted);
        font-size: .67rem;
        font-weight: 850;
        line-height: 1.25;
        margin-bottom: 5px;
    }

    .diagnostic-stat-list dd,
    .diagnostic-dispatcher-list dd {
        color: var(--text);
        font-size: 1rem;
        font-weight: 900;
        margin: 0;
        overflow-wrap: anywhere;
    }

.diagnostic-dispatcher-list {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.diagnostic-context-row,
.diagnostic-status-counts {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}

    .diagnostic-context-row span {
        color: var(--muted);
        font-size: .72rem;
        font-weight: 800;
    }

    .diagnostic-context-row strong {
        color: var(--text);
    }

    .diagnostic-status-counts span {
        border: 1px solid var(--line);
        border-radius: 6px;
        color: var(--muted);
        font-size: .68rem;
        font-weight: 850;
        padding: 5px 7px;
    }

    .diagnostic-status-counts strong {
        color: var(--text);
        margin-left: 4px;
    }

.diagnostic-detail-columns {
    align-items: start;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.diagnostic-issue-list {
    display: grid;
}

    .diagnostic-issue-list article {
        align-items: center;
        border-bottom: 1px solid var(--line);
        display: grid;
        gap: 8px 12px;
        grid-template-columns: minmax(0, 1fr) auto;
        min-width: 0;
        padding: 10px 0;
    }

    .diagnostic-issue-list article:first-child {
        padding-top: 0;
    }

    .diagnostic-issue-list article:last-child {
        border-bottom: 0;
        padding-bottom: 0;
    }

    .diagnostic-issue-list em {
        grid-column: 1 / -1;
    }

@media (max-width: 920px) {
    .diagnostics-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .diagnostic-two-columns {
        grid-template-columns: 1fr;
    }

    .diagnostic-stat-list,
    .diagnostic-dispatcher-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .diagnostic-alert-list article {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .diagnostic-alert-list > article > b {
        grid-column: 2;
    }

    .diagnostic-stat-list,
    .diagnostic-dispatcher-list {
        grid-template-columns: 1fr;
    }
}

.report-stat-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.report-stat-card {
    --report-tone: var(--accent);
    align-items: center;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid color-mix(in srgb, var(--report-tone) 42%, var(--line));
    border-left: 4px solid var(--report-tone);
    border-radius: 7px;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    min-height: 92px;
    min-width: 0;
    padding: 14px;
}

    .report-stat-card.green {
        --report-tone: #4ade80;
    }

    .report-stat-card.blue {
        --report-tone: #38bdf8;
    }

    .report-stat-card.pink {
        --report-tone: #f472b6;
    }

    .report-stat-card.red {
        --report-tone: #ef4444;
    }

    .report-stat-card.orange {
        --report-tone: #f59e0b;
    }

    .report-stat-card.purple {
        --report-tone: #a78bfa;
    }

    .report-stat-card strong {
        color: var(--report-tone);
        display: block;
        font-size: 1.32rem;
        margin-bottom: 5px;
    }

    .report-stat-card span {
        color: var(--muted);
        font-size: .82rem;
        font-weight: 800;
    }

    .report-stat-card > .material-symbols-rounded {
        color: var(--report-tone);
        flex: 0 0 auto;
        font-size: 30px;
    }

.report-line-card {
    overflow: visible;
}

.report-line-chart {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.report-chart-legend {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    justify-content: center;
}

    .report-chart-legend span {
        align-items: center;
        color: var(--text);
        display: inline-flex;
        font-size: .82rem;
        font-weight: 900;
        gap: 6px;
        min-width: 0;
    }

    .report-chart-legend i,
    .report-chart-tooltip i {
        border-radius: 2px;
        display: inline-flex;
        flex: 0 0 auto;
        height: 10px;
        width: 10px;
    }

        .report-chart-legend i.primary,
        .report-chart-tooltip i.primary {
            background: var(--chart-primary);
        }

        .report-chart-legend i.secondary,
        .report-chart-tooltip i.secondary {
            background: var(--chart-secondary);
        }

.report-line-canvas {
    min-height: 286px;
    min-width: 0;
    padding: 14px 44px 0 48px;
    position: relative;
}

.report-line-plot {
    background:
        linear-gradient(rgba(255, 255, 255, .07) 1px, transparent 1px) 0 0 / 100% 25%,
        linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px) 0 0 / calc(100% / 23) 100%;
    border-bottom: 1px solid rgba(255, 255, 255, .62);
    border-left: 1px solid rgba(255, 255, 255, .62);
    height: 230px;
    min-width: 0;
    position: relative;
}

    .report-line-plot svg {
        height: 100%;
        inset: 0;
        overflow: visible;
        position: absolute;
        width: 100%;
    }

.report-chart-area {
    opacity: .34;
}

    .report-chart-area.primary {
        fill: var(--chart-primary);
    }

    .report-chart-area.secondary {
        fill: var(--chart-secondary);
        opacity: .26;
    }

.report-chart-line {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
    vector-effect: non-scaling-stroke;
}

    .report-chart-line.primary {
        stroke: var(--chart-primary);
    }

    .report-chart-line.secondary {
        stroke: var(--chart-secondary);
    }

.report-chart-y-labels {
    bottom: 42px;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 900;
    pointer-events: none;
    position: absolute;
    top: 14px;
    width: 40px;
}

    .report-chart-y-labels.primary {
        left: 0;
        text-align: right;
    }

    .report-chart-y-labels.secondary {
        right: 0;
        text-align: left;
    }

    .report-chart-y-labels span {
        position: absolute;
        transform: translateY(-50%);
        white-space: nowrap;
    }

    .report-chart-y-labels.primary span {
        right: 8px;
    }

    .report-chart-y-labels.secondary span {
        left: 8px;
    }

.report-chart-x-labels {
    color: var(--muted);
    display: grid;
    font-size: .62rem;
    font-weight: 900;
    grid-template-columns: repeat(24, minmax(24px, 1fr));
    margin-top: 6px;
    min-width: 0;
}

    .report-chart-x-labels span {
        overflow: hidden;
        text-align: center;
        text-overflow: clip;
        white-space: nowrap;
    }

.report-chart-points {
    inset: 0;
    pointer-events: none;
    position: absolute;
}

.report-chart-point {
    background: var(--chart-primary);
    border: 2px solid var(--panel);
    border-radius: 999px;
    box-shadow: 0 0 0 1px var(--chart-primary);
    height: 9px;
    left: calc(var(--point-x) * 1%);
    pointer-events: auto;
    position: absolute;
    top: calc(var(--point-y) * 1%);
    transform: translate(-50%, -50%);
    width: 9px;
    z-index: 2;
}

    .report-chart-point::before {
        border-left: 1px dashed rgba(255, 255, 255, .46);
        bottom: 50%;
        content: "";
        height: 230px;
        left: 50%;
        opacity: 0;
        position: absolute;
        transform: translateX(-50%);
        transition: opacity .15s ease;
    }

    .report-chart-point:hover::before,
    .report-chart-point:focus-visible::before {
        opacity: 1;
    }

.report-chart-tooltip {
    background: #202a3b;
    border: 1px solid rgba(148, 163, 184, .24);
    border-radius: 6px;
    box-shadow: 0 18px 36px rgba(0, 0, 0, .34);
    color: var(--text);
    display: grid;
    gap: 8px;
    left: 50%;
    min-width: 240px;
    opacity: 0;
    padding: 10px 12px;
    pointer-events: none;
    position: absolute;
    top: calc(100% + 12px);
    transform: translateX(-50%);
    transition: opacity .15s ease, visibility .15s ease;
    visibility: hidden;
    z-index: 20;
}

    .report-chart-tooltip strong {
        color: var(--text);
        font-size: .8rem;
    }

    .report-chart-tooltip em {
        align-items: center;
        display: grid;
        font-style: normal;
        gap: 8px;
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .report-chart-tooltip span {
        color: var(--muted);
        font-size: .78rem;
        font-weight: 800;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .report-chart-tooltip b {
        color: var(--text);
        font-size: .82rem;
        font-weight: 900;
        white-space: nowrap;
    }

.report-chart-point:hover .report-chart-tooltip,
.report-chart-point:focus-visible .report-chart-tooltip {
    opacity: 1;
    visibility: visible;
}

.report-chart-point.edge-left .report-chart-tooltip {
    left: -12px;
    transform: none;
}

.report-chart-point.edge-right .report-chart-tooltip {
    left: auto;
    right: -12px;
    transform: none;
}

.report-two-columns {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.report-distribution-list,
.report-ranking-list {
    display: grid;
    gap: 10px;
}

.report-distribution-row {
    display: grid;
    gap: 7px;
}

    .report-distribution-row div {
        align-items: baseline;
        display: flex;
        gap: 10px;
        justify-content: space-between;
        min-width: 0;
    }

    .report-distribution-row strong {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .report-distribution-row span {
        color: var(--muted);
        flex: 0 0 auto;
        font-size: .76rem;
        font-weight: 800;
    }

    .report-distribution-row em {
        background: rgba(255, 255, 255, .09);
        border-radius: 999px;
        display: block;
        height: 9px;
        overflow: hidden;
    }

    .report-distribution-row i {
        background: linear-gradient(90deg, #60a5fa, #25d366);
        display: block;
        height: 100%;
    }

.report-ranking-list article {
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto 34px;
    min-height: 42px;
    padding-bottom: 10px;
}

    .report-ranking-list strong,
    .report-ranking-list span {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .report-ranking-list span {
        color: var(--muted);
        font-size: .74rem;
        font-weight: 800;
    }

    .report-ranking-list small {
        background: rgba(37, 211, 102, .22);
        border: 1px solid rgba(37, 211, 102, .45);
        border-radius: 999px;
        color: #c6f6d5;
        font-weight: 900;
        padding: 5px 9px;
        white-space: nowrap;
    }

    .report-ranking-list b {
        align-items: center;
        border: 1px solid var(--line);
        border-radius: 999px;
        display: inline-flex;
        height: 30px;
        justify-content: center;
        width: 30px;
    }

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.setting-row {
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    display: flex;
    gap: 14px;
    justify-content: space-between;
    padding: 14px 16px;
}

.presence {
    background: #7d8796;
    border-radius: 999px;
    display: inline-block;
    height: 9px;
    margin-right: 8px;
    width: 9px;
}

    .presence.online {
        background: #25d366;
    }

.profile-card {
    align-items: center;
    display: flex;
    flex-direction: column;
    text-align: center;
}

.transfer-history-block {
    align-self: stretch;
    background: rgba(248, 251, 255, 0.96);
    border: 1px solid #d7e3f3;
    border-radius: 16px;
    color: #1f2a44;
    margin: 12px 0 18px;
    padding: 12px;
}

    .transfer-history-block > header {
        align-items: center;
        border-bottom: 1px solid #e3edf9;
        display: flex;
        justify-content: space-between;
        margin-bottom: 10px;
        padding-bottom: 8px;
    }

        .transfer-history-block > header strong {
            color: #173f77;
            display: block;
            font-size: 14px;
        }

        .transfer-history-block > header span,
        .transfer-history-details small,
        .transfer-history-note {
            color: #64748b;
            font-size: 12px;
        }

.transfer-history-details {
    background: #ffffff;
    border-radius: 12px;
    margin-top: 8px;
    padding: 8px;
}

    .transfer-history-details summary {
        align-items: center;
        cursor: pointer;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

        .transfer-history-details summary strong {
            color: #1f2a44;
        }

.transfer-history-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.message-bubble.readonly-transfer {
    box-shadow: none;
    opacity: .95;
}

    .message-bubble.readonly-transfer .message-footer {
        justify-content: flex-end;
    }

.theme-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.account-page .pwa-card {
    grid-column: 1 / -1;
}

.pwa-card [hidden] {
    display: none !important;
}

.theme-card input:not(.switch-input) {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    min-height: 36px;
    padding: 8px 10px;
    width: 100%;
}

.theme-card input[readonly] {
    cursor: default;
}

.pwa-card-header,
.pwa-setting-row,
.pwa-actions {
    align-items: center;
    display: flex;
}

.pwa-card-header {
    justify-content: space-between;
}

.pwa-card-header h2 {
    margin: 0 0 3px;
}

.pwa-status,
.pwa-setting-row small {
    color: var(--muted);
    display: block;
    font-size: 11px;
}

.pwa-setting-row {
    border-top: 1px solid var(--line);
    gap: 10px;
    min-height: 56px;
    padding-top: 12px;
}

.pwa-setting-row > .material-symbols-rounded {
    color: var(--accent);
    flex: 0 0 auto;
}

.pwa-setting-row > div,
.pwa-setting-row > span:not(.material-symbols-rounded) {
    flex: 1 1 auto;
    min-width: 0;
}

.pwa-setting-row strong {
    display: block;
    font-size: 12px;
    margin-bottom: 3px;
}

.pwa-setting-row .pwa-ok {
    color: #22a06b;
}

.notification-toggle-row {
    cursor: pointer;
}

.theme-card label.notification-toggle-row {
    align-items: center;
    flex-direction: row;
}

.notification-toggle-row .switch-input {
    appearance: none;
    background: #cfd6e3;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    flex: 0 0 auto;
    height: 20px;
    margin: 0;
    padding: 0;
    position: relative;
    transition: background-color 140ms ease;
    width: 36px;
}

.notification-toggle-row .switch-input::before {
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(23, 32, 51, 0.25);
    content: "";
    height: 14px;
    left: 3px;
    position: absolute;
    top: 3px;
    transition: transform 140ms ease;
    width: 14px;
}

.notification-toggle-row .switch-input:checked {
    background: var(--accent);
}

.notification-toggle-row .switch-input:checked::before {
    transform: translateX(16px);
}

.notification-toggle-row .switch-input:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.notification-toggle-row .switch-input:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.pwa-actions {
    justify-content: flex-end;
}

.working-hours-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    display: grid;
    gap: 12px;
    min-width: 0;
    padding: 16px;
}

.settings-working-hours {
    margin-top: 12px;
}

.modal-working-hours {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    padding: 14px;
}

.working-hours-header {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    min-width: 0;
}

    .working-hours-header h2 {
        font-size: 16px;
        margin: 0 0 4px;
    }

    .working-hours-header span {
        color: var(--muted);
        font-size: 12px;
        font-weight: 800;
    }

.working-hours-list {
    display: grid;
    gap: 8px;
}

.working-hours-row {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(120px, 1fr) 120px 120px;
    min-height: 46px;
    padding: 8px;
}

    .working-hours-row.active {
        border-color: rgba(155, 208, 255, 0.45);
    }

    .working-hours-row input[type="time"] {
        background: #ffffff;
        border: 1px solid #aebbd0;
        border-radius: 7px;
        color: #172033;
        color-scheme: light;
        font-weight: 800;
        min-height: 34px;
        padding: 0 9px;
        width: 100%;
    }

        .working-hours-row input[type="time"]:disabled {
            background: #eef2f7;
            border-color: #d4dbe7;
            color: #68758a;
            opacity: 1;
        }

.working-hours-day-toggle {
    min-width: 0;
}

@media (max-width: 720px) {
    .working-hours-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .working-hours-row {
        grid-template-columns: 1fr 1fr;
    }

    .working-hours-day-toggle {
        grid-column: 1 / -1;
    }
}

/* =========================================================
   Modales / historial
   ========================================================= */
.modal-backdrop {
    align-items: center;
    background: rgba(0, 0, 0, 0.55);
    box-sizing: border-box;
    display: flex;
    inset: 0;
    justify-content: center;
    overflow: auto;
    padding: 16px;
    position: fixed;
    z-index: 20;
}

.modal-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
    color: var(--text);
    max-width: 520px;
    padding: 18px;
    width: min(92vw, 560px);
}

.transfer-modal-panel {
    max-width: 820px;
    width: min(94vw, 820px);
}

.agent-modal-panel {
    max-height: min(88vh, 900px);
    max-width: 980px;
    overflow: hidden;
    width: min(94vw, 980px);
}

    .agent-modal-panel .modal-form {
        max-height: calc(88vh - 118px);
        overflow: auto;
        padding-right: 4px;
    }

.agent-modal-grid {
    display: grid;
    gap: 11px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

    .agent-modal-grid .inline-check {
        align-self: end;
        min-height: 42px;
    }

.agent-area-list {
    border: 1px solid var(--line);
    border-radius: 10px;
    max-height: 260px;
    overflow: auto;
    padding: 10px;
}

@media (max-width: 900px) {
    .agent-modal-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .agent-modal-grid {
        grid-template-columns: 1fr;
    }
}

    .modal-panel header,
    .modal-panel footer {
        align-items: center;
        display: flex;
        justify-content: space-between;
    }

    .modal-panel h2 {
        margin: 0;
    }

    .modal-panel footer {
        gap: 12px;
        justify-content: flex-end;
        margin-top: 14px;
    }

.modal-form {
    display: grid;
    gap: 11px;
    margin-top: 16px;
}

.modal-panel.connection-edit-modal {
    display: flex;
    flex-direction: column;
    max-height: min(88dvh, 860px);
    max-width: 760px;
    overflow: hidden;
    width: min(94vw, 760px);
}

.connection-edit-modal .modal-subtitle {
    color: var(--muted);
    margin: 4px 0 0;
}

.connection-edit-tabs {
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 22px;
    margin-top: 14px;
}

.connection-edit-tabs button {
    background: transparent;
    border: 0;
    border-bottom: 3px solid transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    font-weight: 800;
    min-height: 38px;
    padding: 0 2px;
}

.connection-edit-tabs button.selected {
    border-bottom-color: var(--accent);
    color: var(--text);
}

.connection-edit-tabs button:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.connection-edit-tabs button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.connection-edit-modal .modal-form {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
    overflow: auto;
    padding-right: 4px;
}

.connection-edit-grid,
.connection-reopen-grid {
    display: grid;
    gap: 11px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.connection-edit-section {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 11px;
    padding-top: 13px;
}

.connection-edit-section-first {
    border-top: 0;
    padding-top: 0;
}

.connection-edit-section h3 {
    color: var(--text);
    font-size: 15px;
    grid-column: 1 / -1;
    margin: 0;
}

.connection-edit-modal .connection-edit-section textarea {
    min-height: 86px;
}

.connection-return-agent {
    grid-column: 1 / -1;
    min-height: 40px;
}

@media (max-width: 640px) {
    .connection-edit-grid,
    .connection-reopen-grid {
        grid-template-columns: 1fr;
    }
}

.transfer-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.transfer-mode-toggle {
    background: var(--main-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    display: grid;
    gap: 4px;
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
    padding: 4px;
}

    .transfer-mode-toggle button {
        background: transparent;
        border: 0;
        border-radius: 8px;
        color: var(--muted);
        cursor: pointer;
        font-weight: 800;
        min-height: 34px;
        padding: 7px 10px;
    }

        .transfer-mode-toggle button.selected {
            background: var(--accent);
            color: #fff;
        }

        .transfer-mode-toggle button:disabled {
            cursor: not-allowed;
            opacity: .55;
        }

@media (max-width: 720px) {
    .transfer-grid {
        grid-template-columns: 1fr;
    }
}

.company-selector {
    color: var(--muted);
    display: grid;
    font-weight: 700;
    gap: 6px;
}

.company-selector-box {
    align-items: center;
    background: var(--main-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    display: flex;
    gap: 10px;
    justify-content: space-between;
    min-height: 44px;
    padding: 8px 10px;
}

    .company-selector-box strong {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .company-selector-box div {
        display: flex;
        flex: 0 0 auto;
        gap: 8px;
    }

.tag-color-input {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: 56px 1fr;
}

    .tag-color-input input {
        min-height: 34px;
        padding: 3px;
    }

.tag-palette {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(6, 28px);
}

.tag-palette-button {
    border: 2px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    height: 28px;
    padding: 0;
    width: 28px;
}

    .tag-palette-button.selected {
        border-color: var(--accent);
        box-shadow: 0 0 0 2px rgba(156, 203, 255, .24);
    }

.contact-tag-selector {
    color: var(--muted);
    display: grid;
    font-weight: 700;
    gap: 7px;
}

.contact-tag-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.contact-tag-option {
    --tag-color: #53617a;
    align-items: center;
    background: #ffffff;
    border: 1px solid color-mix(in srgb, var(--tag-color) 38%, #d9e1ec);
    border-radius: 999px;
    color: #172033;
    cursor: pointer;
    display: inline-flex;
    font-size: .78rem;
    font-weight: 800;
    gap: 7px;
    min-height: 30px;
    padding: 0 10px;
    transition: background .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

    .contact-tag-option:hover {
        background: color-mix(in srgb, var(--tag-color) 10%, #ffffff);
        border-color: color-mix(in srgb, var(--tag-color) 55%, #cfd8e6);
    }

    .contact-tag-option.selected {
        background: color-mix(in srgb, var(--tag-color) 16%, #ffffff);
        border-color: color-mix(in srgb, var(--tag-color) 72%, #cfd8e6);
        box-shadow: 0 0 0 2px color-mix(in srgb, var(--tag-color) 14%, transparent);
    }

.contact-tag-color {
    background: var(--tag-color);
    border-radius: 999px;
    display: inline-flex;
    height: 10px;
    width: 10px;
}

.contact-tag-empty {
    color: var(--muted-2);
    font-size: .82rem;
}

.secondary-modal {
    z-index: 30;
}

.company-picker-panel {
    max-width: 720px;
    width: min(94vw, 720px);
}

.internal-chat-panel {
    max-width: 680px;
    width: min(94vw, 680px);
}

.start-conversation-panel {
    max-width: 720px;
    width: min(94vw, 720px);
}

.internal-note-panel {
    max-width: 680px;
    width: min(94vw, 680px);
}

.company-picker-list {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    margin-top: 12px;
    max-height: 420px;
    overflow: auto;
}

.company-picker-item {
    align-items: center;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    cursor: pointer;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 11px 12px;
    text-align: left;
}

    .company-picker-item:hover {
        background: rgba(255, 255, 255, 0.06);
    }

    .company-picker-item > span:first-child {
        display: grid;
        gap: 3px;
        min-width: 0;
    }

    .company-picker-item strong,
    .company-picker-item small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .company-picker-item small {
        color: var(--muted);
        font-size: 12px;
    }

    .company-picker-item .material-symbols-rounded {
        color: var(--accent);
        flex: 0 0 auto;
    }

.company-picker-empty {
    color: var(--muted);
    font-weight: 800;
    padding: 14px;
}

.internal-member-list {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    margin-top: 12px;
    max-height: 420px;
    overflow: auto;
}

.start-contact-list {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    max-height: 240px;
    overflow: auto;
}

.internal-member-item {
    align-items: center;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    cursor: pointer;
    display: grid;
    gap: 12px;
    grid-template-columns: 40px minmax(0, 1fr) 24px;
    min-height: 64px;
    padding: 10px 12px;
    text-align: left;
}

.start-contact-item {
    align-items: center;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    cursor: pointer;
    display: grid;
    gap: 12px;
    grid-template-columns: 40px minmax(0, 1fr) 24px;
    min-height: 64px;
    padding: 10px 12px;
    text-align: left;
}

    .internal-member-item:hover {
        background: rgba(255, 255, 255, 0.06);
    }

    .start-contact-item:hover,
    .start-contact-item.selected {
        background: rgba(155, 208, 255, 0.12);
    }

    .internal-member-item:disabled {
        cursor: wait;
        opacity: 0.68;
    }

    .start-contact-item:disabled {
        cursor: wait;
        opacity: 0.68;
    }

    .internal-member-item > span:nth-child(2) {
        display: grid;
        gap: 2px;
        min-width: 0;
    }

    .start-contact-item > span:nth-child(2) {
        display: grid;
        gap: 2px;
        min-width: 0;
    }

    .internal-member-item strong,
    .internal-member-item small,
    .start-contact-item strong,
    .start-contact-item small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .internal-member-item small,
    .start-contact-item small {
        color: var(--muted);
        font-size: 12px;
    }

    .internal-member-item .material-symbols-rounded,
    .start-contact-item .material-symbols-rounded {
        color: var(--accent);
    }

.internal-note-context {
    align-items: center;
    background: var(--main-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 10px;
    padding: 10px 12px;
}

    .internal-note-context > span:last-child {
        display: grid;
        gap: 2px;
        min-width: 0;
    }

    .internal-note-context strong,
    .internal-note-context small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .internal-note-context small {
        color: var(--muted);
        font-size: 12px;
    }

.internal-note-recipient-list {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    max-height: 260px;
    overflow: auto;
}

.internal-note-recipient-item {
    align-items: center;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    cursor: pointer;
    display: grid;
    gap: 12px;
    grid-template-columns: 40px minmax(0, 1fr) 24px;
    min-height: 62px;
    padding: 10px 12px;
    text-align: left;
}

    .internal-note-recipient-item:last-child {
        border-bottom: 0;
    }

    .internal-note-recipient-item:hover,
    .internal-note-recipient-item.selected {
        background: rgba(250, 204, 21, 0.12);
    }

    .internal-note-recipient-item:disabled {
        cursor: wait;
        opacity: 0.68;
    }

    .internal-note-recipient-item > span:nth-child(2) {
        display: grid;
        gap: 2px;
        min-width: 0;
    }

    .internal-note-recipient-item strong,
    .internal-note-recipient-item small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .internal-note-recipient-item small {
        color: var(--muted);
        font-size: 12px;
    }

    .internal-note-recipient-item .material-symbols-rounded {
        color: #facc15;
    }

.transfer-summary {
    background: var(--main-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    display: grid;
    gap: 4px;
    padding: 12px;
}

    .transfer-summary strong {
        font-size: 14px;
    }

    .transfer-summary span,
    .transfer-summary small {
        color: var(--muted);
        font-size: 12px;
        font-weight: 700;
    }


.return-summary {
    background: var(--main-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    display: grid;
    gap: 4px;
    padding: 12px;
}

    .return-summary strong {
        font-size: 14px;
    }

    .return-summary span {
        color: var(--muted);
        font-size: 12px;
        font-weight: 700;
    }

.return-warning {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    margin: 0;
}

.keep-summary {
    background: var(--main-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    display: grid;
    gap: 4px;
    padding: 12px;
}

    .keep-summary strong {
        font-size: 14px;
    }

    .keep-summary span {
        color: var(--muted);
        font-size: 12px;
        font-weight: 700;
    }

.close-summary {
    background: var(--main-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    display: grid;
    gap: 4px;
    padding: 12px;
}

    .close-summary strong {
        font-size: 14px;
    }

    .close-summary span {
        color: var(--muted);
        font-size: 12px;
        font-weight: 700;
    }

.keep-warning {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    margin: 0;
}

.delete-summary {
    background: rgba(239, 68, 68, 0.10);
    border: 1px solid rgba(239, 68, 68, 0.34);
    border-radius: 10px;
    display: grid;
    gap: 4px;
    padding: 12px;
}

    .delete-summary strong {
        font-size: 14px;
    }

    .delete-summary span {
        color: var(--muted);
        font-size: 12px;
        font-weight: 700;
    }

.delete-warning {
    color: #fecaca;
    font-size: 13px;
    font-weight: 800;
    margin: 0;
}

.danger-pill {
    background: var(--danger);
    color: #ffffff;
}

    .danger-pill:hover {
        background: #dc2626;
    }

/* =========================================================
   Historial del contacto
   ========================================================= */

.history-modal-panel {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: min(720px, calc(100vh - 32px));
    max-height: min(720px, calc(100vh - 32px));
    max-width: min(1040px, calc(100vw - 32px));
    overflow: hidden;
    width: min(1040px, calc(100vw - 32px));
}

.conversation-preview-modal {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: min(640px, calc(100vh - 32px));
    max-height: min(640px, calc(100vh - 32px));
    max-width: min(900px, calc(100vw - 32px));
    overflow: hidden;
    width: min(900px, calc(100vw - 32px));
}



.history-modal-header {
    align-items: center;
    display: flex;
    flex: 0 0 auto;
    gap: 16px;
    justify-content: space-between;
    min-width: 0;
}

.history-modal-title {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

    .history-modal-title h2 {
        margin: 0;
    }

    .history-modal-title small {
        color: var(--muted);
        display: block;
        font-size: 12px;
        line-height: 1.35;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

.history-modal-header-actions {
    align-items: flex-end;
    display: flex;
    flex: 0 0 auto;
    gap: 10px;
}

.history-line-selector {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 230px;
}

    .history-line-selector > span {
        color: var(--muted);
        font-size: 11px;
        font-weight: 700;
    }

    .history-line-selector select {
        background: var(--main-2);
        border: 1px solid var(--line);
        border-radius: 8px;
        box-sizing: border-box;
        color: var(--text);
        font: inherit;
        font-size: 12px;
        height: 34px;
        max-width: 320px;
        min-width: 230px;
        outline: none;
        padding: 0 32px 0 10px;
    }

        .history-line-selector select:focus {
            border-color: var(--accent);
            box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent);
        }

        .history-line-selector select:disabled {
            cursor: wait;
            opacity: 0.65;
        }

.history-line-loading {
    align-self: center;
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
}
.history-layout {
    box-sizing: border-box;
    display: grid;
    flex: 1 1 auto;
    gap: 14px;
    grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
    margin-top: 16px;
    min-height: 0;
    overflow: hidden;
}

.history-layout.preview-mode {
    grid-template-columns: minmax(0, 1fr);
}

.history-list,
.history-detail {
    border: 1px solid var(--line);
    border-radius: 8px;
    box-sizing: border-box;
    min-height: 0;
    min-width: 0;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: scroll;
    padding: 8px;
    scrollbar-width: thin;
}

.history-item {
    align-content: start;
    background: var(--main-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    display: grid;
    gap: 6px;
    flex: 0 0 auto;
    height: auto;
    min-height: 98px;
    padding: 10px;
    text-align: left;
}

.history-cycle-date {
    display: block;
    line-height: 1.35;
    min-height: 18px;
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: normal !important;
}

.history-message-preview {
    display: block;
    line-height: 1.35;
    min-height: 18px;
}

.history-cycle-head {
    align-items: center;
    display: flex;
    gap: 8px;
    min-height: 24px;
    min-width: 0;
    overflow: visible !important;
}

.history-cycle-selector {
    background: transparent;
    border: 1.5px solid var(--muted);
    border-radius: 50%;
    box-sizing: border-box;
    flex: 0 0 16px;
    height: 16px;
    overflow: visible !important;
    position: relative;
    width: 16px;
}

.history-item.selected .history-cycle-selector {
    border-color: var(--accent);
}

.history-item.selected .history-cycle-selector::after {
    background: var(--accent);
    border-radius: 50%;
    content: "";
    inset: 3px;
    position: absolute;
}

.history-cycle-head .status-chip {
    flex: 0 1 auto;
    max-width: calc(100% - 24px);
    position: relative;
    z-index: 1;
}

    .history-item:hover,
    .history-item.selected {
        background: var(--panel-soft);
        border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
    }

    .history-item strong,
    .history-item span,
    .history-item small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .history-item small,
    .history-close-note,
    .empty-note {
        color: var(--muted);
    }

    .history-item .history-topic {
        color: var(--text);
        display: -webkit-box;
        font-size: 12px;
        font-weight: 800;
        line-height: 1.35;
        max-height: 34px;
        white-space: normal;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

.history-detail {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
    padding: 10px;
}

.history-detail-header {
    align-items: flex-start;
    display: flex;
    flex: 0 0 auto;
    gap: 10px;
    justify-content: space-between;
}

    .history-detail-header div {
        display: flex;
        flex-direction: column;
        gap: 3px;
        min-width: 0;
    }

        .history-detail-header div span {
            color: var(--muted);
        }

.history-detail-header .history-topic {
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.35;
}

.history-scope-toggle {
    align-items: center;
    background: color-mix(in srgb, var(--main-2) 86%, transparent);
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex: 0 0 auto;
    gap: 9px;
    min-height: 42px;
    padding: 6px 9px;
}

    .history-scope-toggle input {
        accent-color: var(--accent);
        flex: 0 0 auto;
        height: 17px;
        margin: 0;
        width: 17px;
    }

    .history-scope-toggle span {
        display: flex;
        flex-direction: column;
        gap: 1px;
        min-width: 0;
    }

    .history-scope-toggle strong {
        font-size: 12.5px;
    }

.history-scope-toggle small {
    color: var(--muted);
    font-size: 11.5px;
}

.preview-history-note {
    color: var(--muted);
    flex: 0 0 auto;
    font-size: 12px;
    font-style: italic;
    margin: 0;
}

.history-close-note,
.empty-note {
    flex: 0 0 auto;
    margin: 0;
}

.history-messages {
    box-sizing: border-box;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow-y: scroll;
    padding-right: 8px;
    scrollbar-width: thin;
}

.history-conversation-separator {
    align-items: center;
    background: var(--main-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
    justify-content: space-between;
    padding: 7px 10px;
}

    .history-conversation-separator strong {
        font-size: 12px;
    }

    .history-conversation-separator span {
        color: var(--muted);
        font-size: 11px;
        text-align: right;
    }

.history-close-search-match {
    align-items: flex-start;
    background: color-mix(in srgb, var(--green) 10%, var(--main));
    border: 1px solid color-mix(in srgb, var(--green) 35%, var(--line));
    border-radius: 9px;
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
    padding: 9px 11px;
}

    .history-close-search-match > .material-symbols-rounded {
        color: var(--green);
        font-size: 19px;
    }

    .history-close-search-match div {
        display: flex;
        flex-direction: column;
        gap: 3px;
        min-width: 0;
    }

    .history-close-search-match strong {
        font-size: 12.5px;
    }

    .history-close-search-match small {
        color: var(--muted);
        font-size: 11.5px;
        overflow-wrap: anywhere;
    }

.load-older-button {
    align-self: center;
    margin: 6px auto 12px;
    gap: 6px;
}

    .history-messages .message-bubble {
        max-width: 76%;
    }

.message-bubble {
    overflow: visible;
}

.campaign-grid {
    align-items: stretch;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.campaign-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 190px;
}

    .campaign-card h2,
    .campaign-card p {
        line-height: 1.3;
    }

    .campaign-card .status-pill {
        margin-bottom: 0;
    }

    .campaign-card .campaign-stats {
        gap: 6px;
        margin-bottom: 6px;
    }

        .campaign-card .campaign-stats span {
            color: var(--text);
            font-size: 12.5px;
        }

    .campaign-card .wide-card-action {
        margin-top: auto;
    }

.account-page {
    align-items: start;
}

.profile-card {
    gap: 12px;
    min-height: 255px;
    padding: 26px;
}

    .profile-card h2 {
        margin: 4px 0 0;
    }

    .profile-card p {
        line-height: 1.35;
        margin-bottom: 4px;
    }

/* =========================================================
   Responsive
   ========================================================= */
@media (min-width: 861px) and (max-width: 1180px) {
    .app-shell {
        grid-template-columns: 240px minmax(0, 1fr);
    }

    .app-shell.sidebar-collapsed {
        grid-template-columns: 82px minmax(0, 1fr);
    }

    .chat-workspace {
        grid-template-columns: 340px minmax(0, 1fr);
    }
}

@media (max-width: 860px) {
    html,
    body {
        overflow: auto;
        overflow-x: hidden;
    }

    .app-shell {
        grid-template-columns: 1fr;
        grid-template-rows: 58px auto minmax(0, 1fr);
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .topbar {
        padding: 0 12px;
    }

    .brand-text {
        display: inline;
        font-size: 20px;
    }

    .sidebar {
        border-bottom: 1px solid var(--line);
        border-right: 0;
        flex-direction: row;
        grid-column: 1;
        overflow-x: auto;
        padding: 6px;
    }

    .sidebar-header {
        gap: 6px;
        margin: 0 6px 0 0;
        min-height: 44px;
    }

    .sidebar .aicon-logo-word,
    .nav-label,
    .nav-alert,
    .sidebar .switch-track {
        display: none;
    }

    .nav-panel,
    .sidebar-footer {
        flex-direction: row;
        min-width: max-content;
        overflow: visible;
    }

    .nav-entry {
        justify-content: center;
        min-width: 48px;
        padding: 0;
    }

    .sidebar-collapsed .nav-panel,
    .sidebar-collapsed .sidebar-footer {
        display: none;
    }

    .main-stage {
        overflow: visible;
    }

    .chat-workspace {
        display: flex;
        flex-direction: column;
        min-height: calc(100vh - 122px);
    }

    .conversation-panel {
        flex: 0 0 auto;
        max-height: 330px;
    }

    .chat-panel {
        min-height: 560px;
    }

    .message-bubble {
        max-width: 86%;
    }

    .module-page {
        padding: 14px;
    }

    .page-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 14px;
    }

    .ai-board,
    .account-page,
    .docs-layout {
        grid-template-columns: 1fr;
    }

    .permission-layout {
        grid-template-columns: 1fr;
    }

    .permission-toolbar {
        grid-template-columns: 1fr;
    }

    .permission-tabs {
        justify-self: stretch;
    }

        .permission-tabs button {
            flex: 1 1 0;
        }

    .permission-admin-grid,
    .permission-form-grid,
    .permission-form-grid.task-form {
        grid-template-columns: 1fr;
    }

        .permission-form-grid .wide-field {
            grid-column: auto;
        }

    .reports-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .report-two-columns {
        grid-template-columns: 1fr;
    }

    .report-line-canvas {
        overflow-x: auto;
        padding-right: 38px;
    }

    .report-line-plot,
    .report-chart-x-labels {
        min-width: 640px;
    }

    .report-ranking-list article {
        grid-template-columns: minmax(0, 1fr) 32px;
    }

        .report-ranking-list small {
            display: none;
        }

    .table-card {
        border: 0;
        overflow: visible;
    }

        .table-card table {
            border-collapse: separate;
            border-spacing: 0 10px;
            min-width: 0;
            width: 100%;
        }

        .table-card thead {
            display: none;
        }

        .table-card tbody,
        .table-card tr,
        .table-card td {
            display: block;
            width: 100%;
        }

        .table-card tr {
            background: var(--panel);
            border: 1px solid var(--line);
            border-radius: 8px;
            padding: 10px 12px;
        }

        .table-card td {
            align-items: start;
            border-bottom: 0;
            display: grid;
            gap: 8px;
            grid-template-columns: minmax(88px, 38%) minmax(0, 1fr);
            min-width: 0;
            overflow-wrap: anywhere;
            padding: 7px 0;
        }

            .table-card td::before {
                color: var(--muted);
                content: attr(data-label);
                font-size: 11px;
                font-weight: 800;
                text-transform: uppercase;
            }

            .table-card td.row-actions {
                align-items: center;
                border-top: 1px solid var(--line);
                display: flex;
                gap: 8px;
                justify-content: flex-start;
                margin-top: 6px;
                padding-top: 10px;
                text-align: left;
                white-space: normal;
            }

                .table-card td.row-actions::before {
                    content: none;
                }

                .table-card td.row-actions .material-symbols-rounded {
                    margin-left: 0;
                }
}

/* =========================================================
   Confirm dialog
   ========================================================= */

.confirm-dialog-panel {
    max-width: min(440px, calc(100vw - 32px));
    width: min(440px, calc(100vw - 32px));
}

.confirm-dialog-body {
    display: grid;
    gap: 12px;
    padding: 4px 0 8px;
}

    .confirm-dialog-body p {
        color: var(--text);
        line-height: 1.45;
        margin: 0;
        white-space: pre-line;
    }

.message-deleted {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-style: italic;
    gap: 6px;
    margin: 0;
}

/* =========================================================
   AiconChat CRM visual refresh
   ========================================================= */
.app-shell.theme-light,
.app-shell.theme-dark {
    --topbar: #ffffff;
    --sidebar: #073b78;
    --sidebar-panel: transparent;
    --main: #f4f7fb;
    --main-2: #ffffff;
    --panel: #ffffff;
    --panel-soft: #f7f9fc;
    --line: #e4e9f1;
    --text: #172033;
    --muted: #62708a;
    --muted-2: #8a96aa;
    --accent: #ff6b00;
    --accent-strong: #e95d00;
    --green: #23c55e;
    --danger: #ef4444;
    --bubble-in: #ffffff;
    --bubble-out: #dcf7d1;
    color-scheme: light;
}

body {
    background: #f4f7fb;
}

.app-shell {
    background: var(--main);
    color: var(--text);
    font-size: 13px;
    grid-template-columns: 282px minmax(0, 1fr);
    grid-template-rows: 64px minmax(0, 1fr);
}

.topbar {
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 2px 14px rgba(20, 36, 64, 0.06);
    grid-column: 2;
    grid-row: 1;
}

.topbar .icon-button,
.topbar .small-icon-button {
    color: #25324a;
}

    .topbar .icon-button:hover,
    .topbar .small-icon-button:hover {
        background: #f1f5fb;
    }

.notification-badge,
.unread-badge,
.filter-count,
.filter-chip span {
    background: var(--accent);
    color: #ffffff;
}

.sidebar {
    background: linear-gradient(180deg, #073b78 0%, #052e61 100%);
    border-right: 0;
    grid-column: 1;
    grid-row: 1 / -1;
    padding: 18px 12px 16px;
}

.main-stage {
    grid-column: 2;
    grid-row: 2;
}

.aicon-logo {
    align-items: center;
    display: inline-flex;
    gap: 11px;
    min-width: 0;
    text-decoration: none;
}

.sidebar-header {
    align-items: center;
    display: flex;
    flex: 0 0 auto;
    gap: 6px;
    justify-content: space-between;
    margin: 2px 2px 26px;
    min-height: 50px;
    min-width: 0;
}

.sidebar-logo {
    flex: 1 1 auto;
    margin: 0;
    min-height: 50px;
    overflow: hidden;
}

.sidebar-toggle-button {
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 34px;
    height: 34px;
    justify-content: center;
    padding: 0;
    transition: background-color 0.16s ease, border-color 0.16s ease;
    width: 34px;
}

.sidebar-toggle-button:hover,
.sidebar-toggle-button:focus-visible {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.48);
}

.sidebar-toggle-button:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.sidebar-toggle-button .material-symbols-rounded {
    font-size: 21px;
}

.aicon-logo-mark {
    flex: 0 0 auto;
    height: 42px;
    object-fit: contain;
    width: 42px;
}

.aicon-logo-word {
    align-items: center;
    display: inline-flex;
    gap: 4px;
    line-height: 1;
}

.aicon-wordmark-image {
    display: inline-block;
    height: 26px;
    object-fit: contain;
    width: auto;
}

.sidebar .aicon-wordmark-image {
    filter: brightness(0) invert(1);
}

.logo-chat {
    color: #ff7a00;
    font-family: "Audiowide", Inter, "Segoe UI", system-ui, sans-serif;
    font-size: 24px;
    font-weight: 400;
    letter-spacing: -0.03em;
    line-height: 1;
    transform: translateY(1px);
}

.sidebar .aicon-logo {
    gap: 9px;
}

.sidebar .aicon-logo-word {
    gap: 3px;
    min-width: 0;
}

.sidebar .aicon-wordmark-image {
    height: 25px;
}

.sidebar .logo-chat {
    font-size: 22px;
    letter-spacing: 0;
    transform: none;
}

.login-brand .aicon-logo-word {
    margin: 0;
}

.login-brand .aicon-logo-mark {
    height: 48px;
    width: 48px;
}

.login-brand .aicon-wordmark-image {
    height: 30px;
}

.login-brand .logo-chat {
    font-size: 28px;
}

.sidebar-collapsed .aicon-logo-word {
    display: none;
}

.sidebar-collapsed .sidebar-logo {
    display: none;
}

.sidebar-collapsed .sidebar-header {
    justify-content: center;
    margin-left: 0;
    margin-right: 0;
}

.nav-panel,
.sidebar-footer {
    background: transparent;
    border-radius: 0;
    gap: 8px;
    padding: 0;
}

.nav-entry {
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.88);
    min-height: 44px;
    padding: 0 14px;
}

    .nav-entry:hover,
    .nav-entry.active,
    .theme-light .nav-entry:hover,
    .theme-light .nav-entry.active {
        background: rgba(255, 255, 255, 0.13);
        color: #ffffff;
    }

    .nav-entry.active {
        box-shadow: inset 3px 0 0 var(--accent);
    }

.nav-label {
    font-size: 14px;
    font-weight: 750;
}

.account-avatar {
    background: #ffffff;
    color: #073b78;
}

.switch-track {
    background: rgba(255, 255, 255, 0.24);
}

    .switch-track.on {
        background: rgba(255, 107, 0, 0.85);
    }

.main-stage {
    background: var(--main);
}

.workspace,
.chat-workspace,
.chat-panel {
    background: var(--main);
}

.chat-workspace {
    grid-template-columns: 430px minmax(0, 1fr);
}

.conversation-panel {
    background: #ffffff;
    border-right: 1px solid var(--line);
    box-shadow: 8px 0 24px rgba(23, 32, 51, 0.04);
    padding: 18px 14px;
}

.search-toolbar {
    background: transparent;
    border: 0;
    gap: 8px;
    padding: 0 0 14px;
}

.conversation-inbox-tabs {
    display: grid;
    gap: 6px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0 0 12px;
}

.conversation-inbox-tab {
    align-items: center;
    background: #f7f9fc;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #33415c;
    cursor: pointer;
    display: grid;
    font-size: 11.5px;
    font-weight: 760;
    gap: 6px;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    min-height: 34px;
    min-width: 0;
    padding: 7px 8px;
    text-align: left;
}

    .conversation-inbox-tab:hover,
    .conversation-inbox-tab.active {
        background: #eef5ff;
        border-color: #b8d6fb;
        color: #173057;
    }

    .conversation-inbox-tab .material-symbols-rounded {
        font-size: 18px;
    }

.inbox-tab-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inbox-tab-count {
    background: #ffffff;
    border: 1px solid #dbe5f2;
    border-radius: 999px;
    color: #315d94;
    font-size: 11px;
    font-weight: 820;
    line-height: 1;
    min-width: 22px;
    padding: 4px 6px;
    text-align: center;
}

    .search-toolbar input,
    .composer input,
    .composer-input-host input,
    .composer-input-host textarea {
        background: #f7f9fc;
        border: 1px solid var(--line);
        border-radius: 10px;
        color: var(--text);
        min-height: 42px;
        padding: 10px 14px;
    }

        .search-toolbar input::placeholder,
        .composer input::placeholder,
        .composer-input-host input::placeholder,
        .composer-input-host textarea::placeholder {
            color: #9aa5b8;
        }

.small-icon-button,
.icon-button {
    border-radius: 999px;
    color: #33415c;
}

    .small-icon-button:hover,
    .icon-button:hover {
        background: #eef3fa;
    }

.filter-row {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 14px 34px rgba(23, 32, 51, 0.08);
    margin-bottom: 12px;
    padding: 12px;
}

.status-filter-trigger,
.status-filter-option,
.scope-select,
.unit-toolbar input,
.unit-toolbar select,
.priority-select,
.routing-select,
.permission-mode,
.modal-form input,
.modal-form select,
.modal-form textarea,
.prompt-panel textarea,
.theme-card select {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
}

.status-filter-menu,
.conversation-context-menu,
.contact-column-menu,
.message-context-menu {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 18px 44px rgba(23, 32, 51, 0.14);
}

.conversation-context-menu button,
.conversation-context-menu .material-symbols-rounded,
.message-context-menu button {
    color: var(--text);
}

    .conversation-context-menu button:hover,
    .message-context-menu button:hover {
        background: #f5f7fb;
    }

.conversation-list {
    padding-right: 4px;
}

.conversation-item {
    border: 1px solid transparent;
    border-bottom-color: var(--line);
    border-radius: 12px;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    margin-bottom: 6px;
    min-height: 78px;
    padding: 10px 34px 10px 10px;
}

    .conversation-item:hover,
    .conversation-item.selected,
    .theme-light .conversation-item:hover,
    .theme-light .conversation-item.selected {
        background: #eef5ff;
        border-color: #d8e7fb;
        color: var(--text);
    }

.conversation-title {
    color: #172033;
    font-size: 14px;
    font-weight: 820;
}

.conversation-preview {
    color: #56657d;
    font-size: 12.5px;
    font-weight: 550;
}

.conversation-meta,
.theme-light .conversation-meta {
    color: #65738a;
}

.avatar,
.account-avatar.big {
    background: linear-gradient(135deg, #dbeafe, #fef3c7);
    color: #173057;
}

.avatar.large {
    height: 52px;
    width: 52px;
}

.branch-chip,
.unit-type,
.agent-chip,
.tag-chip,
.status-chip,
.priority-chip {
    border-radius: 999px;
}

.branch-chip,
.agent-chip {
    background: #f0f6ff;
    border-color: #d8e7fb;
    color: #315d94;
}

.tag-chip {
    background: color-mix(in srgb, var(--tag-color) 12%, #ffffff);
    border-color: color-mix(in srgb, var(--tag-color) 34%, #e4e9f1);
    color: #34425a;
}

.status-chip,
.priority-chip {
    color: #26324a;
}


.chat-header {
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    min-height: 84px;
    padding: 14px 24px;
}

    .chat-header h1 {
        color: #172033;
        font-size: 18px;
        font-weight: 850;
    }

    .chat-header p {
        color: var(--muted);
    }

.primary-pill,
.secondary-button {
    background: var(--accent);
    border-radius: 999px;
    color: #ffffff;
    min-height: 38px;
}

    .primary-pill:hover,
    .chat-header-actions .primary-pill:hover {
        background: var(--accent-strong);
    }

.secondary-button {
    background: #eef3fa;
    color: #33415c;
}

.routing-strip,
.message-search-toolbar,
.tag-strip {
    background: #ffffff;
    border-bottom: 1px solid var(--line);
}

.routing-strip {
    align-items: end;
    padding: 12px 24px;
}

.message-search-toolbar input {
    background: #f7f9fc;
    border: 1px solid var(--line);
    color: var(--text);
    min-height: 36px;
}

.message-surface {
    background-color: #f5efe5;
    background-image: radial-gradient(circle at 20px 20px, rgba(7, 59, 120, 0.045) 0 1px, transparent 2px), radial-gradient(circle at 72px 54px, rgba(255, 107, 0, 0.04) 0 1px, transparent 2px);
    background-size: 90px 90px;
    padding: 18px 26px 22px;
}

.day-separator {
    background: #ffffff;
    border: 1px solid var(--line);
    box-shadow: 0 4px 12px rgba(23, 32, 51, 0.06);
    color: #65738a;
    padding: 7px 18px;
}

.message-bubble {
    border: 1px solid rgba(23, 32, 51, 0.08);
    border-radius: 12px;
    box-shadow: 0 3px 10px rgba(23, 32, 51, 0.08);
    color: #172033;
    max-width: min(560px, 72%);
    padding: 10px 12px 7px;
}

    .message-bubble.inbound,
    .theme-light .message-bubble.inbound {
        background: #ffffff;
    }

    .message-bubble.outbound,
    .theme-light .message-bubble.outbound {
        background: #ddf8d4;
    }

    .message-bubble.internal-note,
    .theme-light .message-bubble.internal-note {
        background: #fff7db;
        border-color: #f6d783;
    }

    .message-bubble p {
        font-size: 13px;
        font-weight: 550;
        line-height: 1.42;
    }

    .message-bubble time,
    .theme-light .message-bubble time {
        color: #728096;
        font-weight: 650;
    }

.reply-snippet,
.attachment-pill {
    background: rgba(7, 59, 120, 0.07);
}

.composer {
    background: #ffffff;
    border-top: 1px solid var(--line);
    gap: 10px;
    min-height: 68px;
    padding: 10px 18px;
}

.composer .composer-tool-button {
    background: #073b78;
    color: #ffffff;
}

.composer .composer-tool-button:hover:not(:disabled):not(.disabled) {
    background: #0b4b92;
    color: #ffffff;
}

.composer .composer-internal-note-button {
    background: #92400e;
    color: #ffffff;
}

.composer .composer-internal-note-button:hover:not(:disabled):not(.disabled) {
    background: #b45309;
    color: #ffffff;
}

.composer .small-icon-button.recording:not(:disabled) {
    background: #dc2626;
    color: #ffffff;
}

.module-page {
    background: var(--main);
    padding: 28px min(5vw, 72px);
}

.page-heading h1,
.reports-header h1,
.report-card h2 {
    color: #073b78;
}

.connection-card,
.mini-card,
.campaign-card,
.metric-card,
.plan-card,
.support-card,
.ai-panel,
.prompt-panel,
.profile-card,
.theme-card,
.chart-card,
.docs-layout article,
.reports-header,
.reports-filter-bar,
.report-tabs,
.report-card,
.setting-row,
.table-card,
.permission-panel,
.modal-panel {
    background: #ffffff;
    border: 1px solid var(--line);
    box-shadow: 0 10px 28px rgba(23, 32, 51, 0.06);
}

table {
    background: #ffffff;
}

th {
    background: #f7f9fc;
    color: #33415c;
}

td {
    color: #243047;
}

td span,
.connection-title p,
.campaign-card p,
.support-card p,
.plan-card p,
.ai-panel p,
.profile-card p,
.setting-row p,
.docs-layout p,
.metric-card p,
.metric-card span {
    color: var(--muted);
}

.reports-filter-bar input,
.reports-filter-bar select,
.permission-header-filter select,
.permission-form-grid input,
.contact-column-menu,
.company-selector-box,
.internal-note-context,
.transfer-summary,
.return-summary,
.keep-summary,
.close-summary,
.history-item,
.history-list,
.history-detail {
    background: #ffffff;
    color: var(--text);
}

.form-error {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #b91c1c;
}

.form-info,
.contact-import-status {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.login-stage {
    --main-2: #ffffff;
    --panel: #ffffff;
    --line: #e4e9f1;
    --text: #172033;
    --muted: #62708a;
    --accent: #ff6b00;
    align-items: center;
    background: linear-gradient(135deg, #073b78 0%, #0b4b92 42%, #f4f7fb 42%, #ffffff 100%);
    color: var(--text);
    display: grid;
    min-height: 100%;
}

.login-panel {
    background: #ffffff;
    border: 1px solid rgba(228, 233, 241, 0.92);
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(7, 59, 120, 0.2);
}

.login-brand .brand-mark {
    background: #073b78;
    color: #ffffff;
}

.login-brand h1 {
    color: #0d1b2f;
}

.login-brand p {
    color: var(--muted);
}

.login-panel input {
    background: #f7f9fc;
    border: 1px solid var(--line);
    color: var(--text);
}

@media (min-width: 861px) and (max-width: 1180px) {
    .app-shell {
        grid-template-columns: 240px minmax(0, 1fr);
    }

    .app-shell.sidebar-collapsed {
        grid-template-columns: 82px minmax(0, 1fr);
    }

    .sidebar .aicon-logo-word {
        display: none;
    }

    .sidebar-logo {
        justify-content: flex-start;
    }

    .chat-workspace {
        grid-template-columns: 360px minmax(0, 1fr);
    }
}

/* Estado del sistema: resumen operativo y detalle técnico progresivo. */
.diagnostic-overview {
    display: grid;
    gap: 12px;
}

.diagnostic-overview-banner {
    align-items: center;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-left-width: 5px;
    border-radius: 8px;
    display: grid;
    gap: 14px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    min-width: 0;
    padding: 16px 18px;
}

.diagnostic-overview-banner.ok {
    background: #ecfdf3;
    border-color: #86d9aa;
}

.diagnostic-overview-banner.warning {
    background: #fffbeb;
    border-color: #f2c94c;
}

.diagnostic-overview-banner.error {
    background: #fff1f2;
    border-color: #fda4af;
}

.diagnostic-overview-main-icon {
    font-size: 34px;
}

.diagnostic-overview-banner.ok .diagnostic-overview-main-icon {
    color: #067647;
}

.diagnostic-overview-banner.warning .diagnostic-overview-main-icon {
    color: #9a6700;
}

.diagnostic-overview-banner.error .diagnostic-overview-main-icon {
    color: #b42318;
}

.diagnostic-overview-label {
    color: #53627a;
    display: block;
    font-size: .72rem;
    font-weight: 900;
    margin-bottom: 3px;
    text-transform: uppercase;
}

.diagnostic-overview-banner h2 {
    color: var(--text);
    font-size: 1.08rem;
    margin: 0;
}

.diagnostic-overview-banner p {
    color: #53627a;
    font-size: .82rem;
    font-weight: 650;
    line-height: 1.4;
    margin: 4px 0 0;
}

.diagnostic-overview-updated {
    align-items: flex-end;
    display: flex;
    flex-direction: column;
    min-width: max-content;
}

.diagnostic-overview-updated span {
    color: #64748b;
    font-size: .72rem;
    font-weight: 800;
}

.diagnostic-overview-updated strong {
    color: var(--text);
    font-size: .78rem;
    margin-top: 3px;
}

.diagnostic-overview-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
}

.diagnostic-overview-card {
    background: #ffffff;
    border: 1px solid #d8e0eb;
    border-left: 4px solid #94a3b8;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    min-height: 158px;
    min-width: 0;
    padding: 13px 14px;
}

.diagnostic-overview-card.ok {
    border-left-color: #12b76a;
}

.diagnostic-overview-card.warning {
    border-left-color: #eaaa08;
}

.diagnostic-overview-card.error {
    border-left-color: #f04438;
}

.diagnostic-overview-card > header {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 9px;
}

.diagnostic-overview-card > header > .material-symbols-rounded {
    color: #174a82;
    font-size: 24px;
}

.diagnostic-overview-card h3 {
    color: var(--text);
    font-size: .8rem;
    margin: 0 0 5px;
}

.diagnostic-overview-card > strong {
    color: #0b376b;
    font-size: 1.08rem;
    margin-bottom: 5px;
}

.diagnostic-overview-card p {
    color: #5f6e84;
    font-size: .76rem;
    font-weight: 650;
    line-height: 1.38;
    margin: auto 0 0;
}

.diagnostic-status.ok {
    background: #ecfdf3;
    border-color: #a6e3c3;
    color: #067647;
}

.diagnostic-status.warning {
    background: #fffaeb;
    border-color: #f4d38a;
    color: #8a5d00;
}

.diagnostic-status.error {
    background: #fff1f2;
    border-color: #fda4af;
    color: #b42318;
}

.diagnostic-status.muted {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #526176;
}

.diagnostic-check-card.ok {
    border-color: #a6e3c3;
    color: #067647;
}

.diagnostic-check-card.warning {
    border-color: #f4d38a;
    color: #8a5d00;
}

.diagnostic-check-card.error {
    border-color: #fda4af;
    color: #b42318;
}

.diagnostic-overview-success {
    align-items: center;
    background: #f0fdf4;
    border: 1px solid #bbefcf;
    border-radius: 8px;
    color: #067647;
    display: flex;
    gap: 10px;
    padding: 12px 14px;
}

.diagnostic-overview-success > .material-symbols-rounded {
    font-size: 23px;
}

.diagnostic-overview-success strong,
.diagnostic-overview-success small {
    display: block;
}

.diagnostic-overview-success strong {
    font-size: .8rem;
}

.diagnostic-overview-success small {
    color: #3f6f57;
    font-size: .75rem;
    font-weight: 650;
    margin-top: 2px;
}

.diagnostic-overview-alerts {
    background: #ffffff;
    border: 1px solid #d8e0eb;
    border-radius: 8px;
    display: grid;
    gap: 10px;
    padding: 13px 14px;
}

.diagnostic-overview-alerts > header {
    align-items: center;
    display: flex;
    justify-content: space-between;
}

.diagnostic-overview-alerts h2 {
    color: var(--text);
    font-size: .9rem;
    margin: 0;
}

.diagnostic-overview-alerts header small {
    color: #64748b;
    display: block;
    font-size: .74rem;
    font-weight: 700;
    margin-top: 2px;
}

.diagnostic-overview-alerts > header > span {
    align-items: center;
    background: #fff1f2;
    border: 1px solid #fda4af;
    border-radius: 999px;
    color: #b42318;
    display: inline-flex;
    font-size: .76rem;
    font-weight: 900;
    height: 28px;
    justify-content: center;
    min-width: 28px;
}

.diagnostic-overview-alert-list {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.diagnostic-overview-alert-list article {
    align-items: flex-start;
    background: #f8fafc;
    border: 1px solid #d8e0eb;
    border-left: 4px solid #94a3b8;
    border-radius: 6px;
    display: grid;
    gap: 9px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    min-width: 0;
    padding: 10px 11px;
}

.diagnostic-overview-alert-list article.warning {
    background: #fffbeb;
    border-left-color: #eaaa08;
}

.diagnostic-overview-alert-list article.error {
    background: #fff5f5;
    border-left-color: #f04438;
}

.diagnostic-overview-alert-list article > .material-symbols-rounded {
    color: #174a82;
    font-size: 21px;
}

.diagnostic-overview-alert-list strong,
.diagnostic-overview-alert-list small,
.diagnostic-overview-alert-list em {
    display: block;
}

.diagnostic-overview-alert-list strong {
    color: var(--text);
    font-size: .76rem;
}

.diagnostic-overview-alert-list small,
.diagnostic-overview-alert-list em {
    color: #64748b;
    font-size: .73rem;
    font-style: normal;
    font-weight: 650;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.diagnostic-overview-alert-list em {
    margin-top: 3px;
}

.diagnostic-overview-alert-list b {
    color: var(--text);
    font-size: .86rem;
}

.diagnostic-overview-more {
    color: #64748b;
    font-size: .74rem;
    font-weight: 700;
    margin: 0;
}

.diagnostic-overview-facts {
    align-items: center;
    background: #f8fafc;
    border: 1px solid #d8e0eb;
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    padding: 10px 13px;
}

.diagnostic-overview-facts > span {
    align-items: center;
    color: #5f6e84;
    display: inline-flex;
    font-size: .74rem;
    font-weight: 700;
    gap: 5px;
}

.diagnostic-overview-facts .material-symbols-rounded {
    color: #174a82;
    font-size: 17px;
}

.diagnostic-overview-facts strong {
    color: var(--text);
}

.diagnostic-technical-toggle {
    align-items: center;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    display: grid;
    gap: 10px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 11px 14px;
    text-align: left;
    transition: border-color .15s ease, background-color .15s ease;
    width: 100%;
}

.diagnostic-technical-toggle:hover,
.diagnostic-technical-toggle:focus-visible {
    background: #f8fafc;
    border-color: #174a82;
    outline: none;
}

.diagnostic-technical-toggle > .material-symbols-rounded {
    color: #174a82;
    font-size: 22px;
}

.diagnostic-technical-toggle strong,
.diagnostic-technical-toggle small {
    display: block;
}

.diagnostic-technical-toggle strong {
    font-size: .8rem;
}

.diagnostic-technical-toggle small {
    color: #64748b;
    font-size: .73rem;
    font-weight: 650;
    margin-top: 2px;
}

.diagnostic-overview-stale {
    align-items: center;
    background: #fffbeb;
    border: 1px solid #f4d38a;
    border-radius: 8px;
    color: #8a5d00;
    display: flex;
    gap: 10px;
    padding: 12px 14px;
}

.diagnostic-overview-stale > .material-symbols-rounded {
    flex: 0 0 auto;
    font-size: 23px;
}

.diagnostic-overview-stale strong,
.diagnostic-overview-stale small {
    display: block;
}

.diagnostic-overview-stale strong {
    color: #6f4b00;
    font-size: .8rem;
}

.diagnostic-overview-stale small {
    color: #7a5b1d;
    font-size: .75rem;
    font-weight: 650;
    margin-top: 2px;
}

.diagnostic-technical-shell {
    animation: diagnostic-detail-enter .18s ease-out;
    border-top: 1px solid #d8e0eb;
    display: grid;
    gap: 12px;
    padding-top: 12px;
}

@keyframes diagnostic-detail-enter {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 980px) {
    .diagnostic-overview-banner {
        align-items: flex-start;
        grid-template-columns: auto minmax(0, 1fr);
    }

    .diagnostic-overview-updated {
        align-items: flex-start;
        grid-column: 2;
    }

    .diagnostic-overview-alert-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .diagnostic-overview-banner {
        grid-template-columns: 1fr;
        padding: 14px;
    }

    .diagnostic-overview-main-icon {
        font-size: 30px;
    }

    .diagnostic-overview-updated {
        grid-column: auto;
    }

    .diagnostic-overview-grid {
        grid-template-columns: 1fr;
    }

    .diagnostic-overview-alert-list article {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .diagnostic-overview-alert-list article > b {
        grid-column: 2;
    }
}

@media (prefers-reduced-motion: reduce) {
    .diagnostic-technical-shell {
        animation: none;
    }
}

@media (max-width: 860px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-rows: 58px auto minmax(0, 1fr);
    }

    .app-shell.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    .topbar {
        grid-column: 1;
        grid-row: 1;
    }

    .sidebar {
        background: #073b78;
        grid-column: 1;
        grid-row: 2;
    }

    .sidebar-header {
        gap: 6px;
        margin: 0 6px 0 0;
        min-height: 44px;
    }

    .sidebar .aicon-logo-word {
        display: none;
    }

    .main-stage {
        grid-column: 1;
        grid-row: 3;
    }

    .sidebar-logo {
        margin: 0;
    }

    .conversation-panel {
        max-height: 360px;
    }

    .message-bubble {
        max-width: 88%;
    }

    .login-stage {
        background: #f4f7fb;
        padding: 18px;
    }
}

    .message-deleted .material-symbols-rounded {
        font-size: 16px;
    }

.message-bubble.deleted {
    opacity: .82;
}

.message-state-label {
    color: var(--muted);
    display: inline-block;
    font-size: 10.5px;
    font-style: italic;
    font-weight: 700;
    margin-top: 4px;
}

.message-state-label--error {
    color: #dc2626;
    font-style: normal;
}

.message-bubble .message-status--failed,
.theme-light .message-bubble .message-status--failed {
    color: #dc2626;
}

.message-bubble .message-status--failed .material-symbols-rounded,
.theme-light .message-bubble .message-status--failed .material-symbols-rounded {
    color: #dc2626;
}

.message-bubble .message-status--delivered .material-symbols-rounded,
.message-bubble .message-status--read .material-symbols-rounded,
.theme-light .message-bubble .message-status--delivered .material-symbols-rounded,
.theme-light .message-bubble .message-status--read .material-symbols-rounded {
    color: #2563eb;
}

.internal-note-meta {
    align-items: center;
    color: #f7e8a0;
    display: flex;
    flex-wrap: wrap;
    font-size: 11px;
    font-weight: 800;
    gap: 6px;
    margin-bottom: 5px;
}

.internal-note-badge {
    align-items: center;
    background: rgba(250, 204, 21, 0.16);
    border: 1px solid rgba(250, 204, 21, 0.32);
    border-radius: 6px;
    display: inline-flex;
    gap: 4px;
    padding: 3px 6px;
}

    .internal-note-badge .material-symbols-rounded {
        font-size: 14px;
    }

.theme-light .internal-note-meta {
    color: #7c4a03;
}


.message-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0;
}

.message-footer {
    align-items: center;
    display: flex;
    gap: 2px;
    justify-content: flex-end;
    margin-top: 4px;
}

    .message-footer time {
        margin-top: 0;
    }

.message-action {
    align-items: center;
    background: transparent;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    height: 24px;
    justify-content: center;
    padding: 0;
    width: 24px;
}

    .message-action:hover {
        color: var(--danger, #ef4444);
    }

    .message-action .material-symbols-rounded {
        font-size: 17px;
    }

.message-select-toggle {
    align-items: center;
    background: rgba(15, 23, 42, 0.26);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 6px;
    color: var(--accent);
    cursor: pointer;
    display: inline-flex;
    height: 26px;
    justify-content: center;
    left: 8px;
    padding: 0;
    position: absolute;
    top: 8px;
    width: 26px;
}

    .message-select-toggle:disabled {
        color: var(--muted-2);
        cursor: not-allowed;
        opacity: .55;
    }

    .message-select-toggle .material-symbols-rounded {
        font-size: 18px;
    }

.forward-message-panel {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 32px);
    max-width: 760px;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    width: min(96vw, 760px);
}

    .forward-message-panel > header {
        flex: 0 0 auto;
        padding: 16px 18px 12px;
    }

    .forward-message-panel > .modal-form {
        flex: 1 1 auto;
        margin-top: 0;
        min-height: 0;
        overflow: auto;
        padding: 0 18px 14px;
    }

    .forward-message-panel > footer {
        border-top: 1px solid var(--border);
        flex: 0 0 auto;
        margin-top: 0;
        padding: 12px 18px 16px;
    }

.forward-route-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.forward-route-card {
    display: grid;
    gap: 6px;
}

    .forward-route-card label {
        color: var(--muted);
        font-size: 12px;
        font-weight: 700;
    }

.forward-route-value {
    align-items: center;
    background: rgba(148, 163, 184, .10);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    gap: 12px;
    min-height: 56px;
    padding: 10px 12px;
}

    .forward-route-value strong {
        display: block;
    }

    .forward-route-value span {
        color: var(--muted);
        font-size: 12px;
    }

.whatsapp-route-icon {
    color: #22c55e;
}

.route-dot {
    background: #0891b2;
    border-radius: 999px;
    display: inline-block;
    height: 10px;
    width: 10px;
}

.forward-route-card > span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.forward-route-select {
    background: rgba(148, 163, 184, .10);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    min-height: 56px;
    padding: 0 12px;
    width: 100%;
}

.forward-preview {
    align-items: flex-start;
    background: rgba(148, 163, 184, .12);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    gap: 10px;
    padding: 12px;
}

    .forward-preview p {
        color: var(--muted);
        margin: 4px 0 0;
    }

    .forward-preview small {
        color: var(--muted);
        display: inline-block;
        font-size: 12px;
        font-weight: 800;
        margin-top: 5px;
    }

.forward-destination-tabs {
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
}

.forward-destination-tab {
    align-items: center;
    background: transparent;
    border: 0;
    color: var(--muted);
    display: inline-flex;
    font-weight: 800;
    gap: 8px;
    justify-content: center;
    min-height: 42px;
}

    .forward-destination-tab + .forward-destination-tab {
        border-left: 1px solid var(--border);
    }

    .forward-destination-tab.active {
        background: rgba(96, 165, 250, .14);
        color: var(--text);
    }

.forward-list {
    border: 1px solid var(--border);
    border-radius: 12px;
    display: grid;
    max-height: min(30dvh, 260px);
    overflow: auto;
}

.forward-list-heading {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    margin-bottom: -4px;
    margin-top: 2px;
}

.forward-item {
    align-items: center;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    display: grid;
    gap: 12px;
    grid-template-columns: auto 1fr auto;
    padding: 12px;
    text-align: left;
}

    .forward-item:last-child {
        border-bottom: 0;
    }

    .forward-item:hover,
    .forward-item.selected {
        background: rgba(96, 165, 250, .12);
    }

.forward-item-main {
    display: grid;
    gap: 2px;
}

    .forward-item-main small,
    .forward-item-main span {
        color: var(--muted);
        font-size: 12px;
    }

@media (max-width: 680px) {
    .modal-backdrop {
        align-items: stretch;
        padding: 8px;
    }

    .forward-message-panel {
        max-height: calc(100dvh - 16px);
        width: 100%;
    }

    .forward-route-grid {
        grid-template-columns: 1fr;
    }

    .forward-destination-tab {
        font-size: 12px;
        min-height: 38px;
    }

    .forward-list {
        max-height: 34dvh;
    }
}

.message-deleted-detail {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.message-deleted-badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    color: #fecaca;
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .02em;
}

    .message-deleted-badge .material-symbols-rounded {
        font-size: 1rem;
    }

.message-deleted-detail p {
    margin: 0;
    color: #fee2e2;
    font-style: normal;
}

.message-deleted-detail small {
    color: #fca5a5;
    font-size: .72rem;
}

.message-deleted-empty {
    opacity: .75;
    font-style: italic !important;
}


.message-bubble.deleted-visible {
    border: 1px solid rgba(248, 113, 113, .85);
    background: rgba(127, 29, 29, .28) !important;
    box-shadow: 0 0 0 1px rgba(248, 113, 113, .12);
    opacity: .98;
}

    .message-bubble.deleted-visible.outbound {
        background: rgba(127, 29, 29, .34) !important;
    }

    .message-bubble.deleted-visible.inbound {
        background: rgba(127, 29, 29, .22) !important;
    }

/* =========================================================
   Composer - respuestas rápidas
   ========================================================= */
.quick-reply-composer-shell {
    position: relative;
}

.suggested-reply-composer-shell {
    position: relative;
}

.suggested-reply-picker {
    background: #ffffff;
    border: 1px solid #e4e9f1;
    border-radius: 8px;
    bottom: 48px;
    box-shadow: 0 18px 44px rgba(23, 32, 51, 0.16);
    color: #172033;
    display: grid;
    gap: 10px;
    padding: 12px;
    position: absolute;
    right: 0;
    width: min(380px, calc(100vw - 32px));
    z-index: 52;
}

.suggested-reply-picker-header,
.suggested-reply-picker-header > span,
.suggested-reply-loading,
.suggested-reply-option {
    align-items: center;
    display: flex;
}

.suggested-reply-picker-header {
    justify-content: space-between;
}

.suggested-reply-picker-header > span {
    gap: 4px;
}

.suggested-reply-list {
    display: grid;
    gap: 6px;
    max-height: 280px;
    overflow-y: auto;
}

.suggested-reply-option {
    background: #f7f9fc;
    border: 1px solid #e4e9f1;
    border-radius: 7px;
    color: #172033;
    cursor: pointer;
    gap: 10px;
    justify-content: space-between;
    line-height: 1.4;
    min-height: 48px;
    padding: 10px 12px;
    text-align: left;
    width: 100%;
}

.suggested-reply-option:hover {
    background: #eef5ff;
    border-color: #cbdcf4;
}

.suggested-reply-option > span:first-child {
    min-width: 0;
    overflow-wrap: anywhere;
}

.suggested-reply-option .material-symbols-rounded {
    color: #ff6800;
    flex: 0 0 auto;
    font-size: 18px;
}

.suggested-reply-loading {
    color: #667085;
    gap: 8px;
    min-height: 70px;
    justify-content: center;
}

@media (max-width: 860px) {
    .suggested-reply-picker {
        bottom: 72px;
        left: 12px;
        max-height: calc(100vh - 96px);
        position: fixed;
        right: 12px;
        width: auto;
    }

    .suggested-reply-list {
        max-height: min(42vh, 280px);
    }
}

.emoji-composer-shell {
    display: inline-flex;
    position: relative;
}

.emoji-picker {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    bottom: 48px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.28);
    display: grid;
    gap: 4px;
    grid-template-columns: repeat(8, 32px);
    /* Con 128 emojis el panel scrollea (unas 9 filas visibles) en vez de tapar el chat. */
    max-height: 340px;
    overflow-y: auto;
    overscroll-behavior: contain;
    left: 0;
    padding: 10px;
    position: absolute;
    z-index: 55;
}

.emoji-picker button {
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    height: 32px;
    line-height: 1;
    width: 32px;
}

.emoji-picker button:hover {
    background: rgba(147, 197, 253, 0.16);
}

.quick-reply-picker {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 16px;
    bottom: 48px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
    gap: 10px;
    left: 0;
    max-height: 360px;
    min-width: 360px;
    padding: 12px;
    position: absolute;
    z-index: 50;
}

.quick-reply-picker-header {
    align-items: center;
    color: var(--text);
    display: flex;
    justify-content: space-between;
}

.quick-reply-search {
    background: #3b465b;
    border: 0;
    border-radius: 12px;
    color: var(--text);
    outline: 0;
    padding: 9px 12px;
    width: 100%;
}

.quick-reply-picker-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 250px;
    overflow-y: auto;
}

.quick-reply-option {
    align-items: flex-start;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--text);
    cursor: pointer;
    display: grid;
    gap: 8px;
    grid-template-columns: auto 1fr auto;
    padding: 9px 10px;
    text-align: left;
}

.quick-reply-option:hover {
    background: rgba(255, 255, 255, 0.11);
    border-color: rgba(255, 255, 255, 0.16);
}

.quick-reply-option-shortcut {
    background: rgba(56, 189, 248, 0.16);
    border-radius: 999px;
    color: #7dd3fc;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 8px;
}

.quick-reply-option-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.quick-reply-option-body small {
    color: var(--muted);
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.quick-reply-option-scope {
    color: var(--muted-2);
    font-size: 11px;
    white-space: nowrap;
}

.quick-reply-empty {
    color: var(--muted);
    margin: 6px 0;
}

.theme-light .quick-reply-picker,
.theme-light .quick-reply-search {
    background: #d8e1eb;
}

.theme-light .quick-reply-option {
    background: rgba(15, 23, 42, 0.06);
}

.theme-light .quick-reply-option:hover {
    background: rgba(15, 23, 42, 0.11);
}

/* =========================================================
   AiconChat CRM visual refresh - final normalization
   Mantener este bloque al final para pisar estilos heredados oscuros.
   ========================================================= */
.app-shell.theme-light,
.app-shell.theme-dark,
.login-stage {
    --border: #e4e9f1;
    --panel-2: #ffffff;
    --hover: #f2f6fc;
}

.theme-dark .brand-mark,
.theme-light .brand-mark {
    background: transparent;
}

.theme-dark .module-page,
.theme-light .module-page,
.theme-dark .workspace,
.theme-light .workspace {
    background: #f4f7fb;
}

.theme-dark .connection-card,
.theme-dark .mini-card,
.theme-dark .campaign-card,
.theme-dark .metric-card,
.theme-dark .plan-card,
.theme-dark .support-card,
.theme-dark .ai-panel,
.theme-dark .prompt-panel,
.theme-dark .profile-card,
.theme-dark .theme-card,
.theme-dark .chart-card,
.theme-dark .docs-layout article,
.theme-dark .table-card,
.theme-dark .permission-panel,
.theme-dark .permission-toolbar,
.theme-dark .permission-tabs,
.theme-dark .reports-header,
.theme-dark .reports-filter-bar,
.theme-dark .report-tabs,
.theme-dark .report-card,
.theme-dark .setting-row,
.theme-dark .modal-panel,
.theme-light .connection-card,
.theme-light .mini-card,
.theme-light .campaign-card,
.theme-light .metric-card,
.theme-light .plan-card,
.theme-light .support-card,
.theme-light .ai-panel,
.theme-light .prompt-panel,
.theme-light .profile-card,
.theme-light .theme-card,
.theme-light .chart-card,
.theme-light .docs-layout article,
.theme-light .table-card,
.theme-light .permission-panel,
.theme-light .permission-toolbar,
.theme-light .permission-tabs,
.theme-light .reports-header,
.theme-light .reports-filter-bar,
.theme-light .report-tabs,
.theme-light .report-card,
.theme-light .setting-row,
.theme-light .modal-panel {
    background: #ffffff;
    border-color: #e4e9f1;
    box-shadow: 0 10px 28px rgba(23, 32, 51, 0.06);
    color: #172033;
}

.theme-dark input,
.theme-dark select,
.theme-dark textarea,
.theme-light input,
.theme-light select,
.theme-light textarea {
    background-color: #ffffff;
    border-color: #dbe3ef;
    color: #172033;
}

.theme-dark input::placeholder,
.theme-dark textarea::placeholder,
.theme-light input::placeholder,
.theme-light textarea::placeholder {
    color: #9aa5b8;
}

.theme-dark table,
.theme-light table {
    background: #ffffff;
}

.theme-dark th,
.theme-light th {
    background: #f7f9fc;
    color: #33415c;
}

.theme-dark td,
.theme-light td {
    color: #243047;
}

.theme-dark td span,
.theme-light td span {
    color: #62708a;
}

.theme-dark .permission-tabs button,
.theme-light .permission-tabs button {
    color: #62708a;
}

.theme-dark .permission-tabs button.active,
.theme-light .permission-tabs button.active {
    background: #ff6b00;
    color: #ffffff;
}

.theme-dark .permission-toolbar label,
.theme-light .permission-toolbar label {
    color: #62708a;
}

.theme-dark .report-stat-card,
.theme-light .report-stat-card {
    background: #ffffff;
}

.theme-dark .report-distribution-row em,
.theme-light .report-distribution-row em {
    background: #eef3fa;
}

.theme-dark .report-ranking-list article,
.theme-light .report-ranking-list article {
    border-bottom-color: #eef2f7;
}

.theme-dark .report-ranking-list small,
.theme-light .report-ranking-list small {
    background: #e7f8ef;
    border-color: #b9ebcd;
    color: #187245;
}

.theme-dark .contact-column-menu,
.theme-dark .company-picker-list,
.theme-dark .internal-member-list,
.theme-dark .start-contact-list,
.theme-dark .internal-note-recipient-list,
.theme-dark .history-list,
.theme-dark .history-detail,
.theme-dark .forward-list,
.theme-light .contact-column-menu,
.theme-light .company-picker-list,
.theme-light .internal-member-list,
.theme-light .start-contact-list,
.theme-light .internal-note-recipient-list,
.theme-light .history-list,
.theme-light .history-detail,
.theme-light .forward-list {
    background: #ffffff;
    border-color: #e4e9f1;
}

.theme-dark .company-picker-item,
.theme-dark .internal-member-item,
.theme-dark .start-contact-item,
.theme-dark .internal-note-recipient-item,
.theme-dark .forward-item,
.theme-light .company-picker-item,
.theme-light .internal-member-item,
.theme-light .start-contact-item,
.theme-light .internal-note-recipient-item,
.theme-light .forward-item {
    color: #172033;
    border-bottom-color: #edf1f7;
}

.theme-dark .company-picker-item:hover,
.theme-dark .internal-member-item:hover,
.theme-dark .start-contact-item:hover,
.theme-dark .start-contact-item.selected,
.theme-dark .internal-note-recipient-item:hover,
.theme-dark .internal-note-recipient-item.selected,
.theme-dark .forward-item:hover,
.theme-dark .forward-item.selected,
.theme-light .company-picker-item:hover,
.theme-light .internal-member-item:hover,
.theme-light .start-contact-item:hover,
.theme-light .start-contact-item.selected,
.theme-light .internal-note-recipient-item:hover,
.theme-light .internal-note-recipient-item.selected,
.theme-light .forward-item:hover,
.theme-light .forward-item.selected {
    background: #f2f7ff;
}

.theme-dark .forward-route-value,
.theme-dark .forward-route-select,
.theme-dark .forward-preview,
.theme-dark .forward-destination-tabs,
.theme-light .forward-route-value,
.theme-light .forward-route-select,
.theme-light .forward-preview,
.theme-light .forward-destination-tabs {
    background: #ffffff;
    border-color: #e4e9f1;
    color: #172033;
}

.theme-dark .forward-destination-tab,
.theme-light .forward-destination-tab {
    color: #62708a;
}

.theme-dark .forward-destination-tab.active,
.theme-light .forward-destination-tab.active {
    background: #fff3e8;
    color: #c65400;
}

.theme-dark .emoji-picker,
.theme-dark .quick-reply-picker,
.theme-light .emoji-picker,
.theme-light .quick-reply-picker {
    background: #ffffff;
    border-color: #e4e9f1;
    box-shadow: 0 18px 44px rgba(23, 32, 51, 0.14);
}

.theme-dark .emoji-picker button:hover,
.theme-light .emoji-picker button:hover {
    background: #f2f7ff;
}

.theme-dark .quick-reply-search,
.theme-light .quick-reply-search {
    background: #f7f9fc;
    border: 1px solid #e4e9f1;
    color: #172033;
}

.theme-dark .quick-reply-option,
.theme-light .quick-reply-option {
    background: #ffffff;
    border-color: #edf1f7;
    color: #172033;
}

.theme-dark .quick-reply-option:hover,
.theme-light .quick-reply-option:hover {
    background: #f2f7ff;
    border-color: #d8e7fb;
}

.theme-dark .quick-reply-option-shortcut,
.theme-light .quick-reply-option-shortcut {
    background: #fff3e8;
    color: #c65400;
}

.theme-dark .message-deleted-badge,
.theme-light .message-deleted-badge {
    color: #b91c1c;
}

.theme-dark .message-deleted-detail p,
.theme-dark .message-deleted-detail small,
.theme-light .message-deleted-detail p,
.theme-light .message-deleted-detail small {
    color: #7f1d1d;
}

.theme-dark .message-bubble.deleted-visible,
.theme-light .message-bubble.deleted-visible {
    background: #fff1f2 !important;
    border-color: #fca5a5;
    color: #7f1d1d;
}

.theme-dark .message-bubble.deleted-visible.outbound,
.theme-dark .message-bubble.deleted-visible.inbound,
.theme-light .message-bubble.deleted-visible.outbound,
.theme-light .message-bubble.deleted-visible.inbound {
    background: #fff1f2 !important;
}

.message-bubble.remote-deleted-visible {
    border: 1px solid rgba(245, 158, 11, 0.84);
    background: rgba(120, 53, 15, 0.22) !important;
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.12);
    opacity: .98;
}

    .message-bubble.remote-deleted-visible.outbound {
        background: rgba(120, 53, 15, 0.28) !important;
    }

    .message-bubble.remote-deleted-visible.inbound {
        background: rgba(120, 53, 15, 0.18) !important;
    }

.theme-dark .message-bubble.remote-deleted-visible,
.theme-light .message-bubble.remote-deleted-visible {
    background: #fffbeb !important;
    border-color: #f59e0b;
    color: #92400e;
}

.theme-dark .message-bubble.remote-deleted-visible.outbound,
.theme-dark .message-bubble.remote-deleted-visible.inbound,
.theme-light .message-bubble.remote-deleted-visible.outbound,
.theme-light .message-bubble.remote-deleted-visible.inbound {
    background: #fffbeb !important;
}

.message-bubble.remote-deleted-visible .message-deleted {
    color: #92400e;
}

.theme-dark .delete-warning,
.theme-light .delete-warning {
    color: #b91c1c;
}

.theme-dark .error-card,
.theme-light .error-card {
    background: #ffffff;
    border-color: #e4e9f1;
    color: #172033;
}

.theme-dark .error-message,
.theme-light .error-message {
    color: #62708a;
}

.theme-dark .error-request,
.theme-light .error-request {
    background: #f7f9fc;
    border-color: #e4e9f1;
}

.theme-dark code,
.theme-light code {
    background: #f7f9fc;
    border-color: #dbe3ef;
    color: #073b78;
}

.theme-dark .wide-card-action,
.theme-light .wide-card-action {
    background: #eef3fa;
    color: #33415c;
}

.theme-dark .status-pill,
.theme-light .status-pill {
    background: #e7f8ef;
    border-color: #b9ebcd;
    color: #187245;
}

.theme-dark .status-pill.pending,
.theme-light .status-pill.pending {
    background: #fff8db;
    border-color: #f5d76b;
    color: #7c4a03;
}

.theme-dark .status-pill.disconnected,
.theme-light .status-pill.disconnected {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #b91c1c;
}

.theme-dark .duplicate-chip,
.theme-light .duplicate-chip {
    background: #fff8db;
    border-color: #f5d76b;
    color: #7c4a03;
}

/* Chat action menus must remain usable on narrow operator screens. */
.chat-header {
    overflow: visible;
}

.chat-header > div:not(.chat-header-actions) {
    flex: 1 1 260px;
    min-width: 0;
}

.chat-header-actions {
    align-items: center;
    flex: 0 0 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 100%;
    overflow: visible;
    position: relative;
}

.chat-header-actions .primary-pill.icon-only,
.chat-header-actions .refresh-pill {
    flex: 0 0 38px;
    height: 38px;
    min-width: 38px;
    width: 38px;
}

.header-context-menu-shell {
    flex: 0 0 auto;
    overflow: visible;
}

.header-context-menu {
    z-index: 80;
}

@media (max-width: 760px) {
    .chat-header {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px 16px;
    }

    .chat-header > div:not(.chat-header-actions) {
        flex: 1 1 calc(100% - 72px);
    }

    .chat-header-actions {
        justify-content: flex-start;
        margin-left: 0;
        order: 3;
        width: 100%;
    }

    .header-context-menu {
        left: 0;
        right: auto;
        top: 44px;
    }

    .contact-insight-strip {
        grid-template-columns: 1fr;
        padding: 8px 16px;
    }

    .contact-insight-status {
        min-height: 28px;
    }

    .conversation-trace-panel {
        padding: 8px 16px;
    }

    .conversation-trace-header {
        flex-wrap: wrap;
    }

    .conversation-trace-item {
        flex-basis: min(245px, 82vw);
    }
}

.chatbot-config-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    padding: 14px;
}

.chatbot-config-header,
.chatbot-step-head,
.chatbot-step-toolbar {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.chatbot-config-header span {
    font-size: 14px;
    font-weight: 800;
}

.chatbot-step-toolbar {
    justify-content: flex-start;
}

.chatbot-step {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 10px;
    padding: 12px;
}

.chatbot-options {
    display: grid;
    gap: 8px;
}

.chatbot-option {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: 52px minmax(0, 1fr) 34px;
}

.chatbot-option-value {
    text-align: center;
}

.chatbot-option select {
    grid-column: 1 / -1;
}

/* =========================================================
   Reports interactive dashboard
   ========================================================= */

.report-stat-card,
.report-distribution-row,
.report-ranking-item,
.report-donut-legend button,
.report-heatmap-cell {
    appearance: none;
    color: inherit;
    cursor: pointer;
    font: inherit;
}

.report-stat-card {
    text-align: left;
    transform: translateY(0);
    transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

    .report-stat-card:hover,
    .report-stat-card:focus-visible,
    .report-stat-card.is-active {
        background: color-mix(in srgb, var(--report-tone) 12%, transparent);
        border-color: color-mix(in srgb, var(--report-tone) 72%, var(--line));
        box-shadow: 0 12px 30px rgba(15, 23, 42, .14);
        outline: 0;
        transform: translateY(-1px);
    }

.report-insight-card header,
.report-detail-card header {
    align-items: flex-start;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

    .report-insight-card header small,
    .report-detail-card header small,
    .report-heatmap-panel header small {
        color: var(--muted);
        display: block;
        font-size: .74rem;
        font-weight: 800;
        margin-top: 4px;
    }

.report-insight-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(260px, .85fr) minmax(0, 1.15fr);
}

.report-donut-panel,
.report-heatmap-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 14px;
    min-width: 0;
    padding: 14px;
}

.report-donut-panel {
    align-items: center;
    grid-template-columns: 150px minmax(0, 1fr);
}

.report-donut {
    align-items: center;
    animation: reportRise .28s ease both;
    aspect-ratio: 1;
    border-radius: 50%;
    display: grid;
    justify-items: center;
    min-width: 0;
    place-content: center;
    position: relative;
}

    .report-donut::after {
        background: var(--panel);
        border-radius: 50%;
        content: "";
        inset: 22px;
        position: absolute;
    }

    .report-donut strong,
    .report-donut span {
        position: relative;
        z-index: 1;
    }

    .report-donut strong {
        color: var(--text);
        font-size: 1.35rem;
        font-weight: 950;
    }

    .report-donut span {
        color: var(--muted);
        font-size: .72rem;
        font-weight: 900;
        text-transform: uppercase;
    }

.report-donut-legend {
    display: grid;
    gap: 8px;
    min-width: 0;
}

    .report-donut-legend button {
        align-items: center;
        background: transparent;
        border: 1px solid transparent;
        border-radius: 7px;
        display: grid;
        gap: 9px;
        grid-template-columns: auto minmax(0, 1fr) auto;
        padding: 9px;
        text-align: left;
        transition: background .16s ease, border-color .16s ease;
    }

        .report-donut-legend button:hover,
        .report-donut-legend button:focus-visible,
        .report-donut-legend button.is-active {
            background: rgba(148, 163, 184, .1);
            border-color: var(--line);
            outline: 0;
        }

        .report-donut-legend button i {
            border-radius: 999px;
            height: 10px;
            width: 10px;
        }

        .report-donut-legend button span {
            font-size: .78rem;
            font-weight: 900;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .report-donut-legend button strong {
            color: var(--text);
            font-size: .8rem;
            font-weight: 950;
        }

.report-heatmap-panel header h3 {
    font-size: .95rem;
    margin: 0;
}

.report-heatmap-grid {
    display: grid;
    gap: 7px;
    grid-template-columns: repeat(12, minmax(0, 1fr));
}

.report-heatmap-cell {
    background: color-mix(in srgb, #38bdf8 var(--heat), rgba(148, 163, 184, .11));
    border: 1px solid rgba(148, 163, 184, .22);
    border-radius: 7px;
    display: grid;
    min-height: 54px;
    min-width: 0;
    padding: 8px 6px;
    text-align: center;
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

    .report-heatmap-cell:hover,
    .report-heatmap-cell:focus-visible,
    .report-heatmap-cell.is-active {
        border-color: #38bdf8;
        box-shadow: 0 10px 24px rgba(56, 189, 248, .16);
        outline: 0;
        transform: translateY(-1px);
    }

    .report-heatmap-cell span {
        color: var(--muted);
        font-size: .66rem;
        font-weight: 900;
    }

    .report-heatmap-cell strong {
        color: var(--text);
        font-size: .84rem;
        font-weight: 950;
    }

.report-distribution-row {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 8px;
    text-align: left;
    transition: background .16s ease, border-color .16s ease;
    width: 100%;
}

    .report-distribution-row:hover,
    .report-distribution-row:focus-visible,
    .report-distribution-row.is-active {
        background: rgba(148, 163, 184, .1);
        border-color: var(--line);
        outline: 0;
    }

    .report-distribution-row:hover i,
    .report-distribution-row:focus-visible i,
    .report-distribution-row.is-active i {
        background: linear-gradient(90deg, #38bdf8, #f97316);
    }

.report-ranking-list .report-ranking-item {
    align-items: center;
    background: transparent;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    border-radius: 7px;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto 34px;
    min-height: 42px;
    padding: 8px 4px 10px;
    text-align: left;
    transition: background .16s ease, box-shadow .16s ease;
    width: 100%;
}

    .report-ranking-list .report-ranking-item:hover,
    .report-ranking-list .report-ranking-item:focus-visible,
    .report-ranking-list .report-ranking-item.is-active {
        background: rgba(148, 163, 184, .1);
        box-shadow: inset 3px 0 0 #38bdf8;
        outline: 0;
    }

    .report-ranking-list .report-ranking-item strong,
    .report-ranking-list .report-ranking-item span {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .report-ranking-list .report-ranking-item span {
        color: var(--muted);
        font-size: .74rem;
        font-weight: 800;
    }

    .report-ranking-list .report-ranking-item small {
        background: rgba(37, 211, 102, .22);
        border: 1px solid rgba(37, 211, 102, .45);
        border-radius: 999px;
        color: #c6f6d5;
        font-weight: 900;
        padding: 5px 9px;
        white-space: nowrap;
    }

    .report-ranking-list .report-ranking-item b {
        align-items: center;
        border: 1px solid var(--line);
        border-radius: 999px;
        display: inline-flex;
        height: 30px;
        justify-content: center;
        width: 30px;
    }

.report-detail-table table {
    min-width: 980px;
}

.report-detail-table td strong,
.report-detail-table td span:not(.request-status) {
    display: block;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.report-detail-table td span:not(.request-status) {
    color: var(--muted);
    font-size: .76rem;
    font-weight: 800;
    margin-top: 3px;
}

.report-detail-table .secondary-button.compact {
    min-height: 30px;
    padding: 0 12px;
    text-decoration: none;
}

.reports-header-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.report-export-status {
    justify-self: end;
    margin-top: -8px;
}

.report-card header small,
.report-performance-grid header small {
    color: var(--muted);
    display: block;
    font-size: .74rem;
    font-weight: 800;
    margin-top: 4px;
}

.report-bar-list {
    display: grid;
    gap: 10px;
}

.report-bar-row {
    appearance: none;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    color: inherit;
    cursor: pointer;
    display: grid;
    font: inherit;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 10px;
    text-align: left;
    transition: background .16s ease, border-color .16s ease, box-shadow .16s ease;
}

    .report-bar-row:hover,
    .report-bar-row:focus-visible,
    .report-bar-row.is-active {
        background: rgba(148, 163, 184, .1);
        border-color: var(--line);
        box-shadow: inset 3px 0 0 #38bdf8;
        outline: 0;
    }

    .report-bar-row div {
        min-width: 0;
    }

    .report-bar-row strong,
    .report-bar-row span {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .report-bar-row span {
        color: var(--muted);
        font-size: .74rem;
        font-weight: 800;
        margin-top: 4px;
    }

    .report-bar-row small {
        color: var(--text);
        font-size: .82rem;
        font-weight: 950;
        white-space: nowrap;
    }

.report-stacked-bar,
.report-solid-bar {
    background: rgba(148, 163, 184, .15);
    border-radius: 999px;
    grid-column: 1 / -1;
    height: 10px;
    overflow: hidden;
    position: relative;
    width: 100%;
}

    .report-stacked-bar::before,
    .report-solid-bar::before {
        background: rgba(148, 163, 184, .2);
        border-radius: inherit;
        content: "";
        inset: 0 auto 0 0;
        position: absolute;
        width: var(--bar-width);
    }

    .report-stacked-bar i,
    .report-stacked-bar b,
    .report-solid-bar i {
        border-radius: inherit;
        display: block;
        height: 100%;
        left: 0;
        position: absolute;
        top: 0;
    }

    .report-stacked-bar i {
        background: #38bdf8;
        width: calc(var(--bar-width) * var(--inbound-width) / 100);
    }

    .report-stacked-bar b {
        background: #f97316;
        left: calc(var(--bar-width) * var(--inbound-width) / 100);
        width: calc(var(--bar-width) - (var(--bar-width) * var(--inbound-width) / 100));
    }

    .report-solid-bar i {
        background: linear-gradient(90deg, #38bdf8, #4ade80);
        width: var(--bar-width);
    }

.report-transfer-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(220px, .8fr) minmax(0, 1.2fr);
}

.report-transfer-actor,
.report-transfer-item {
    border: 1px solid var(--line);
    border-radius: 7px;
    display: grid;
    gap: 4px;
    padding: 10px;
}

.report-transfer-actor span,
.report-transfer-item span,
.report-transfer-item small {
    color: var(--muted);
    font-size: .74rem;
    font-weight: 800;
}

.report-transfer-list {
    display: grid;
    gap: 10px;
}

.report-transfer-item {
    align-items: start;
    color: inherit;
    grid-template-columns: minmax(0, 1fr) auto;
    text-decoration: none;
    transition: background .16s ease, border-color .16s ease;
}

    .report-transfer-item:hover,
    .report-transfer-item:focus-visible {
        background: rgba(148, 163, 184, .1);
        border-color: #38bdf8;
        outline: 0;
    }

    .report-transfer-item div {
        min-width: 0;
    }

    .report-transfer-item strong,
    .report-transfer-item span,
    .report-transfer-item small {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

.report-transfer-item time {
        color: var(--muted);
        font-size: .72rem;
        font-weight: 900;
        white-space: nowrap;
    }

.report-chart-line {
    animation: reportStroke .45s ease both;
}

.sla-risk-item {
    border-left: 3px solid #f59e0b;
}

.sla-risk-item.breach {
    border-left-color: #ef4444;
}

.sla-report-status {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 7px;
    border-radius: 4px;
    background: #e2e8f0;
    color: #334155;
    font-size: 0.72rem;
    font-weight: 700;
}

.sla-report-status.cumplida {
    background: #dcfce7;
    color: #166534;
}

.sla-report-status.en_riesgo {
    background: #fef3c7;
    color: #92400e;
}

.sla-report-status.vencida {
    background: #fee2e2;
    color: #991b1b;
}

.report-management-grid {
    align-items: start;
}

.report-chart-area {
    animation: reportFade .4s ease both;
}

@keyframes reportRise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes reportFade {
    from {
        opacity: 0;
    }
}

@keyframes reportStroke {
    from {
        stroke-dasharray: 120;
        stroke-dashoffset: 120;
    }
    to {
        stroke-dasharray: 120;
        stroke-dashoffset: 0;
    }
}

@media (max-width: 860px) {
    .reports-shell,
    .module-page {
        max-width: 100vw;
        overflow-x: hidden;
    }

    .report-insight-card header,
    .report-detail-card header,
    .report-transfer-card header {
        flex-direction: column;
    }

    .report-insight-grid,
    .report-donut-panel {
        grid-template-columns: 1fr;
    }

    .report-donut {
        justify-self: center;
        max-width: 180px;
        width: 62vw;
    }

    .report-heatmap-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .report-line-canvas {
        overflow: hidden;
        padding-left: 36px;
        padding-right: 30px;
    }

    .report-line-plot,
    .report-chart-x-labels {
        min-width: 0;
    }

    .report-chart-x-labels {
        grid-template-columns: repeat(12, minmax(0, 1fr));
    }

        .report-chart-x-labels span:nth-child(odd) {
            display: none;
        }

    .report-ranking-list .report-ranking-item {
        grid-template-columns: minmax(0, 1fr) 32px;
    }

        .report-ranking-list .report-ranking-item small {
            display: none;
        }

    .report-detail-table table {
        min-width: 0;
    }

    .reports-header-actions {
        justify-content: flex-start;
        width: 100%;
    }

    .report-transfer-grid {
        grid-template-columns: 1fr;
    }

    .sidebar,
    .nav-panel,
    .sidebar-footer {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

        .sidebar::-webkit-scrollbar,
        .nav-panel::-webkit-scrollbar,
        .sidebar-footer::-webkit-scrollbar {
            display: none;
        }
}

/* =========================================================
   UX/UI integral - operador/admin
   ========================================================= */
.app-shell,
.workspace,
.main-stage,
.chat-workspace,
.chat-panel,
.conversation-panel,
.module-page,
.reports-shell,
.report-card,
.table-card {
    min-width: 0;
}

.sidebar {
    overflow: hidden;
}

.nav-panel {
    gap: 6px;
    padding-right: 4px;
    scrollbar-gutter: auto;
}

.nav-entry {
    border-left: 3px solid transparent;
}

.nav-entry.active {
    border-left-color: var(--accent);
    box-shadow: none;
}

.search-toolbar {
    min-height: 44px;
    min-width: 0;
}

.search-toolbar input {
    min-width: 110px;
}

.filter-row {
    gap: 10px;
    padding: 11px;
}

.filter-panel-header {
    min-width: 0;
}

.filter-panel-actions {
    flex: 0 0 auto;
}

.filter-select-grid {
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.status-filter-trigger,
.status-filter-option,
.scope-select,
.routing-select,
.priority-select,
.reports-filter-bar input,
.reports-filter-bar select,
.permission-header-filter select {
    min-height: 34px;
}

.conversation-list {
    scrollbar-gutter: stable;
}

.conversation-item {
    min-height: 72px;
}

.conversation-title,
.conversation-preview,
.chat-header h1,
.chat-header p,
.wa-line {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-header > div:not(.chat-header-actions) {
    min-width: 0;
}

.routing-strip {
    grid-template-columns: minmax(136px, 170px) minmax(124px, 150px) minmax(190px, auto);
    min-width: 0;
}

.routing-strip .routing-field:nth-child(1) .routing-select,
.routing-strip .routing-field:nth-child(2) .priority-select,
.routing-field {
    max-width: 100%;
    min-width: 0;
    width: 100%;
}

.routing-transfer-button {
    justify-content: center;
}

.contact-insight-strip {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    min-width: 0;
}

.contact-insight-status {
    min-height: 40px;
}

.conversation-trace-list {
    scrollbar-gutter: stable;
}

.conversation-trace-item {
    flex-basis: min(258px, calc(100vw - 72px));
}

.message-search-toolbar {
    min-width: 0;
}

.message-search-toolbar input {
    min-width: 0;
}

.module-page {
    padding: 20px min(4vw, 56px);
}

.page-heading {
    margin-bottom: 12px;
}

.reports-shell,
.diagnostics-shell {
    gap: 12px;
}

.reports-header,
.reports-filter-bar,
.report-card,
.diagnostics-header,
.diagnostic-check-card,
.diagnostic-metric-grid article {
    border-radius: 8px;
}

.reports-header {
    padding: 14px 16px;
}

.reports-filter-bar {
    gap: 8px;
    grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
    padding: 12px;
}

.reports-filter-bar label {
    gap: 4px;
}

.report-card {
    gap: 12px;
    padding: 14px;
}

.report-stat-grid {
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(156px, 1fr));
}

.report-stat-card {
    min-height: 76px;
    padding: 12px;
}

.report-stat-card > .material-symbols-rounded {
    font-size: 26px;
}

.report-donut-panel,
.report-heatmap-panel,
.report-transfer-actor,
.report-transfer-item {
    border-radius: 8px;
}

.table-card {
    background-image: linear-gradient(90deg, rgba(244, 247, 251, 0), rgba(244, 247, 251, 0)), linear-gradient(270deg, rgba(23, 32, 51, .12), rgba(23, 32, 51, 0));
    background-position: left center, right center;
    background-repeat: no-repeat;
    background-size: 16px 100%, 18px 100%;
    overscroll-behavior-x: contain;
    scrollbar-gutter: stable;
}

.table-card th,
.table-card td {
    padding: 9px 10px;
}

/* OJO: este generico le gana por orden a cualquier ".X-table-card table" de una
   sola clase. Las tablas que reparten el 100% (equipo, contactos, areas, catalogo,
   respuestas rapidas, empresas) usan el selector DOBLE .table-card.X-table-card
   para ganarle (20/08/2026). */
.table-card table {
    width: max-content;
}

.table-card table:not(.permission-table) {
    min-width: min(100%, 900px);
}

.report-detail-table table {
    min-width: 980px;
}

.permission-table {
    min-width: 560px;
}

.contact-toolbar {
    align-items: end;
}

.contact-toolbar-main,
.contact-toolbar-config {
    min-width: 0;
}

.contact-search-field {
    min-width: 0;
}

.contact-toolbar-main .contact-search-field {
    flex: 1 1 auto;
    width: 100%;
}

.contact-search-field input,
.contact-company-search-field input {
    min-width: 0;
    width: 100%;
}

.contact-toolbar-config label {
    min-width: 0;
}

.contact-toolbar-config select {
    max-width: 210px;
}

@media (max-width: 1380px) {
    .contact-toolbar {
        grid-template-columns: minmax(320px, 1fr) minmax(240px, auto);
    }

    .contact-import-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

.empty-state,
.report-empty,
.message-search-empty,
.company-picker-empty,
.quick-reply-empty,
.contact-tag-empty {
    background: #f8fafc;
    border: 1px dashed #d5deea;
    border-radius: 8px;
    color: #62708a;
    text-align: center;
}

.report-empty {
    min-height: 132px;
    padding: 18px;
}

.report-empty.compact {
    min-height: 64px;
}

.form-error,
.diagnostic-error {
    align-items: flex-start;
    background: #fff1f2;
    border: 1px solid #fda4af;
    border-left: 4px solid #ef4444;
    border-radius: 8px;
    color: #991b1b;
    line-height: 1.35;
    padding: 10px 12px;
}

.diagnostic-error .material-symbols-rounded {
    color: #dc2626;
    flex: 0 0 auto;
}

.modal-backdrop {
    padding: clamp(8px, 2vw, 18px);
    z-index: 100;
}

.modal-panel {
    max-height: min(88dvh, 900px);
    overflow: auto;
    scrollbar-gutter: stable;
}

.modal-panel header {
    background: #ffffff;
    border-bottom: 1px solid transparent;
    position: sticky;
    top: 0;
    z-index: 1;
}

.modal-panel footer {
    background: #ffffff;
    border-top: 1px solid #e4e9f1;
    bottom: 0;
    padding-top: 12px;
    position: sticky;
    z-index: 1;
}

.modal-form {
    gap: 10px;
}

.modal-form label,
.prompt-panel label,
.theme-card label {
    font-size: 12px;
}

.modal-form input,
.modal-form select,
.modal-form textarea {
    min-height: 38px;
}

.modal-form textarea {
    min-height: 112px;
}

@media (max-width: 1180px) {
    .sidebar {
        overflow: hidden;
    }

    .nav-entry {
        min-height: 42px;
    }
}

@media (min-width: 861px) and (max-width: 1380px) {
    .routing-strip {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .routing-transfer-button {
        width: 100%;
    }
}

@media (max-width: 860px) {
    html,
    body {
        max-width: 100vw;
        overflow-x: hidden;
    }

    .app-shell {
        max-width: 100vw;
        width: 100%;
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 42;
    }

    .sidebar {
        max-width: 100vw;
        min-width: 0;
        overflow-x: auto;
        position: sticky;
        top: 58px;
        width: 100vw;
        z-index: 41;
    }

    .sidebar-logo {
        flex: 0 0 auto;
    }

    .nav-panel {
        flex: 1 1 auto;
        min-width: 0;
        overflow-x: auto;
    }

    .sidebar-footer {
        flex: 0 0 auto;
    }

    .chat-workspace {
        max-width: 100vw;
        overflow-x: hidden;
        width: 100%;
    }

    .conversation-panel {
        border-bottom: 1px solid var(--line);
        border-right: 0;
        max-height: 350px;
        padding: 12px;
        width: 100%;
    }

    .search-toolbar {
        min-height: 54px;
        overflow-x: auto;
        overflow-y: hidden;
        padding-top: 6px;
        padding-bottom: 8px;
        scrollbar-width: none;
    }

    .search-toolbar::-webkit-scrollbar {
        display: none;
    }

    .search-toolbar input {
        flex: 1 0 150px;
    }

    .search-toolbar .small-icon-button {
        flex: 0 0 30px;
    }

    .conversation-inbox-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .conversation-item {
        grid-template-columns: 40px minmax(0, 1fr) auto;
        padding-right: 30px;
    }

    .chat-panel {
        max-width: 100vw;
        overflow: hidden;
        width: 100%;
    }

    .chat-header {
        padding: 12px 14px;
    }

    .chat-header > .avatar,
    .chat-header > .contact-avatar {
        flex: 0 0 auto;
    }

    .chat-header > div:not(.chat-header-actions) {
        flex: 1 1 calc(100% - 64px);
        max-width: calc(100% - 64px);
    }

    .chat-header-actions {
        gap: 8px;
    }

    .routing-strip {
        align-items: stretch;
        gap: 9px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        min-height: 0;
        padding: 10px 14px;
    }

    .routing-field:nth-child(1),
    .routing-field:nth-child(2) {
        max-width: none;
    }

    .routing-transfer-button {
        grid-column: 1 / -1;
        width: 100%;
    }

    .contact-insight-strip {
        grid-template-columns: 1fr;
        padding: 10px 14px;
    }

    .conversation-trace-panel {
        padding: 9px 14px;
    }

    .conversation-trace-item {
        flex-basis: min(250px, calc(100vw - 44px));
    }

    .message-search-toolbar {
        gap: 7px;
        grid-template-columns: auto minmax(0, 1fr) auto auto;
        padding: 8px 14px;
    }

    .message-search-toolbar .message-search-count {
        display: none;
    }

    .message-search-toolbar .secondary-button.compact {
        min-width: 38px;
        padding-left: 10px;
        padding-right: 10px;
    }

    .message-surface {
        padding: 12px 14px 18px;
    }

    .composer {
        bottom: 0;
        gap: 7px;
        padding: 9px 10px;
        position: sticky;
        z-index: 5;
    }

    .composer .small-icon-button {
        flex: 0 0 32px;
    }

    .module-page {
        padding: 12px;
    }

    .reports-header,
    .diagnostics-header {
        gap: 10px;
        padding: 12px;
    }

    .reports-header-actions {
        gap: 8px;
    }

    .reports-filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 10px;
    }

    .reports-filter-bar .report-clear-button {
        width: 100%;
    }

    .report-card {
        padding: 12px;
    }

    .report-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .report-stat-card {
        min-height: 72px;
        padding: 10px;
    }

    .report-stat-card strong {
        font-size: 1.18rem;
    }

    .report-stat-card span {
        font-size: .76rem;
    }

    .table-card table,
    .table-card table:not(.permission-table),
    .permission-table,
    .report-detail-table table {
        min-width: 0;
        width: 100%;
    }

    .modal-backdrop {
        align-items: stretch;
        padding: 8px;
    }

    .modal-panel,
    .transfer-modal-panel,
    .agent-modal-panel,
    .history-modal-panel,
    .forward-message-panel {
        max-height: calc(100dvh - 16px);
        max-width: 100%;
        width: 100%;
    }

    .modal-panel footer {
        flex-wrap: wrap;
    }
}

@media (max-width: 520px) {
    .reports-filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .reports-filter-bar label:nth-child(5) {
        grid-column: 1 / -1;
    }

    .report-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .reports-header-actions .secondary-button,
    .reports-header-actions .primary-pill {
        flex: 1 1 auto;
        justify-content: center;
    }

    .report-working-hours {
        width: 100%;
    }

    .message-bubble {
        max-width: 92%;
    }
}

/* Conversation-first mode: collapse secondary controls to give the message history the viewport. */
.conversation-tools-panel {
    max-height: min(55dvh, 520px);
    opacity: 1;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable;
    transform: translateY(0);
    transition: max-height .24s ease, opacity .18s ease, transform .24s ease;
}

.conversation-tools-panel.is-collapsed {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transform: translateY(-8px);
    visibility: hidden;
}

.conversation-tools-toggle {
    flex: 0 0 38px;
    height: 38px;
    min-width: 38px;
    padding: 0 9px;
}

.chat-panel {
    container-type: inline-size;
}

/*
 * Desktop/tablet chat layout must not depend on how many optional rows are
 * rendered for the current user's permissions (SLA, follow-ups, etc.).
 * Keep every toolbar at its natural height, give the remaining space only to
 * the message history and pin the composer to the bottom of the panel.
 * Mobile <= 640px keeps the explicit six-row grid defined below.
 */
@media (min-width: 641px) {
    .chat-panel {
        display: flex;
        flex-direction: column;
    }

    .chat-panel > :not(.message-surface) {
        flex: 0 0 auto;
    }

    .chat-panel > .message-surface {
        flex: 1 1 0;
        min-height: 0;
    }
}

@container (max-width: 900px) {
    .routing-strip {
        gap: 8px;
        grid-template-columns: minmax(0, 1fr) minmax(0, .88fr) minmax(190px, 1.25fr);
        padding-left: 14px;
        padding-right: 14px;
    }

    .routing-transfer-button {
        padding-left: 10px;
        padding-right: 10px;
    }
}

@container (max-width: 520px) {
    .chat-header {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px 16px;
    }

    .chat-header > .avatar,
    .chat-header > .contact-avatar {
        flex: 0 0 auto;
    }

    .chat-header > div:not(.chat-header-actions) {
        flex: 1 1 calc(100% - 64px);
        max-width: calc(100% - 64px);
    }

    .chat-header-actions {
        justify-content: flex-end;
        margin-left: 0;
        width: 100%;
    }

    .header-context-menu {
        left: auto;
        right: 0;
        top: 44px;
    }

    .routing-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .routing-transfer-button {
        grid-column: 1 / -1;
        width: 100%;
    }

    .message-search-toolbar {
        gap: 7px;
        grid-template-columns: auto minmax(0, 1fr) auto auto auto;
        padding-left: 14px;
        padding-right: 14px;
    }

    .message-search-toolbar .message-search-count {
        display: none;
    }
}

@container (max-width: 440px) {
    .message-search-toolbar .secondary-button.compact {
        font-size: 0;
        min-width: 34px;
        padding-left: 8px;
        padding-right: 8px;
    }

    .message-search-toolbar .secondary-button.compact .material-symbols-rounded {
        font-size: 18px;
    }
}

.active-internal-filter {
    align-items: center;
    background: #fff7ed;
    border-bottom: 1px solid #fed7aa;
    color: #9a3412;
    display: flex;
    font-size: 12px;
    font-weight: 800;
    gap: 10px;
    justify-content: space-between;
    min-height: 38px;
    padding: 5px 12px;
}

.filter-toggle-button.active,
.create-menu-trigger.active {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    color: var(--accent);
}

.toolbar-filter-badge {
    align-items: center;
    background: var(--accent);
    border: 2px solid var(--main-2);
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    font-size: 9px;
    font-weight: 900;
    height: 17px;
    justify-content: center;
    min-width: 17px;
    padding: 0 3px;
    position: absolute;
    right: -3px;
    top: -4px;
}

.chat-create-menu-popover {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 42px rgba(23, 32, 51, .22);
    display: grid;
    gap: 3px;
    padding: 5px;
    position: absolute;
    right: 10px;
    top: 58px;
    width: min(230px, calc(100% - 20px));
    z-index: 70;
}

.chat-create-menu-popover button {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    font-size: 12px;
    font-weight: 800;
    gap: 9px;
    min-height: 36px;
    padding: 7px 9px;
    text-align: left;
    width: 100%;
}

.chat-create-menu-popover button:hover {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.chat-create-menu-popover button:disabled {
    cursor: not-allowed;
    opacity: .45;
}

.chat-create-menu-popover .material-symbols-rounded {
    color: var(--accent);
    font-size: 19px;
}

.active-filter-chips {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 6px 8px;
}

.active-filter-chip {
    align-items: center;
    background: #eef3fa;
    border: 1px solid #d7e1ee;
    border-radius: 999px;
    color: #33415c;
    cursor: pointer;
    display: inline-flex;
    font-size: 10.5px;
    font-weight: 800;
    gap: 5px;
    max-width: 100%;
    min-height: 25px;
    padding: 3px 7px 3px 9px;
}

.active-filter-chip > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.active-filter-chip .material-symbols-rounded {
    flex: 0 0 auto;
    font-size: 15px;
}

.active-filter-chip:hover {
    background: #e1eaf5;
    border-color: #c4d3e5;
}

.active-filter-chip:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 42%, transparent);
    outline-offset: 2px;
}

.theme-dark .active-filter-chip {
    background: #263650;
    border-color: #607899;
    color: #ffffff;
}

.theme-dark .active-filter-chip > span,
.theme-dark .active-filter-chip .material-symbols-rounded {
    color: #ffffff;
}

.theme-dark .active-filter-chip:hover {
    background: #344b6d;
    border-color: #8299b8;
}

.active-internal-filter > span,
.active-internal-filter button {
    align-items: center;
    display: inline-flex;
    gap: 6px;
}

.active-internal-filter .material-symbols-rounded {
    font-size: 17px;
}

.active-internal-filter button {
    background: transparent;
    border: 0;
    color: #9a3412;
    cursor: pointer;
    font: inherit;
    padding: 5px 2px;
}

.active-internal-filter button:hover {
    color: #c2410c;
    text-decoration: underline;
}

@media (max-width: 520px) {
    .active-internal-filter {
        align-items: flex-start;
        flex-direction: column;
        gap: 2px;
    }
}

@media (max-width: 760px) {
    .conversation-tools-panel {
        max-height: min(55dvh, 460px);
    }
}

/* Permisos: matriz utilizable en notebooks sin scroll horizontal ni columnas truncadas. */
.permission-module-page {
    padding-left: clamp(20px, 3vw, 42px);
    padding-right: clamp(20px, 3vw, 42px);
}

.permission-assignment-layout .permission-panel .permission-table {
    min-width: 0;
    table-layout: fixed;
    width: 100%;
}

.permission-assignment-layout .permission-table-scroll {
    overflow-x: hidden;
}

.permission-assignment-layout .permission-table th,
.permission-assignment-layout .permission-table td {
    overflow: hidden;
}

.permission-assignment-layout .permission-table td:first-child strong,
.permission-assignment-layout .permission-table td:first-child span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.permission-assignment-layout .permission-panel:first-child .permission-table th:nth-child(2),
.permission-assignment-layout .permission-panel:first-child .permission-table td:nth-child(2) {
    width: 74px;
}

.permission-assignment-layout .permission-panel:first-child .permission-table th:nth-child(3),
.permission-assignment-layout .permission-panel:first-child .permission-table td:nth-child(3) {
    width: 70px;
}

.permission-assignment-layout .permission-panel:first-child .permission-table th:nth-child(4),
.permission-assignment-layout .permission-panel:first-child .permission-table td:nth-child(4) {
    text-align: center;
    width: 52px;
}

.permission-assignment-layout .permission-panel:nth-child(2) .permission-table th:nth-child(2),
.permission-assignment-layout .permission-panel:nth-child(2) .permission-table td:nth-child(2) {
    width: 94px;
}

.permission-assignment-layout .permission-panel:nth-child(2) .permission-table th:nth-child(3),
.permission-assignment-layout .permission-panel:nth-child(2) .permission-table td:nth-child(3) {
    width: 132px;
}

.permission-assignment-layout .permission-mode {
    min-width: 0;
    width: 100%;
}

.permission-catalog-layout .permission-table {
    min-width: 0;
    table-layout: fixed;
    width: 100%;
}

.permission-catalog-layout .permission-table th,
.permission-catalog-layout .permission-table td {
    overflow: hidden;
}

.permission-catalog-layout .permission-table td:first-child strong,
.permission-catalog-layout .permission-table td:first-child span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.permission-catalog-layout .permission-panel:first-child .permission-table th:nth-child(2),
.permission-catalog-layout .permission-panel:first-child .permission-table td:nth-child(2) {
    width: 88px;
}

.permission-catalog-layout .permission-panel:first-child .permission-table th:nth-child(3),
.permission-catalog-layout .permission-panel:first-child .permission-table td:nth-child(3) {
    width: 68px;
}

.permission-catalog-layout .permission-panel:nth-child(2) .permission-table th:nth-child(2),
.permission-catalog-layout .permission-panel:nth-child(2) .permission-table td:nth-child(2) {
    width: 88px;
}

.permission-catalog-layout .permission-panel:nth-child(2) .permission-table th:nth-child(3),
.permission-catalog-layout .permission-panel:nth-child(2) .permission-table td:nth-child(3) {
    width: 74px;
}

.permission-catalog-layout .permission-table th:last-child,
.permission-catalog-layout .permission-table td:last-child {
    width: 72px;
}

.denied-panel .permission-table {
    min-width: 0;
    table-layout: fixed;
    width: 100%;
}

@media (min-width: 861px) and (max-width: 1360px) {
    .permission-catalog-layout .permission-form-grid.role-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .permission-catalog-layout .permission-form-grid.task-form {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 861px) and (max-width: 1150px) {
    .permission-assignment-layout {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 861px) and (max-height: 820px) {
    .sidebar {
        gap: 8px;
        padding: 14px 10px 12px;
    }

    .sidebar-header {
        margin: 0 2px 16px;
        min-height: 44px;
    }

    .sidebar .aicon-logo-mark {
        height: 38px;
        width: 38px;
    }

    .sidebar-toggle-button {
        flex-basis: 32px;
        height: 32px;
        width: 32px;
    }

    .nav-panel {
        gap: 3px;
        padding-right: 0;
    }

    .nav-entry {
        min-height: 38px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .sidebar-footer .nav-entry {
        min-height: 40px;
    }
}

@media (max-width: 860px) {
    .permission-module-page {
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* Ajustes operativos: navegación, filtros y foco en la conversación. */
.sidebar-header {
    justify-content: flex-start;
}

.sidebar-header .sidebar-toggle-button {
    order: 0;
}

.sidebar-header .sidebar-logo {
    order: 1;
}

.sidebar .aicon-logo-mark {
    height: 36px;
    width: 36px;
}

.sidebar .aicon-wordmark-image {
    height: 21px;
}

.sidebar .logo-chat {
    font-size: 19px;
}

.filter-select-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.filter-select-grid .filter-span-full {
    grid-column: 1 / -1;
}

.filter-select-grid .scope-select:disabled {
    background: #eef1f5;
    color: #778397;
    cursor: not-allowed;
    opacity: 1;
}

.line-filter-checks {
    border: 1px solid #d8e0eb;
    border-radius: 10px;
    background: #fff;
    padding: 8px 10px;
}

.line-filter-checks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: #516078;
    font-size: 12px;
    font-weight: 700;
}

.line-filter-checks-header button {
    border: 0;
    border-radius: 999px;
    background: #eef3fb;
    color: #173f77;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
}

.line-filter-checks-header button:disabled {
    color: #91a0b5;
    cursor: default;
}

.line-filter-check-list {
    display: grid;
    gap: 6px;
    margin-top: 8px;
    max-height: 150px;
    overflow-y: auto;
}

.line-filter-check-list label {
    align-items: center;
    display: flex;
    gap: 8px;
    min-width: 0;
}

.line-filter-check-list span,
.line-filter-empty {
    color: #1f2a44;
    font-size: 12px;
}

.line-filter-check-list span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.routing-strip {
    gap: 10px;
    grid-template-columns: minmax(150px, 170px) minmax(140px, 150px) max-content;
    justify-content: start;
}

.routing-transfer-button {
    min-width: 0;
    width: auto;
}

.conversation-item {
    cursor: pointer;
}

.conversation-item:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 42%, transparent);
    outline-offset: -3px;
}

.header-context-menu button {
    font-size: 12.5px;
    min-height: 34px;
}

.avatar-preview-enabled {
    cursor: zoom-in;
}

.avatar-preview-enabled:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 38%, transparent);
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.avatar-preview-backdrop {
    z-index: 140;
}

.avatar-preview-panel {
    max-width: min(92vw, 720px);
    overflow: hidden;
    width: auto;
}

.avatar-preview-body {
    align-items: center;
    background: #111827;
    display: flex;
    justify-content: center;
    min-height: min(58vh, 420px);
    min-width: min(78vw, 560px);
    overflow: hidden;
}

.avatar-preview-body img {
    display: block;
    max-height: min(72vh, 680px);
    max-width: min(88vw, 680px);
    object-fit: contain;
}

.avatar-preview-error {
    align-items: center;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    font-weight: 700;
    gap: 10px;
    justify-content: center;
    padding: 40px;
}

.avatar-preview-error .material-symbols-rounded {
    font-size: 42px;
}

.logout-confirmation-form {
    margin: 0;
}

@container (max-width: 520px) {
    .routing-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .routing-transfer-button {
        grid-column: 1 / -1;
        width: 100%;
    }
}

@media (max-width: 520px) {
    .avatar-preview-panel {
        max-width: 100%;
        width: 100%;
    }

    .avatar-preview-body {
        min-height: 52dvh;
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 860px) {
    .conversation-panel {
        background: var(--main-2);
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        position: relative;
        scrollbar-gutter: auto;
        z-index: 2;
    }

    .chat-panel {
        height: max(560px, calc(100dvh - 122px));
        min-height: 560px;
        overflow: hidden;
        position: relative;
        z-index: 1;
    }
}

/*
 * PWA/mobile shell: keep navigation in a compact left rail and reserve an
 * independent grid column for the active page. The previous mobile rules
 * converted the sidebar into a 100vw horizontal row and stacked the inbox
 * above the conversation, which caused both surfaces to compete for height.
 */
.sidebar-toggle-mobile,
.mobile-sidebar-backdrop,
.mobile-conversation-back {
    display: none;
}

@media (max-width: 860px) {
    .app-shell,
    .app-shell.sidebar-collapsed {
        --mobile-sidebar-width: 64px;
        grid-template-columns: var(--mobile-sidebar-width) minmax(0, 1fr);
        grid-template-rows: 58px minmax(0, 1fr);
        height: 100dvh;
        min-height: 100dvh;
        overflow: hidden;
        width: 100%;
    }

    .topbar {
        grid-column: 2;
        grid-row: 1;
        padding-left: 10px;
        padding-right: max(12px, env(safe-area-inset-right));
        position: relative;
        top: auto;
        z-index: 30;
    }

    .sidebar {
        background: linear-gradient(180deg, #073b78 0%, #052e61 100%);
        border-bottom: 0;
        border-right: 1px solid rgba(255, 255, 255, .14);
        box-sizing: border-box;
        flex-direction: column;
        grid-column: 1;
        grid-row: 1 / -1;
        height: 100dvh;
        max-width: var(--mobile-sidebar-width);
        min-width: var(--mobile-sidebar-width);
        overflow: hidden;
        padding: max(8px, env(safe-area-inset-top)) 6px max(8px, env(safe-area-inset-bottom));
        position: relative;
        top: auto;
        width: var(--mobile-sidebar-width);
        z-index: 51;
    }

    .sidebar-header,
    .sidebar-collapsed .sidebar-header {
        flex: 0 0 auto;
        justify-content: center;
        margin: 0 0 10px;
        min-height: 42px;
        width: 100%;
    }

    .sidebar-toggle-desktop {
        display: none;
    }

    .sidebar-toggle-mobile {
        display: inline-flex;
    }

    .sidebar-logo,
    .sidebar-collapsed .sidebar-logo {
        display: none;
    }

    .nav-panel,
    .sidebar-footer,
    .sidebar-collapsed .nav-panel,
    .sidebar-collapsed .sidebar-footer {
        display: flex;
        flex-direction: column;
        min-width: 0;
        overflow-x: hidden;
        width: 100%;
    }

    .nav-panel {
        flex: 1 1 auto;
        overflow-y: auto;
        padding-right: 0;
    }

    .sidebar-footer {
        flex: 0 0 auto;
        overflow-y: visible;
    }

    .nav-entry,
    .sidebar-collapsed .nav-entry {
        justify-content: center;
        min-height: 42px;
        min-width: 0;
        padding: 0;
        width: 100%;
    }

    .nav-label,
    .nav-alert,
    .sidebar .switch-track {
        display: none;
    }

    .main-stage {
        grid-column: 2;
        grid-row: 2;
        min-height: 0;
        min-width: 0;
        overflow: auto;
        width: auto;
    }

    .workspace {
        height: 100%;
        min-height: 0;
    }

    .chat-workspace {
        display: grid;
        grid-template-columns: minmax(250px, 36%) minmax(0, 1fr);
        height: 100%;
        min-height: 0;
        overflow: hidden;
        width: 100%;
    }

    .conversation-panel {
        border-bottom: 0;
        border-right: 1px solid var(--line);
        height: 100%;
        max-height: none;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: hidden;
        padding: 12px;
        width: auto;
    }

    .chat-panel {
        height: 100%;
        max-width: none;
        min-height: 0;
        overflow: hidden;
        width: auto;
    }

    .notification-popover {
        max-height: calc(100dvh - 78px - env(safe-area-inset-bottom));
        min-width: 0;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        position: fixed;
        right: max(10px, env(safe-area-inset-right));
        top: 68px;
        width: min(380px, calc(100vw - var(--mobile-sidebar-width) - 20px - env(safe-area-inset-right)));
    }

    .notification-popover .notification-list {
        max-height: none;
        overflow: visible;
    }

    .mobile-sidebar-expanded .sidebar {
        box-shadow: 18px 0 45px rgba(4, 20, 45, .34);
        max-width: min(82vw, 282px);
        min-width: min(82vw, 282px);
        padding-left: 12px;
        padding-right: 12px;
        position: fixed;
        width: min(82vw, 282px);
    }

    .mobile-sidebar-expanded .sidebar-header,
    .mobile-sidebar-expanded.sidebar-collapsed .sidebar-header {
        gap: 8px;
        justify-content: flex-start;
        margin: 0 2px 18px;
        width: auto;
    }

    .mobile-sidebar-expanded .sidebar-logo,
    .mobile-sidebar-expanded.sidebar-collapsed .sidebar-logo {
        display: inline-flex;
        flex: 1 1 auto;
        min-width: 0;
    }

    .mobile-sidebar-expanded .nav-entry,
    .mobile-sidebar-expanded.sidebar-collapsed .nav-entry {
        justify-content: flex-start;
        padding-left: 14px;
        padding-right: 14px;
    }

    .mobile-sidebar-expanded .nav-label,
    .mobile-sidebar-expanded .nav-alert {
        display: inline-block;
    }

    .mobile-sidebar-backdrop {
        background: rgba(6, 18, 35, .42);
        border: 0;
        cursor: pointer;
        display: block;
        inset: 0;
        padding: 0;
        position: fixed;
        z-index: 50;
    }
}

@media (max-width: 640px) {
    .chat-workspace {
        grid-template-columns: minmax(0, 1fr);
    }

    .chat-workspace .conversation-panel {
        display: none;
    }

    .chat-workspace .chat-panel {
        display: grid;
    }

    .chat-workspace.mobile-conversation-list-open .conversation-panel {
        display: flex;
    }

    .chat-workspace.mobile-conversation-list-open .chat-panel {
        display: none;
    }

    .mobile-conversation-back {
        display: inline-flex;
        flex: 0 0 34px;
    }

    .chat-header {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 9px;
        padding: 10px;
    }

    .chat-header > div:not(.chat-header-actions) {
        flex: 1 1 120px;
        max-width: calc(100% - 108px);
        min-width: 0;
    }

    .chat-header-actions {
        justify-content: flex-end;
        margin-left: 0;
        width: 100%;
    }

    .search-toolbar {
        flex-wrap: wrap;
        overflow-x: visible;
        overflow-y: visible;
    }

    .search-toolbar input {
        flex: 1 1 calc(100% - 34px);
        min-width: 0;
    }

    .composer {
        flex-wrap: wrap;
        padding-bottom: max(9px, env(safe-area-inset-bottom));
    }

    .composer > .composer-input-host {
        flex: 1 1 calc(100% - 82px);
        order: 10;
    }

    .composer > .composer-input-host ~ .small-icon-button {
        flex: 0 0 32px;
        order: 11;
    }
}

@media (max-width: 420px) {
    .routing-strip {
        grid-template-columns: minmax(0, 1fr);
    }

    .routing-transfer-button {
        grid-column: auto;
    }
}

/*
 * PWA/mobile: responsive corrections for the administrative cards and tables.
 * Conversation-specific mobile rules are kept in the separate block below.
 */
@media (max-width: 860px) {
    .responsive-admin-module-page {
        box-sizing: border-box;
        max-width: 100%;
        min-width: 0;
        overflow-x: hidden;
        overflow-y: auto;
        width: 100%;
    }

    .responsive-admin-module-page .table-card,
    .responsive-admin-module-page .table-card table,
    .responsive-admin-module-page .table-card tbody,
    .responsive-admin-module-page .table-card tr,
    .responsive-admin-module-page .table-card td {
        box-sizing: border-box;
        max-width: 100%;
        min-width: 0;
        width: 100%;
    }

    .responsive-admin-module-page .table-card table {
        table-layout: auto;
    }

    .responsive-admin-module-page .table-card colgroup {
        display: none;
    }

    .responsive-admin-module-page .table-card td:not(.row-actions) {
        grid-template-columns: minmax(88px, 40%) minmax(0, 1fr);
        overflow: visible;
        width: 100% !important;
    }

    .responsive-admin-module-page .table-card td:not(.row-actions)::before {
        grid-column: 1;
        grid-row: 1;
        min-width: 0;
        overflow-wrap: anywhere;
        word-break: normal;
    }

    .responsive-admin-module-page .table-card td:not(.row-actions) > * {
        grid-column: 2;
        max-width: 100%;
        min-width: 0;
    }

    .responsive-admin-module-page .catalog-table-card td {
        overflow-wrap: normal;
        word-break: normal;
    }

    .responsive-admin-module-page .contact-company-table-card,
    .responsive-admin-module-page .team-table-card {
        max-height: none;
    }

    .responsive-admin-module-page .contact-company-table-card table,
    .responsive-admin-module-page .team-table-card table,
    .responsive-admin-module-page .catalog-table-card table {
        min-width: 0;
        table-layout: auto;
        width: 100%;
    }

    .responsive-admin-module-page .contact-toolbar {
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
    }

    .responsive-admin-module-page .contact-toolbar-main,
    .responsive-admin-module-page .contact-toolbar-config,
    .responsive-admin-module-page .contact-import-actions {
        flex-wrap: wrap;
        justify-content: flex-start;
        min-width: 0;
        width: 100%;
    }

    .responsive-admin-module-page .contact-toolbar .contact-search-field {
        display: grid;
        gap: 6px;
        min-width: 0;
        width: 100%;
    }

    .responsive-admin-module-page .contact-toolbar-config > label {
        align-items: stretch;
        display: grid;
        flex: 1 1 174px;
        gap: 6px;
        min-width: 0;
    }

    .responsive-admin-module-page .contact-toolbar-config select {
        max-width: none;
        min-width: 0;
        width: 100%;
    }

    .responsive-admin-module-page .contact-import-actions .secondary-button,
    .responsive-admin-module-page .contact-import-actions .file-action-button {
        flex: 1 1 138px;
        justify-content: center;
    }

    .responsive-admin-module-page .contact-toolbar-config .contact-column-menu {
        left: 0;
        max-width: calc(100vw - var(--mobile-sidebar-width, 64px) - 24px);
        min-width: 0;
        right: auto;
        width: min(220px, calc(100vw - var(--mobile-sidebar-width, 64px) - 24px));
    }

    .responsive-admin-module-page .team-toolbar {
        align-items: stretch;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        justify-content: stretch;
        width: 100%;
    }

    .responsive-admin-module-page .team-toolbar > label {
        align-items: stretch;
        display: grid;
        gap: 6px;
        min-width: 0;
        width: 100%;
    }

    .responsive-admin-module-page .team-toolbar > label input {
        min-width: 0;
        width: 100%;
    }

    .responsive-admin-module-page .team-toolbar .contact-column-picker {
        justify-self: start;
    }

    .responsive-admin-module-page .team-toolbar .contact-column-menu {
        left: 0;
        max-width: calc(100vw - var(--mobile-sidebar-width, 64px) - 24px);
        min-width: 0;
        right: auto;
        width: min(220px, calc(100vw - var(--mobile-sidebar-width, 64px) - 24px));
    }

    .permission-module-page .permission-page,
    .permission-module-page .permission-layout,
    .permission-module-page .permission-admin-grid,
    .permission-module-page .permission-panel {
        max-width: 100%;
        min-width: 0;
        width: 100%;
    }

    .permission-module-page .permission-tabs {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        justify-self: stretch;
        width: 100%;
    }

    .permission-module-page .permission-tabs button {
        font-size: .72rem;
        min-height: 40px;
        min-width: 0;
        padding-left: 6px;
        padding-right: 6px;
    }

    .permission-module-page .permission-panel-header {
        flex-wrap: wrap;
    }

    .permission-module-page .permission-panel-header .status-pill {
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .permission-module-page .permission-table-scroll,
    .permission-module-page .permission-table-scroll.catalog,
    .permission-module-page .permission-table-scroll.audit {
        max-height: none;
        overflow: visible;
        width: 100%;
    }

    .permission-module-page .permission-assignment-layout .permission-panel .permission-table,
    .permission-module-page .permission-catalog-layout .permission-table,
    .permission-module-page .denied-panel .permission-table {
        min-width: 0;
        table-layout: auto;
        width: 100%;
    }

    .permission-module-page .permission-table th,
    .permission-module-page .permission-table td {
        overflow: visible;
        width: 100% !important;
    }

    .permission-module-page .permission-table td:first-child strong,
    .permission-module-page .permission-table td:first-child span {
        overflow: visible;
        text-overflow: clip;
        white-space: normal;
    }

    .permission-module-page .permission-mode {
        min-width: 0;
        width: 100%;
    }
}

/* Chat mobile: compact conversation header, bounded pickers and stable composer. */
.composer-tools-row {
    display: contents;
}

.composer-audio-recording-hint {
    align-items: center;
    color: #b42318;
    display: inline-flex;
    flex: 1 1 auto;
    font-size: 11px;
    font-weight: 700;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.composer-audio-recording-hint .material-symbols-rounded {
    animation: composer-audio-pulse 1.1s ease-in-out infinite;
    font-size: 17px;
    flex: 0 0 auto;
}

@keyframes composer-audio-pulse {
    0%, 100% { opacity: .45; }
    50% { opacity: 1; }
}

.conversation-tools-panel {
    min-width: 0;
    width: 100%;
}

@media (max-width: 640px) {
    .chat-workspace.mobile-conversation-list-open .conversation-panel > .search-toolbar,
    .chat-workspace.mobile-conversation-list-open .conversation-panel > .conversation-inbox-tabs,
    .chat-workspace.mobile-conversation-list-open .conversation-panel > .filter-row {
        flex: 0 0 auto;
    }

    .chat-panel {
        max-width: 100%;
        min-width: 0;
    }

    .chat-header {
        align-items: center;
        display: grid;
        flex-wrap: nowrap;
        gap: 6px;
        grid-template-columns: 32px minmax(0, 1fr) auto;
        grid-row: 1;
        min-height: 52px;
        padding: 7px 8px;
    }

    .chat-header > .mobile-conversation-back {
        grid-column: 1;
        grid-row: 1;
        height: 32px;
        min-width: 32px;
        width: 32px;
    }

    .chat-header > .avatar,
    .chat-header > .contact-avatar {
        display: none;
    }

    .chat-header > div:not(.chat-header-actions) {
        flex: none;
        grid-column: 2;
        grid-row: 1;
        max-width: none;
        min-width: 0;
        width: auto;
    }

    .chat-header > div:not(.chat-header-actions) p {
        display: none;
    }

    .chat-header h1 {
        display: block;
        font-size: 16px;
        margin: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .chat-header-actions {
        flex-wrap: nowrap;
        gap: 4px;
        grid-column: 3;
        grid-row: 1;
        justify-content: flex-end;
        margin: 0;
        order: initial;
        width: auto;
    }

    .chat-header-actions .primary-pill.icon-only,
    .chat-header-actions .refresh-pill,
    .conversation-tools-toggle {
        flex: 0 0 32px;
        height: 32px;
        min-height: 32px;
        min-width: 32px;
        padding: 0;
        width: 32px;
    }

    .chat-header-actions .primary-pill:not(.icon-only) {
        font-size: 12px;
        min-height: 32px;
        padding: 0 10px;
    }

    .header-context-menu {
        bottom: auto;
        box-sizing: border-box;
        left: calc(var(--mobile-sidebar-width, 64px) + 10px);
        max-height: calc(100dvh - 124px);
        min-width: 0;
        position: fixed;
        right: 10px;
        top: 116px;
        width: auto;
    }

    .chat-panel.conversation-tools-collapsed > .routing-strip {
        display: none;
    }

    .routing-strip {
        align-items: end;
        gap: 5px;
        grid-template-columns: minmax(0, 1fr) minmax(0, .9fr) 34px;
        grid-row: 2;
        min-height: 0;
        padding: 6px 8px 7px;
    }

    .routing-field,
    .routing-field:nth-child(1),
    .routing-field:nth-child(2) {
        gap: 3px;
        max-width: none;
    }

    .routing-field > span {
        font-size: 9px;
    }

    .routing-strip .routing-field:nth-child(1) .routing-select,
    .routing-strip .routing-field:nth-child(2) .priority-select {
        min-height: 32px;
        width: 100%;
    }

    .routing-transfer-button {
        grid-column: auto;
        height: 34px;
        min-height: 34px;
        min-width: 34px;
        padding: 0;
        width: 34px;
    }

    .routing-transfer-button > span:last-child {
        display: none;
    }

    .conversation-tools-panel,
    .contact-insight-strip,
    .conversation-trace-panel,
    .conversation-trace-list {
        box-sizing: border-box;
        max-width: 100%;
        min-width: 0;
    }

    .conversation-tools-panel {
        grid-row: 3;
    }

    .message-tools-slot {
        grid-row: 4;
    }

    .message-surface {
        grid-row: 5;
        overflow-x: hidden;
    }

    .message-bubble,
    .message-bubble p,
    .message-bubble a {
        max-width: 100%;
        min-width: 0;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .message-bubble .attachment-image {
        height: auto;
        max-width: 100%;
    }

    .composer {
        align-items: center;
        bottom: auto;
        display: grid;
        gap: 7px;
        grid-template-columns: minmax(0, 1fr) 32px 32px 32px 32px;
        grid-template-rows: 32px 42px;
        grid-row: 6;
        min-height: 99px;
        min-width: 0;
        padding: 9px 10px max(9px, env(safe-area-inset-bottom));
        position: static;
    }

    .composer-tools-row {
        align-items: center;
        display: flex;
        gap: 7px;
        grid-column: 1 / -1;
        grid-row: 1;
        min-width: 0;
    }

    .composer-audio-recording-hint {
        flex: 1 1 100%;
        min-width: 0;
    }

    .composer > .composer-input-host {
        flex: none;
        grid-column: 1;
        grid-row: 2;
        min-width: 0;
        order: initial;
        width: 100%;
    }

    .composer > .composer-send-button,
    .composer > .composer-audio-button,
    .composer > .composer-input-host ~ .small-icon-button {
        align-self: center;
        flex: none;
        height: 32px;
        min-width: 32px;
        order: initial;
        width: 32px;
    }

    .composer > .composer-expand-button {
        grid-column: 2;
        grid-row: 2;
    }

    .composer > .composer-internal-note-button {
        grid-column: 3;
        grid-row: 2;
    }

    .composer > .composer-send-button {
        grid-column: 4;
        grid-row: 2;
    }

    .composer > .composer-audio-button {
        grid-column: 5;
        grid-row: 2;
    }

    /* Keep message actions inside the mobile viewport instead of opening
       outside the clipped message surface to the left. */
    .message-context-menu,
    .message-context-menu.inbound-menu,
    .message-context-menu.outbound-menu {
        bottom: calc(82px + env(safe-area-inset-bottom));
        box-sizing: border-box;
        left: auto;
        max-height: min(60dvh, 360px);
        max-width: calc(100vw - 20px);
        min-width: min(210px, calc(100vw - 20px));
        overflow-x: hidden;
        overflow-y: auto;
        position: fixed;
        right: 10px;
        top: auto;
    }

    .emoji-picker,
    .quick-reply-picker,
    .suggested-reply-picker {
        bottom: calc(108px + env(safe-area-inset-bottom));
        box-sizing: border-box;
        left: calc(var(--mobile-sidebar-width, 64px) + 10px);
        margin: 0;
        max-width: none;
        min-width: 0;
        position: fixed;
        right: 10px;
        width: auto;
        z-index: 80;
    }

    .emoji-picker {
        grid-template-columns: repeat(6, 32px);
        justify-content: center;
        max-height: min(48dvh, 270px);
        overflow-y: auto;
    }

    .quick-reply-picker,
    .suggested-reply-picker {
        max-height: min(52dvh, 360px);
    }

    .quick-reply-option {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .quick-reply-option-scope {
        grid-column: 2;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .quick-reply-picker-list,
    .suggested-reply-list {
        min-height: 0;
        overflow-y: auto;
    }
}

@media (max-width: 380px) {
    .login-shell {
        padding: 8px;
    }

    .login-panel {
        padding: 22px;
    }

    .login-brand {
        gap: 8px;
    }

    .login-brand .aicon-logo-mark {
        height: 40px;
        width: 40px;
    }

    .login-brand .aicon-wordmark-image {
        height: 24px;
    }

    .login-brand .logo-chat {
        font-size: 22px;
    }

    .login-brand p {
        font-size: 11px;
    }
}
.collaboration-strip {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .45rem .8rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    background: #f8fafc;
    font-size: .82rem;
}

.collaboration-presence,
.collaboration-warning {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .55rem;
    border-radius: 999px;
}

.collaboration-presence { color: #334155; background: #e2e8f0; }
.collaboration-presence.typing { color: #075985; background: #e0f2fe; }
.collaboration-warning { color: #92400e; background: #fef3c7; }
.collaboration-strip .material-symbols-rounded { font-size: 1rem; }
.collaboration-warning button {
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.working-hours-automation,
.working-hours-exceptions {
    display: grid;
    gap: .65rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.working-hours-automation textarea { min-height: 4.5rem; }
.working-hours-exception-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

.working-hours-exception-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    padding: .5rem .65rem;
    border-radius: .55rem;
    background: #f8fafc;
}

.working-hours-exception-row span { display: grid; gap: .1rem; }

.follow-up-alerts,
.selected-follow-ups { display: grid; gap: .4rem; padding: .65rem; background: #fff7ed; border-bottom: 1px solid #fed7aa; }
.follow-up-alerts strong { display: flex; align-items: center; gap: .35rem; color: #9a3412; }
.follow-up-alerts button { display: grid; gap: .1rem; text-align: left; border: 0; border-radius: .45rem; padding: .45rem; background: #fff; cursor: pointer; }
.selected-follow-ups span { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: .8rem; }
.selected-follow-ups span.due { color: #b91c1c; }
.selected-follow-ups button { border: 0; border-radius: .35rem; padding: .2rem .4rem; cursor: pointer; }
.quality-config-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.quality-checklist-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .65rem; }
.quality-checklist-chips span { padding: .3rem .5rem; border-radius: 999px; background: #eef2ff; }
.quality-checklist-chips button { border: 0; background: transparent; cursor: pointer; }
.quality-criterion { justify-content: space-between; padding: .55rem; border-radius: .45rem; background: #f8fafc; }
.quality-feedback-alert { display: grid; gap: .3rem; margin: .55rem; padding: .65rem; border-radius: .55rem; background: #eef2ff; color: #3730a3; }
.quality-feedback-alert button { justify-self: start; border: 0; border-radius: .35rem; padding: .3rem .5rem; cursor: pointer; }

/* =========================================================
   Seguimientos
   ========================================================= */
.follow-up-modal {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    max-height: min(90dvh, 760px);
    max-width: 720px;
    overflow: hidden;
    padding: 0;
    width: min(94vw, 720px);
}

.follow-up-modal > .follow-up-modal-header {
    background: #ffffff;
    border-bottom: 1px solid #e4e9f1;
    flex: 0 0 auto;
    padding: 20px 22px 17px;
    position: relative;
}

.follow-up-title-group {
    align-items: center;
    display: flex;
    gap: 13px;
    min-width: 0;
}

.follow-up-title-icon {
    align-items: center;
    background: #fff1e8;
    border-radius: 12px;
    color: var(--accent, #ff6b00);
    display: inline-flex;
    flex: 0 0 44px;
    font-size: 25px;
    height: 44px;
    justify-content: center;
}

.follow-up-title-group h2 {
    color: #172033;
    font-size: 20px;
    font-weight: 850;
    line-height: 1.2;
}

.follow-up-title-group p {
    color: #62708a;
    font-size: 13px;
    line-height: 1.35;
    margin: 4px 0 0;
}

.follow-up-form {
    gap: 16px;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 18px 22px 20px;
}

.follow-up-context {
    align-items: center;
    background: #f7f9fc;
    border: 1px solid #e4e9f1;
    border-radius: 12px;
    display: grid;
    gap: 12px;
    grid-template-columns: auto minmax(130px, .8fr) minmax(280px, 1.7fr);
    padding: 13px 15px;
}

.follow-up-contact-avatar {
    flex: 0 0 44px;
    height: 44px;
    width: 44px;
}

.follow-up-contact {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.follow-up-contact strong,
.follow-up-context-details strong {
    color: #172033;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.follow-up-contact strong {
    font-size: 14px;
}

.follow-up-contact > span {
    color: #62708a;
    font-size: 12px;
}

.follow-up-context-details {
    border-left: 1px solid #dbe3ef;
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding-left: 14px;
}

.follow-up-context-details > span {
    display: grid;
    gap: 2px;
    grid-template-columns: auto minmax(0, 1fr);
    min-width: 0;
}

.follow-up-context-details .material-symbols-rounded {
    color: var(--accent, #ff6b00);
    font-size: 17px;
    grid-row: 1 / span 2;
    margin-right: 4px;
}

.follow-up-context-details small {
    color: #7b879b;
    font-size: 10px;
    font-weight: 750;
    line-height: 1.1;
    text-transform: uppercase;
}

.follow-up-context-details strong {
    font-size: 11px;
    font-weight: 750;
}

.follow-up-form-grid {
    display: grid;
    gap: 15px 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.follow-up-field {
    display: grid !important;
    gap: 7px;
    min-width: 0;
}

.follow-up-field-full {
    grid-column: 1 / -1;
}

.follow-up-field-label {
    align-items: center;
    color: #33415c;
    display: flex;
    font-size: 12px;
    font-style: normal;
    font-weight: 800;
    gap: 5px;
    justify-content: flex-start;
}

.follow-up-field-label > strong,
.follow-up-modal-footer > span strong {
    color: var(--accent, #ff6b00);
}

.follow-up-field-label > em {
    background: #eef2f7;
    border-radius: 999px;
    color: #68758b;
    font-size: 10px;
    font-style: normal;
    font-weight: 750;
    padding: 2px 7px;
}

.follow-up-field-label > small {
    color: #8994a7;
    font-size: 10px;
    font-weight: 650;
    margin-left: auto;
}

.follow-up-field > input,
.follow-up-field > select,
.follow-up-field > textarea {
    border: 1px solid #cfd8e6;
    border-radius: 9px;
    box-sizing: border-box;
    font: inherit;
    margin: 0;
    min-width: 0;
    padding: 10px 12px;
    width: 100%;
}

.follow-up-field > input,
.follow-up-field > select {
    height: 42px;
}

.follow-up-field > textarea {
    line-height: 1.4;
    min-height: 68px;
    resize: vertical;
}

.follow-up-field > input:focus,
.follow-up-field > select:focus,
.follow-up-field > textarea:focus {
    border-color: var(--accent, #ff6b00);
    box-shadow: 0 0 0 3px rgba(255, 107, 0, .13);
    outline: 0;
}

.follow-up-field > small,
.follow-up-helper {
    color: #77849a;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
}

.follow-up-helper {
    align-items: center;
    display: flex;
    gap: 5px;
}

.follow-up-helper .material-symbols-rounded {
    color: #4674a7;
    font-size: 15px;
}

.follow-up-modal > .follow-up-modal-footer {
    align-items: center;
    background: #ffffff;
    border-top: 1px solid #e4e9f1;
    display: flex;
    flex: 0 0 auto;
    justify-content: space-between;
    margin: 0;
    padding: 14px 22px 16px;
    position: relative;
}

.follow-up-modal-footer > span {
    color: #7b879b;
    font-size: 11px;
}

.follow-up-modal-footer > div {
    display: flex;
    gap: 10px;
}

.follow-up-modal-footer .primary-pill,
.follow-up-modal-footer .secondary-button {
    align-items: center;
    display: inline-flex;
    justify-content: center;
    min-height: 40px;
}

.follow-up-modal-footer .primary-pill .material-symbols-rounded {
    font-size: 18px;
}

@media (max-width: 680px) {
    .follow-up-modal {
        max-height: calc(100dvh - 16px);
        width: 100%;
    }

    .follow-up-modal > .follow-up-modal-header,
    .follow-up-form,
    .follow-up-modal > .follow-up-modal-footer {
        padding-left: 16px;
        padding-right: 16px;
    }

    .follow-up-context {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .follow-up-context-details {
        border-left: 0;
        border-top: 1px solid #dbe3ef;
        grid-column: 1 / -1;
        padding: 11px 0 0;
    }

    .follow-up-form-grid {
        grid-template-columns: 1fr;
    }

    .follow-up-field-full {
        grid-column: auto;
    }
}

@media (max-width: 460px) {
    .follow-up-title-icon,
    .follow-up-modal-footer > span {
        display: none;
    }

    .follow-up-title-group h2 {
        font-size: 18px;
    }

    .follow-up-context-details {
        grid-template-columns: 1fr;
    }

    .follow-up-modal > .follow-up-modal-footer,
    .follow-up-modal-footer > div {
        width: 100%;
    }

    .follow-up-modal-footer > div > button {
        flex: 1 1 0;
    }
}

@media (max-width: 760px) {
    .history-modal-panel {
        height: calc(100vh - 16px);
        max-height: calc(100vh - 16px);
        max-width: calc(100vw - 16px);
        width: calc(100vw - 16px);
    }

    .conversation-preview-modal {
        height: calc(100vh - 16px);
        max-height: calc(100vh - 16px);
        max-width: calc(100vw - 16px);
        width: calc(100vw - 16px);
    }

    .history-modal-header {
        align-items: stretch;
        flex-wrap: wrap;
        gap: 10px;
    }

    .history-modal-title {
        flex: 1 1 100%;
    }

        .history-modal-title small {
            white-space: normal;
        }

    .history-modal-header-actions {
        align-items: center;
        flex: 1 1 100%;
        justify-content: space-between;
    }

    .history-line-selector {
        flex: 1 1 auto;
        min-width: 0;
    }

        .history-line-selector select {
            max-width: none;
            min-width: 0;
            width: 100%;
        }

    .history-layout {
        grid-template-columns: minmax(150px, 42%) minmax(0, 1fr);
    }
}

@media (max-width: 560px) {
    .history-layout {
        display: flex;
        flex-direction: column;
        overflow-y: auto;
    }

    .history-list {
        flex: 0 0 auto;
        max-height: 210px;
        overflow-y: auto;
    }

    .history-detail {
        flex: 1 1 auto;
        min-height: 420px;
    }
}

/* =========================================================
   Configuración CRM
   ========================================================= */
.crm-config-module-page {
    padding-left: clamp(20px, 4vw, 64px);
    padding-right: clamp(20px, 4vw, 64px);
}

.crm-config-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 12px 34px rgba(23, 32, 51, .07);
    color: #172033;
    display: block;
    margin: 0 auto;
    max-width: 1120px;
    overflow: hidden;
    width: 100%;
}

.crm-config-header {
    align-items: center;
    border-bottom: 1px solid #e5eaf1;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    padding: 18px 20px;
}

.crm-config-title,
.crm-config-section-heading,
.crm-config-safety-note,
.crm-config-loading,
.crm-config-empty {
    align-items: center;
    display: flex;
}

.crm-config-title {
    gap: 12px;
}

.crm-config-title > .material-symbols-rounded {
    align-items: center;
    background: #eaf2ff;
    border-radius: 10px;
    color: #0b4b92;
    display: inline-flex;
    font-size: 24px;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.crm-config-title h2,
.crm-config-section-heading h3 {
    color: #172033;
    margin: 0;
}

.crm-config-title h2 {
    font-size: 16px;
}

.crm-config-title p,
.crm-config-section-heading p {
    color: #64748b;
    margin: 4px 0 0;
}

.crm-config-status {
    align-items: center;
    border-radius: 999px;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 900;
    gap: 5px;
    min-height: 30px;
    padding: 5px 11px;
    text-transform: uppercase;
}

.crm-config-status .material-symbols-rounded {
    font-size: 17px;
}

.crm-config-status.active {
    background: #dcfce7;
    color: #166534;
}

.crm-config-status.inactive {
    background: #f1f5f9;
    color: #64748b;
}

.crm-config-line-bar {
    background: #f7f9fc;
    border-bottom: 1px solid #e5eaf1;
    padding: 14px 20px;
}

.crm-config-field {
    color: #475569;
    display: grid;
    font-size: 12px;
    font-weight: 800;
    gap: 7px;
    min-width: 0;
}

.crm-config-field > span {
    line-height: 1.2;
}

.crm-config-line-field {
    max-width: 520px;
}

.crm-config-field select,
.crm-config-field input {
    background: #ffffff;
    border: 1px solid #d7e0eb;
    border-radius: 9px;
    color: #172033;
    font-weight: 700;
    min-height: 42px;
    outline: 0;
    padding: 8px 11px;
    width: 100%;
}

.crm-config-field select:focus,
.crm-config-field input:focus {
    border-color: #ff6500;
    box-shadow: 0 0 0 3px rgba(255, 101, 0, .13);
}

.crm-config-field select:disabled,
.crm-config-field input:disabled {
    background: #f3f6fa;
    color: #738096;
    cursor: not-allowed;
    opacity: 1;
}

.crm-config-loading,
.crm-config-empty {
    color: #64748b;
    gap: 9px;
    justify-content: center;
    min-height: 180px;
    padding: 24px;
}

.crm-config-loading .material-symbols-rounded {
    animation: crm-config-spin 1s linear infinite;
    color: #ff6500;
}

@keyframes crm-config-spin {
    to { transform: rotate(360deg); }
}

.crm-config-empty {
    flex-direction: column;
}

.crm-config-empty .material-symbols-rounded {
    color: #94a3b8;
    font-size: 36px;
}

.crm-config-empty p {
    margin: 0;
}

.crm-config-body {
    display: grid;
    gap: 14px;
    padding: 18px 20px;
}

.crm-config-section {
    background: #fbfcfe;
    border: 1px solid #e4e9f1;
    border-radius: 11px;
    padding: 16px;
}

.crm-config-section-heading {
    gap: 10px;
    margin-bottom: 14px;
}

.crm-config-section-heading > .material-symbols-rounded {
    color: #0b4b92;
    font-size: 22px;
}

.crm-config-section-heading h3 {
    font-size: 14px;
}

.crm-config-section-heading p {
    font-size: 11.5px;
}

.crm-config-card .crm-form-grid {
    gap: 13px 14px;
}

.crm-active-toggle {
    align-items: center;
    align-self: end;
    background: #ffffff;
    border: 1px solid #d7e0eb;
    border-radius: 9px;
    color: #172033;
    display: flex;
    gap: 10px;
    min-height: 42px;
    padding: 7px 11px;
}

.crm-active-toggle .switch-input:checked {
    background: #ff6500;
}

.crm-active-toggle > span {
    display: grid;
    gap: 1px;
}

.crm-active-toggle strong {
    font-size: 12px;
}

.crm-active-toggle small {
    color: #64748b;
    font-size: 10.5px;
}

.crm-final-state-grid {
    display: grid;
    gap: 9px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.crm-final-state-option {
    align-items: center;
    background: #ffffff;
    border: 1px solid #d7e0eb;
    border-radius: 9px;
    color: #334155;
    cursor: pointer;
    display: flex;
    font-weight: 800;
    gap: 9px;
    min-height: 40px;
    padding: 8px 11px;
}

.crm-final-state-option:has(input:checked) {
    background: #fff4eb;
    border-color: #ff9a57;
    color: #9a3412;
}

.crm-final-state-option input {
    accent-color: #ff6500;
    height: 16px;
    margin: 0;
    width: 16px;
}

.crm-final-state-option:has(input:disabled) {
    cursor: not-allowed;
    opacity: .72;
}

.crm-config-footer {
    align-items: center;
    border-top: 1px solid #e5eaf1;
    display: flex;
    gap: 14px;
    justify-content: flex-end;
    padding: 15px 20px;
}

.crm-config-safety-note {
    color: #64748b;
    font-size: 11.5px;
    gap: 7px;
    margin-right: auto;
    max-width: 610px;
}

.crm-config-safety-note .material-symbols-rounded {
    color: #16803c;
    font-size: 19px;
}

.crm-readonly-note {
    background: #f1f5f9;
    border-radius: 999px;
    color: #64748b;
    font-size: 11px;
    font-weight: 800;
    padding: 6px 10px;
}

.crm-config-error {
    margin: 16px 20px 0;
}

.crm-config-retry {
    display: flex;
    justify-content: flex-end;
    padding: 12px 20px 18px;
}

.crm-config-retry .material-symbols-rounded {
    font-size: 17px;
}

@media (max-width: 820px) {
    .crm-final-state-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .crm-config-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .crm-config-footer .primary-pill {
        justify-content: center;
    }
}

@media (max-width: 640px) {
    .crm-config-module-page {
        padding-left: 12px;
        padding-right: 12px;
    }

    .crm-config-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .crm-config-line-bar,
    .crm-config-body,
    .crm-config-header,
    .crm-config-footer {
        padding-left: 14px;
        padding-right: 14px;
    }

    .crm-final-state-grid {
        grid-template-columns: 1fr;
    }
}

/* Conversation mobile hardening: keep header, details and composer inside the viewport. */
@media (max-width: 640px) {
    .chat-header {
        align-items: center;
        grid-template-columns: 32px minmax(0, 1fr);
        grid-template-rows: 32px 32px;
        min-height: 78px;
    }

    .chat-header-actions {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: flex-end;
        min-width: 0;
        width: 100%;
    }

    .chat-header-actions .primary-pill:not(.icon-only) {
        font-size: 11px;
        padding-inline: 8px;
    }

    .conversation-tools-panel {
        max-height: min(48dvh, 420px);
        overflow-x: hidden;
        overflow-y: auto;
    }

    .contact-insight-strip {
        gap: 6px;
        grid-template-columns: minmax(0, 1fr);
        padding: 6px 8px;
    }

    .contact-insight-card,
    .contact-insight-card strong,
    .contact-insight-card span {
        max-width: 100%;
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .conversation-trace-panel {
        padding: 6px 8px;
    }

    .conversation-trace-list {
        display: grid;
        gap: 6px;
        grid-template-columns: minmax(0, 1fr);
        overflow-x: hidden;
    }

    .conversation-trace-item {
        box-sizing: border-box;
        flex: none;
        max-width: 100%;
        min-width: 0;
        width: 100%;
    }

    .composer {
        box-sizing: border-box;
        grid-template-columns: minmax(0, 1fr) repeat(4, 32px);
        grid-template-rows: 32px 42px 32px;
        min-height: 138px;
        overflow: hidden;
        width: 100%;
    }

    .composer-tools-row {
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
    }

    .composer-tools-row::-webkit-scrollbar {
        display: none;
    }

    .composer > .composer-input-host {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .composer > .composer-expand-button {
        grid-column: 2;
        grid-row: 3;
    }

    .composer > .composer-internal-note-button {
        grid-column: 3;
        grid-row: 3;
    }

    .composer > .composer-send-button {
        grid-column: 4;
        grid-row: 3;
    }

    .composer > .composer-audio-button {
        grid-column: 5;
        grid-row: 3;
    }
}

@media (max-width: 380px) {
    .chat-header-actions {
        gap: 3px;
    }

    .chat-header-actions .primary-pill:not(.icon-only) {
        padding-inline: 6px;
    }

    .composer {
        gap: 6px;
        padding-inline: 8px;
    }
}

.mobile-composer-expanded-heading {
    display: none;
}

/* Mobile-only full-screen editor for long messages. Desktop keeps its current expansion. */
@media (max-width: 640px) {
    .composer.composer-expanded {
        background: #ffffff;
        bottom: 0;
        grid-template-columns: minmax(0, 1fr) repeat(4, 32px);
        grid-template-rows: auto minmax(0, 1fr) 32px;
        height: 100dvh;
        left: var(--mobile-sidebar-width, 64px);
        max-height: 100dvh;
        max-width: calc(100vw - var(--mobile-sidebar-width, 64px));
        padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
        position: fixed;
        right: 0;
        top: 0;
        width: auto;
        z-index: 500;
    }

    .composer.composer-expanded .mobile-composer-expanded-heading {
        display: grid;
        gap: 2px;
        grid-column: 1 / -1;
        grid-row: 1;
        min-width: 0;
    }

    .composer.composer-expanded .mobile-composer-expanded-heading strong {
        color: #172033;
        font-size: 16px;
    }

    .composer.composer-expanded .mobile-composer-expanded-heading small {
        color: #64748b;
        font-size: 11px;
    }

    .composer.composer-expanded .composer-tools-row {
        display: none;
    }

    .composer.composer-expanded > .composer-input-host {
        align-self: stretch;
        grid-column: 1 / -1;
        grid-row: 2;
        height: 100%;
        min-height: 0;
    }

    .composer.composer-expanded > .composer-input-host textarea {
        box-sizing: border-box;
        direction: ltr;
        display: block;
        height: 100%;
        max-height: none;
        max-width: 100%;
        min-height: 0;
        min-width: 0;
        overflow-wrap: anywhere;
        overflow-x: hidden;
        overflow-y: auto;
        resize: none;
        text-align: start;
        unicode-bidi: plaintext;
        white-space: pre-wrap;
        width: 100%;
        word-break: break-word;
    }

    .composer.composer-expanded > .composer-expand-button {
        grid-column: 2;
        grid-row: 3;
    }

    .composer.composer-expanded > .composer-internal-note-button {
        grid-column: 3;
        grid-row: 3;
    }

    .composer.composer-expanded > .composer-send-button {
        grid-column: 4;
        grid-row: 3;
    }

    .composer.composer-expanded > .composer-audio-button {
        grid-column: 5;
        grid-row: 3;
    }
}

/* End mobile-only full-screen editor. */
