* {
    font-family: 'Roboto', sans-serif;
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
}

/* Header y navegación (fijo al hacer scroll) */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #1a237e 0%, #0d47a1 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    margin-bottom: 0;
}
.app-header-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
/* Avisos globales (p. ej. sesión por inactividad) */
.app-flash-wrap {
    max-width: 1600px;
    margin: 0 auto;
    padding: 12px 20px 0;
}
.app-flash {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.95rem;
    margin-bottom: 8px;
}
.app-flash--info {
    background: #e3f2fd;
    color: #0d47a1;
    border: 1px solid #90caf9;
}

.app-logo {
    font-size: 1.35rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    letter-spacing: 0.5px;
}
.app-nav {
    display: flex;
    gap: 4px;
}
.app-nav-link {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
}
.app-nav-link:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
.app-nav-link.active {
    background: rgba(255,255,255,0.25);
    color: #fff;
}
.app-user-menu {
    position: relative;
    margin-left: 12px;
}
.app-user-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
}
.app-user-trigger:hover {
    background: rgba(255, 255, 255, 0.2);
}
.app-user-name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.app-user-chevron {
    font-size: 10px;
    opacity: 0.85;
}
.app-user-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 220px;
    margin: 0;
    padding: 6px 0;
    list-style: none;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    z-index: 200;
}
.app-user-dropdown-link {
    display: block;
    padding: 10px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}
.app-user-dropdown-link:hover {
    background: #f0f4fa;
    color: #0d47a1;
}

/* Contenedor principal debajo del header */
.app-main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 20px;
}

.main-content {
    display: flex;
    gap: 20px;
}

.sidebar {
    width: 250px;
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Ocultar flechas de inputs numéricos en sidebar (por ejemplo percentiles ICA) */
.sidebar input[type="number"]::-webkit-outer-spin-button,
.sidebar input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.sidebar input[type="number"] {
    -moz-appearance: textfield;
}

.sidebar h3 {
    margin-top: 0;
    color: #333;
}

.content {
    flex: 1;
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.prediction-section {
    background-color: white;
}
.prediction-section-bg {
    background-color: #f8f9fa;
}

/* Estado de Resultados: secciones (#f0f0f0) y subsecciones más claras (#f5f5f5) */
.estado-resultados-table .er-seccion td {
    background-color: #f0f0f0;
}
.estado-resultados-table .er-seccion td:first-child {
    font-weight: 700;
}
/* Espaciado entre secciones: fila en blanco */
.estado-resultados-table tr.er-seccion-spacer td {
    height: 12px;
    padding: 0;
    border: none;
    background: transparent;
    vertical-align: middle;
}
.estado-resultados-table .er-subseccion td {
    background-color: #f5f5f5;
}

/* Estilos para el filtro personalizado tipo Looker Studio */
.filter-container {
    margin-bottom: 20px;
}

.filter-label {
    font-weight: 500;
    margin-bottom: 8px;
    display: block;
    color: #333;
}

.filter-dropdown {
    position: relative;
    width: 100%;
}

.filter-header {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 12px;
    background-color: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 38px;
    user-select: none;
}

.filter-header:hover {
    border-color: #999;
}

.filter-header.open {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.filter-selected-text {
    flex: 1;
    color: #333;
    font-size: 14px;
}

.filter-arrow {
    color: #666;
    transition: transform 0.2s;
}

.filter-header.open .filter-arrow {
    transform: rotate(180deg);
}

.filter-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.filter-menu.show {
    display: block;
}

.filter-menu-header {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.filter-menu-header input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.filter-menu-header label {
    flex: 1;
    cursor: pointer;
    font-weight: 500;
    margin: 0;
}

.filter-search {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
}

.filter-search input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.filter-options {
    max-height: 200px;
    overflow-y: auto;
}

.filter-option {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

.filter-option:hover {
    background-color: #f8f9fa;
}

.filter-option:last-child {
    border-bottom: none;
}

.filter-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.filter-option label {
    flex: 1;
    cursor: pointer;
    margin: 0;
    font-size: 14px;
    user-select: none;
}

.filter-option-button {
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid #ddd;
    background-color: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    color: #666;
}

.filter-option-button:hover {
    background-color: #e9ecef;
    border-color: #999;
}

.metrics {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    flex: 1;
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.metric-card h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #666;
    font-weight: 400;
}

.metric-card .value {
    font-size: 32px;
    font-weight: 500;
    color: #333;
    margin: 0;
}

.metric-card.total .value {
    color: #1f77b4;
}

.metric-card.selected .value {
    color: #2ca02c;
}

.metric-card.percentage .value {
    color: #d62728;
}

.stats {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.stat-box {
    flex: 1;
    padding: 15px;
    background-color: #e3f2fd;
    border-radius: 5px;
    text-align: center;
}

.stat-box strong {
    display: block;
    margin-bottom: 5px;
    color: #333;
}

.range-slider {
    margin-top: 10px;
}

.range-slider input[type="range"] {
    width: 100%;
}

.range-values {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: 12px;
    color: #666;
}

/* Grid de modelos de predicción */
.model-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 15px;
}

.model-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px 14px;
    background-color: #fdfdfd;
}

.model-card h4 {
    margin: 0 0 6px 0;
    font-size: 16px;
    color: #333;
}

.model-predictions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 8px;
}

.model-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 8px;
    font-size: 12px;
}

.model-metrics-extra {
    margin-top: 8px;
    font-size: 11px;
    color: #555;
}

/* Overlay de carga (Random Forest) */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: all;
    cursor: wait;
}

.loading-content {
    text-align: center;
    padding: 2rem;
}

.loading-spinner {
    width: 56px;
    height: 56px;
    margin: 0 auto 1.25rem;
    border: 4px solid #e0e0e0;
    border-top-color: #ff9800;
    border-radius: 50%;
    animation: loading-spin 0.9s linear infinite;
}

.loading-text {
    font-size: 1.1rem;
    font-weight: 500;
    color: #333;
    margin: 0 0 0.35rem 0;
}

.loading-subtext {
    font-size: 0.85rem;
    color: #666;
    margin: 0;
}

@keyframes loading-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Página de login */
.login-page {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-box {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 32px;
}
.login-title {
    margin: 0 0 4px 0;
    font-size: 1.5rem;
    color: #1a237e;
    text-align: center;
}
.login-subtitle {
    margin: 0 0 24px 0;
    font-size: 0.9rem;
    color: #666;
    text-align: center;
}
.login-error {
    background: #ffebee;
    color: #c62828;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
}
.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.login-field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
    color: #333;
}
.login-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}
.login-field input:focus {
    outline: none;
    border-color: #0d47a1;
    box-shadow: 0 0 0 2px rgba(13, 71, 161, 0.2);
}
.login-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #1a237e 0%, #0d47a1 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    margin-top: 8px;
}
.login-btn:hover {
    opacity: 0.95;
}
.login-footer {
    margin: 20px 0 0 0;
    font-size: 12px;
    color: #888;
    text-align: center;
}
.login-footer em {
    font-style: normal;
    color: #666;
}

/* --- Responsive layout --- */

@media (max-width: 1024px) {
    .app-header-inner {
        flex-wrap: wrap;
        gap: 8px;
    }
    .app-main {
        padding: 16px;
    }
    .main-content {
        align-items: flex-start;
    }
}

@media (max-width: 768px) {
    .app-main {
        padding: 12px;
    }
    h1 {
        font-size: 1.4rem;
        margin-bottom: 16px;
    }
    .main-content {
        flex-direction: column;
        gap: 16px;
    }
    .sidebar {
        width: 100%;
        order: 0;
    }
    .content {
        order: 1;
        padding: 16px;
    }
    .metrics {
        flex-direction: column;
    }
    .stats {
        flex-direction: column;
    }
    .estado-resultados-wrapper {
        overflow-x: auto;
    }
    .app-header-inner {
        padding: 10px 12px;
    }
    .app-nav {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
}

@media (max-width: 480px) {
    .app-main {
        padding: 10px 8px 16px 8px;
    }
    .content {
        padding: 12px;
    }
    .metric-card {
        padding: 14px;
    }
    .metric-card .value {
        font-size: 24px;
    }
    .stats {
        gap: 12px;
    }
    .stat-box {
        padding: 10px;
    }
    .model-card {
        padding: 10px 12px;
    }
    .filter-header {
        padding: 6px 10px;
    }
    .filter-selected-text {
        font-size: 13px;
    }
    .login-box {
        padding: 24px;
    }
}

