:root {
    /* ============================================================
       Plenus CRM — Design System Tokens (Brand Manual)
       ============================================================ */

    /* Primary — Azul Plenus */
    --primary: #1a3a5c;
    --primary-light: #2d5a87;
    --primary-dark: #132339;
    --primary-50: #e8eef5;
    --primary-100: #b3c7db;
    --primary-500: #1a3a5c;
    --primary-700: #132339;
    --primary-900: #0B1522;

    /* Navy — Navy Plenus */
    --navy: #16375A;
    --navy-dark: #132339;
    --navy-darkest: #0B1522;

    /* Accent — Dorado Plenus */
    --yellow: #c9a54e;
    --yellow-dark: #b8943f;

    /* Accent — Rosa Plenus */
    --red: #C00074;
    --red-dark: #A00063;

    /* Accent — Verde Plenus */
    --olive: #c9a54e;
    --olive-dark: #b8943f;

    /* Semantic */
    --success: #1a3a5c;
    --warning: #c9a54e;
    --danger: #C00074;
    --info: #16375A;
    --whatsapp: #25D366;

    /* Neutrals */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Typography — Lato (titulos) + Sarabun (body) */
    --font-titles: 'Lato', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-xs: 10px;
    --font-sm: 12px;
    --font-base: 13px;
    --font-md: 14px;
    --font-lg: 16px;
    --font-xl: 18px;
    --font-2xl: 20px;
    --font-3xl: 24px;
    --font-4xl: 28px;
    --font-5xl: 32px;

    /* Spacing */
    --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
    --space-5: 20px; --space-6: 24px; --space-8: 32px;

    /* Radius */
    --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px;
    --radius-xl: 16px; --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.12);

    /* Layout */
    --sidebar-width: 256px;
    --header-height: 64px;
    --bottom-nav-height: 64px;

    /* ============================================================
       Luminous Education — nueva paleta/tipografia, se aplica
       incrementalmente pantalla por pantalla (ver desing/luminous_education/DESIGN.md).
       No reemplaza los tokens de arriba todavia.
       ============================================================ */
    --lum-deep-blue: #00023D;
    --lum-magenta: #A349A4;
    --lum-pink: #FC2981;
    --lum-red: #E8170D;
    --lum-surface: #F8F9FA;
    --lum-font-heading: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --lum-font-body: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
}

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
    font-size: 18px;
    vertical-align: middle;
    user-select: none;
    line-height: 1;
}

/* Iconos minimalistas en tono rosa (Luminous Education) para encabezados de
   sección y acciones destacadas — sustituyen emoji por Material Symbols. */
.card__header h3 .material-symbols-outlined,
.ld-hero__actions .btn .material-symbols-outlined {
    color: var(--lum-pink);
    margin-right: 4px;
}

.phase-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-family: var(--lum-font-body);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    background: var(--lum-deep-blue);
    color: white;
    white-space: nowrap;
}
.phase-badge--bajo_interes { background: var(--gray-300); color: var(--gray-700); }
.phase-badge--en_inscripcion { background: var(--lum-pink); }

.pipeline-phase-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pipeline-phase-group__header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--lum-deep-blue);
    color: white;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-family: var(--lum-font-heading);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.pipeline-phase-group--bajo_interes .pipeline-phase-group__header { background: var(--gray-500); }
.pipeline-phase-group__stages {
    display: flex;
    gap: 12px;
    padding: 10px;
    background: var(--gray-100);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    overflow-x: auto;
}

/* Sincronización de Calendario (Admisiones) — Luminous Education */
.cal-sync-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 6px;
}
.cal-sync-toolbar .btn .material-symbols-outlined { font-size: 16px; margin-right: 4px; }
.cal-sync-counts { display: flex; gap: 8px; margin: 10px 0 14px; flex-wrap: wrap; }
.cal-sync-day-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--lum-deep-blue);
    color: white;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-family: var(--lum-font-heading);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.cal-sync-agenda-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--gray-100);
    font-family: var(--lum-font-body);
}
.cal-sync-agenda-row:last-child { border-bottom: none; }
.cal-sync-agenda-time { min-width: 80px; font-size: 12px; color: var(--gray-500); }

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font-family); font-size: var(--font-md); color: var(--gray-900); background: var(--gray-50); line-height: 1.5; font-weight: 300; }
h1,h2,h3,h4,h5,h6 { font-family: var(--font-titles); font-weight: 900; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); font-family: var(--font-family); font-size: var(--font-md); font-weight: 500; border: 1px solid transparent; border-radius: var(--radius-md); cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.ld-tabs-header .btn-ghost.active {
    color: var(--lum-pink);
    background: rgba(252,41,129,0.08);
    box-shadow: inset 0 -2px 0 var(--lum-pink);
    font-weight: 700;
}
.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--font-sm); }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: var(--font-lg); }

/* Cards */
.card { background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200); overflow: hidden; }
.card__header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--gray-100); }
.card__body { padding: var(--space-5); }
.card--hoverable { transition: box-shadow 0.2s, transform 0.2s; }
.card--hoverable:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 2px var(--space-2); font-size: var(--font-sm); font-weight: 500; border-radius: var(--radius-full); }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-neutral { background: var(--gray-100); color: var(--gray-600); }

/* Animations */
@keyframes fadeIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.6; } }
@keyframes loadingBar { 0% { width:0%; } 50% { width:70%; } 100% { width:100%; } }
.animate-fade-in { animation: fadeIn 0.3s ease forwards; }
.animate-pulse { animation: pulse 2s ease-in-out infinite; }


/* ===== DARK MODE ===== */
:root[data-theme="dark"] {
    /* Override the ACTUAL variables that body/elements use */
    --gray-50: #0f0f23;
    --gray-100: #1a1a2e;
    --gray-200: #2d3748;
    --gray-300: #4a5568;
    --gray-400: #718096;
    --gray-500: #a0aec0;
    --gray-600: #cbd5e1;
    --gray-700: #e2e8f0;
    --gray-800: #f1f5f9;
    --gray-900: #f8fafc;

    /* Override semantic colors for dark */
    --primary: #2d5a87;
    --primary-light: #34d399;
    --primary-dark: #1a3a5c;
    --navy: #e2e8f0;
    --navy-dark: #1e293b;
    --navy-darkest: #0B1522;

    /* Dark mode extras */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 20px rgba(0,0,0,0.5);
}

/* Body & base overrides */
:root[data-theme="dark"] body { background: #0c0c1d; color: #e2e8f0; }

/* Cards: white → dark */
:root[data-theme="dark"] .card { background: #161b2e; border-color: #2d3748; }
:root[data-theme="dark"] .card__header { border-color: #2d3748; }

/* Dashboard v2 */
:root[data-theme="dark"] .dash-kpi,
:root[data-theme="dark"] .dash-card,
:root[data-theme="dark"] .dash-stat-strip { background: #161b2e; border-color: #2d3748; }
:root[data-theme="dark"] .dash-card__header,
:root[data-theme="dark"] .dash-stat-strip__item { border-color: #2d3748; }
:root[data-theme="dark"] .dash-kpi__value,
:root[data-theme="dark"] .dash-card__header h3,
:root[data-theme="dark"] .dash-stat-strip__value,
:root[data-theme="dark"] .dash-mini-stat__value { color: #e8eef5; }

/* Sidebar */
:root[data-theme="dark"] .sidebar { background: #0a0a1a; border-right-color: #1e293b; }
:root[data-theme="dark"] .sidebar .nav-item { color: #94a3b8; }
:root[data-theme="dark"] .sidebar .nav-item:hover { background: #1e293b; color: #e2e8f0; }
:root[data-theme="dark"] .sidebar .nav-item.active { background: rgba(252,41,129,0.22); color: var(--lum-pink); }

/* Tables — CRITICAL: text must be visible */
:root[data-theme="dark"] .data-table { border-color: #2d3748; }
:root[data-theme="dark"] .data-table th { background: #1a1a2e; color: #94a3b8; border-color: #2d3748; }
:root[data-theme="dark"] .data-table td { color: #e2e8f0; border-color: #1e293b; }
:root[data-theme="dark"] .data-table tr:hover td { background: #1a2036; }
:root[data-theme="dark"] .data-table tr:nth-child(even) td { background: #131828; }

/* Inputs */
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea { background: #1a1a2e; color: #e2e8f0; border-color: #2d3748; }
:root[data-theme="dark"] input::placeholder { color: #64748b; }

/* Modals */
:root[data-theme="dark"] .modal-content { background: #161b2e; border-color: #2d3748; }
:root[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,0.7); }

/* Buttons ghost/secondary */
:root[data-theme="dark"] .btn-secondary { background: #1e293b; color: #e2e8f0; border-color: #2d3748; }
:root[data-theme="dark"] .btn-ghost { color: #94a3b8; }
:root[data-theme="dark"] .btn-ghost:hover { background: #1e293b; color: #e2e8f0; }

/* Badges keep contrast */
:root[data-theme="dark"] .badge-success { background: #064e3b; color: #34d399; }
:root[data-theme="dark"] .badge-warning { background: #78350f; color: #fbbf24; }
:root[data-theme="dark"] .badge-danger { background: #7f1d1d; color: #f87171; }
:root[data-theme="dark"] .badge-info { background: #1e3a5f; color: #60a5fa; }
:root[data-theme="dark"] .badge-neutral { background: #1e293b; color: #94a3b8; }

/* Social/Marketing cards */
:root[data-theme="dark"] .post-card,
:root[data-theme="dark"] .intent-card,
:root[data-theme="dark"] .suggestion-card,
:root[data-theme="dark"] .report-card,
:root[data-theme="dark"] .stage-item,
:root[data-theme="dark"] .flag-item,
:root[data-theme="dark"] .kpi-card { background: #161b2e; border-color: #2d3748; color: #e2e8f0; }

/* Text globally visible */
:root[data-theme="dark"] h1, :root[data-theme="dark"] h2, :root[data-theme="dark"] h3,
:root[data-theme="dark"] h4, :root[data-theme="dark"] strong { color: #f1f5f9; }
:root[data-theme="dark"] p, :root[data-theme="dark"] span, :root[data-theme="dark"] label { color: #cbd5e1; }
:root[data-theme="dark"] .subtitle, :root[data-theme="dark"] .text-muted { color: #94a3b8; }
:root[data-theme="dark"] .page-title { color: #f1f5f9; }

/* Main content area */
:root[data-theme="dark"] .main-content { background: #0f0f23; }
:root[data-theme="dark"] .top-header { background: #0f0f23; border-color: #1e293b; }

/* Marketing tabs */
:root[data-theme="dark"] .mtab, :root[data-theme="dark"] .atab { color: #94a3b8; }
:root[data-theme="dark"] .mtab:hover, :root[data-theme="dark"] .atab:hover { background: #1e293b; color: #e2e8f0; }

/* Scrollbar */
:root[data-theme="dark"] ::-webkit-scrollbar-track { background: #0f0f23; }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #2d3748; }

/* ===== Additional Dark Mode: White backgrounds ===== */
:root[data-theme="dark"] .modal-content { background: #161b2e; border-color: #2d3748; color: #e2e8f0; }
:root[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,0.75); }
:root[data-theme="dark"] .modal-header { border-color: #2d3748; }
:root[data-theme="dark"] .modal-close { color: #94a3b8; }
:root[data-theme="dark"] .modal-close:hover { background: #1e293b; color: #e2e8f0; }

/* Form fields in modals and everywhere */
:root[data-theme="dark"] .form-row label { color: #cbd5e1; }
:root[data-theme="dark"] .form-row select,
:root[data-theme="dark"] .form-row input,
:root[data-theme="dark"] .form-row textarea { background: #0f0f23; color: #e2e8f0; border-color: #2d3748; }
:root[data-theme="dark"] .form-group input,
:root[data-theme="dark"] .form-group select { background: #0f0f23; color: #e2e8f0; border-color: #2d3748; }
:root[data-theme="dark"] .config-input { background: #0f0f23; color: #e2e8f0; border-color: #2d3748; }
:root[data-theme="dark"] .search-input { background: #0f0f23; color: #e2e8f0; border-color: #2d3748; }
:root[data-theme="dark"] .form-select { background: #0f0f23; color: #e2e8f0; border-color: #2d3748; }

/* Calendar dark */
:root[data-theme="dark"] .cal-day { background: #161b2e; }
:root[data-theme="dark"] .cal-day.empty { background: #0f0f23; }
:root[data-theme="dark"] .cal-day.today { background: rgba(59,130,246,0.2); }
:root[data-theme="dark"] .day-num { color: #e2e8f0; }

/* Pipeline dark */
:root[data-theme="dark"] .pipeline-column__header { background: #161b2e; }

/* Cards with hardcoded white → dark */
:root[data-theme="dark"] .mkt-engagement,
:root[data-theme="dark"] .social-sidebar,
:root[data-theme="dark"] .account-item,
:root[data-theme="dark"] .template-card,
:root[data-theme="dark"] .rule-card,
:root[data-theme="dark"] .report-result { background: #161b2e; border-color: #2d3748; color: #e2e8f0; }

/* Notification dropdown */
:root[data-theme="dark"] .notif-dropdown { background: #161b2e; border-color: #2d3748; }
:root[data-theme="dark"] .notif-dropdown__header { background: #0f0f23; border-color: #2d3748; }
:root[data-theme="dark"] .notif-item { border-color: #1e293b; }
:root[data-theme="dark"] .notif-unread { background: rgba(59,130,246,0.15); }

/* Sidebar footer/theme toggle in dark */
:root[data-theme="dark"] .sidebar-footer { border-color: rgba(255,255,255,0.08); }
:root[data-theme="dark"] .theme-toggle { background: rgba(255,255,255,0.08); color: #e2e8f0; border-color: rgba(255,255,255,0.12); }
:root[data-theme="dark"] .theme-toggle:hover { background: rgba(255,255,255,0.15); }

/* Auto tabs dark */
:root[data-theme="dark"] .auto-tabs { background: #0f0f23; }
:root[data-theme="dark"] .auto-tab { color: #94a3b8; }
:root[data-theme="dark"] .auto-tab.active { background: #161b2e; color: #e2e8f0; }

/* Existing elements with white BG */
:root[data-theme="dark"] .intent-content { background: #0f0f23; color: #cbd5e1; }
:root[data-theme="dark"] .sug-type { background: #1e293b; color: #94a3b8; }
:root[data-theme="dark"] .tag { background: #1e293b; color: #94a3b8; }
:root[data-theme="dark"] .var-tag { background: #1e293b; color: #94a3b8; }
:root[data-theme="dark"] .rm { background: #0f0f23; }
:root[data-theme="dark"] .funnel-bar-wrap { background: #1e293b; }
:root[data-theme="dark"] .score-bar-track { background: #1e293b; }

/* Login card in dark */
:root[data-theme="dark"] .login-card { background: #161b2e; }
:root[data-theme="dark"] .login-logo { color: #e2e8f0; }

/* Fix badge-seg/role in dark */
:root[data-theme="dark"] .badge-seg { background: #1e3a5f; color: #93c5fd; }
:root[data-theme="dark"] .badge-role { border: 1px solid rgba(255,255,255,0.1); }
