:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --card: #ffffff;
    --border: #e8ebf0;
    --border-alt: #D1D5DB;
    --text: #1f2937;
    --text-alt: #111111;
    --muted: #6b7280;
    --muted-alt: #5b6878;
    --primary: #0099ff;
    --primary-soft: #e6f7ff;
    --success: #00a650;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 14px;
    --radius-lg: 18px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
    --font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --ml-blue: #009EE3;
    --ml-blue-hover: #0082c8;
    --ml-gray-bg: #F5F5F5;
    --ml-card-border: #E5E5E5;
    --ml-text: #111111;
    --ml-text-muted: #5b6878;
    --ml-shadow: 0 2px 8px rgba(0,0,0,0.04);
    --ml-shadow-hover: 0 6px 16px rgba(0,0,0,0.08);
    /* Nuevo diseño Canva */
    --sidebar-icon-width: 80px;
    --panel-width: 280px;
}

@font-face {
    font-family: 'Nunito';
    src: url('/static/fonts/nunito-v32-latin-regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Nunito';
    src: url('/static/fonts/nunito-v32-latin-600.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Nunito';
    src: url('/static/fonts/nunito-v32-latin-700.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Nunito';
    src: url('/static/fonts/nunito-v32-latin-800.woff2') format('woff2');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    color: var(--text);
    background: var(--bg);
}
button, input, textarea, select { font: inherit; }

/* ========== CABECERA GLOBAL (ANTIGUO, OCULTO) ========== */
.global-header {
    display: none !important;
}

/* ========== SIDEBAR IZQUIERDA (NUEVO DISEÑO) ========== */
.sidebar-icons {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-icon-width);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    z-index: 200;
}

.logo-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 20px;
    margin-bottom: 24px;
}

.icon-btn {
    width: 70px;
    padding: 8px 0;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--muted);
    cursor: pointer;
    margin-bottom: 8px;
    transition: 0.2s;
    background: transparent;
    border: none;
}
.icon-btn i, .icon-btn svg {
    width: 22px;
    height: 22px;
}
.icon-btn span {
    font-size: 10px;
    font-weight: 500;
    text-align: center;
}
.icon-btn:hover {
    background: #f3f4f6;
}
.icon-btn.active {
    background: #e0f2fe;
    color: var(--primary);
}
.icon-btn.active svg {
    stroke: var(--primary);
}

/* Botón toggle panel (solo desktop) */
.toggle-panel-btn {
    margin-top: auto;
    margin-bottom: 16px;
}

/* ========== PANEL SECUNDARIO (NUEVO DISEÑO) ========== */
.secondary-panel {
    position: fixed;
    left: var(--sidebar-icon-width);
    top: 0;
    bottom: 0;
    width: var(--panel-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 28px 20px;
    overflow-y: auto;
    z-index: 150;
    transition: transform 0.2s ease;
}
.secondary-panel.collapsed {
    transform: translateX(-100%);
}
.secondary-panel h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 28px;
    margin-top: 0;
}
.panel-section {
    margin-bottom: 28px;
}
.panel-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 12px;
}
.panel-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text);
    transition: all 0.2s;
    font-weight: 500;
    margin-bottom: 2px;
}
.panel-menu-item i, .panel-menu-item svg {
    width: 18px;
    height: 18px;
    color: var(--muted);
}
.panel-menu-item:hover {
    background: #f5f7fb;
}
.panel-menu-item.active {
    background: #e0f2fe;
    color: var(--primary);
}
.panel-menu-item.active svg {
    stroke: var(--primary);
}

/* Botón cerrar dentro del panel (mobile) */
#closePanelBtn {
    display: none;
    position: absolute;
    right: 16px;
    background: transparent;
    border: none;
    font-size: 24px !important;
    cursor: pointer;
}
.secondary-panel.open #closePanelBtn {
    display: block;
}

/* Overlay para cerrar panel en móvil */
.panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 1000;
    display: none;
}
.panel-overlay.active {
    display: block;
}

/* ========== CONTENIDO PRINCIPAL ========== */
.main-content {
    margin-left: calc(var(--sidebar-icon-width) + var(--panel-width));
    padding: 28px 32px;
    min-height: 100vh;
    transition: margin-left 0.2s ease;
}
.main-content.expanded {
    margin-left: var(--sidebar-icon-width);
}

/* ========== BOTTOM NAV (MOBILE) ========== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    padding: 8px 8px 12px;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.04);
}
.bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--muted);
    font-size: 11px;
    background: none;
    border: none;
    cursor: pointer;
}
.bottom-nav button.active {
    color: var(--primary);
}
.bottom-nav i, .bottom-nav svg {
    width: 20px;
    height: 20px;
}
input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

/* ========== MOBILE (BREAKPOINT 600px) ========== */
@media (max-width: 600px) {
    .sidebar-icons {
        display: none;
    }
    .secondary-panel {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: none;
        display: block !important;
    }
    .secondary-panel.open {
        transform: translateX(0);
        box-shadow: 2px 0 12px rgba(0,0,0,0.1);
        width: 100%;
        z-index: 1002;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 16px;
        padding-bottom: 80px;
    }
    .bottom-nav {
        display: flex !important;
    }
    .toggle-panel-btn {
        display: none;
    }
    /* Ajustes de checkbox en móvil */
    .bulk-select,
    .list-card-header .bulk-select,
    .extra-filters .input-group label input[type="checkbox"] {
        display: inline-block !important;
        width: 18px;
        height: 18px;
        margin-right: 8px;
    }
    /* Filtros chips en móvil */
    .filter-chips {
        flex-wrap: wrap;
        gap: 8px;
    }
    .chip {
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* ========== LAYOUTS Y COMPONENTES EXISTENTES ========== */
.app-shell {
    display: flex;
    min-height: 100vh;
}
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.app-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
}
.view {
    display: none;
    flex-direction: column;
    gap: 20px;
}
.view.is-visible {
    display: flex;
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.page-title {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.03em;
}
.page-subtitle {
    margin: 6px 0 0;
    color: var(--muted-alt);
    font-weight: 500;
}
.page-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}
@media (max-width: 600px) {
    .page-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Tarjetas y contenedores */
.status-banner, .filters-bar, .card {
    background: var(--card);
    border: 1px solid var(--border-alt);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}
.status-banner {
    padding: 14px 16px;
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.card-header {
    padding: 18px 18px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}
.card-body {
    padding: 18px;
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    gap: 16px;
}
.kpi-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.content-grid { display: grid; gap: 16px; }
.content-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 600px) {
    .kpi-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .kpi-grid-3 { grid-template-columns: 1fr; }
    .kpi-grid-2 { grid-template-columns: 1fr; }
    .content-grid-2 { grid-template-columns: 1fr; }
}
.kpi-card, .mini-kpi-card {
    background: var(--card);
    border: 1px solid var(--border-alt);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.kpi-label {
    color: var(--muted-alt);
    font-size: 14px;
    font-weight: 600;
}
.kpi-value {
    font-size: 28px;
    font-weight: 800;
}

/* Filtros */
.filters-bar {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.filters-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.search-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.search-input {
    width: 100%;
    height: 44px;
    border: 1px solid var(--border-alt);
    border-radius: 12px;
    padding: 0 14px;
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,158,227,0.15);
}
.filters-toggle {
    display: none;
    background: var(--primary-soft);
    border: 1px solid var(--primary);
    border-radius: 12px;
    padding: 0 12px;
    height: 44px;
    font-weight: 600;
}
.extra-filters {
    display: none;
    flex-wrap: wrap;
    gap: 12px;
    transition: all 0.2s;
}
.extra-filters.open {
    display: flex;
}
@media (max-width: 600px) {
    .filters-toggle {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }
    .extra-filters {
        display: none;
        flex-direction: column;
        width: 100%;
    }
    .extra-filters.open {
        display: flex;
    }
    .extra-filters .input-group {
        width: 100%;
    }
}

/* Filter chips */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    padding: 8px 0;
}
.chip {
    border: 1px solid var(--border-alt);
    background: #fff;
    height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
    color: var(--muted-alt);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.chip:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}
.chip.is-active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
    font-weight: 700;
}

/* Tablas */
.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}
.table th, .table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border-alt);
    text-align: left;
    vertical-align: middle;
}
.table th {
    color: var(--muted-alt);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.card-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 18px;
}

/* Badges de estado */
.status-badge {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.01em;
}
.status-success {
    background: rgba(0, 166, 80, 0.12);
    color: var(--success);
}
.status-warning {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}
.status-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}
.status-pending {
    background: rgba(0, 158, 227, 0.12);
    color: var(--primary);
}

/* Botones */
.primary-button, .secondary-button, .text-button, .icon-button, .table-action-button {
    border: 0;
    cursor: pointer;
    border-radius: 12px;
    font-weight: 700;
    transition: all 0.2s;
}
.primary-button {
    background: var(--primary);
    color: #fff;
    padding: 0 18px;
    height: 44px;
    font-size: 15px;
    box-shadow: 0 4px 12px rgba(0, 158, 227, 0.3);
    letter-spacing: -0.01em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.primary-button:hover {
    background: #0082c8;
    box-shadow: 0 6px 16px rgba(0, 158, 227, 0.45);
    transform: translateY(-1px);
}
.secondary-button {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 0 18px;
    height: 44px;
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.secondary-button:hover {
    background: var(--primary-soft);
    transform: translateY(-1px);
}
.text-button {
    background: transparent;
    color: var(--primary);
    padding: 0;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.text-button:hover {
    color: #0082c8;
}
.icon-button {
    width: 40px;
    height: 40px;
    background: transparent;
    color: var(--muted-alt);
    justify-content: center;
    display: inline-flex;
    align-items: center;
    border-radius: 10px;
}
.icon-button:hover {
    background: var(--primary-soft);
    color: var(--primary);
}
.table-action-button {
    background: #fff;
    color: var(--primary);
    padding: 6px 10px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.table-action-button:hover {
    background: var(--primary-soft);
    color: #0082c8;
}

/* Formularios */
.form-row {
    display: grid;
    gap: 12px;
}
.form-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-row-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 600px) {
    .form-row-2, .form-row-3, .form-row-4, .form-row-5 {
        grid-template-columns: 1fr !important;
    }
}
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.input-group label {
    color: var(--muted-alt);
    font-weight: 600;
}
.input-group input, .input-group textarea, .input-group select {
    min-height: 44px;
    border: 1px solid var(--border-alt);
    border-radius: 12px;
    padding: 10px 14px;
    background: #fff;
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-group input:focus, .input-group textarea:focus, .input-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,158,227,0.15);
}

/* Listados (grid de cards) */
.list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}
@media (max-width: 600px) {
    .list-grid {
        grid-template-columns: 1fr;
    }
}
.list-card {
    background: var(--card);
    border: 1px solid var(--border-alt);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.list-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.list-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
}
.list-card-title {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-alt);
}
.list-card-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.list-card-field {
    display: flex;
    flex-direction: column;
    flex: 1;
}
.list-card-label {
    font-size: 12px;
    color: var(--muted-alt);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: 2px;
}
.list-card-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-alt);
}
.list-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-alt);
    padding-top: 10px;
    margin-top: 4px;
}
.list-card-highlight {
    font-weight: 800;
    font-size: 18px;
    color: var(--primary);
}
.bulk-select {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Ocultar edición masiva en móviles (mantener checkboxes visibles) */
@media (max-width: 600px) {
    #bulk-actions-bar {
        display: none !important;
    }
}

/* Alertas */
.alert-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.alert-item {
    border: 1px solid var(--border-alt);
    background: #fff;
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    text-align: left;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.2s;
}
.alert-item:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}
.alert-level {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    margin-top: 6px;
    flex-shrink: 0;
}
.alert-level.is-danger {
    background: var(--danger);
}
.alert-level.is-warning {
    background: var(--warning);
}
.alert-item .icon-button {
    margin-left: auto;
    opacity: 0;
    width: 32px;
    height: 32px;
}
.alert-item:hover .icon-button {
    opacity: 1;
}

/* Drawers y paneles laterales */
.drawer, .modal {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1000;
}
.drawer-overlay, .modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    opacity: 0;
    transition: 0.2s;
    backdrop-filter: blur(2px);
}
.drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 520px;
    max-width: 100%;
    height: 100%;
    background: var(--bg);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: 0.25s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.drawer-panel-left {
    right: auto;
    left: 0;
    transform: translateX(-100%);
}
.drawer.is-open .drawer-panel {
    transform: translateX(0);
}
.drawer-body {
    padding: 18px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-height: calc(100vh - 68px);
    background: var(--bg);
}
.drawer-header, .drawer-footer, .modal-header, .modal-footer {
    height: 68px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-alt);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.drawer-footer, .modal-footer {
    border-top: 1px solid var(--border-alt);
    border-bottom: 0;
    gap: 10px;
    height: 76px;
}
.drawer.is-open, .modal.is-open {
    pointer-events: auto;
}
.drawer.is-open .drawer-overlay, .modal.is-open .modal-overlay {
    opacity: 1;
}
@media (max-width: 600px) {
    .drawer-panel, .drawer-panel-lg {
        width: 100%;
        border-radius: 0;
    }
    .drawer-footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        min-height: 70px;
    }
}

/* Panel lateral de alertas (side-panel) */
.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    pointer-events: none;
    z-index: 1100;
}
.side-panel .side-panel-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    opacity: 0;
    transition: opacity 0.2s;
}
.side-panel .side-panel-content {
    position: absolute;
    top: 0;
    right: 0;
    width: 360px;
    max-width: 100%;
    height: 100%;
    background: #fff;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-alt);
    pointer-events: auto;
}
.side-panel .side-panel-header {
    height: 68px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-alt);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.side-panel .side-panel-body {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    background: var(--bg);
}
.side-panel.is-open {
    pointer-events: auto;
}
.side-panel.is-open .side-panel-overlay {
    opacity: 1;
}
.side-panel.is-open .side-panel-content {
    transform: translateX(0);
}

/* Paginación */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    flex-wrap: wrap;
}
.pagination button {
    background: #fff;
    border: 1px solid var(--border-alt);
    padding: 8px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}
.pagination button:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}
.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 12px 20px;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.2s;
    font-weight: 600;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* HTMX indicador */
#htmx-indicator {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.7);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}
#htmx-indicator.htmx-request {
    display: flex;
}
.htmx-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-alt);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Otros componentes */
.empty-state {
    padding: 28px;
    text-align: center !important;
    color: var(--muted-alt);
}
.welcome-banner {
    background: linear-gradient(135deg, var(--primary-soft), #ffffff);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 20px;
    border: 1px solid var(--primary);
    box-shadow: 0 4px 16px rgba(0, 158, 227, 0.08);
}
.welcome-title {
    font-size: 26px;
    font-weight: 800;
    margin: 0 0 8px;
}
.welcome-subtitle {
    color: var(--muted-alt);
    font-size: 15px;
    margin: 0;
}
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    margin-top: 20px;
}
.quick-action-card {
    background: #ffffff;
    border: 1px solid var(--border-alt);
    border-radius: var(--radius);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    color: var(--text-alt);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.quick-action-card:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    color: var(--primary);
}
.progress-bar-container {
    background: #e9ecef;
    border-radius: 20px;
    overflow: hidden;
    height: 10px;
}
.progress-bar {
    height: 10px;
    border-radius: 20px;
    transition: width 0.3s ease;
    width: var(--width, 0%);
}
.progress-bar-low {
    background-color: #28a745;
}
.progress-bar-warning {
    background-color: #ffc107;
}
.progress-bar-danger {
    background-color: #dc3545;
}
.section-toggle {
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 8px;
}
.subscription-banner {
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 600;
    text-align: center;
}
.subscription-banner.info {
    background: #e6f7ff;
    color: #0070c9;
    border: 1px solid #91d5ff;
}
.subscription-banner.error {
    background: #fff1f0;
    color: #cf1322;
    border: 1px solid #ffa39e;
}
.floating-menu {
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    min-width: 180px;
    z-index: 100;
    overflow: hidden;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    transition: background 0.2s;
}
.menu-item:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

/* Estilos de SUSCRIPCIÓN */
.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 30px;
    margin: 32px 0;
}
.plan-card {
    background: var(--card);
    border: 1px solid var(--border-alt);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: var(--shadow);
    position: relative;
}
.plan-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
}
.plan-card.featured {
    border-color: var(--primary);
    box-shadow: 0 8px 24px rgba(0, 158, 227, 0.15);
}
.plan-card.featured::before {
    content: "🔥 Más popular";
    position: absolute;
    top: -12px;
    right: 24px;
    background: var(--primary);
    color: white;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.plan-name {
    font-size: 24px;
    font-weight: 800;
    margin: 0;
}
.plan-description {
    color: var(--muted-alt);
    font-size: 14px;
    margin: 0;
    line-height: 1.4;
}
.plan-price {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -0.04em;
    margin: 0;
}
.plan-price small {
    font-size: 16px;
    font-weight: 600;
    color: var(--muted-alt);
}
.plan-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.plan-features li {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 14px;
    color: var(--muted-alt);
}
.plan-features li::before {
    content: "✓";
    color: var(--success);
    font-weight: 800;
    background: rgba(0, 166, 80, 0.1);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.plan-btn {
    display: block;
    width: 100%;
    padding: 14px;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 15px;
    text-align: center;
    text-decoration: none;
    transition: all 0.2s;
    margin-top: 8px;
    border: 2px solid transparent;
}
.plan-btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.plan-btn-primary:hover {
    background: #0082c8;
    transform: translateY(-2px);
}
.plan-btn-secondary {
    border-color: var(--primary);
    color: var(--primary);
    background: transparent;
}
.plan-btn-secondary:hover {
    background: var(--primary-soft);
    transform: translateY(-1px);
}
.plans-toggle {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}
.plans-toggle-buttons {
    display: flex;
    background: var(--surface);
    border-radius: 999px;
    padding: 4px;
    border: 1px solid var(--border-alt);
}
.plans-toggle-button-month,
.plans-toggle-button-year {
    padding: 8px 18px;
    border: none;
    border-radius: 999px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    color: var(--muted-alt);
}
.plans-toggle-button-month.active,
.plans-toggle-button-year.active {
    background: var(--primary);
    color: white;
}
.plans-toggle-saving {
    margin-left: 10px;
    background: rgba(0, 166, 80, 0.1);
    color: var(--success);
    padding: 8px 14px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 13px;
}

/* Estilos de INTEGRACIONES */
.integrations-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-alt);
    margin-bottom: 24px;
}
.tab-btn {
    background: transparent;
    border: none;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    color: var(--muted-alt);
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.platforms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}
.platform-card {
    background: var(--surface);
    border: 1px solid var(--border-alt);
    border-radius: 20px;
    padding: 20px;
    transition: all 0.2s;
}
.platform-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.platform-header {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 16px;
}
.platform-icon {
    width: 48px;
    height: 48px;
    background: var(--bg);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}
.platform-header h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 4px;
}
.platform-desc {
    font-size: 13px;
    color: var(--muted-alt);
    margin: 0;
}
.platform-status {
    margin-bottom: 16px;
}
.status-badge.connected {
    background: rgba(0, 166, 80, 0.1);
    color: var(--success);
}
.status-badge.disconnected {
    background: rgba(91, 104, 120, 0.1);
    color: var(--muted-alt);
}
.platform-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.btn-primary-ml, .btn-outline-ml {
    padding: 8px 18px;
    border-radius: 40px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
}
.btn-primary-ml {
    background: var(--primary);
    color: white;
}
.btn-primary-ml:hover {
    background: #0082c8;
    transform: translateY(-1px);
}
.btn-outline-ml {
    border: 1px solid var(--primary);
    color: var(--primary);
    background: white;
}
.btn-outline-ml:hover {
    background: var(--primary-soft);
}
.simulator-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.input-ml {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-alt);
    border-radius: 12px;
    font-size: 14px;
}
.simulation-result {
    padding: 12px;
    border-radius: 12px;
    background: #f8f9fa;
    margin-top: 12px;
}

/* Action buttons grid */
.action-buttons-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 80px;
}

/* Ajustes generales responsive (adicionales) */
@media (max-width: 600px) {
    .app-content {
        padding: 16px;
    }
    .kpi-value {
        font-size: 24px;
    }
    .table-view {
        display: none !important;
    }
    .card-list {
        display: flex !important;
        flex-direction: column;
        gap: 12px;
    }
    .table-card {
        background: var(--card);
        border: 1px solid var(--border-alt);
        border-radius: var(--radius-lg);
        padding: 16px;
        display: flex;
        flex-direction: column;
        gap: 10px;
        cursor: pointer;
    }
    .table-card .card-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
    }
    .table-card .card-row.primary {
        font-size: 16px;
        font-weight: 700;
    }
    .table-card .card-row.secondary {
        font-size: 14px;
        color: var(--muted-alt);
    }
    .global-header {
        display: none;
    }
    .primary-button, .secondary-button {
        height: 48px;
        font-size: 16px;
    }
}
@media (min-width: 601px) {
    .card-list {
        display: none !important;
    }
    .table-view {
        display: block !important;
    }
}

/* Estilos de autenticación */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    padding: 16px;
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px 28px;
    text-align: center;
}
.auth-logo {
    width: 120px;
    height: 49px;
    display: grid;
    place-items: center;
    margin: 0 auto 20px;
}
.auth-title {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}
.auth-subtitle {
    color: var(--muted-alt);
    margin-bottom: 28px;
}
.auth-input-group {
    margin-bottom: 20px;
    text-align: left;
}
.auth-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-alt);
    border-radius: 12px;
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,158,227,0.15);
}
.auth-input-code {
    font-size: 20px;
    text-align: center;
    letter-spacing: 4px;
}
.auth-button {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 158, 227, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.auth-button:hover {
    background: #0082c8;
    box-shadow: 0 6px 16px rgba(0, 158, 227, 0.45);
    transform: translateY(-1px);
}
.auth-message {
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 20px;
}
.auth-message.error {
    background: #fee2e2;
    color: var(--danger);
}
.auth-message.success {
    background: #e0f2e6;
    color: var(--success);
}
.auth-footer-link {
    margin-top: 20px;
    font-size: 14px;
}
.auth-footer-link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
.auth-card-wide {
    max-width: 480px;
}
.brand-option {
    display: flex;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--border-alt);
    border-radius: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.brand-option:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
}
.brand-option input {
    margin-right: 16px;
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
}
.brand-info {
    flex: 1;
}
.brand-name {
    font-weight: 700;
    margin-bottom: 4px;
}
.brand-meta {
    font-size: 13px;
    color: var(--muted-alt);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-alt);
}
.tab {
    border: none;
    background: transparent;
    padding: 10px 16px;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    color: var(--muted-alt);
    font-weight: 600;
    transition: all 0.2s;
}
.tab:hover {
    color: var(--primary);
}
.tab.active {
    border-bottom-color: var(--primary);
    color: var(--primary);
}
.tab-pane {
    display: none;
}
.tab-pane.active {
    display: block;
}

/* Utilidades generales */
.w-full { width: 100%; }
.jc-center { justify-content: center; }
.mb-8 { margin-bottom: 8px; }
.mt-8 { margin-top: 8px; }
.mb-15 { margin-bottom: 15px; }
.mb-20 { margin-bottom: 20px; }
.mt-15 { margin-top: 15px; }
.text-align-right { text-align: right; }
.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.text-button-link {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

/* Badge de notificaciones (campana) */
#alert-sidebar-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    isolation: auto;
}
/* Badge de alerta con z-index alto */
#alert-badge-sidebar {
    position: absolute;
    top: -6px;
    right: 0px;
    background: var(--danger);
    color: white;
    border-radius: 20px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
    line-height: 1.2;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 0 2px rgba(0,0,0,0.2);
    animation: pulse-badge 1.5s ease infinite;
}
/* Si el botón no tiene relative, forzarlo */
.icon-btn {
    position: relative;
}
#alert-badge-sidebar:empty {
    display: none;
}

.alert-badge {
    width: 20px; 
    height: 20px; 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 11px; 
    top: -4px; 
    right: -4px;
}
/* Animación de pulso para el badge de alertas */
@keyframes pulse-badge {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.9;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
@media (max-width: 600px) {
    .grid-3 { grid-template-columns: 1fr; }
}
.drawer-panel-lg { width: 768px; }
.section-header-inline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.search-results-list { display: flex; flex-direction: column; }
.search-result-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background 0.15s; }
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--primary-soft); }
.client-name { font-weight: 600; }
.client-phone { font-size: 13px; color: var(--muted); }
.search-result-item .empty-state { padding: 12px; text-align: center; color: var(--muted); }
/* ========== INBOX (BANDEJA DE ENTRADA) ========== */
.inbox-container {
    display: flex;
    gap: 24px;
    min-height: calc(100vh - 120px);
}

.inbox-list {
    width: 360px;
    flex-shrink: 0;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-alt);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.inbox-filters {
    padding: 16px;
    border-bottom: 1px solid var(--border-alt);
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-alt);
    cursor: pointer;
    transition: background 0.2s;
}

.conversation-item:hover {
    background: var(--primary-soft);
}

.conversation-avatar {
    width: 48px;
    height: 48px;
    background: var(--bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.conversation-preview {
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.unread-badge {
    background: var(--primary);
    color: white;
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    margin-top: 4px;
    display: inline-block;
}

/* Chat panel */
.inbox-chat {
    flex: 1;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-alt);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-alt);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-contact {
    font-weight: 600;
}

.chat-status {
    font-size: 12px;
    color: var(--muted);
    margin-left: 8px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 70%;
}

.message.inbound {
    align-self: flex-start;
}

.message.outbound {
    align-self: flex-end;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    background: var(--bg);
    color: var(--text);
    word-break: break-word;
}

.message.outbound .message-bubble {
    background: var(--primary);
    color: white;
}

.message-time {
    font-size: 10px;
    color: var(--muted);
    margin-top: 4px;
    margin-left: 8px;
}

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

.chat-input form {
    display: flex;
    gap: 12px;
}

.chat-input input {
    flex: 1;
    border: 1px solid var(--border-alt);
    border-radius: 40px;
    padding: 10px 16px;
    outline: none;
}

.chat-input input:focus {
    border-color: var(--primary);
}

/* Responsive mobile */
@media (max-width: 600px) {
    .inbox-container {
        flex-direction: column;
    }
    .inbox-list {
        width: 100%;
        max-height: 300px;
    }
}
.pipeline-container {
    overflow-x: auto;
    padding-bottom: 16px;
}
.pipeline-columns {
    display: flex;
    gap: 20px;
    min-width: fit-content;
}
.pipeline-column {
    width: 280px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-alt);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 160px);
}
.pipeline-column-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-alt);
    font-weight: 700;
    background: var(--bg);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.pipeline-column-body {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    min-height: 300px;
}
.pipeline-card {
    background: var(--card);
    border: 1px solid var(--border-alt);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 12px;
    cursor: grab;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}
.pipeline-card:active {
    cursor: grabbing;
}
.pipeline-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.pipeline-card .contact-name {
    font-weight: 700;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
}
.pipeline-card .last-message {
    font-size: 12px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pipeline-card .whatsapp-badge {
    font-size: 10px;
    background: #25d36620;
    color: #075e54;
    padding: 2px 6px;
    border-radius: 20px;
}
.empty-column {
    text-align: center;
    color: var(--muted);
    padding: 20px;
    font-size: 13px;
}

/* ========== NUEVO CENTRO DE VENTAS ========== */
.app {
    display: flex;
    height: 100vh;
    width: 100%;
    background: var(--bg);
}

/* Panel izquierdo (bandejas) */
.inbox-panel {
    width: 320px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Estadísticas del vendedor (colapsable) */
.seller-stats {
    background: #f9fafb;
    margin: 16px;
    border-radius: 20px;
    overflow: hidden;
}
.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: white;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.stats-header h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
}
.stats-content {
    padding: 16px;
    display: none;
}
.stats-content.open {
    display: block;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 13px;
}
.stat-label {
    color: var(--muted);
}
.stat-value {
    font-weight: 700;
    color: var(--primary);
}

/* Filtros de bandeja */
.filter-buttons {
    padding: 0 16px 16px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid var(--border);
}
.filter-btn {
    background: #f3f4f6;
    border: none;
    border-radius: 30px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.filter-btn.active {
    background: var(--primary);
    color: white;
}

/* Búsqueda */
.search-box {
    margin: 16px;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.search-box input {
    border: none;
    background: none;
    width: 100%;
    outline: none;
    font-size: 14px;
}

/* Lista de conversaciones */
.conversations-list {
    flex: 1;
    overflow-y: auto;
}
.convo-item {
    padding: 16px;
    border-bottom: 1px solid #f0f2f5;
    cursor: pointer;
    transition: background 0.2s;
}
.convo-item:hover {
    background: #f9fafb;
}
.convo-item.active {
    background: #eef2ff;
    border-left: 3px solid var(--primary);
}
.convo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.convo-name {
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.attention-badge {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 30px;
    font-weight: 600;
}
.badge-nuevo { background: #fee2e2; color: #dc2626; }
.badge-sinatender { background: #fed7aa; color: #ea580c; }
.badge-atencion { background: #dbeafe; color: #2563eb; }
.badge-espera { background: #fef08a; color: #854d0e; }
.badge-seguimiento { background: #e9d5ff; color: #6b21a5; }
.badge-vendido { background: #dcfce7; color: #16a34a; }
.sale-badge {
    font-size: 10px;
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 30px;
}
.convo-amount {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    margin: 6px 0 4px;
}
.convo-assignee {
    font-size: 11px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}
.convo-last-msg {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.convo-time {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 4px;
}

/* Área central de chat */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    min-width: 0;
}
.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chat-contact h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}
.chat-contact p {
    font-size: 12px;
    color: var(--muted);
    margin: 4px 0 0;
}
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f9fafb;
}
.message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
}
.message.inbound {
    align-self: flex-start;
}
.message.outbound {
    align-self: flex-end;
}
.bubble {
    padding: 10px 14px;
    border-radius: 18px;
    background: white;
    box-shadow: 0 1px 1px rgba(0,0,0,0.05);
    font-size: 14px;
}
.message.outbound .bubble {
    background: var(--primary);
    color: white;
}
.time {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 4px;
    margin-left: 8px;
}
.message-input {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
}
.message-input input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 12px 18px;
    outline: none;
}
.message-input button {
    background: var(--primary);
    border: none;
    border-radius: 30px;
    padding: 0 20px;
    color: white;
    font-weight: 600;
    cursor: pointer;
}

/* Panel derecho (acciones) */
.actions-panel {
    width: 260px;
    background: white;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 16px;
}
.client-card, .quick-buttons {
    background: #f9fafb;
    border-radius: 16px;
    padding: 16px;
}
.section-title {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 12px;
}
.client-field {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 13px;
}
.client-field i {
    width: 20px;
    color: #9ca3af;
}
.quick-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.quick-btn {
    background: white;
    border: 1px solid var(--border);
    border-radius: 40px;
    padding: 10px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
}
.quick-btn:hover {
    background: #f3f4f6;
    border-color: var(--primary);
}
.note-area textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 10px;
    font-size: 12px;
    resize: vertical;
}
.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 40px 20px;
}

/* Paginación */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-top: 1px solid var(--border);
}
.pagination button {
    background: white;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
}
.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.pagination span {
    font-size: 12px;
}

/* Mobile */
@media (max-width: 900px) {
    .inbox-panel, .actions-panel {
        position: fixed;
        top: 0;
        bottom: 0;
        z-index: 20;
        transform: translateX(-100%);
        transition: transform 0.2s;
    }
    .actions-panel {
        right: 0;
        transform: translateX(100%);
    }
    .inbox-panel.open, .actions-panel.open {
        transform: translateX(0);
    }
    .mobile-buttons {
        display: flex;
        position: fixed;
        bottom: 20px;
        right: 20px;
        gap: 10px;
        z-index: 30;
    }
    .mobile-btn {
        background: var(--primary);
        border: none;
        border-radius: 50%;
        width: 50px;
        height: 50px;
        color: white;
        font-size: 20px;
        cursor: pointer;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    }
    .chat-area {
        width: 100%;
    }
}
/* Asegurar que la barra de entrada quede abajo */
.chat-area {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f9fafb;
}
.message-input {
    flex-shrink: 0;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    background: white;
}
.client-card, .quick-buttons, .status-selector {
    margin-bottom: 16px;
}