:root {
    --bg-page: #7B8FDE;
    --bg-card: #ffffff;
    --bg-index-item: #EEF1F8;
    --primary-dark: #2C4A7C;
    --primary-medium: #4A6FA5;
    --primary-light: #6B83C4;
    --text-dark: #1a1a1a;
    --text-main: #333333;
    --text-muted: #666666;
    --border: #d0d7e5;
    --warning-bg: #fff3cd;
    --warning-text: #856404;
    --success-bg: #d4edda;
    --success-text: #155724;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.6;
    padding: 20px;
}

/* Header institucional */
.institutional-header {
    background: var(--bg-card);
    border-radius: 8px 8px 0 0;
    padding: 25px 40px;
    border-bottom: 3px solid var(--primary-dark);
}
.header-inner { display: flex; align-items: center; gap: 25px; }
.header-logo { width: 85px; height: 85px; object-fit: contain; flex-shrink: 0; }
.header-text { flex: 1; text-align: center; }
.header-text h1, .header-text h2, .header-text h3, .header-text h4 { border: none; padding: 0; margin: 0; }
.header-text h1 { font-family: 'Georgia', serif; font-size: 1.25rem; color: var(--text-dark); font-weight: 700; margin-bottom: 6px; }
.header-text h2 { font-family: 'Georgia', serif; font-size: 1.1rem; color: var(--text-dark); font-weight: 700; margin-bottom: 6px; }
.header-text h3, .header-text h4 { font-family: 'Georgia', serif; font-size: 1rem; color: var(--text-main); font-style: italic; font-weight: 400; margin-bottom: 4px; }

/* Banner */
.title-banner {
    background: var(--primary-dark); color: white; padding: 45px 40px; text-align: center;
    border-radius: 0 0 8px 8px; margin-bottom: 25px;
}
.title-banner h1 { font-size: 2rem; font-weight: 700; margin-bottom: 15px; }
.title-banner .subtitle { font-size: 1.1rem; opacity: 0.95; margin-bottom: 8px; }
.title-banner .subtitle-small { font-size: 0.95rem; opacity: 0.85; }

/* Índice */
.index-section { margin-bottom: 25px; }
.index-card { background: var(--bg-card); border-radius: 10px; padding: 30px 35px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.index-title { font-size: 1.6rem; color: var(--primary-dark); margin-bottom: 20px; padding-bottom: 12px; border-bottom: 2px solid var(--primary-light); }
.index-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px; }
.index-item { display: flex; align-items: center; gap: 15px; background: var(--bg-index-item); padding: 15px 18px; border-radius: 8px; border-left: 4px solid var(--primary-medium); text-decoration: none; color: var(--text-main); transition: all 0.2s ease; }
.index-item:hover { background: #e4eaf5; border-left-color: var(--primary-dark); transform: translateX(3px); }
.index-number { width: 38px; height: 38px; background: var(--primary-medium); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.index-item div { display: flex; flex-direction: column; }
.index-item strong { font-size: 1rem; color: var(--primary-dark); font-weight: 700; }
.index-item span { font-size: 0.85rem; color: var(--text-muted); }

/* Contenido */
.content-wrapper { display: flex; flex-direction: column; gap: 20px; }
.content-card { background: var(--bg-card); border-radius: 10px; padding: 35px 40px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.content-card h2 { color: var(--primary-dark); font-size: 1.7rem; margin-bottom: 18px; padding-bottom: 10px; border-bottom: 2px solid var(--primary-light); }
.content-card h3 { color: var(--primary-medium); font-size: 1.25rem; margin: 25px 0 12px; }
.content-card p { margin-bottom: 15px; }
.content-card ul, .content-card ol { margin-left: 20px; margin-bottom: 15px; }
.content-card li { margin-bottom: 8px; }
.content-card strong { color: var(--primary-dark); }

/* Fórmulas */
.formula-box { background: var(--bg-index-item); padding: 20px 25px; border-radius: 8px; margin: 20px 0; border-left: 4px solid var(--primary-medium); }
.formula { text-align: center; font-size: 1.3rem; font-weight: 600; color: var(--primary-dark); margin: 12px 0; font-family: 'Times New Roman', serif; }
.formula-note { text-align: center; font-size: 0.9rem; color: var(--text-muted); font-style: italic; }

/* Tablas */
.table-responsive { overflow-x: auto; margin: 15px 0; }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--primary-dark); color: white; font-weight: 600; }
tr:nth-child(even) { background: #f7f9fc; }
tr:hover { background: #eef2fa; }

/* Comparación */
.comparison-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin: 20px 0; }
.strategy-card { background: var(--bg-index-item); padding: 20px; border-radius: 8px; border-top: 4px solid var(--primary-medium); }
.strategy-card h3 { color: var(--primary-dark); margin-top: 0; font-size: 1.15rem; }

/* Alerts */
.alert { padding: 18px 22px; border-radius: 8px; margin: 15px 0; border-left: 5px solid; }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); border-left-color: #ffc107; }
.alert-success { background: var(--success-bg); color: var(--success-text); border-left-color: #28a745; }

/* ========================================= */
/* SIMULACIÓN INTERACTIVA                    */
/* ========================================= */
.sim-wrapper {
    background: var(--bg-index-item);
    padding: 25px;
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-top: 20px;
}

.sim-canvas-container {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: inset 0 0 8px rgba(0,0,0,0.05);
    margin-bottom: 25px;
    text-align: center;
    overflow: hidden;
}

canvas {
    max-width: 100%;
    height: auto;
    border: 2px solid var(--primary-dark);
    border-radius: 6px;
    background: #fafbfd;
    display: block;
    margin: 0 auto;
}

.sim-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    justify-content: center;
    align-items: flex-start;
    margin-bottom: 10px;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 150px;
}

.control-group label {
    font-weight: 600;
    color: var(--primary-dark);
    font-size: 0.95rem;
}

input[type="range"] {
    width: 160px;
    height: 6px;
    background: #d0d7e5;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-medium);
    cursor: pointer;
    transition: background 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-dark);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-medium);
    cursor: pointer;
    border: none;
}

/* Footer */
.page-footer { background: var(--primary-dark); color: white; text-align: center; padding: 18px; border-radius: 8px; margin-top: 25px; font-size: 0.9rem; }
.back-link { color: white; text-decoration: none; font-weight: 600; display: inline-block; margin-bottom: 8px; transition: opacity 0.2s; }
.back-link:hover { opacity: 0.8; }

/* Responsive */
@media (max-width: 768px) {
    body { padding: 10px; }
    .institutional-header { padding: 20px; }
    .header-inner { flex-direction: column; text-align: center; }
    .header-logo { width: 70px; height: 70px; }
    .header-text h1 { font-size: 1rem; }
    .title-banner { padding: 30px 20px; }
    .title-banner h1 { font-size: 1.4rem; }
    .content-card { padding: 25px 20px; }
    .content-card h2 { font-size: 1.4rem; }
    .index-card { padding: 25px 20px; }
    .index-grid { grid-template-columns: 1fr; }
    .formula { font-size: 1.1rem; }
    .sim-controls { gap: 15px; }
    .sim-wrapper { padding: 15px; }
}