/* =========================================================
   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 {
    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, #9bd0ff, #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 {
    height: 1px;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    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;
}

.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;
}

.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: #242c3b;
    --panel: #30394d;
    --line: rgba(255, 255, 255, 0.11);
    --text: #f6f8fc;
    --muted: #b7bfce;
    --accent: #9ccbff;
    background: linear-gradient(135deg, rgba(74, 85, 107, 0.92), rgba(32, 40, 56, 0.98)), #202838;
    color: var(--text);
    min-height: 100vh;
}

.login-shell {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 28px;
}

.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;
    max-width: 390px;
    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;
    outline: 0;
    padding: 9px 11px;
}

.login-button {
    justify-content: center;
    margin-top: 4px;
    width: 100%;
}

/* =========================================================
   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;
}

.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(2, minmax(0, 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 {
    min-width: 238px;
    right: 0;
    top: 42px;
}

.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);
}

.floating-add {
    align-items: center;
    background: #9bd0ff;
    border: 0;
    border-radius: 999px;
    bottom: 14px;
    color: #10233b;
    display: inline-flex;
    height: 46px;
    justify-content: center;
    left: 32px;
    position: absolute;
    width: 46px;
}

.chat-panel {
    display: grid;
    grid-template-rows: 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;
}

.chat-header-actions .resolve-pill {
    border-bottom-right-radius: 0;
    border-right: 1px solid rgba(16, 35, 59, 0.22);
    border-top-right-radius: 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.16);
}

.primary-pill.icon-only:not(.refresh-pill) {
    align-items: center;
    border-bottom-left-radius: 0;
    border-top-left-radius: 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.16);
    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 190px 380px;
    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;
    }

    /* Agente */
    .routing-field:nth-child(3) {
        max-width: 220px;
    }

    /* Unidad */
    .routing-field:nth-child(4) {
        max-width: 320px;
    }

    .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-strip .routing-field:nth-child(3) .routing-select {
    width: 190px;
}

.routing-strip .routing-field:nth-child(4) .routing-select {
    width: 380px;
}

.tag-chip {
    background: #53617a;
    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 12px 18px;
}

.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 p {
        font-weight: 700;
        font-size: 12.5px;
        line-height: 1.3;
        margin: 0;
    }

    .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: 10px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .28);
    display: grid;
    gap: 2px;
    min-width: 190px;
    padding: 8px;
    position: absolute;
    right: 10px;
    top: 34px;
    z-index: 30;
}

    .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 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;
}

/* =========================================================
   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;
}

.card-menu {
    position: absolute;
    right: 14px;
    top: 14px;
}

.connection-title {
    align-items: flex-start;
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
    min-width: 0;
}

    .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;
    }

.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;
    }

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;
}

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 {
    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;
    }

.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;
}

.permission-toolbar {
    justify-content: space-between;
}

    .permission-toolbar label:first-child {
        flex: 1 1 260px;
    }

    .permission-toolbar input {
        width: 100%;
    }

.permission-admin-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
    margin-bottom: 16px;
}

.permission-layout {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.permission-panel {
    min-width: 0;
}

.permission-panel-header {
    align-items: flex-start;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 14px;
}

    .permission-panel-header h2 {
        font-size: 15px;
        margin: 0 0 4px;
    }

    .permission-panel-header p {
        color: var(--muted);
        margin: 0;
    }

.permission-table {
    min-width: 560px;
}

.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 {
    margin-bottom: 16px;
}

.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 {
    min-height: 130px;
    resize: vertical;
}

.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;
        }

.prompt-panel textarea,
.theme-card select,
.modal-form input,
.modal-form select,
.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, #9bd0ff, #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, #9bd0ff, #08736d);
        border-radius: 8px 8px 0 0;
        flex: 1 1 0;
        min-width: 14px;
    }

.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;
}

.theme-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* =========================================================
   Modales / historial
   ========================================================= */
.modal-backdrop {
    align-items: center;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    inset: 0;
    justify-content: center;
    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);
}

    .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;
}

.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 {
        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));
}

.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-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 {
    background: var(--main-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    display: grid;
    gap: 6px;
    min-height: 98px;
    padding: 10px;
    text-align: left;
}

    .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-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-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-messages .message-bubble {
        max-width: 76%;
    }

.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 (max-width: 1180px) {
    .app-shell {
        grid-template-columns: 82px minmax(0, 1fr);
    }

    .brand-text,
    .nav-label,
    .nav-alert,
    .sidebar .switch-track {
        display: none;
    }

    .sidebar {
        padding-left: 8px;
        padding-right: 8px;
    }

    .nav-entry {
        justify-content: center;
        padding: 0;
    }

    .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;
    }

    .nav-panel,
    .sidebar-footer {
        flex-direction: row;
        min-width: max-content;
        overflow: visible;
    }

    .nav-entry {
        min-width: 48px;
    }

    .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-admin-grid,
    .permission-form-grid,
    .permission-form-grid.task-form {
        grid-template-columns: 1fr;
    }

        .permission-form-grid .wide-field {
            grid-column: auto;
        }
}

/* =========================================================
   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;
    }

.message-deleted {
    align-items: center;
    color: var(--muted);
    display: flex;
    font-style: italic;
    gap: 6px;
    margin: 0;
}

    .message-deleted .material-symbols-rounded {
        font-size: 16px;
    }

.message-bubble.deleted {
    opacity: .82;
}


.message-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

.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;
    }

.forward-message-panel {
    max-width: 560px;
}


 .forward-route-grid {
    display: grid;
    gap: 10px;
}

.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-list {
    border: 1px solid var(--border);
    border-radius: 12px;
    display: grid;
    max-height: 340px;
    overflow: auto;
}

.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;
    }
/* Indicador de mensaje editado en WhatsApp */
.message-bubble time .edited-flag {
    font-style: italic;
    opacity: 0.75;
    margin-right: 0.35rem;
    font-size: 0.7rem;
}

/* Texto de ayuda en modales */
.modal-hint {
    font-size: 0.8rem;
    opacity: 0.75;
    margin: 0 0 0.5rem 0;
}
