:root {
    --primary-color: #8b5cf6; /* Morado corporativo / moderno */
    --secondary-color: #3b82f6; /* Azul legal */
    --accent-color: #06b6d4; /* Cian acento */
    --success-color: #10b981; /* Verde esmeralda (Cumple) */
    --warning-color: #f59e0b; /* Ambar (Parcial) */
    --critical-color: #ef4444; /* Rojo (No cumple / Crítico) */
    
    --bg-dark: #0f172a; 
    --sidebar-bg: rgba(15, 23, 42, 0.7); 
    --card-bg: rgba(30, 41, 59, 0.6);
    --card-border: rgba(255, 255, 255, 0.1);
    
    --text-primary: #f8fafc;
    --text-muted: #cbd5e1;
    
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background: radial-gradient(circle at top right, #1e293b, #0f172a);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    padding: 2.5rem 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.logo-container {
    margin-bottom: 3rem;
    display: flex;
    justify-content: center;
}

.logo-container img {
    max-width: 80%;
    height: auto;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.1));
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    padding: 0.8rem 1.2rem;
    margin-bottom: 0.5rem;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-muted);
    transition: all var(--transition-speed);
}

.sidebar-nav li:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    transform: translateX(4px);
}

.sidebar-nav li.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(59, 130, 246, 0.2));
    border-left: 4px solid var(--secondary-color);
    color: white;
}

.user-profile {
    margin-top: auto;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    letter-spacing: 1px;
}

.user-info .user-name { display: block; font-size: 0.9rem; font-weight: 600; }
.user-info .user-role { display: block; font-size: 0.75rem; color: var(--text-muted); }

/* Main Content */
.main-content {
    flex: 1;
    padding: 2.5rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 1.5rem;
}

.actions { display: flex; gap: 1rem; }

/* Buttons */
.btn {
    padding: 0.7rem 1.5rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: transform 0.2s, opacity 0.2s;
}

.btn:active { transform: scale(0.97); }
.btn:hover { opacity: 0.9; }

.btn-primary { background: linear-gradient(135deg, var(--secondary-color), var(--primary-color)); color: white; box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3); }
.btn-secondary { background: rgba(255, 255, 255, 0.05); color: white; border: 1px solid var(--card-border); }

/* Views */
.view {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}
.view-header h2 { font-size: 1.8rem; font-weight: 600; color: white; }

/* Dashboard View */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 3px;
    background: linear-gradient(90deg, var(--secondary-color), transparent);
}

.stat-info h3 { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.5px;}
.stat-value { font-size: 2.2rem; font-weight: 700; letter-spacing: -1px; }

.text-critical { color: var(--critical-color); text-shadow: 0 0 10px rgba(239, 68, 68, 0.4); }
.text-success { color: var(--success-color); }
.text-warning { color: var(--warning-color); }
.text-accent { color: var(--accent-color); }

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.chart-container.large { grid-column: span 2; }
.chart-container {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 1.5rem;
}
.chart-header h2 { font-size: 1.1rem; font-weight: 600; color: var(--text-muted); margin-bottom: 1.5rem; }

/* Matrix Table */
.table-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

table { width: 100%; border-collapse: collapse; }
th, td { padding: 1.2rem; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.03); }
th { background: rgba(0,0,0,0.2); font-weight: 600; color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px;}
td { font-size: 0.95rem; vertical-align: top;}
tr:last-child td { border-bottom: none; }
tr:hover { background: rgba(255, 255, 255, 0.02); }

/* Badges */
.badge { display: inline-flex; align-items: center; justify-content: center; padding: 0.4rem 0.8rem; border-radius: 20px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;}
.badge-medium { background: rgba(245, 158, 11, 0.15); color: var(--warning-color); border: 1px solid rgba(245, 158, 11, 0.3);}
.badge-extreme { background: rgba(239, 68, 68, 0.15); color: var(--critical-color); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-high { background: rgba(249, 115, 22, 0.15); color: #f97316; border: 1px solid rgba(249, 115, 22, 0.3); }

/* Diagnosis Summary (New) */
.diagnosis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.diag-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    border-top: 4px solid;
}
.diag-card.critical { border-top-color: var(--critical-color); background: linear-gradient(180deg, rgba(239,68,68,0.05), transparent); }
.diag-card.warning { border-top-color: var(--warning-color); background: linear-gradient(180deg, rgba(245,158,11,0.05), transparent); }
.diag-card.success { border-top-color: var(--success-color); background: linear-gradient(180deg, rgba(16,185,129,0.05), transparent); }

.diag-header { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 1rem; }
.diag-header h3 { font-size: 1.1rem; font-weight: 600; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.status-dot.red { color: var(--critical-color); background: var(--critical-color); }
.status-dot.yellow { color: var(--warning-color); background: var(--warning-color); }
.status-dot.green { color: var(--success-color); background: var(--success-color); }

.diag-content p { font-size: 0.9rem; margin-bottom: 0.8rem; color: var(--text-muted); line-height: 1.5; }
.diag-content strong { color: white; }
.diag-actions { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,0.05); }
.diag-actions h4 { font-size: 0.85rem; color: var(--accent-color); margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.5px;}
.diag-actions ul { padding-left: 1.2rem; font-size: 0.85rem; color: var(--text-muted); }
.diag-actions li { margin-bottom: 0.4rem; }

/* Plan de accion */
.phases-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.phase-card { background: var(--card-bg); border-radius: 16px; padding: 1.5rem; border: 1px solid var(--card-border); }
.phase-card h3 { color: var(--primary-color); font-size: 1.2rem; margin-bottom: 1.5rem; padding-bottom: 0.8rem; border-bottom: 1px solid rgba(255,255,255,0.05); }
.task-list { list-style: none; }
.task-list li { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; font-size: 0.95rem; color: var(--text-primary); line-height: 1.5;}
.task-list input[type="checkbox"] { margin-top: 0.3rem; accent-color: var(--primary-color); width: 1.1rem; height: 1.1rem; cursor: pointer;}
.task-list span { flex: 1; }

/* Modal */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); backdrop-filter: blur(5px); justify-content: center; align-items: center; z-index: 1000; }
.modal-content { background: var(--bg-dark); padding: 2.5rem; border-radius: 20px; width: 400px; border: 1px solid var(--card-border); }
.modal-header { display: flex; justify-content: space-between; margin-bottom: 1.5rem; }
.close-modal { background: none; border: none; font-size: 2rem; color: var(--text-muted); cursor: pointer; }
