:root {
    --primary: #003049;
    --secondary: #005f73;
    --accent: #0a9396;
    --bg: #f4f6f9;
    --text: #1a1c1e;
    --sidebar-width: 260px;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

header {
    width: var(--sidebar-width);
    background: var(--primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 2rem 1rem;
    position: fixed;
    height: 100vh;
    box-sizing: border-box;
    overflow-y: auto;
    z-index: 1000;
}

/* Estilo refinado para el scrollbar del menú lateral */
header::-webkit-scrollbar {
    width: 4px;
}

header::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}

header h1 {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    padding-left: 1rem;
    border-left: 4px solid var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

nav button, .menu-toggle {
    padding: 0.8rem 1rem;
    border: 0;
    background: transparent;
    color: #aeb5bd;
    cursor: pointer;
    text-align: left;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-group {
    margin-bottom: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-group-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.5rem 1rem;
    opacity: 0.8;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px;
    transition: background 0.2s;
}

.nav-group-label:hover {
    background: rgba(255, 255, 255, 0.05);
}

.nav-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

.nav-group.open .nav-content {
    max-height: 500px; /* Suficiente para los submódulos */
}

.chevron {
    transition: transform 0.3s;
    font-size: 16px !important;
}

.nav-group.open .chevron {
    transform: rotate(180deg);
}

.sub-nav {
    padding-left: 1.5rem !important;
    font-size: 0.85rem !important;
}

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 1rem 0;
}

.menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--primary);
    color: white;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px;
    z-index: 1100;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.menu-toggle small { font-size: 10px; font-weight: bold; }

nav button:hover, nav button.active {
    background: var(--secondary);
    color: #fff;
}

nav button.active {
    border-left: 3px solid var(--accent);
}

.material-icons {
    font-size: 20px;
}

main {
    margin-left: var(--sidebar-width);
    padding: 2.5rem 3rem;
    flex-grow: 1;
    max-width: 1200px;
    transition: all 0.3s ease;
}

.card {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
    transition: transform 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Dashboard Layers */
.kpi-layer { margin-bottom: 1rem; }
.kpi-card { padding: 1.2rem; border-bottom: 4px solid #e2e8f0; }
.kpi-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.5rem; }
.kpi-header small { font-weight: 700; color: #64748b; font-size: 0.7rem; }
.kpi-value { font-size: 1.8rem; display: block; }
.info-icon { font-size: 16px; color: #94a3b8; cursor: help; }

.risk-alto { color: #e63946; }
.risk-medio { color: #f4a261; }
.risk-bajo { color: #2a9d8f; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.section-header h3 { margin: 0 !important; }
.dashboard-section h3 { font-size: 1rem; margin-top: 0; margin-bottom: 0.5rem; color: var(--primary); }
.section-subtitle { font-size: 0.85rem; color: #64748b; margin-bottom: 1.5rem; }

.demand-viz-container { margin: 1.5rem 0; }
.demand-bar-stack {
    height: 40px;
    display: flex;
    border-radius: 6px;
    overflow: hidden;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    line-height: 40px;
    text-align: center;
}
.bar-segment.prev { background: var(--primary); }
.bar-segment.proj { background: var(--secondary); border-left: 2px solid #fff; }
.bar-segment.corr { 
    background: repeating-linear-gradient(45deg, var(--accent), var(--accent) 10px, #088385 10px, #088385 20px);
    border-left: 2px solid #fff;
}

.demand-legend { display: flex; gap: 20px; margin-top: 1rem; font-size: 0.8rem; color: #64748b; }
.dot { height: 8px; width: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.dot.prev { background: var(--primary); }
.dot.proj { background: var(--secondary); }
.dot.corr { background: var(--accent); }

.col-2 { grid-template-columns: 2fr 1fr; }

.coverage-stats { display: flex; flex-direction: column; gap: 1rem; }
.stat-bar { background: #f1f5f9; height: 12px; border-radius: 10px; display: flex; align-items: center; gap: 10px; }
.stat-bar .fill { height: 100%; border-radius: 10px; }
.stat-bar span { font-size: 0.8rem; font-weight: bold; color: #64748b; }
.stat-label { font-size: 0.85rem; color: #4b5563; }

.health-list { list-style: none; padding: 0; margin: 1rem 0; }
.health-list li { margin-bottom: 0.5rem; font-size: 0.9rem; border-bottom: 1px solid #f1f5f9; padding-bottom: 4px; }
.data-link { color: var(--accent); cursor: pointer; font-size: 0.8rem; font-weight: bold; }

.badge { 
    padding: 2px 8px; 
    border-radius: 4px; 
    font-size: 0.7rem; 
    font-weight: bold; 
    text-transform: uppercase;
    color: white;
}
.badge.prev { background: var(--primary); }
.badge.corr { background: var(--accent); }

h2 { margin-bottom: 1.5rem; color: var(--primary); font-weight: 700; font-size: 1.75rem; }

table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th { text-align: left; padding: 12px; border-bottom: 2px solid #edf2f7; color: #64748b; font-size: 0.85rem; text-transform: uppercase; }
td { padding: 12px; border-bottom: 1px solid #edf2f7; font-size: 0.9rem; }

/* Inputs y Selects dentro de tablas */
.table-container select, .table-container input { 
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    font-size: 0.85rem;
    background: #fff;
    cursor: pointer;
}
.table-container select:focus {
    outline: none;
    border-color: var(--accent);
}
.table-container input { cursor: text; width: 100%; box-sizing: border-box; }
.status-select { font-size: 1.1rem !important; min-width: 60px; }
.note-input {
    width: 100%;
    border: none;
    border-bottom: 1px solid transparent;
    padding: 4px;
    font-size: 0.85rem;
    color: #64748b;
    background: transparent;
    font-style: italic;
    transition: border-color 0.3s;
}

.note-input:focus {
    outline: none;
    border-bottom-color: var(--accent);
    background: #f8fafc;
}

/* Estilos para Supuestos y Dependencias */
.context-header p { color: #64748b; font-size: 1.1rem; margin-bottom: 2rem; }

.filter-bar {
    display: flex;
    gap: 1.5rem;
    background: #fff;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border: 1px solid #e2e8f0;
    flex-wrap: wrap;
    align-items: flex-end;
}

.btn-download {
    margin-left: auto;
    background: var(--secondary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 0.75rem; font-weight: bold; color: var(--secondary); text-transform: uppercase; }
.filter-group select, .filter-group input { padding: 6px 12px; border-radius: 4px; border: 1px solid #cbd5e1; background: #fff; }

.domain-block {
    background: #fff;
    border-radius: 12px;
    margin-bottom: 2.5rem;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    border: 1px solid #edf2f7;
}

.domain-header {
    background: #f1f5f9;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
}

.domain-info h3 { margin: 0; color: var(--primary); font-size: 1.1rem; }
.domain-info small { color: var(--accent); font-weight: 500; }

.domain-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
}
.status-ready { background: #dcfce7; color: #166534; }
.status-partial { background: #fef9c3; color: #854d0e; }
.status-not-ready { background: #fee2e2; color: #991b1b; }

.table-container { overflow-x: auto; padding: 0 1rem; }

.micro-pedagogy {
    padding: 1rem 1.5rem;
    font-size: 0.85rem;
    color: #64748b;
    background: #f8fafc;
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid #f1f5f9;
    font-style: italic;
}
.convention-legend {
    padding: 1rem 1.5rem;
    font-size: 0.8rem;
    color: #94a3b8;
    border-top: 1px dashed #e2e8f0;
}
.pedagogical-footer {
    margin-top: 4rem;
    padding: 2rem;
    border-top: 2px solid #e2e8f0;
    color: #64748b;
    font-size: 0.9rem;
    text-align: center;
}
@media print {
    header, .menu-toggle, .filter-bar, .btn-download, nav { display: none !important; }
    main { margin-left: 0 !important; padding: 0 !important; width: 100% !important; max-width: 100% !important; }
    .domain-block { break-inside: avoid; border: 1px solid #ccc; box-shadow: none; }
    body { background: white; }
    .table-container select { border: none; appearance: none; -webkit-appearance: none; color: black; font-weight: bold; }
}

/* Estilos para Demanda Preventiva & Gantt */
.upload-zone {
    border: 2px dashed #cbd5e1;
    padding: 2rem;
    text-align: center;
    border-radius: 8px;
    background: #f8fafc;
    margin-bottom: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}
.upload-zone:hover { border-color: var(--accent); background: #f0f9ff; }

.gantt-wrapper { overflow-x: auto; background: #fff; border-radius: 8px; border: 1px solid #e2e8f0; margin-top: 1rem; }
.gantt-table { width: 100%; border-collapse: collapse; min-width: 1000px; }
.gantt-table th, .gantt-table td { border: 1px solid #edf2f7; padding: 10px; text-align: center; font-size: 0.75rem; }
.gantt-header-month { background: var(--primary); color: white; width: 7%; font-weight: bold; }
.gantt-asset-col { text-align: left !important; width: 20%; background: #f8fafc; font-weight: bold; border-right: 2px solid #e2e8f0 !important; }
.gantt-event {
    background: var(--accent);
    color: white;
    border-radius: 4px;
    padding: 6px 4px;
    font-size: 0.65rem;
    font-weight: bold;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.gantt-event small { opacity: 0.9; font-weight: normal; }
@media (max-width: 768px) {
    header {
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        width: 240px;
    }
    header.open {
        transform: translateX(0);
    }
    main {
        margin-left: 0;
        padding: 5rem 1.5rem 2rem 1.5rem;
    }
    .menu-toggle { display: flex; }
}

/* Modal de Ayuda Floating */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: #fff;
    width: 90%;
    max-width: 600px;
    margin: 5vh auto;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    overflow: hidden;
}

.modal-header {
    background: var(--primary);
    color: #fff;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 { margin: 0; font-size: 1.1rem; }

.close-modal {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-body { padding: 2rem; max-height: 70vh; overflow-y: auto; }
.modal-body h4 { color: var(--primary); margin-top: 1.5rem; border-bottom: 2px solid var(--bg); padding-bottom: 4px; }
.modal-body section:first-child h4 { margin-top: 0; }
.modal-body p, .modal-body li { font-size: 0.95rem; color: #4b5563; line-height: 1.6; }

/* Botón de ayuda circular en filtros */
.help-btn-circle {
    background: none;
    border: 1px solid #cbd5e1;
    color: #64748b;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 0px;
}

.help-btn-circle:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: #f0f9ff;
}

/* Estilos para Sliders de Simulación */
input[type=range] {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 5px;
    outline: none;
    margin: 15px 0;
    box-sizing: border-box;
}
/* Estilo para el "camino" del slider */
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: #e2e8f0;
    border-radius: 5px;
}
input[type=range]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50;
    background: var(--accent);
    cursor: pointer;
    margin-top: -7px; /* Centra el círculo en el track */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: 2px solid #fff;
    transition: transform 0.1s ease;
}

input[type=range]::-webkit-slider-thumb:active {
    transform: scale(1.2);
}

/* Estilos para el Mapa de Proceso / Flujo Operativo */
.flow-steps {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    position: relative;
    padding-left: 10px;
}
.flow-steps::before {
    content: '';
    position: absolute;
    left: 25px;
    top: 10px;
    bottom: 10px;
    width: 2px;
    background: #e2e8f0;
    z-index: 0;
}
.flow-step {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    position: relative;
    z-index: 1;
}
.flow-step .step-num {
    background: var(--accent);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.75rem;
    flex-shrink: 0;
    box-shadow: 0 0 0 4px #fff;
}
.flow-step p { margin: 2px 0 0 0; font-size: 0.85rem; color: #64748b; line-height: 1.4; }