: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;
    --info-bg: #d1ecf1;
    --info-text: #0c5460;
    --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 */
.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 h4 { color: var(--primary-dark); font-size: 1.05rem; margin: 15px 0 10px; font-weight: 600; }
.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); }

/* Diagrama de flujo */
.flow-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 25px 0;
    padding: 20px;
    background: var(--bg-index-item);
    border-radius: 10px;
}

.flow-box {
    background: white;
    border: 2px solid var(--primary-medium);
    border-radius: 10px;
    padding: 15px 12px;
    text-align: center;
    min-width: 110px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transition: transform 0.2s;
}

.flow-box:hover { transform: translateY(-3px); }

.flow-box .flow-icon { font-size: 1.8rem; margin-bottom: 5px; }
.flow-box strong { display: block; color: var(--primary-dark); font-size: 0.9rem; margin-bottom: 4px; }
.flow-box span { font-size: 0.75rem; color: var(--text-muted); display: block; }

.flow-box.input { border-color: #2C4A7C; }
.flow-box.compress { border-color: #e67e22; background: #fef5e7; }
.flow-box.quantize { border-color: #27ae60; background: #eafaf1; }
.flow-box.expand { border-color: #8e44ad; background: #f4ecf7; }
.flow-box.output { border-color: #2C4A7C; background: #eaf0f9; }

.flow-arrow {
    font-size: 1.8rem;
    color: var(--primary-dark);
    font-weight: bold;
}

/* 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.2rem; font-weight: 600; color: var(--primary-dark); margin: 12px 0; font-family: 'Times New Roman', serif; }

/* 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; }

/* Alerts */
.alert { padding: 18px 22px; border-radius: 8px; margin: 15px 0; border-left: 5px solid; }
.alert-info { background: var(--info-bg); color: var(--info-text); border-left-color: #17a2b8; }
.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;
}

.canvas-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 25px;
}

.canvas-box {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    border-top: 3px solid var(--primary-medium);
}

.canvas-box h4 {
    color: var(--primary-dark);
    font-size: 0.95rem;
    margin: 0 0 10px 0;
    text-align: center;
    font-weight: 600;
}

.canvas-box canvas {
    width: 100%;
    height: auto;
    border: 1px solid #e0e5ec;
    border-radius: 4px;
    background: #fafbfd;
    display: block;
}

#canvasCurve {
    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: 25px;
    justify-content: center;
    align-items: flex-start;
    margin-bottom: 15px;
    padding: 15px;
    background: white;
    border-radius: 8px;
}

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

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

input[type="range"] {
    width: 140px;
    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;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-medium);
    cursor: pointer;
}

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

select {
    padding: 6px 12px;
    border: 2px solid var(--primary-medium);
    border-radius: 6px;
    background: white;
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
}

.sim-legend, .curve-legend {
    display: flex;
    justify-content: center;
    gap: 25px;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: var(--text-main);
    margin-top: 15px;
}

.legend-item { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.legend-color { width: 25px; height: 4px; display: inline-block; border-radius: 2px; }

/* 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; }
    .canvas-grid { grid-template-columns: 1fr; }
    .flow-diagram { flex-direction: column; }
    .flow-arrow { transform: rotate(90deg); }
    .sim-controls { gap: 15px; }
}