/* ============================================================
   Plenus Growth OS — App Styles
   ============================================================ */

/* === Login === */
.login-page {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: linear-gradient(135deg, var(--navy-darkest) 0%, var(--navy-dark) 50%, var(--navy) 100%);
}
.login-card { width: 400px; max-width: 90vw; }
.login-header { text-align: center; padding: var(--space-8) var(--space-5) var(--space-4); }
.login-logo { font-size: 40px; font-weight: 800; letter-spacing: -1px; color: var(--gray-900); }
.login-logo .logo-d { color: var(--primary); font-size: 48px; }
.login-subtitle { color: var(--gray-400); font-size: var(--font-sm); letter-spacing: 2px; text-transform: uppercase; margin-top: var(--space-1); }
.login-form { padding: 0 var(--space-5) var(--space-6); }
.form-group { margin-bottom: var(--space-4); }
.form-group label { display: block; font-size: var(--font-sm); font-weight: 500; color: var(--gray-600); margin-bottom: var(--space-1); }
.form-group input, .form-group select {
    width: 100%; padding: var(--space-2) var(--space-3); border: 1px solid var(--gray-200);
    border-radius: var(--radius-md); font-family: var(--font-family); font-size: var(--font-md);
    transition: border-color 0.2s; outline: none; background: white;
}
input[type="email"], input[name*="email"], input[id*="email"], input[id*="Email"], .email-input {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
    letter-spacing: 0.01em;
}
.form-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(2,150,108,0.1); }
.form-error { background: #fee2e2; color: #991b1b; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); font-size: var(--font-sm); margin-bottom: var(--space-3); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }

/* === App Layout === */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-width); background: var(--navy-darkest); color: white; display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 10; overflow: hidden;
}
.sidebar__logo { padding: var(--space-5); font-size: 24px; font-weight: 800; letter-spacing: -1px; border-bottom: 1px solid rgba(255,255,255,0.08); flex-shrink: 0; }
.sidebar__logo .logo-d { color: var(--primary-light, #0ab98a); font-size: 28px; }
.sidebar__nav { flex: 1; padding: var(--space-3); display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; }
.nav-item {
    display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3);
    color: var(--gray-400); border-radius: var(--radius-md); font-size: var(--font-md); text-decoration: none; transition: all 0.2s;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-item.active { background: rgba(252,41,129,0.16); color: var(--lum-pink, #FC2981); font-weight: 600; }
.sidebar__footer { padding: var(--space-4); border-top: 1px solid rgba(255,255,255,0.08); flex-shrink: 0; }
.sidebar__user { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.avatar {
    width: 36px; height: 36px; border-radius: var(--radius-full); background: var(--primary); color: white;
    display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: var(--font-md);
}
.user-info { display: flex; flex-direction: column; }
.user-name { font-size: var(--font-sm); font-weight: 500; color: white; }
.user-role { font-size: var(--font-xs); color: var(--gray-400); text-transform: capitalize; }
.main-content { flex: 1; margin-left: var(--sidebar-width); background: var(--gray-50); }
.top-header {
    display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-6);
    background: white; border-bottom: 1px solid var(--gray-200); height: var(--header-height);
}
.header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: nowrap; }
.impersonate-selector-wrap {
    display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
    background: var(--gray-100, #f1f5f9); padding: 4px 12px; border-radius: 20px;
    border: 1px solid var(--gray-200, #e2e8f0);
}
.impersonate-selector-wrap select {
    padding: 3px 8px; font-size: 12px; border-radius: 12px; border: 1px solid #cbd5e1;
    background: #fff; cursor: pointer; outline: none; font-weight: 500; color: var(--gray-800);
}
.page-title { font-size: var(--font-2xl); font-weight: 700; color: var(--gray-900); }
.page-content { padding: var(--space-6); }
.loading { text-align: center; padding: var(--space-8); color: var(--gray-400); }
.text-muted { color: var(--gray-400); font-size: var(--font-sm); }

/* === KPI Grid === */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); margin-bottom: var(--space-6); }
.kpi-card { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-5); }
.kpi-card__icon { width: 48px; height: 48px; border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kpi-card__data { display: flex; flex-direction: column; }
.kpi-value { font-size: var(--font-3xl); font-weight: 700; color: var(--gray-900); line-height: 1; }
.kpi-label { font-size: var(--font-sm); color: var(--gray-500); margin-top: var(--space-1); }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.sem-row, .ind-row { display: flex; align-items: center; justify-content: space-between; padding: var(--space-2) 0; }
.sem-dot { width: 10px; height: 10px; border-radius: var(--radius-full); display: inline-block; margin-right: var(--space-2); flex-shrink: 0; }
.sem-count { font-weight: 600; font-size: var(--font-lg); }

/* === Dashboard v2 (Luminous Education flat style) === */
.dash-kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }
.dash-kpi { background: #fff; border: 1px solid rgba(0,2,61,0.08); border-radius: 0.75rem; padding: var(--space-5); }
.dash-kpi__icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: var(--space-3); }
.dash-kpi__value { font-family: var(--lum-font-heading); font-size: 2rem; font-weight: 800; color: var(--lum-deep-blue); line-height: 1; }
.dash-kpi__label { font-family: var(--lum-font-body); font-size: 12px; color: var(--gray-500); font-weight: 500; margin-top: 4px; }

.dash-card { background: #fff; border: 1px solid rgba(0,2,61,0.08); border-radius: 0.75rem; overflow: hidden; }
.dash-card__header { padding: var(--space-4) var(--space-5); border-bottom: 1px solid rgba(0,2,61,0.06); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dash-card__header h3 { font-family: var(--lum-font-heading); font-size: 15px; font-weight: 700; color: var(--lum-deep-blue); margin: 0; display: flex; align-items: center; gap: 8px; }
.dash-card__body { padding: var(--space-5); }

.dash-stat-strip { display: flex; flex-wrap: wrap; background: #fff; border: 1px solid rgba(0,2,61,0.08); border-radius: 0.75rem; overflow: hidden; }
.dash-stat-strip__item { flex: 1; min-width: 120px; padding: var(--space-4) var(--space-5); text-align: center; border-right: 1px solid rgba(0,2,61,0.06); }
.dash-stat-strip__item:last-child { border-right: none; }
.dash-stat-strip__value { font-family: var(--lum-font-heading); font-size: 22px; font-weight: 800; color: var(--lum-deep-blue); }
.dash-stat-strip__label { font-family: var(--lum-font-body); font-size: 11px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.03em; margin-top: 2px; }

.dash-mini-stats { display: flex; justify-content: space-around; margin-top: var(--space-3); }
.dash-mini-stat { text-align: center; }
.dash-mini-stat__value { font-family: var(--lum-font-heading); font-size: 20px; font-weight: 800; color: var(--lum-deep-blue); }
.dash-mini-stat__label { font-family: var(--lum-font-body); font-size: 11px; color: var(--gray-500); margin-top: 2px; }

.dash-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--gray-300); gap: 8px; text-align: center; }
.dash-empty .material-symbols-outlined { font-size: 32px; }
.dash-empty span.dash-empty__text { font-size: 12px; color: var(--gray-400); }

@media (max-width: 900px) {
    .dash-kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-stat-strip { flex-direction: column; }
    .dash-stat-strip__item { border-right: none; border-bottom: 1px solid rgba(0,2,61,0.06); }
    .dash-stat-strip__item:last-child { border-bottom: none; }
}

/* === Leads === */
.leads-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-4); gap: 8px; flex-wrap: wrap; }
.search-input {
    padding: var(--space-2) var(--space-4); border: 1px solid var(--gray-200); border-radius: var(--radius-md);
    font-family: var(--font-family); font-size: var(--font-md); width: 300px; max-width: 100%; min-width: 0;
    outline: none; background: white;
}
/* Muchos modales usan .search-input dentro de grids/flex de varias columnas
   (ej. "Desde"/"Hasta" lado a lado) -- el ancho fijo de 300px de arriba
   hacia afuera del contenedor y lo recortaba. max-width:100% + min-width:0
   hace que respete el ancho real disponible sin romper su uso normal como
   barra de búsqueda suelta. */
.search-input:focus { border-color: var(--primary); }
/* El fix de arriba no basta por si solo: el <div> que envuelve label+input
   dentro de cada columna del grid es el "grid item" real, y los navegadores
   siguen usando el width:300px del input como aporte al tamaño minimo
   automatico de ESE div (min-width:0 en .search-input no se hereda hacia
   arriba). Sin esto, columnas 1fr se siguen ensanchando de mas y el input
   vuelve a salirse del modal -- visto de nuevo en "Nuevo Profesor" pese al
   fix de arriba. */
[style*="display:grid"] > div { min-width: 0; }
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: var(--space-3) var(--space-4); text-align: left; font-size: var(--font-sm); font-weight: 600; color: var(--gray-500); border-bottom: 1px solid var(--gray-200); background: var(--gray-50); }
.data-table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--gray-100); }
.lead-row { cursor: pointer; transition: background 0.15s; }
.lead-row:hover { background: var(--gray-50); }
.score-pill {
    display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 24px;
    border-radius: var(--radius-full); font-size: var(--font-sm); font-weight: 600; color: white;
}
.score-high { background: #10b981; }
.score-mid { background: #f59e0b; }
.score-low { background: #ef4444; }

/* === Pipeline — acordeon de 21 etapas === */
.pipeline-stage-header { transition: background 0.15s; }
.pipeline-stage-header:hover { background: var(--gray-50); }
.pipeline-stage-header.pipeline-drag-over { background: rgba(2,150,108,0.12); }
.pipeline-card-mini { transition: box-shadow 0.15s; }
.pipeline-card-mini:hover { box-shadow: var(--shadow-md); }
.pipeline-card-mini.dragging { opacity: 0.4; }
.pipeline-card { cursor: grab; }
.pipeline-card.dragging { opacity: 0.4; }
.pipeline-card__header { display: flex; justify-content: space-between; align-items: center; padding: var(--space-3) var(--space-3) var(--space-1); }
.pipeline-card__body { padding: 0 var(--space-3); }
.pipeline-card__body span { display: block; font-size: var(--font-sm); }
.pipeline-card__footer { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3) var(--space-3); }
.empty-stage { text-align: center; padding: var(--space-6); color: var(--gray-300); font-size: var(--font-sm); }

/* === Modal === */
.modal, .modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 100; overflow-y: auto; padding: 20px 16px; }
.modal-content { width: 600px; max-width: 90vw; max-height: calc(100vh - 40px); overflow-y: auto; background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); }
.modal-content.card { overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--gray-200); }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--gray-400); padding: 4px 8px; border-radius: 4px; }
.modal-close:hover { background: var(--gray-100); color: var(--gray-900); }
/* BEM modal (used by Kommo import) */
.modal__backdrop { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
.modal__content { width: 720px; max-width: 95vw; max-height: calc(100vh - 40px); overflow-y: auto; background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); z-index: 1; }
.modal__header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--gray-200); }
.modal__body { padding: 20px; }

/* === Loading === */
.loading-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--navy-darkest), var(--navy-dark), var(--navy)); color: white; }
.loading-logo { font-size: 48px; font-weight: 800; letter-spacing: -1px; margin-bottom: var(--space-3); }
.logo-d { color: var(--primary-light, #0ab98a); font-size: 56px; }
.logo-rest { color: white; }
.loading-subtitle { font-size: var(--font-md); color: var(--primary-light, #0ab98a); letter-spacing: 2px; text-transform: uppercase; margin-bottom: var(--space-8); }
.loading-bar { width: 200px; height: 3px; background: rgba(255,255,255,0.15); border-radius: var(--radius-full); overflow: hidden; }
.loading-bar__fill { height: 100%; background: linear-gradient(90deg, var(--primary-light, #0ab98a), white); border-radius: var(--radius-full); animation: loadingBar 2s ease-in-out infinite; }

/* === Form Select === */
.form-select {
    width: 100%; min-width: 0; padding: var(--space-2) var(--space-3); border: 1px solid var(--gray-200);
    border-radius: var(--radius-md); font-family: var(--font-family); font-size: var(--font-md);
    outline: none; background: white; cursor: pointer;
}
.form-select:focus { border-color: var(--primary); }

/* === Lead Detail 360° === */
.ld-back { margin-bottom: var(--space-4); }
.ld-hero { padding: var(--space-5); display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.ld-hero__main { display: flex; align-items: center; gap: var(--space-4); }
.ld-avatar-lg {
    width: 56px; height: 56px; border-radius: var(--radius-full); background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white; display: flex; align-items: center; justify-content: center; font-size: var(--font-3xl); font-weight: 700; flex-shrink: 0;
}
.ld-hero__info h2 { font-size: var(--font-2xl); margin-bottom: 2px; }
.ld-hero__info p { color: var(--gray-500); font-size: var(--font-md); margin-bottom: var(--space-2); }
.ld-hero__badges { display: flex; align-items: center; gap: var(--space-2); }
.ld-hero__actions { display: flex; gap: var(--space-2); }
.ld-grid { display: grid; grid-template-columns: 1fr 1.5fr; gap: var(--space-4); margin-bottom: var(--space-4); align-items: start; }

/* Info List */
.info-list { display: flex; flex-direction: column; }
.info-item { display: flex; justify-content: space-between; padding: var(--space-2) 0; border-bottom: 1px solid var(--gray-100); font-size: var(--font-md); }
.info-item:last-child { border-bottom: none; }
.info-label { color: var(--gray-500); font-weight: 500; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item {
    display: flex; gap: var(--space-3); padding: var(--space-3) 0; border-left: 2px solid var(--gray-200);
    margin-left: 14px; padding-left: var(--space-4); position: relative;
}
.tl-item::before {
    content: ''; position: absolute; left: -6px; top: 16px; width: 10px; height: 10px;
    border-radius: var(--radius-full); background: var(--gray-300); border: 2px solid white;
}
.tl-note::before { background: #3b82f6; }
.tl-call::before { background: #10b981; }
.tl-email::before { background: #8b5cf6; }
.tl-meeting::before { background: #f59e0b; }
.tl-stage_change::before { background: var(--primary); }
.tl-whatsapp::before { background: #25D366; }
.tl-system::before { background: var(--gray-400); }
.tl-icon { font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.tl-content { flex: 1; min-width: 0; }
.tl-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.tl-header strong { font-size: var(--font-sm); }
.tl-content p { font-size: var(--font-md); color: var(--gray-700); margin: 0; word-break: break-word; }

/* Tasks */
.task-list { display: flex; flex-direction: column; }
.task-item {
    display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) 0;
    border-bottom: 1px solid var(--gray-100); transition: opacity 0.2s;
}
.task-item:last-child { border-bottom: none; }
.task-item input[type="checkbox"] {
    width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0;
}
.task-item__body { flex: 1; min-width: 0; }
.task-title { font-size: var(--font-md); font-weight: 500; display: block; }
.task-meta { display: flex; align-items: center; gap: var(--space-2); margin-top: 2px; flex-wrap: wrap; }
.task-prio-dot { width: 8px; height: 8px; border-radius: var(--radius-full); display: inline-block; flex-shrink: 0; }
.task-done { opacity: 0.5; }
.task-done .task-title { text-decoration: line-through; }
.task-filters { display: flex; gap: var(--space-2); }
.task-filter { background: var(--gray-100); color: var(--gray-600); border: 1px solid var(--gray-200); }
.task-filter.active { background: var(--primary); color: white; border-color: var(--primary); }
.ld-tasks { margin-bottom: var(--space-4); }

/* === Proposal Wizard === */
.btn-accent { background: linear-gradient(135deg, #FFCE38, #f59e0b); color: #1e293b; font-weight: 600; border: none; }
.btn-accent:hover { filter: brightness(1.08); transform: translateY(-1px); }
.services-checklist { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; padding: 8px; background: var(--gray-50); border-radius: var(--radius-md); border: 1px solid var(--gray-200); }
.svc-check { display: flex; align-items: center; gap: var(--space-2); padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; font-size: var(--font-md); transition: background 0.15s; }
.svc-check:hover { background: var(--gray-100); }
.svc-check input { accent-color: var(--primary); width: 16px; height: 16px; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.proposal-row { cursor: pointer; transition: background 0.15s; }
.proposal-row:hover { background: var(--gray-50); }

/* === Notifications Bell === */
.notif-bell { position: relative; cursor: pointer; padding: 8px; border-radius: var(--radius-md); transition: background 0.15s; display: flex; align-items: center; }
.notif-bell:hover { background: var(--gray-100); }
.notif-badge { position: absolute; top: 2px; right: 2px; background: #ef4444; color: white; font-size: 10px; font-weight: 700; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }
.notif-dropdown { position: absolute; top: 52px; right: 16px; width: 360px; background: white; border-radius: var(--radius-lg); box-shadow: 0 12px 40px rgba(0,0,0,0.15); z-index: 1000; border: 1px solid var(--gray-200); overflow: hidden; }
.notif-dropdown__header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--gray-200); background: var(--gray-50); }
.notif-dropdown__body { max-height: 320px; overflow-y: auto; }
.notif-item { display: flex; gap: 12px; padding: 12px 16px; cursor: pointer; transition: background 0.15s; border-bottom: 1px solid var(--gray-100); }
.notif-item:hover { background: var(--gray-50); }
.notif-unread { background: #eff6ff; border-left: 3px solid #3b82f6; }
.notif-icon { font-size: 20px; flex-shrink: 0; }
.notif-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-time { font-size: 11px; color: var(--gray-400); }
.notif-empty { padding: 24px; text-align: center; color: var(--gray-400); font-size: 13px; }

/* === Score Breakdown === */
.score-breakdown { padding: 8px 0; }
.score-bar-group { display: flex; flex-direction: column; gap: 6px; }
.score-bar-item { display: flex; align-items: center; gap: 8px; }
.score-bar-label { font-size: 11px; color: var(--gray-500); width: 80px; text-align: right; }
.score-bar-track { flex: 1; height: 8px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.score-bar-val { font-size: 11px; font-weight: 600; width: 40px; color: var(--gray-600); }
.score-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--gray-100); }
.score-detail-grid small { font-size: 11px; color: var(--gray-500); }

/* === Automations Module === */
.auto-tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--gray-100); padding: 4px; border-radius: var(--radius-lg); }
.auto-tab { flex: 1; padding: 10px 16px; border: none; background: transparent; border-radius: var(--radius-md); font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s; color: var(--gray-500); }
.auto-tab.active { background: white; color: var(--gray-900); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

.templates-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.template-card { background: white; border-radius: var(--radius-lg); border: 1px solid var(--gray-200); padding: 20px; cursor: pointer; transition: all 0.2s; }
.template-card:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(2,150,108,0.1); transform: translateY(-2px); }
.template-card__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.template-icon { font-size: 28px; }
.template-card__title { font-size: 15px; font-weight: 600; color: var(--gray-900); margin-bottom: 4px; }
.template-card__subject { font-size: 12px; color: var(--gray-500); margin-bottom: 12px; }
.template-card__vars { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.var-tag { font-size: 10px; background: var(--gray-100); color: var(--gray-600); padding: 2px 8px; border-radius: 12px; font-family: monospace; }
.template-card__actions { display: flex; gap: 8px; }

.rules-list { display: flex; flex-direction: column; gap: 12px; }
.rule-card { background: white; border-radius: var(--radius-lg); border: 1px solid var(--gray-200); padding: 20px; transition: all 0.2s; }
.rule-card:hover { border-color: var(--gray-300); }
.rule-inactive { opacity: 0.5; }
.rule-card__header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.rule-card__info { display: flex; gap: 12px; align-items: flex-start; }
.rule-icon { font-size: 24px; }
.rule-card__title { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.rule-trigger { font-size: 12px; color: var(--gray-500); }
.rule-card__controls { display: flex; gap: 8px; align-items: center; }
.rule-actions-list { display: flex; flex-direction: column; gap: 6px; padding-left: 36px; }
.rule-action-item { font-size: 13px; color: var(--gray-600); padding: 4px 0; }

.toggle-switch { position: relative; width: 44px; height: 24px; display: inline-block; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--gray-300); border-radius: 12px; transition: 0.3s; }
.toggle-slider::before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.3s; }
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* === Collapsible Sidebar Menu === */
.nav-section { margin-bottom: 2px; }
.nav-section__toggle {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    padding: var(--space-2) var(--space-3); color: var(--gray-400); border-radius: var(--radius-md);
    font-size: var(--font-md); text-decoration: none; transition: all 0.2s; cursor: pointer;
    background: none; border: none; font-family: var(--font-family);
}
.nav-section__toggle:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-section__toggle.active { color: var(--lum-pink, #FC2981); font-weight: 600; }
.nav-section__toggle svg { flex-shrink: 0; }
.nav-section__toggle .toggle-left { display: flex; align-items: center; gap: var(--space-3); }
.nav-section__arrow { transition: transform 0.2s; font-size: 12px; }
.nav-section__arrow.open { transform: rotate(90deg); }
.nav-section__items {
    display: none; flex-direction: column; gap: 1px;
    padding-left: var(--space-6); margin-top: 2px;
    border-left: 1px solid rgba(255,255,255,0.08); margin-left: 22px;
}
.nav-section__items.open { display: flex; }
.nav-section__items .nav-item { font-size: var(--font-sm); padding: 6px var(--space-3); }

/* === Generic List/Detail Styles (reusable across modules) === */
.module-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-4); gap: var(--space-3); }
.module-toolbar .search-input { flex: 1; max-width: 360px; }
.detail-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-5); margin-bottom: var(--space-4); }
.detail-header__main { display: flex; align-items: center; gap: var(--space-4); }
.detail-header__info h2 { font-size: var(--font-2xl); margin-bottom: 2px; }
.detail-header__info p { color: var(--gray-500); font-size: var(--font-md); }
.detail-header__actions { display: flex; gap: var(--space-2); }
.detail-grid { display: grid; grid-template-columns: 1fr 1.5fr; gap: var(--space-4); margin-bottom: var(--space-4); }
.detail-section { margin-bottom: var(--space-4); }
.detail-section .card__header { display: flex; justify-content: space-between; align-items: center; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--gray-200); margin-bottom: var(--space-4); }
.tab-btn {
    padding: var(--space-2) var(--space-4); border: none; background: none; font-size: var(--font-md);
    font-weight: 500; color: var(--gray-500); cursor: pointer; border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all 0.2s; font-family: var(--font-family);
}
.tab-btn:hover { color: var(--gray-700); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Items Table (Ofertas) */
.items-table { width: 100%; border-collapse: collapse; font-size: var(--font-sm); }
.items-table th { background: var(--gray-50); padding: var(--space-2) var(--space-3); text-align: left; font-weight: 600; color: var(--gray-500); border-bottom: 1px solid var(--gray-200); }
.items-table td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--gray-100); }
.items-total { display: flex; justify-content: flex-end; padding: var(--space-3); font-size: var(--font-lg); font-weight: 700; color: var(--primary); }

/* Status badges */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.status-activo { background: #10b981; }
.status-inactivo { background: #ef4444; }
.status-prospecto { background: #f59e0b; }
.status-abierta { background: #3b82f6; }
.status-ganada { background: #10b981; }
.status-perdida { background: #ef4444; }
.status-borrador { background: #94a3b8; }
.status-enviada { background: #3b82f6; }
.status-aceptada { background: #10b981; }
.status-rechazada { background: #ef4444; }

/* === Responsive === */
@media (max-width: 1024px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .kpi-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .pipeline-board { flex-direction: column; }
    .pipeline-column { min-width: 100%; }
}


/* === Phase 3: AI Copilot Styles === */
.copilot-page { max-width: 900px; }
.copilot-hero { display: flex; align-items: center; gap: 16px; padding: 20px 24px; }
.copilot-hero__icon { font-size: 36px; }
.copilot-hero__info h2 { margin-bottom: 2px; }
.copilot-status { margin-left: auto; }
.copilot-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-top: 16px; }
.copilot-card { min-height: 180px; }
.ai-result { padding: 8px 0; }
.ai-result h4 { font-size: 16px; }
.ai-result h5 { font-size: 13px; }
.ai-result ul { list-style: disc; }
.ai-result ul li { margin-bottom: 4px; font-size: 13px; line-height: 1.5; }
.badge-success { background: #10b981; color: white; }
.badge-error { background: #ef4444; color: white; }
.badge-warning { background: #f59e0b; color: white; }
@media (max-width: 768px) {
    .copilot-grid { grid-template-columns: 1fr; }
}


/* ==========================================================================
   PHASE 4: MARKETING + SOCIAL MEDIA
   ========================================================================== */

/* Marketing Page */
.marketing-page { padding: 0; }
.marketing-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 0; border-bottom: 1px solid var(--gray-200);
}
.marketing-header h1 { font-size: 1.6rem; margin: 0; }
.marketing-header .subtitle { color: var(--gray-500); margin-top: 4px; }
.btn-ai-agent {
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: white; border: none; padding: 10px 20px; border-radius: 10px;
    cursor: pointer; font-weight: 600; transition: all 0.3s;
}
.btn-ai-agent:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(124,58,237,0.4); }
.btn-ai-agent:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* Marketing Tabs */
.marketing-tabs {
    display: flex; gap: 4px; padding: 16px 0; border-bottom: 1px solid var(--gray-200);
    overflow-x: auto;
}
.mtab {
    padding: 8px 18px; border: none; background: transparent; cursor: pointer;
    border-radius: 8px; font-size: 0.85rem; white-space: nowrap; transition: all 0.2s;
    color: var(--gray-500);
}
.mtab:hover { background: var(--gray-100); }
.mtab.active { background: var(--primary); color: white; font-weight: 600; }

/* KPI Cards */
.mkt-kpis {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px; padding: 20px 0;
}
.kpi-card {
    background: white; border: 1px solid var(--gray-200); border-radius: 14px;
    padding: 20px; text-align: center; transition: transform 0.2s;
}
.kpi-card:hover { transform: translateY(-3px); }
.kpi-icon { font-size: 2rem; margin-bottom: 8px; }
.kpi-value { font-size: 2.2rem; font-weight: 700; color: var(--gray-900); }
.kpi-label { font-size: 0.85rem; color: var(--gray-500); margin-top: 4px; }
.kpi-sub { font-size: 0.75rem; color: var(--gray-500); margin-top: 6px; opacity: 0.8; }
.kpi-campaigns { border-left: 4px solid #3b82f6; }
.kpi-social { border-left: 4px solid #10b981; }
.kpi-ai { border-left: 4px solid #7c3aed; }
.kpi-selling { border-left: 4px solid #f59e0b; }

.mkt-engagement {
    background: white; border-radius: 14px; padding: 20px; margin-top: 8px;
    border: 1px solid var(--gray-200);
}
.engagement-row { display: flex; gap: 30px; margin-top: 12px; }
.eng-item { font-size: 1.1rem; font-weight: 600; }

/* Calendar */
.calendar-view { padding: 20px 0; }
.cal-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.cal-total { color: var(--gray-500); font-size: 0.85rem; }
.cal-grid {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
    background: var(--gray-200); border-radius: 12px; overflow: hidden;
}
.cal-header {
    background: var(--primary); color: white; text-align: center; padding: 10px;
    font-weight: 600; font-size: 0.8rem;
}
.cal-day {
    background: white; min-height: 70px; padding: 8px; position: relative;
}
.cal-day.empty { background: var(--gray-100); }
.cal-day.today { background: rgba(59,130,246,0.1); }
.day-num { font-weight: 600; font-size: 0.85rem; }
.cal-dots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.cal-dot {
    width: 8px; height: 8px; border-radius: 50%; cursor: pointer;
}
.cal-dot.linkedin { background: #0a66c2; }
.cal-dot.facebook { background: #1877f2; }
.cal-dot.instagram { background: #e4405f; }
.cal-dot.twitter { background: #1da1f2; }

/* Campaigns Table */
.campaigns-section { padding: 20px 0; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.data-table { width: 100%; border-collapse: collapse; background: white; border-radius: 12px; overflow: hidden; }
.data-table th { background: var(--gray-100); padding: 12px 14px; text-align: left; font-size: 0.8rem; text-transform: uppercase; color: var(--gray-500); }
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--gray-200); font-size: 0.9rem; }
.data-table tr:hover td { background: var(--gray-100); }
.badge-status { padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-draft { background: #fef3c7; color: #92400e; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-paused { background: #fecaca; color: #991b1b; }
.badge-completed { background: #dbeafe; color: #1e40af; }
.badge-new { background: #ede9fe; color: #5b21b6; }
.badge-converted { background: #d1fae5; color: #065f46; }
.badge-dismissed { background: #f3f4f6; color: #6b7280; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-executed { background: #dbeafe; color: #1e40af; }
.badge-rejected { background: #fecaca; color: #991b1b; }
.badge-ai { background: linear-gradient(135deg,#7c3aed,#a855f7); color: white; padding: 2px 8px; border-radius: 12px; font-size: 0.7rem; }
.badge-seg { background: #e0e7ff; color: #3730a3; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; }
.btn-sm { padding: 4px 12px; border-radius: 6px; border: none; cursor: pointer; font-size: 0.8rem; transition: all 0.2s; }
.btn-start { background: #10b981; color: white; }
.btn-del { background: #fee2e2; color: #dc2626; }
.btn-convert { background: #10b981; color: white; }
.btn-dismiss { background: #f3f4f6; color: #6b7280; }
.btn-approve { background: #10b981; color: white; }
.btn-reject { background: #fee2e2; color: #dc2626; }
.btn-primary { background: var(--primary); color: white; border: none; padding: 10px 20px; border-radius: 10px; cursor: pointer; font-weight: 600; }
.btn-secondary { background: var(--gray-100); color: var(--gray-900); border: 1px solid var(--gray-200); padding: 10px 20px; border-radius: 10px; cursor: pointer; }
.empty-state { text-align: center; padding: 40px; color: var(--gray-500); font-size: 0.95rem; }

/* Intent Alert Cards */
.social-selling-section { padding: 20px 0; }
.intent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; }
.intent-card {
    background: white; border: 1px solid var(--gray-200); border-radius: 14px;
    padding: 18px; transition: transform 0.2s;
}
.intent-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.intent-card.intent-new { border-left: 4px solid #f59e0b; }
.intent-card.intent-converted { border-left: 4px solid #10b981; opacity: 0.7; }
.intent-card.intent-dismissed { border-left: 4px solid #9ca3af; opacity: 0.5; }
.intent-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.source-badge { padding: 3px 10px; border-radius: 20px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; }
.source-badge.twitter { background: #e0f2fe; color: #0369a1; }
.source-badge.linkedin { background: #e0e7ff; color: #3730a3; }
.source-badge.reddit { background: #fef3c7; color: #92400e; }
.source-badge.google { background: #fce7f3; color: #9d174d; }
.intent-score { position: relative; width: 80px; height: 6px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.score-bar { position: absolute; left: 0; top: 0; height: 100%; background: linear-gradient(90deg, #10b981, #f59e0b); border-radius: 4px; transition: width 0.5s; }
.score-text { position: absolute; right: -35px; top: -6px; font-size: 0.75rem; font-weight: 700; }
.intent-author { font-size: 0.95rem; }
.intent-author strong { color: var(--gray-900); }
.author-handle { color: var(--gray-500); font-size: 0.85rem; margin-left: 6px; }
.intent-company { color: var(--gray-500); font-size: 0.8rem; margin-top: 2px; }
.intent-content { background: var(--gray-100); padding: 10px 14px; border-radius: 10px; margin: 10px 0; font-style: italic; color: var(--gray-900); font-size: 0.9rem; line-height: 1.5; }
.intent-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.tag { background: var(--gray-100); padding: 2px 8px; border-radius: 12px; font-size: 0.7rem; color: var(--gray-500); }
.intent-response { background: rgba(124,58,237,0.08); padding: 10px 14px; border-radius: 10px; font-size: 0.85rem; margin: 8px 0; border-left: 3px solid #7c3aed; }
.intent-actions { display: flex; gap: 8px; margin-top: 12px; }

/* AI Suggestions */
.suggestions-section { padding: 20px 0; }
.suggestions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.suggestion-card {
    background: white; border: 1px solid var(--gray-200); border-radius: 14px;
    padding: 18px; transition: all 0.2s;
}
.suggestion-card:hover { transform: translateY(-2px); }
.suggestion-card.sug-pending { border-left: 4px solid #f59e0b; }
.suggestion-card.sug-approved, .suggestion-card.sug-executed { border-left: 4px solid #10b981; opacity: 0.75; }
.suggestion-card.sug-rejected { border-left: 4px solid #ef4444; opacity: 0.5; }
.sug-header { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.sug-type { background: var(--gray-100); padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; }
.sug-priority { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; }
.priority-alta { color: #dc2626; }
.priority-media { color: #f59e0b; }
.priority-baja { color: #6b7280; }
.sug-platform { font-size: 0.75rem; color: var(--gray-500); }
.suggestion-card h4 { margin: 6px 0; font-size: 1rem; color: var(--gray-900); }
.sug-content { font-size: 0.88rem; color: var(--gray-500); line-height: 1.5; margin: 8px 0; }
.sug-reasoning { font-size: 0.8rem; color: #7c3aed; background: rgba(124,58,237,0.05); padding: 8px 12px; border-radius: 8px; margin: 8px 0; }
.sug-actions { display: flex; gap: 8px; margin-top: 12px; }

/* Social Media Page */
.social-page { padding: 0; }
.social-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 0; border-bottom: 1px solid var(--gray-200); }
.social-content { display: grid; grid-template-columns: 1fr 280px; gap: 20px; padding: 20px 0; }
.social-sidebar {
    background: white; border: 1px solid var(--gray-200); border-radius: 14px;
    padding: 18px; height: fit-content; position: sticky; top: 20px;
}
.social-sidebar h3 { font-size: 0.9rem; margin-bottom: 12px; }
.account-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--gray-200); }
.account-status { margin-left: auto; }
.platform-icon { font-size: 1.2rem; }

/* Post Cards */
.post-card {
    background: white; border: 1px solid var(--gray-200); border-radius: 14px;
    padding: 18px; margin-bottom: 12px; transition: transform 0.2s;
}
.post-card:hover { transform: translateY(-2px); }
.post-card.post-published { border-left: 4px solid #10b981; }
.post-card.post-scheduled { border-left: 4px solid #3b82f6; }
.post-card.post-draft { border-left: 4px solid #f59e0b; }
.post-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.post-type { font-size: 0.75rem; color: var(--gray-500); text-transform: capitalize; }
.post-content { font-size: 0.9rem; line-height: 1.6; margin: 8px 0; }
.post-hashtags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.hashtag { color: var(--primary); font-size: 0.85rem; }
.post-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--gray-200); }
.post-date { font-size: 0.8rem; color: var(--gray-500); }
.post-actions { display: flex; gap: 8px; align-items: center; }
.btn-publish { background: var(--primary); color: white; }
.btn-publish-now { background: #10b981; color: white; border: none; padding: 10px 20px; border-radius: 10px; cursor: pointer; font-weight: 600; }
.metrics-inline { font-size: 0.8rem; color: var(--gray-500); }

/* Post Composer Modal */
.modal-wide { max-width: 600px; }
.composer-body { padding: 20px; }
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.85rem; }
.form-row select, .form-row input, .form-row textarea {
    width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--gray-200);
    background: white; color: var(--gray-900); font-size: 0.9rem; font-family: inherit;
}
.form-row textarea { resize: vertical; }
.btn-ai-gen {
    margin-top: 8px; background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: white; border: none; padding: 8px 16px; border-radius: 8px; cursor: pointer;
    font-size: 0.85rem; transition: all 0.2s;
}
.btn-ai-gen:hover { opacity: 0.9; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Loading */
.loading-pulse { text-align: center; padding: 40px; color: var(--gray-500); animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }


/* ==========================================================================
   PHASE 5: REPORTS + ADMIN + PWA
   ========================================================================== */

/* Reports */
.reports-page { padding: 0; }
.reports-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 0; border-bottom: 1px solid var(--gray-200); }
.reports-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; padding: 20px 0; }
.report-card { background: white; border: 1px solid var(--gray-200); border-radius: 14px; padding: 20px; cursor: pointer; transition: all 0.2s; }
.report-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--primary); }
.report-icon { font-size: 2rem; margin-bottom: 10px; }
.report-card h3 { font-size: 1rem; margin: 6px 0; }
.report-card p { font-size: 0.85rem; color: var(--gray-500); }
.report-actions { display: flex; gap: 8px; margin-top: 12px; }
.btn-excel { background: #d1fae5; color: #065f46; }
.btn-preview { background: var(--gray-100); color: var(--gray-900); }
.report-preview { padding: 20px 0; }
.report-result { background: white; border: 1px solid var(--gray-200); border-radius: 14px; padding: 24px; }
.report-title-bar { display: flex; justify-content: space-between; align-items: center; }
.report-date { font-size: 0.8rem; color: var(--gray-500); margin-top: 4px; }
.report-summary { display: flex; gap: 30px; margin: 16px 0; font-size: 1.05rem; }
.report-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin: 16px 0; }
.rm { text-align: center; padding: 16px; background: var(--gray-100); border-radius: 12px; }
.rm-val { display: block; font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.rm-label { display: block; font-size: 0.8rem; color: var(--gray-500); margin-top: 4px; }
.funnel-chart { margin: 16px 0; }
.funnel-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.funnel-label { width: 120px; font-size: 0.85rem; text-align: right; }
.funnel-bar-wrap { flex: 1; background: var(--gray-100); border-radius: 8px; height: 32px; overflow: hidden; }
.funnel-bar { height: 100%; background: linear-gradient(90deg, var(--primary), #60a5fa); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: white; font-weight: 600; font-size: 0.85rem; min-width: 30px; transition: width 0.5s; }

/* Admin */
.admin-page { padding: 0; }
.admin-header { padding: 20px 0; border-bottom: 1px solid var(--gray-200); }
.admin-tabs { display: flex; gap: 4px; padding: 16px 0; border-bottom: 1px solid var(--gray-200); overflow-x: auto; }
.atab { padding: 8px 18px; border: none; background: transparent; cursor: pointer; border-radius: 8px; font-size: 0.85rem; color: var(--gray-500); transition: all 0.2s; }
.atab:hover { background: var(--gray-100); }
.atab.active { background: var(--primary); color: white; font-weight: 600; }
.badge-role { padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-director_comercial { background: #dbeafe; color: #1e40af; }
.badge-vendedor { background: #d1fae5; color: #065f46; }
.badge-ejecutivo { background: #dbeafe; color: #1e40af; }
.badge-marketing { background: #f3e8ff; color: #7e22ce; }
.badge-visualizacion { background: #e2e8f0; color: #475569; }
.status-active { color: #10b981; font-size: 0.85rem; }
.status-inactive { color: #9ca3af; font-size: 0.85rem; }
.btn-edit { background: #dbeafe; color: #1e40af; }
.stages-list { display: flex; flex-direction: column; gap: 8px; padding: 16px 0; }
.stage-item { display: flex; align-items: center; gap: 16px; padding: 12px 16px; background: white; border: 1px solid var(--gray-200); border-radius: 10px; }
.stage-order { font-weight: 700; color: var(--gray-500); width: 30px; }
.stage-name { flex: 1; font-weight: 600; }
.stage-color { width: 20px; height: 20px; border-radius: 50%; }
.flags-list { display: flex; flex-direction: column; gap: 12px; padding: 16px 0; }
.flag-item { display: flex; align-items: center; gap: 16px; padding: 14px 18px; background: white; border: 1px solid var(--gray-200); border-radius: 10px; }
.flag-info p { font-size: 0.8rem; color: var(--gray-500); margin: 2px 0 0; }
.toggle-switch { position: relative; width: 48px; height: 26px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: #ccc; border-radius: 26px; cursor: pointer; transition: 0.3s; }
.toggle-slider::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.3s; }
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }
.config-group { margin: 16px 0; }
.config-group h4 { text-transform: capitalize; color: var(--gray-500); margin-bottom: 8px; }
.config-item { display: flex; align-items: center; gap: 16px; padding: 8px 0; }
.config-item label { width: 200px; font-size: 0.85rem; font-weight: 600; }
.config-input { flex: 1; padding: 8px 12px; border: 1px solid var(--gray-200); border-radius: 8px; background: white; color: var(--gray-900); }

/* Dark Mode Toggle */
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--gray-200); margin-top: auto; }
.theme-toggle { width: 100%; padding: 8px; border: 1px solid var(--gray-200); border-radius: 8px; background: var(--gray-100); color: var(--gray-900); cursor: pointer; font-size: 0.85rem; transition: all 0.2s; }
.theme-toggle:hover { background: var(--gray-100); }

/* ============================================================
   CHATS INBOX — Kommo-style unified messaging
   ============================================================ */
.chats-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    height: 100%;
    max-height: 100%;
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--gray-200);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.chats-sidebar {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--gray-200);
    background: white;
    overflow: hidden;
    min-height: 0;
}
.chats-sidebar__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
}
.chats-sidebar__search {
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-100);
}
.chats-sidebar__list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.chat-item {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.15s;
    position: relative;
}
.chat-item:hover { background: var(--gray-50); }
.chat-item--active { background: rgba(2,150,108,0.08) !important; border-left: 3px solid var(--primary); }
.chat-item--unread { background: #eff6ff; }
.chat-item--human {
    animation: humanBlink 1.5s ease-in-out infinite;
}
@keyframes humanBlink {
    0%, 100% { background: rgba(245,158,11,0.06); }
    50% { background: rgba(245,158,11,0.18); }
}
.chat-item__avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #0ab98a);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}
.chat-item__content {
    flex: 1;
    min-width: 0;
}
.chat-item__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}
.chat-item__name {
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-item__time {
    font-size: 11px;
    color: var(--gray-400);
    flex-shrink: 0;
    margin-left: 8px;
}
.chat-item__child {
    font-size: 11px;
    color: var(--gray-500);
    margin-bottom: 3px;
}
.chat-item__preview {
    font-size: 13px;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.chat-item--unread .chat-item__preview {
    color: var(--gray-800);
    font-weight: 500;
}
.chat-item__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
}
.chat-item__stage {
    font-size: 10px;
    color: white;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 600;
}
.chat-item__human-badge {
    font-size: 10px;
    background: #fef3c7;
    color: #92400e;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 600;
    animation: humanPulse 1s ease-in-out infinite;
}
@keyframes humanPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.chat-item__unread-count {
    background: #3b82f6;
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}

/* Main chat panel */
.chats-main {
    display: flex;
    flex-direction: column;
    background: var(--gray-50);
    overflow: hidden;
    min-height: 0;
    height: 100%;
}
.chats-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.chats-main__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}
.chats-main__lead-info strong {
    font-size: 16px;
    color: var(--gray-900);
}
.chats-main__messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    min-height: 0;
}
.chats-main__input {
    display: flex;
    gap: 8px;
    padding: 14px 20px;
    background: white;
    border-top: 1px solid var(--gray-200);
    flex-shrink: 0;
}
.chats-main__input textarea {
    flex: 1;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    resize: none;
    height: 42px;
    font-family: var(--font-family);
    font-size: 14px;
    outline: none;
}
.chats-main__input textarea:focus {
    border-color: var(--primary);
}

/* Responsive */
@media (max-width: 768px) {
    .chats-layout { grid-template-columns: 1fr; }
    .chats-main { display: none; }
}

/* WhatsApp chat wrapper (lead detail) */
.wa-chat-wrapper {
    display: flex;
    flex-direction: column;
    height: 580px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: white;
}

/* Chats with lead panel open */
.chats-layout.chats-layout--with-lead {
    grid-template-columns: 320px 1fr 380px;
}
.chats-lead-panel {
    border-left: 1px solid var(--gray-200);
    background: white;
    overflow-y: auto;
    padding: 0;
}
.chats-lead-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
    position: sticky;
    top: 0;
    z-index: 2;
}
.chats-lead-panel__body {
    padding: 16px;
}
.chats-lead-panel .info-item {
    font-size: 13px;
    padding: 6px 0;
}
.chats-lead-panel .info-label {
    font-size: 12px;
}


/* Template message bubble */
.msg-bubble--template {
    background: linear-gradient(135deg, #1a3a5c, #234e78) !important;
    color: white !important;
    border: none !important;
    position: relative;
}
.msg-bubble--template::before {
    content: '\1F4CB Plantilla';
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
    margin-bottom: 6px;
}
.msg-bubble--template .template-body {
    white-space: pre-line;
    line-height: 1.5;
}

/* Next Actions panel/modal */
.next-actions-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeInNA 0.2s ease;
}
@keyframes fadeInNA {
    from { opacity: 0; }
    to { opacity: 1; }
}
.next-actions-card {
    background: white;
    border-radius: 16px;
    padding: 0;
    width: 420px;
    max-width: 90vw;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    animation: slideUpNA 0.25s ease;
    overflow: hidden;
}
@keyframes slideUpNA {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.next-actions-card__header {
    background: linear-gradient(135deg, #1a3a5c, #234e78);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.next-actions-card__header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}
.next-actions-card__close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.next-actions-card__close:hover {
    background: rgba(255,255,255,0.35);
}
.next-actions-card__body {
    padding: 24px;
}
.next-actions-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
}
.next-actions-item:last-child {
    border-bottom: none;
}
.next-actions-item__icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.next-actions-item__content {
    flex: 1;
}
.next-actions-item__label {
    font-size: 12px;
    color: var(--gray-500);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}
.next-actions-item__value {
    font-size: 14px;
    color: var(--gray-900);
    font-weight: 600;
}
.next-actions-template-preview {
    background: var(--gray-50);
    border-radius: 10px;
    padding: 14px;
    margin-top: 12px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--gray-700);
    white-space: pre-line;
    border-left: 3px solid var(--primary);
}
.btn-next-actions {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}
.btn-next-actions:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99,102,241,0.4);
}

/* Chats page: constrain page-content height so chats-layout scroll works */
.page-content:has(.chats-layout) {
    padding: 0;
    height: calc(100vh - var(--header-height, 64px));
    overflow: hidden;
}

/* Audio player in chat */
.msg-audio-player {
    display: flex;
    align-items: center;
}
.msg-audio-player audio {
    filter: invert(1) hue-rotate(180deg);
    opacity: 0.9;
}
.msg-image img {
    display: block;
}

/* Transcribed audio message */
.msg-audio-transcribed {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.msg-audio-transcribed__label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.6;
}
.msg-audio-transcribed__text {
    font-style: italic;
    line-height: 1.4;
}
