:root {
    --bg-color: #111827;
    --text-color: #f3f4f6;
    --card-bg: #1f2937;
    --border-color: #374151;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --danger-color: #dc2626;
    --input-bg: #2d3748;
    --input-text: #ffffff;
    --navbar-bg: rgba(31, 41, 55, 0.7);
    --text-muted: #9ca3af;
    
    /* Variables espejo para compatibilidad */
    --primary: var(--primary-color);
    --bg-main: var(--bg-color);
    --border: var(--border-color);
    --text-dark: var(--text-color);
    --danger: var(--danger-color);
    --success: #10b981;
    --purple: #7c3aed;
    --table-hover: rgba(255, 255, 255, 0.03);
    --th-bg: #111827;
    --th-color: #f3f4f6;
    --bg-light: var(--card-bg);
}

body.light-mode {
    --bg-color: #f9fafb;
    --text-color: #111827;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --input-bg: #ffffff;
    --input-text: #111827;
    --navbar-bg: rgba(255, 255, 255, 0.8);
    --text-muted: #4b5563;
    
    /* Añade esta línea para que el espejo también cambie en modo claro */
    --text-dark: var(--text-color);
    
    --table-hover: #f8fafc;
    --th-bg: #f1f5f9;
    --th-color: #475569;
    --bg-light: var(--surface-raised, #f8fafc);
}

/* ==========================================================================
   2. ESTILOS GENERALES Y RESET
   ========================================================================== */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 25px;
    transition: background-color 0.3s, color 0.3s;
    min-height: 100vh;
}

.container {
    max-width: 1450px;
    margin: 0 auto;
}

.session-timeout-indicator {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 142px;
    padding: 7px 11px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-muted);
    font-size: .78rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    transition: background-color .2s, border-color .2s, color .2s;
}

.session-timeout-indicator i { color: var(--primary); }
.session-timeout-indicator.is-warning { color: #b45309; border-color: #f59e0b; background: rgba(245, 158, 11, .12); }
.session-timeout-indicator.is-warning i { color: #d97706; }
.session-timeout-indicator.is-critical { color: #b91c1c; border-color: #ef4444; background: rgba(239, 68, 68, .12); animation: sessionPulse 1.2s ease-in-out infinite; }
.session-timeout-indicator.is-critical i { color: #dc2626; }

@keyframes sessionPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
    50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, .12); }
}

/* Forzar consistencia de colores en textos secundarios y etiquetas */
td small, 
.form-group label, 
.filter-card label, 
.metric-title,
.page-header p,
.portal-dept,
.task-time,
.task-meta,
.anotacion-header {
    color: var(--text-muted) !important;
}

td, .app-card h3, .page-header h2 {
    color: var(--text-color);
}
.task-meta strong,
.task-desc,
.anotacion-item,
.anotacion-item strong {
    color: var(--text-color) !important;
}
.task-meta a,
.task-meta .assigned-user {
    color: var(--primary-color) !important;
}

/* ==========================================================================
   3. NAVEGACIÓN Y CABECERAS
   ========================================================================== */
.navbar, .top-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--navbar-bg);
    backdrop-filter: blur(12px);
    padding: 12px 24px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin: 15px auto 25px auto;
    max-width: 1450px;
    flex-wrap: wrap;
    gap: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    box-sizing: border-box;
}

.navbar-brand {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--text-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-datetime-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted, #68778d);
    margin-left: 10px;
    white-space: nowrap;
}
@media (max-width: 650px) {
    .header-datetime-badge {
        margin-left: 0;
        flex-basis: 100%;
        order: 3;
    }
}

.nav-right, .nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.page-header {
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.page-header h2 {
    margin: 0;
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ==========================================================================
   Estructura específica para Aplicaciones
   ========================================================================== */
.main-container {
    max-width: 1450px;
    margin: 0 auto;
    box-sizing: border-box;
}

.header-section {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 30px;
}

.header-section img {
    width: min(220px, 100%);
    max-width: 100%;
    height: auto;
}

.header-section h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0;
}

/* ==========================================================================
   4. BOTONES Y ACCIONES
   ========================================================================== */
.btn, .mode-toggle, .btn-back, .btn-logout, .btn-custom {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    text-decoration: none;
}

.mode-toggle:hover, .btn-back:hover, .btn-logout:hover { 
    background: var(--border-color); 
}

.btn-excel { background-color: #10b981 !important; color: white !important; border: none; }
.btn-excel:hover { background-color: #059669 !important; }

.btn-task, .btn-submit {
    width: 100%;
    background-color: var(--primary-color) !important;
    color: var(--primary-contrast) !important;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.2s;
    margin-top: 10px;
}
.btn-task:hover, .btn-submit:hover {
    background-color: var(--primary-hover) !important;
}

.btn-success { background-color: #10b981 !important; color: white !important; border: none; }
.btn-success:hover { background-color: #059669 !important; }

.btn-summary { background-color: #8b5cf6 !important; color: white !important; border: none; }
.btn-summary:hover { background-color: #7c3aed !important; }

.btn-secondary, .btn-back-custom { background-color: #64748b !important; color: white !important; border: none; }
.btn-secondary:hover, .btn-back-custom:hover { background-color: #475569 !important; }

/* Botones de filtro de estado */
.filtro-estado {
    background: var(--th-bg) !important;
    color: var(--text-muted) !important;
    border: 1px solid var(--border-color) !important;
    transition: all 0.2s ease;
}

.filtro-estado.active {
    background: var(--primary-color) !important;
    color: var(--primary-contrast) !important;
    border-color: var(--primary-color) !important;
    font-weight: 600;
}

/* ==========================================================================
   5. TARJETAS, MÉTRICAS Y FILTROS
   ========================================================================== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.metric-card, .card, .filter-card, .toolbar {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: background-color 0.3s, border-color 0.3s;
}

.metric-card.alert-border {
    border-left: 5px solid var(--danger-color);
    background: rgba(220, 38, 38, 0.05);
}

.metric-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 800;
    margin-top: 8px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    align-items: end;
}

/* ==========================================================================
   6. TABLAS
   ========================================================================== */
.table-responsive {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow-x: auto;
    margin-bottom: 25px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.88rem;
}

th {
    background: var(--th-bg);
    padding: 14px 16px;
    font-weight: 600;
    color: var(--th-color);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

tr:hover {
    background-color: var(--table-hover);
}

/* ==========================================================================
   7. BADGES Y ESTADOS
   ========================================================================== */
.badge-error { background: #fee2e2; color: #991b1b; padding: 4px 10px; border-radius: 20px; font-weight: 700; font-size: 0.78rem; display: inline-block; border: 1px solid #fca5a5; }
.badge-warning { background: #fff7ed; color: #c2410c; padding: 4px 10px; border-radius: 20px; font-weight: 700; font-size: 0.78rem; display: inline-block; border: 1px solid #fdba74; }
.badge-info { background: #e0f2fe; color: #0369a1; padding: 4px 10px; border-radius: 20px; font-weight: 700; font-size: 0.78rem; display: inline-block; border: 1px solid #bae6fd; }
.badge-success { background: #d1fae5; color: #065f46; padding: 4px 10px; border-radius: 20px; font-weight: 700; font-size: 0.78rem; display: inline-block; border: 1px solid #a7f3d0; }

.badge-estado {
    display: inline-block;
    padding: 3px 7px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    margin-top: 5px;
    text-transform: uppercase;
}
.estado-proceso { background-color: #f59e0b; color: #ffffff; }
.estado-finalizada { background-color: #10b981; color: #ffffff; }

/* ==========================================================================
   8. MODALES Y FORMULARIOS
   ========================================================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(3px);
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

.modal-content {
    background: var(--card-bg);
    color: var(--text-color);
    width: 550px;
    max-width: 92%;
    margin: 5% auto;
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2);
}

.modal-content-large {
    width: 850px;
    max-width: 95%;
    margin: 3% auto;
}

.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-control, .ts-control {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px !important;
    border: 1px solid var(--border-color) !important;
    background-color: var(--input-bg) !important;
    color: var(--input-text) !important;
    font-family: inherit;
    font-size: 0.95rem;
    box-sizing: border-box;
    transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}

.form-control:focus, .ts-control:focus {
    outline: none;
    border-color: var(--primary-color) !important;
}

select.form-control option {
    background-color: var(--card-bg);
    color: var(--text-color);
}

/* ==========================================================================
   9. COMPONENTES ESPECÍFICOS (APLICACIONES, TAREAS Y LOGIN)
   ========================================================================== */
.login-body {
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding: 15px;
}

.login-card, .login-container { 
    background: var(--card-bg); 
    padding: 82px 36px 34px; 
    border-radius: 18px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.4); 
    width: 100%; 
    max-width: 430px; 
    border: 1px solid var(--border-color); 
    text-align: center; 
    position: relative;
}

.login-logo { display: flex; justify-content: center; margin: 0 auto 28px; }
.login-logo img { display: block; width: min(230px, 82%); max-width: 100%; height: auto; }
.portal-header { margin-bottom: 30px; }
.portal-subtitle { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.18em; color: var(--primary-color); font-weight: 700; display: block; margin-bottom: 8px; }
.portal-header h2 { font-size: 1.55rem; font-weight: 700; margin-bottom: 7px; display: flex; align-items: center; justify-content: center; gap: 10px; letter-spacing: 0; }
.portal-dept { font-size: 0.92rem; }

.app-card { 
    background: var(--card-bg); 
    border: 1px solid var(--border-color); 
    padding: 28px 25px; 
    border-radius: 16px; 
    text-align: center; 
    text-decoration: none; 
    color: var(--text-color); 
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease; 
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); 
}
.app-card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.2); border-color: var(--primary-color); }
.app-card:focus-visible, .btn-custom:focus-visible, .form-control:focus-visible {
    outline: 3px solid rgba(59, 130, 246, 0.45);
    outline-offset: 2px;
}
.app-icon { font-size: 2.5rem; color: var(--primary-color); margin-bottom: 20px; }
.app-card h3 { font-family: 'Poppins', sans-serif; font-size: 1.3rem; margin-bottom: 10px; font-weight: 600; }
.app-card p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.5; }

/* Tareas y elementos relacionados */
.task-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; padding: 20px; margin-bottom: 20px; text-align: left; }
.border-importance-baja { border-left: 5px solid #10b981; }
.border-importance-media { border-left: 5px solid #f59e0b; }
.border-importance-alta { border-left: 5px solid #ef4444; }
.task-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.task-title { font-weight: 600; font-size: 1.15rem; margin: 0; }
.task-desc { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border-color); font-size: 0.95rem; line-height: 1.6; white-space: pre-line; }
.apps-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); 
    gap: 20px; 
    width: 100%; 
}

.portal-link { width: 100%; justify-content: center; }
.nav-identity { font-size: 0.9rem; color: var(--text-color); }
.nav-identity i { color: var(--primary-color); margin-right: 4px; }

.password-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
}
.password-modal[hidden] { display: none !important; }
.password-modal-content {
    position: relative;
    width: min(100%, 400px);
    padding: 25px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}
.password-modal-content h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 20px; }
.password-modal-content h3 i { color: var(--primary-color); }
.modal-close { position: absolute; top: 10px; right: 12px; border: 0; background: transparent; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; }
.password-field { margin-bottom: 15px; text-align: left; }
.password-field label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.88rem; }
.password-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 5px; }
.btn-cancel { background: var(--text-muted); color: #fff; border: 0; }
.password-feedback {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 14px 16px;
    border: 1px solid rgba(16, 185, 129, 0.35);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: var(--shadow-md);
    animation: portal-enter 0.35s ease-out both;
}
.password-feedback i { color: #10b981; }
.password-feedback button { margin-left: auto; border: 0; background: transparent; color: var(--text-muted); font-size: 1.3rem; cursor: pointer; }

/* ==========================================================================
   ESTILOS DE ADJUNTOS E IMÁGENES EN TAREAS
   ========================================================================== */
.adjuntos-seccion {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 6px;
    margin-top: 10px;
}
.adjunto-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}
.adjunto-item:last-child { margin-bottom: 0; }
.adjunto-link {
    color: var(--primary-color);
    text-decoration: none;
    word-break: break-all;
}
.adjunto-link:hover { text-decoration: underline; }

.anotacion-desc img,
.task-desc img,
.anotacion img {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 4px;
    margin: 8px 0;
    display: block;
}
/* ==========================================================================
   10. MEDIA QUERIES (RESPONSIVE)
   ========================================================================== */
@media (max-width: 768px) {
    .navbar, .top-navbar {
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
    }
    .nav-right, .nav-user {
        justify-content: space-between;
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
}

/*CUSTOMIZACION DE MENU SUPERIOR*/

/* Colores específicos para los botones de la barra de aplicaciones */
.btn-theme-toggle {
    background-color: #f59e0b !important;
    color: #ffffff !important;
    border: none !important;
}
.btn-theme-toggle:hover {
    background-color: #d97706 !important;
}

.btn-logout-custom {
    background-color: #ef4444 !important;
    color: #ffffff !important;
    border: none !important;
}
.btn-logout-custom:hover {
    background-color: #dc2626 !important;
}

.btn-profile {
    background-color: #8b5cf6 !important;
    color: #ffffff !important;
    border: none !important;
}
.btn-profile:hover {
    background-color: #7c3aed !important;
}

/* Interaccion refinada del portal */
.btn, .btn-custom, .mode-toggle, .btn-submit, .app-card {
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}
.btn:hover, .btn-custom:hover, .mode-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(2, 8, 23, 0.2);
}
.btn:active, .btn-custom:active, .mode-toggle:active { transform: translateY(0); }
.btn:focus-visible, .btn-custom:focus-visible, .mode-toggle:focus-visible,
.form-control:focus-visible, .ts-control:focus-visible, a:focus-visible {
    outline: 3px solid rgba(90, 167, 255, 0.38);
    outline-offset: 3px;
}
.form-group:focus-within label, .password-field:focus-within label {
    color: var(--primary-color) !important;
}
.form-control:focus, .ts-control:focus {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.14), 0 6px 16px rgba(2, 8, 23, 0.1) !important;
}
.ui-ripple {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
    animation: ui-ripple 0.55s ease-out forwards;
}
.is-loading { pointer-events: none; opacity: 0.78; }
.is-loading::after {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 7px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    content: "";
    vertical-align: -2px;
    animation: ui-spin 0.65s linear infinite;
}
.ui-toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 11000;
    display: flex;
    align-items: center;
    gap: 11px;
    width: min(410px, calc(100vw - 32px));
    padding: 15px 16px;
    border: 1px solid rgba(16, 185, 129, 0.32);
    border-radius: 13px;
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: var(--shadow-md, 0 18px 48px rgba(2, 8, 23, 0.28));
    animation: toast-in 0.35s ease-out both;
}
.ui-toast i { color: #10b981; font-size: 1.1rem; }
.ui-toast button { margin-left: auto; border: 0; background: transparent; color: var(--text-muted); font-size: 1.25rem; cursor: pointer; }
.ui-toast-error { border-color: rgba(239, 68, 68, 0.36); }
.ui-toast-error i { color: #ef4444; }
.ui-toast.is-closing { animation: toast-out 0.25s ease-in forwards; }
@keyframes ui-ripple { to { opacity: 0; transform: translate(-50%, -50%) scale(18); } }
@keyframes ui-spin { to { transform: rotate(360deg); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px) scale(0.98); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 600px) {
    .ui-toast { right: 16px; bottom: 16px; width: calc(100vw - 32px); }
    .btn:hover, .btn-custom:hover, .mode-toggle:hover { transform: none; }
}

/* Refinamiento exclusivo de index.php */
body.login-body {
    min-height: 100svh;
    padding: 24px;
}
.login-card {
    overflow: hidden;
    background: linear-gradient(145deg, rgba(20, 34, 58, 0.97), rgba(12, 22, 40, 0.94));
    box-shadow: 0 28px 80px rgba(2, 8, 23, 0.42), 0 0 0 1px rgba(126, 180, 255, 0.08);
}
.login-card::before {
    position: absolute;
    top: 0;
    right: 12%;
    left: 12%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
    content: "";
}
.login-card::after {
    position: absolute;
    top: -110px;
    right: -90px;
    width: 260px;
    height: 260px;
    border: 1px solid rgba(90, 167, 255, 0.11);
    border-radius: 50%;
    content: "";
    pointer-events: none;
}
.login-logo {
    position: relative;
    z-index: 1;
    padding: 8px 0 4px;
}
.login-logo img { filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.2)); }
.portal-header { position: relative; z-index: 1; }
.portal-header h2 { line-height: 1.2; }
.icon-wrapper {
    display: inline-grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid rgba(90, 167, 255, 0.28);
    border-radius: 10px;
    background: rgba(90, 167, 255, 0.12);
    color: var(--primary-color);
    font-size: 0.9em;
}
.login-card form { position: relative; z-index: 1; margin-top: 4px; }
.login-card .form-group { margin-bottom: 18px; }
.login-card .form-group label { color: var(--text-muted); font-size: 0.82rem; font-weight: 700; letter-spacing: 0.02em; }
.login-card .form-control { min-height: 48px; padding: 12px 14px; background: rgba(7, 16, 30, 0.62) !important; }
.login-card .btn-submit {
    min-height: 48px;
    margin-top: 7px;
    border: 1px solid rgba(154, 205, 255, 0.18);
    background: linear-gradient(135deg, #62b0ff, #3289e8) !important;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.24);
}
.login-card .btn-submit:hover { box-shadow: 0 14px 28px rgba(37, 99, 235, 0.34); }
.login-card .mode-toggle {
    top: 18px !important;
    right: 18px !important;
    width: 40px;
    height: 40px;
    justify-content: center;
    padding: 0;
    border-color: rgba(148, 163, 184, 0.2);
    background: rgba(255, 255, 255, 0.035);
}
.login-card .mode-toggle:hover { border-color: rgba(90, 167, 255, 0.5); background: rgba(90, 167, 255, 0.12); }

[data-theme="light"] .login-card, body.light-mode .login-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(239, 246, 255, 0.96));
    color: #172033;
    box-shadow: 0 24px 70px rgba(30, 64, 105, 0.16), 0 0 0 1px rgba(23, 105, 209, 0.08);
}
[data-theme="light"] .login-card .form-control, body.light-mode .login-card .form-control {
    background: rgba(255, 255, 255, 0.92) !important;
    color: #172033 !important;
}
[data-theme="light"] .login-card .form-group label, body.light-mode .login-card .form-group label { color: #5f6f85; }
[data-theme="light"] .login-card .mode-toggle, body.light-mode .login-card .mode-toggle { background: rgba(23, 105, 209, 0.06); }

@media (max-width: 480px) {
    body.login-body { padding: 14px; }
    .login-card { padding: 38px 22px 28px; }
    .login-logo img { width: min(215px, 82%); }
}

/* ========================================================================== 
   11. SISTEMA VISUAL UNIFICADO DEL PORTAL
   ========================================================================== */
:root {
    color-scheme: dark;
    --bg-color: #0b1120;
    --text-color: #e8eef8;
    --card-bg: rgba(18, 29, 49, 0.88);
    --border-color: rgba(148, 163, 184, 0.18);
    --primary-color: #5aa7ff;
    --primary-hover: #3289f1;
    --input-bg: rgba(15, 23, 42, 0.82);
    --input-text: #f8fafc;
    --navbar-bg: rgba(15, 23, 42, 0.76);
    --text-muted: #9aaac0;
    --table-hover: rgba(90, 167, 255, 0.08);
    --th-bg: rgba(7, 14, 28, 0.72);
    --th-color: #dbeafe;
    --surface-raised: rgba(30, 43, 68, 0.74);
    --shadow-sm: 0 8px 24px rgba(2, 8, 23, 0.18);
    --shadow-md: 0 18px 48px rgba(2, 8, 23, 0.28);
    --radius-md: 14px;
    --radius-sm: 9px;
    --cursor-x: 50vw;
    --cursor-y: 20vh;
}

[data-theme="light"], body.light-mode {
    color-scheme: light;
    --bg-color: #f2f6fb;
    --text-color: #172033;
    --card-bg: rgba(255, 255, 255, 0.92);
    --border-color: rgba(71, 85, 105, 0.16);
    --primary-color: #1769d1;
    --primary-hover: #0e55b0;
    --input-bg: #ffffff;
    --input-text: #172033;
    --navbar-bg: rgba(255, 255, 255, 0.82);
    --text-muted: #5f6f85;
    --table-hover: #edf5ff;
    --th-bg: #eaf1f9;
    --th-color: #334155;
    --surface-raised: rgba(248, 250, 252, 0.96);
    --shadow-sm: 0 8px 24px rgba(30, 64, 105, 0.08);
    --shadow-md: 0 18px 48px rgba(30, 64, 105, 0.14);
}

html { min-width: 320px; background: var(--bg-color); }
body {
    position: relative;
    isolation: isolate;
    background:
        radial-gradient(500px circle at var(--cursor-x) var(--cursor-y), rgba(90, 167, 255, 0.08), transparent 68%),
        linear-gradient(rgba(148, 163, 184, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.035) 1px, transparent 1px),
        var(--bg-color);
    background-size: auto, 42px 42px, 42px 42px, auto;
    background-attachment: fixed;
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.navbar, .top-navbar {
    border-color: var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.card, .metric-card, .filter-card, .toolbar, .task-card, .table-responsive,
.login-card, .login-container, .app-card {
    border-color: var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.login-card, .login-container { animation: portal-enter 0.5s ease-out both; }
.app-card { animation: portal-enter 0.45s ease-out both; }
.app-card:nth-child(2) { animation-delay: 0.06s; }
.app-card:nth-child(3) { animation-delay: 0.12s; }
.app-card:nth-child(4) { animation-delay: 0.18s; }
.app-card:nth-child(5) { animation-delay: 0.24s; }
.app-card:nth-child(6) { animation-delay: 0.3s; }
.card:hover, .metric-card:hover, .task-card:hover { border-color: rgba(90, 167, 255, 0.42); }

@keyframes portal-enter {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.app-card {
    position: relative;
    overflow: hidden;
    background: linear-gradient(145deg, var(--card-bg), var(--surface-raised));
}
.app-card::after {
    position: absolute;
    right: -30px;
    bottom: -42px;
    width: 130px;
    height: 130px;
    border: 1px solid rgba(90, 167, 255, 0.16);
    border-radius: 50%;
    content: "";
    pointer-events: none;
}
.app-card:hover { transform: translateY(-7px); box-shadow: var(--shadow-md); }
.app-card h3 { letter-spacing: 0.01em; }
.app-icon { filter: drop-shadow(0 5px 12px rgba(59, 130, 246, 0.2)); }

.btn, .btn-custom, .mode-toggle, .form-control, .ts-control {
    min-height: 40px;
    border-radius: var(--radius-sm);
}
.btn:hover, .btn-custom:hover, .mode-toggle:hover { transform: translateY(-1px); }
.btn:active, .btn-custom:active, .mode-toggle:active { transform: translateY(0); }
.btn:focus-visible, .btn-custom:focus-visible, .mode-toggle:focus-visible,
.form-control:focus-visible, .ts-control:focus-visible, a:focus-visible {
    outline: 3px solid rgba(90, 167, 255, 0.38);
    outline-offset: 3px;
}

.form-control, .ts-control {
    border-color: var(--border-color) !important;
    box-shadow: inset 0 1px 2px rgba(2, 8, 23, 0.08);
}
.form-control::placeholder { color: var(--text-muted); opacity: 0.82; }
.form-control:hover { border-color: rgba(90, 167, 255, 0.46) !important; }
.form-control:focus, .ts-control.focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 4px rgba(90, 167, 255, 0.14) !important;
}

/* Contraste uniforme de texto introducido, placeholders y listas en todos los temas. */
.form-control,
.form-control input,
.form-control select,
.form-control textarea,
input.form-control,
select.form-control,
textarea.form-control,
.ts-control,
.ts-control input {
    color: var(--input-text) !important;
    caret-color: var(--input-text) !important;
}
.form-control::placeholder,
input::placeholder,
textarea::placeholder,
.ts-control input::placeholder {
    color: var(--text-muted) !important;
    opacity: 1 !important;
}
select.form-control option,
select option,
.theme-picker select option {
    background: var(--input-bg) !important;
    color: var(--input-text) !important;
}
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--input-text) !important;
    box-shadow: 0 0 0 1000px var(--input-bg) inset !important;
    caret-color: var(--input-text) !important;
}
.login-card .form-control,
.login-card input.form-control {
    background: var(--input-bg) !important;
    color: var(--input-text) !important;
    -webkit-text-fill-color: var(--input-text) !important;
}
.login-card .form-control::placeholder { color: var(--text-muted) !important; }
[data-theme="light"] .login-card .form-control,
body.light-mode .login-card .form-control {
    background: #fff !important;
    color: #172033 !important;
    -webkit-text-fill-color: #172033 !important;
}

.table-responsive { box-shadow: var(--shadow-sm); }
th { letter-spacing: 0.03em; text-transform: uppercase; font-size: 0.74rem; }
tbody tr { transition: background-color 0.18s ease; }
tbody tr:hover { background-color: var(--table-hover); }

.modal { backdrop-filter: blur(8px); background: rgba(2, 8, 23, 0.68); }
.modal-content, .password-modal-content { box-shadow: var(--shadow-md); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

@media (max-width: 768px) {
    body { padding: 14px; }
    .header-section h1 { font-size: 1.65rem; }
    .navbar, .top-navbar { margin: 0 auto 16px; padding: 14px; }
    .nav-user { grid-template-columns: 1fr 1fr; }
    .nav-user > span { grid-column: 1 / -1; }
    .metrics-grid { grid-template-columns: 1fr; gap: 14px; }
    .metric-card, .card, .filter-card, .toolbar { padding: 16px; }
    .password-actions { flex-direction: column-reverse; }
    .password-actions .btn-custom { width: 100%; justify-content: center; }
}
body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(120deg, transparent 0 45%, rgba(90, 167, 255, 0.035) 50%, transparent 55%);
    content: "";
    pointer-events: none;
}
.app-card::before, .metric-card::before {
    position: absolute;
    inset: 0;
    background: radial-gradient(240px circle at var(--pointer-x, 50%) var(--pointer-y, 0%), rgba(125, 190, 255, 0.13), transparent 70%);
    content: "";
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.app-card:hover::before, .metric-card:hover::before { opacity: 1; }
.app-card > *, .metric-card > * { position: relative; z-index: 1; }
.js-reveal { opacity: 0; transform: translateY(12px); }
.js-reveal.is-visible { animation: portal-enter 0.55s var(--reveal-delay, 0ms) ease-out both; }
.btn, .btn-custom, .btn-submit, .app-card { position: relative; overflow: hidden; }
.ui-ripple {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
    animation: ui-ripple 0.55s ease-out forwards;
}
@keyframes ui-ripple {
    to { opacity: 0; transform: translate(-50%, -50%) scale(18); }
}

/* Centro de mensajeria */
.chat-center-dialog {
    width: min(94vw, 1380px) !important;
    max-width: none !important;
    min-width: 0;
    height: min(88vh, 820px) !important;
    margin: 3vh auto !important;
}
.chat-center-content {
    display: flex !important;
    flex-direction: column;
    width: 100% !important;
    overflow: hidden;
    min-height: 0;
    border: 1px solid var(--border-color) !important;
    border-radius: 18px !important;
    background: var(--card-bg) !important;
    color: var(--text-color) !important;
    box-shadow: var(--shadow-md) !important;
}
.chat-center-body { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.chat-center-header { flex-wrap: wrap; gap: 12px; }
.chat-center-views { display: inline-flex; align-items: center; gap: 5px; padding: 4px; border: 1px solid var(--border-color); border-radius: 9px; background: var(--bg-main); }
.chat-center-tab { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 7px 12px; border: 0; border-radius: 6px; background: transparent; color: var(--text-muted); font: inherit; font-size: .82rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.chat-center-tab.active { background: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(15, 23, 42, .14); }
.chat-tab-badge { min-width: 18px; padding: 1px 5px; border-radius: 999px; background: #dc2626; color: #fff; font-size: .68rem; line-height: 1.4; text-align: center; }
.chat-conversation-sidebar {
    display: flex;
    flex: 0 0 360px;
    flex-direction: column;
    min-width: 0;
    border-right: 1px solid var(--border-color);
    background: var(--surface-raised, var(--bg-main));
}
.chat-thread-panel { display: flex; flex: 1; flex-direction: column; min-width: 0; background: var(--card-bg); }
.chat-conversation-sidebar > .chat-sidebar-view { flex: 1; min-height: 0; padding: 0 !important; }
.chat-sidebar-view { display: flex; flex-direction: column; min-width: 0; }
.directos-sidebar-head { display: flex; flex-direction: column; gap: 9px; padding: 14px; border-bottom: 1px solid var(--border-color); }
.directos-sidebar-head .form-control, .directos-contactos > .form-control { min-height: 40px; }
.directos-nuevo { min-height: 38px; justify-content: center; }
.directos-lista { display: flex; flex: 1; min-height: 70px; flex-direction: column; gap: 6px; overflow-y: auto; padding: 10px; }
.directos-vacio { padding: 22px 12px; color: var(--text-muted); font-size: .84rem; text-align: center; }
.directos-card, .directos-contacto { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid transparent; border-radius: 8px; background: var(--card-bg); color: var(--text-dark); cursor: pointer; text-align: left; }
.directos-card:hover, .directos-contacto:hover, .directos-card.activo { border-color: var(--border-color); background: var(--bg-main); }
.directos-card-copy, .directos-contacto-copy { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 3px; }
.directos-card-copy strong, .directos-contacto-copy strong { overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.directos-card-copy span { overflow: hidden; color: var(--text-muted); font-size: .74rem; text-overflow: ellipsis; white-space: nowrap; }
.directos-card-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.directos-fecha { color: var(--text-muted); font-size: .65rem; white-space: nowrap; }
.directos-no-leidos { min-width: 18px; padding: 1px 5px; border-radius: 999px; background: #dc2626; color: #fff; font-size: .66rem; font-weight: 700; text-align: center; }
.directo-avatar { position: relative; display: inline-flex; flex: 0 0 34px; width: 34px; height: 34px; align-items: center; justify-content: center; border-radius: 50%; background: rgba(37, 99, 235, .1); color: var(--primary); }
.directo-avatar .directo-presencia-punto { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border: 2px solid var(--card-bg); border-radius: 50%; background: #94a3b8; }
.directo-avatar.en-linea .directo-presencia-punto { background: #10b981; }
.directos-contactos { display: flex; max-height: 48%; flex: 0 1 48%; flex-direction: column; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--border-color); background: var(--bg-main); }
.directos-contactos-head { display: flex; align-items: center; justify-content: space-between; color: var(--text-dark); font-size: .82rem; }
.directos-cerrar-contactos { width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--text-muted); font-size: 1.25rem; cursor: pointer; }
.directos-cerrar-contactos:hover { background: var(--card-bg); color: var(--text-dark); }
.directos-lista-contactos { min-height: 45px; padding: 2px 0; }
.directo-presencia { display: inline-flex; align-items: center; gap: 5px; margin-top: 3px; color: var(--text-muted); font-size: .72rem; }
.directo-presencia-punto { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.directo-presencia.en-linea { color: #047857; }
.directo-presencia.en-linea .directo-presencia-punto { background: #10b981; }
.directo-chat-header { display: flex; align-items: center; padding: 13px 18px; border-bottom: 1px solid var(--border-color); background: var(--bg-main); }
.directo-chat-identidad { display: flex; align-items: center; gap: 11px; min-width: 0; }
.directo-mensajes { display: flex; flex: 1; min-height: 0; flex-direction: column; gap: 10px; overflow-y: auto; padding: 22px; }
.directo-mensaje { max-width: min(76%, 680px); padding: 10px 13px; border: 1px solid var(--border-color); border-radius: 12px 12px 12px 3px; background: var(--bg-main); color: var(--text-dark); overflow-wrap: anywhere; white-space: pre-wrap; }
.directo-mensaje.mio { align-self: flex-end; border-color: var(--primary); border-radius: 12px 12px 3px 12px; background: var(--primary); color: #fff; }
.directo-mensaje-autor { margin-bottom: 3px; font-size: .7rem; font-weight: 700; opacity: .76; }
.directo-mensaje-texto { font-size: .88rem; line-height: 1.45; }
.directo-mensaje-fecha { margin-top: 5px; font-size: .64rem; opacity: .68; text-align: right; }
.directo-formulario { display: flex; gap: 9px; padding: 14px 18px; border-top: 1px solid var(--border-color); background: var(--bg-main); }
.directo-formulario .form-control { min-height: 44px; }
.directo-formulario button { width: 46px; min-height: 44px; justify-content: center; }
.chat-conversation-sidebar > .chat-sidebar-view > div:first-child { padding: 18px !important; border-color: var(--border-color) !important; }
#listaConversacionesBandeja { padding: 14px !important; gap: 10px !important; }
.tarjeta-conversacion {
    padding: 15px 16px !important;
    border: 1px solid var(--border-color) !important;
    border-left: 3px solid transparent !important;
    border-radius: 11px !important;
    background: var(--card-bg) !important;
    color: var(--text-color);
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}
.tarjeta-conversacion:hover, .tarjeta-conversacion:focus-visible {
    border-color: var(--primary-color) !important;
    background: var(--surface-raised) !important;
    box-shadow: 0 8px 20px rgba(2, 8, 23, 0.16);
    outline: none;
    transform: translateY(-1px);
}
.conversacion-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.conversacion-card-head strong { color: var(--text-color); font-size: 0.9rem; }
.conversacion-card-head strong span { display: block; margin-top: 3px; color: var(--primary-color); font-size: 1rem; }
.conversacion-card-meta { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; margin-bottom: 14px; }
.conversacion-card-meta span, .conversacion-card-foot span:last-child { min-width: 0; overflow: hidden; color: var(--text-muted); font-size: 0.76rem; text-overflow: ellipsis; white-space: nowrap; }
.conversacion-card-meta small { display: block; margin-bottom: 3px; color: var(--text-muted); font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.08em; }
.conversacion-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Portal principal: herramientas de descubrimiento y densidad */
.portal-main { position: relative; }
.portal-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; padding: clamp(22px, 4vw, 44px) 0 28px; border-bottom: 1px solid var(--border-color); }
.portal-hero-copy { max-width: 680px; }
.portal-kicker { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 14px; color: var(--primary-color); font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.portal-hero h1 { margin: 0; font-family: 'Poppins', sans-serif; font-size: clamp(2rem, 4vw, 3.4rem); line-height: 1.08; letter-spacing: -.03em; }
.portal-hero p { max-width: 560px; margin: 14px 0 0; color: var(--text-muted); font-size: 1rem; line-height: 1.65; }
.portal-hero-mark { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.portal-hero-mark img { width: min(180px, 30vw); height: auto; filter: drop-shadow(0 12px 20px rgba(0, 0, 0, .15)); }
.portal-hero-mark span { color: var(--text-muted); font-size: .82rem; font-weight: 600; }
.portal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 24px 0 18px; }
.portal-search { display: flex; align-items: center; gap: 10px; width: min(460px, 100%); padding: 0 12px; border: 1px solid var(--border-color); border-radius: 10px; background: var(--card-bg); color: var(--text-muted); box-shadow: 0 5px 18px rgba(2, 8, 23, .06); }
.portal-search:focus-within { border-color: var(--primary-color); box-shadow: 0 0 0 4px rgba(59, 130, 246, .13); }
.portal-search input { min-width: 0; flex: 1; padding: 12px 0; border: 0; outline: 0; background: transparent; color: var(--text-color); font: inherit; }
.portal-search kbd { padding: 2px 6px; border: 1px solid var(--border-color); border-radius: 5px; color: var(--text-muted); font-size: .72rem; }
.portal-toolbar-meta { display: flex; align-items: center; gap: 14px; color: var(--text-muted); font-size: .84rem; }
.portal-app-count strong { color: var(--text-color); }
.portal-view-toggle { display: inline-flex; align-items: center; gap: 7px; padding: 8px 10px; border: 1px solid var(--border-color); border-radius: 8px; background: transparent; color: var(--text-muted); cursor: pointer; font: inherit; }
.portal-view-toggle:hover, .portal-view-toggle[aria-pressed="true"] { border-color: var(--primary-color); color: var(--primary-color); }
.apps-grid.is-compact { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.apps-grid.is-compact .app-card { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; gap: 0 14px; padding: 18px; text-align: left; }
.apps-grid.is-compact .app-icon { grid-row: 1 / span 2; grid-column: 1; margin: 0; font-size: 1.8rem; display: flex; align-items: center; justify-content: center; }
.apps-grid.is-compact .app-card h3 { grid-column: 2; align-self: end; margin: 0; font-size: 1rem; line-height: 1.3; }
.apps-grid.is-compact .app-card p { grid-column: 2; align-self: start; margin-top: 4px; font-size: .82rem; line-height: 1.4; }
.app-card.is-hidden { display: none; }
.portal-empty-state { max-width: 500px; margin: 40px auto; padding: 24px; border: 1px solid rgba(239, 68, 68, .45); border-radius: 12px; background: rgba(239, 68, 68, .1); color: #fca5a5; text-align: center; }
.portal-empty-state i { display: block; margin-bottom: 12px; color: #ef4444; font-size: 2.5rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.task-search { display: flex; align-items: center; gap: 10px; margin: 14px 0 16px; padding: 0 12px; border: 1px solid var(--border-color); border-radius: 10px; background: var(--card-bg); color: var(--text-muted); }
.task-search:focus-within { border-color: var(--primary-color); box-shadow: 0 0 0 4px rgba(59, 130, 246, .13); }
.task-search input { min-width: 0; flex: 1; padding: 11px 0; border: 0; outline: 0; background: transparent; color: var(--text-color); font: inherit; }
.task-visible-count { white-space: nowrap; color: var(--text-muted); font-size: .78rem; }
.task-card.is-hidden { display: none; }

/* Temas visuales alternativos */
:root {
    --font-body: 'Inter', system-ui, sans-serif;
    --font-heading: 'Poppins', 'Inter', sans-serif;
    --ambient-glow: rgba(90, 167, 255, .08);
    --accent-strong: var(--primary-color);
    --accent-secondary: #8b5cf6;
    --accent-contrast: #ffffff;
    --primary-contrast: #ffffff;
    --secondary-contrast: #ffffff;
    --control-radius: var(--radius-sm);
    --button-shadow: 0 8px 20px rgba(2, 8, 23, .16);
}
[data-theme="ocean"] {
    color-scheme: dark;
    --bg-color: #071b29; --text-color: #e5fbff; --card-bg: rgba(9, 42, 57, .91); --border-color: rgba(103, 232, 249, .22);
    --primary-color: #22d3ee; --primary-hover: #06b6d4; --input-bg: #082536; --input-text: #ecfeff; --navbar-bg: rgba(5, 29, 43, .82);
    --text-muted: #91c6d2; --table-hover: rgba(34, 211, 238, .1); --th-bg: rgba(3, 25, 38, .85); --th-color: #cffafe; --surface-raised: rgba(14, 67, 83, .72);
    --shadow-sm: 0 8px 24px rgba(0, 24, 39, .28); --shadow-md: 0 20px 52px rgba(0, 20, 35, .4); --font-body: 'Trebuchet MS', system-ui, sans-serif; --font-heading: 'Arial', sans-serif;
    --ambient-glow: rgba(34, 211, 238, .11); --accent-strong: #22d3ee; --accent-secondary: #14b8a6; --accent-contrast: #082536; --primary-contrast: #082536; --secondary-contrast: #062c2b; --control-radius: 6px; --button-shadow: 0 8px 20px rgba(8, 145, 178, .22);
}
[data-theme="forest"] {
    color-scheme: dark;
    --bg-color: #0b1d17; --text-color: #ebfff3; --card-bg: rgba(20, 49, 37, .92); --border-color: rgba(134, 239, 172, .2);
    --primary-color: #4ade80; --primary-hover: #22c55e; --input-bg: #102a20; --input-text: #f0fdf4; --navbar-bg: rgba(10, 35, 25, .84);
    --text-muted: #9bc8ad; --table-hover: rgba(74, 222, 128, .1); --th-bg: rgba(8, 31, 21, .84); --th-color: #dcfce7; --surface-raised: rgba(32, 75, 52, .76);
    --shadow-sm: 0 8px 24px rgba(1, 20, 10, .28); --shadow-md: 0 20px 52px rgba(1, 20, 10, .42); --font-body: 'Segoe UI', system-ui, sans-serif; --font-heading: 'Georgia', serif;
    --ambient-glow: rgba(74, 222, 128, .1); --accent-strong: #4ade80; --accent-secondary: #facc15; --accent-contrast: #052e16; --primary-contrast: #052e16; --secondary-contrast: #422006; --control-radius: 11px; --button-shadow: 0 8px 20px rgba(22, 101, 52, .28);
}
[data-theme="sunset"] {
    color-scheme: dark;
    --bg-color: #28161a; --text-color: #fff3e8; --card-bg: rgba(67, 35, 39, .93); --border-color: rgba(253, 186, 116, .24);
    --primary-color: #fb923c; --primary-hover: #f97316; --input-bg: #351b20; --input-text: #fff7ed; --navbar-bg: rgba(53, 25, 29, .86);
    --text-muted: #d8aaa0; --table-hover: rgba(251, 146, 60, .11); --th-bg: rgba(46, 21, 26, .86); --th-color: #ffedd5; --surface-raised: rgba(91, 44, 46, .78);
    --shadow-sm: 0 8px 24px rgba(34, 10, 15, .3); --shadow-md: 0 20px 52px rgba(34, 10, 15, .45); --font-body: 'Verdana', system-ui, sans-serif; --font-heading: 'Georgia', serif;
    --ambient-glow: rgba(251, 146, 60, .11); --accent-strong: #fb923c; --accent-secondary: #f43f5e; --accent-contrast: #431407; --primary-contrast: #431407; --secondary-contrast: #ffffff; --control-radius: 5px; --button-shadow: 0 8px 20px rgba(194, 65, 12, .25);
}
[data-theme="graphite"] {
    color-scheme: dark;
    --bg-color: #17191d; --text-color: #f2f4f7; --card-bg: rgba(39, 43, 49, .94); --border-color: rgba(226, 232, 240, .18);
    --primary-color: #d1d5db; --primary-hover: #ffffff; --input-bg: #20242a; --input-text: #f8fafc; --navbar-bg: rgba(27, 30, 35, .88);
    --text-muted: #aab2bd; --table-hover: rgba(226, 232, 240, .08); --th-bg: rgba(22, 25, 29, .9); --th-color: #e5e7eb; --surface-raised: rgba(54, 59, 67, .8);
    --shadow-sm: 0 8px 24px rgba(0, 0, 0, .3); --shadow-md: 0 20px 52px rgba(0, 0, 0, .48); --font-body: 'Arial', system-ui, sans-serif; --font-heading: 'Arial', sans-serif;
    --ambient-glow: rgba(226, 232, 240, .07); --accent-strong: #e5e7eb; --accent-secondary: #9ca3af; --accent-contrast: #17191d; --primary-contrast: #17191d; --secondary-contrast: #17191d; --control-radius: 3px; --button-shadow: 0 6px 16px rgba(0, 0, 0, .3);
}
[data-theme="paper"] {
    color-scheme: light;
    --bg-color: #f7f0e5; --text-color: #2f241c; --card-bg: rgba(255, 252, 246, .96); --border-color: rgba(120, 82, 45, .2);
    --primary-color: #a04f24; --primary-hover: #843d1c; --input-bg: #fffdf9; --input-text: #2f241c; --navbar-bg: rgba(255, 249, 239, .9);
    --text-muted: #776658; --table-hover: #f4e8d8; --th-bg: #eee0ce; --th-color: #5d4634; --surface-raised: rgba(249, 239, 224, .95);
    --shadow-sm: 0 8px 24px rgba(94, 65, 35, .1); --shadow-md: 0 20px 52px rgba(94, 65, 35, .16); --font-body: 'Verdana', system-ui, sans-serif; --font-heading: 'Georgia', serif;
    --ambient-glow: rgba(160, 79, 36, .08); --accent-strong: #a04f24; --accent-secondary: #2f766e; --accent-contrast: #ffffff; --primary-contrast: #ffffff; --secondary-contrast: #ffffff; --control-radius: 4px; --button-shadow: 0 8px 20px rgba(120, 82, 45, .14);
}

body { font-family: var(--font-body); background-image: radial-gradient(500px circle at var(--cursor-x) var(--cursor-y), var(--ambient-glow), transparent 68%), linear-gradient(rgba(148, 163, 184, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(148, 163, 184, .035) 1px, transparent 1px); }
h1, h2, h3, h4, h5, h6, .navbar-brand, .portal-hero h1, .app-card h3 { font-family: var(--font-heading); }
.btn, .btn-custom, .mode-toggle, .btn-submit, .form-control, .ts-control, .theme-picker, .theme-picker select { border-radius: var(--control-radius); }
.btn, .btn-custom, .mode-toggle, .btn-submit { box-shadow: var(--button-shadow); }
.btn-theme-toggle, .btn-theme { background-color: var(--accent-strong) !important; color: var(--accent-contrast) !important; }
.btn-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: var(--primary-contrast) !important;
}
.btn-primary:hover,
.btn-primary:focus-visible {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    color: var(--primary-contrast) !important;
}
.btn-profile { background-color: var(--accent-secondary) !important; color: var(--secondary-contrast) !important; }
.btn-outline-secondary {
    background: var(--surface-raised) !important;
    border-color: var(--border-color) !important;
    color: var(--text-color) !important;
}
.btn-outline-secondary:hover,
.btn-outline-secondary:focus-visible {
    background: var(--card-bg) !important;
    border-color: var(--primary-color) !important;
    color: var(--primary-color) !important;
}
.theme-picker { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 9px; border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-muted); box-shadow: var(--button-shadow); }
.theme-picker i { color: var(--primary-color); }
.theme-picker select { max-width: 125px; padding: 7px 22px 7px 2px; border: 0; outline: 0; background: transparent; color: var(--text-color); cursor: pointer; font: 600 .78rem var(--font-body); }
.theme-picker select,
.theme-picker option {
    color: var(--text-color) !important;
    background-color: var(--card-bg) !important;
    color-scheme: inherit;
}
.dropdown-item-custom,
#dropdownAnalisisMenu {
    background-color: var(--card-bg) !important;
    color: var(--text-color) !important;
}
.dropdown-item-custom:hover,
.dropdown-item-custom:focus {
    background-color: var(--surface-raised) !important;
    color: var(--primary-color) !important;
}
#dropdownAnalisisMenu > div {
    background-color: var(--surface-raised) !important;
    color: var(--text-muted) !important;
    border-color: var(--border-color) !important;
}
.theme-picker-login {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 2;
    max-width: calc(100% - 72px);
}
.theme-picker-login select { max-width: 105px; }

@media (max-width: 768px) {
    .portal-hero, .portal-toolbar { align-items: stretch; flex-direction: column; }
    .portal-hero-mark { align-items: flex-start; }
    .portal-hero-mark img { width: min(170px, 55vw); }
    .portal-toolbar-meta { justify-content: space-between; }
    .nav-user .theme-picker,
    .nav-user .session-timeout-indicator { flex: 1 1 auto; min-width: 0; }
}

@media (max-width: 480px) {
    .login-card, .login-container { padding: 78px 22px 28px; }
    .theme-picker-login { left: 12px; top: 12px; }
    .theme-picker-login select { max-width: 96px; }
}
.conversation-status { max-width: 100%; overflow-wrap: anywhere; padding: 4px 8px; border: 1px solid rgba(245, 158, 11, 0.35); border-radius: 6px; background: var(--status-bg); color: var(--status-color); font-size: 0.68rem !important; font-weight: 700; line-height: 1.25; text-align: center; white-space: normal; }
.conversacion-card-foot { flex-wrap: wrap; align-items: flex-start; }
.conversacion-card-foot > span:last-child { flex: 1 1 100%; }
.chat-conversation-sidebar > .chat-sidebar-view > div:first-child > div { display: flex !important; flex-wrap: wrap !important; overflow: visible !important; }
.chat-conversation-sidebar .filtro-estado { flex: 1 1 74px; min-height: 38px; white-space: normal !important; line-height: 1.15; }
.chat-context-label { display: block; margin-bottom: 4px; color: var(--text-muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; }
#panelChatActivoBandeja > div:first-child { flex-wrap: wrap; gap: 8px; }
#panelChatActivoBandeja > div:first-child > div { min-width: 0; flex: 1 1 200px; }
#bandejaBadgeEstado { flex: 0 1 auto; max-width: 100%; overflow-wrap: anywhere; line-height: 1.25; text-align: center; white-space: normal !important; }
#bandejaContenedorMensajes { padding: 24px !important; gap: 14px !important; }
#bandejaContenedorMensajes > div { max-width: min(75%, 620px) !important; padding: 13px 16px !important; border-radius: 14px !important; box-shadow: 0 5px 14px rgba(2, 8, 23, 0.12); line-height: 1.45; }
#formEnviarMensajeBandeja { padding: 16px 22px !important; gap: 12px !important; border-color: var(--border-color) !important; }
#formEnviarMensajeBandeja .form-control { min-height: 48px; }
#formEnviarMensajeBandeja button { width: 48px; min-height: 48px; justify-content: center; }

@media (max-width: 760px) {
    .chat-center-dialog { width: 96vw !important; height: 92vh !important; margin: 2vh auto !important; }
    .chat-center-header { justify-content: center !important; }
    .chat-center-header > div:first-child { flex: 1 1 calc(100% - 50px); }
    .chat-center-views { order: 3; flex: 1 1 100%; justify-content: center; }
    .chat-center-tab { flex: 1 1 50%; justify-content: center; }
    .directo-mensaje { max-width: 88%; }
    .chat-center-body { flex-direction: column; overflow-y: auto; }
    .chat-conversation-sidebar { flex: 0 0 42%; border-right: 0; border-bottom: 1px solid var(--border-color); }
    .chat-thread-panel { flex: 1 0 58%; min-height: 360px; }
    #bandejaContenedorMensajes > div { max-width: 86% !important; }
}

@media (min-width: 761px) {
    .chat-center-dialog {
        width: calc(100vw - 48px) !important;
        max-width: 1600px !important;
        min-width: 760px !important;
    }
    .chat-center-content { width: 100% !important; }
    .chat-center-body { width: 100%; }
    .chat-conversation-sidebar { flex: 0 0 360px !important; width: 360px; }
    .chat-thread-panel { flex: 1 1 auto !important; width: auto; min-width: 0; }
    .directo-formulario .form-control { min-width: 0; flex: 1 1 auto; }
}

@media (min-width: 900px) {
    .chat-center-dialog {
        width: min(96vw, 1600px) !important;
        height: min(88vh, 860px) !important;
    }
    .chat-conversation-sidebar { flex-basis: 340px; }
    .chat-thread-panel { min-width: 0; }
    #bandejaContenedorMensajes > div { max-width: min(68%, 760px) !important; }
    #bandejaBadgeEntidad { max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    #formEnviarMensajeBandeja { padding: 18px 28px !important; }
}

@media (min-width: 500px) {
    .chat-center-dialog {
        width: min(96vw, 1600px) !important;
        max-width: 1600px !important;
    }
    .chat-center-body {
        flex-direction: row !important;
    }
    .chat-conversation-sidebar {
        flex: 0 0 32% !important;
    }
    .chat-thread-panel {
        flex: 1 1 68% !important;
        width: auto !important;
    }
    #panelChatActivoBandeja > div:first-child,
    #bandejaContenedorMensajes,
    #formEnviarMensajeBandeja {
        min-width: 0;
    }
    #bandejaBadgeEntidad { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (min-width: 1100px) {
    .chat-conversation-sidebar { flex: 0 0 360px !important; }
    .chat-thread-panel { flex: 1 1 auto !important; }
}

@media (min-width: 761px) {
    .chat-center-dialog {
        width: calc(100vw - 48px) !important;
        max-width: 1600px !important;
        min-width: 760px !important;
    }
    .chat-conversation-sidebar {
        flex: 0 0 360px !important;
        width: 360px !important;
    }
    .chat-thread-panel {
        flex: 1 1 auto !important;
        width: auto !important;
        min-width: 0 !important;
    }
}

/* ==========================================================================
   CABECERA COMUN DE MODULOS (_cabecera.php)
   ========================================================================== */
/* Copia de las variables de tema: varios modulos redefinen --card-bg, --text-muted o --primary en su :root. */
:root { --hdr-card-bg: rgba(18, 29, 49, 0.88); --hdr-text-muted: #9aaac0; --hdr-primary: #5aa7ff; }
[data-theme="light"], body.light-mode { --hdr-card-bg: rgba(255, 255, 255, 0.92); --hdr-text-muted: #5f6f85; --hdr-primary: #1769d1; }
[data-theme="ocean"] { --hdr-card-bg: rgba(9, 42, 57, .91); --hdr-text-muted: #91c6d2; --hdr-primary: #22d3ee; }
[data-theme="forest"] { --hdr-card-bg: rgba(20, 49, 37, .92); --hdr-text-muted: #9bc8ad; --hdr-primary: #4ade80; }
[data-theme="sunset"] { --hdr-card-bg: rgba(67, 35, 39, .93); --hdr-text-muted: #d8aaa0; --hdr-primary: #fb923c; }
[data-theme="graphite"] { --hdr-card-bg: rgba(39, 43, 49, .94); --hdr-text-muted: #aab2bd; --hdr-primary: #d1d5db; }
[data-theme="paper"] { --hdr-card-bg: rgba(255, 252, 246, .96); --hdr-text-muted: #776658; --hdr-primary: #a04f24; }

.top-navbar.app-topbar {
    --card-bg: var(--hdr-card-bg);
    --text-muted: var(--hdr-text-muted);
    --primary: var(--hdr-primary);
    --primary-color: var(--hdr-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    width: 100%;
    max-width: 1450px;
    margin: 15px auto 25px auto;
    padding: 12px 24px;
    box-sizing: border-box;
    background: var(--navbar-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    color: var(--text-color);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: normal;
    text-align: left;
}
.top-navbar.app-topbar .nav-user { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; width: auto; }
.top-navbar.app-topbar .nav-identity { font-size: 0.9rem; color: var(--text-color); }
.top-navbar.app-topbar .nav-identity i { margin-right: 4px; color: var(--primary-color); }
.top-navbar.app-topbar .btn-custom {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 14px;
    border-radius: var(--control-radius);
    box-shadow: var(--button-shadow);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: normal;
    text-decoration: none;
    cursor: pointer;
}
.top-navbar.app-topbar .btn-custom:hover { text-decoration: none; }
.top-navbar.app-topbar .portal-link { width: 100%; justify-content: center; }

/* Modal comun de cambio de contraseña (_cabecera.php) */
.password-modal#modalPassword {
    --card-bg: var(--hdr-card-bg);
    --text-muted: var(--hdr-text-muted);
    --primary: var(--hdr-primary);
    --primary-color: var(--hdr-primary);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: normal;
    text-align: left;
}
#modalPassword .password-modal-content { color: var(--text-color); }
#modalPassword .password-modal-content h3 { font-family: var(--font-heading); font-size: 1.17rem; color: var(--text-color); }
#modalPassword .password-field label { color: var(--text-color); }
#modalPassword .form-control { width: 100%; min-height: 40px; padding: 10px 12px; font-size: 0.95rem; }
#modalPassword .btn-custom {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 14px;
    border-radius: var(--control-radius);
    box-shadow: var(--button-shadow);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

@media (max-width: 768px) {
    .top-navbar.app-topbar { flex-direction: column; align-items: stretch; padding: 14px; margin: 0 auto 16px; }
    .top-navbar.app-topbar .nav-user { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
    .top-navbar.app-topbar .nav-user > span { grid-column: 1 / -1; }
}