* {
    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, #09869c 0%, #09869c 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: #E0F4F8;
    color: #09869c;
    border: 1px solid #7EC8D8;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}
.app-logo-img {
    height: 38px;
    width: auto;
    filter: brightness(0) invert(1);
}

.app-db-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.app-db-badge--local {
    background: rgba(67, 160, 71, 0.28);
    color: #e8f5e9;
}

.app-db-badge--rds {
    background: rgba(229, 57, 53, 0.28);
    color: #ffebee;
}

.app-db-badge--remote,
.app-db-badge--unknown {
    background: rgba(251, 192, 45, 0.28);
    color: #fff8e1;
}

.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: #09869c;
}

/* Contenedor principal debajo del header */
.app-main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

@media (max-width: 1100px) {
    .app-header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .app-nav {
        flex-wrap: wrap;
    }
}

.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"] {
    appearance: textfield;
    -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: #09869c;
    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-logo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.login-logo-img {
    height: 70px;
    width: auto;
}
.login-brand-name {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: #09869c;
    letter-spacing: 0.5px;
    text-align: center;
    line-height: 1.15;
}
.login-brand-name span {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: #80c0cb;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-top: 2px;
}
.login-title {
    margin: 0 0 4px 0;
    font-size: 1.5rem;
    color: #09869c;
    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: #09869c;
    box-shadow: 0 0 0 2px rgba(9, 134, 156, 0.2);
}
.login-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #09869c 0%, #09869c 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;
}

/* --- Modal de inactividad (warning + countdown) --- */
.idle-timeout-modal[hidden] {
    display: none;
}
.idle-timeout-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
}
.idle-timeout-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.55);
}
.idle-timeout-card {
    position: relative;
    max-width: 520px;
    margin: 0 auto;
    top: 20vh;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(0,0,0,0.25);
    padding: 20px 22px;
}
.idle-timeout-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #09869c;
    margin-bottom: 8px;
}
.idle-timeout-text {
    font-size: 0.95rem;
    color: #333;
    line-height: 1.35;
    margin-bottom: 16px;
}
.idle-timeout-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}
.idle-timeout-btn {
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #d0d7de;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
}
.idle-timeout-btn--secondary {
    background: #fff;
    color: #111827;
}
.idle-timeout-btn--secondary:hover {
    background: #f6f8fa;
}
.idle-timeout-btn--primary {
    background: linear-gradient(135deg, #09869c 0%, #09869c 100%);
    color: #fff;
    border-color: rgba(255,255,255,0.0);
}
.idle-timeout-btn--primary:hover {
    opacity: 0.96;
}

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

/* --- Muestra comparable para FCRe / FCRb (arquitectura mixta) --- */
.fcr-sample-card {
    background-color: #fff8e1;
    border: 1px solid #ffe082;
    border-left: 4px solid #ff9800;
    border-radius: 8px;
    padding: 16px 20px;
    margin: 24px 0 16px;
}
.fcr-sample-card h4 {
    margin: 0 0 6px 0;
    color: #5d4037;
    font-size: 16px;
}
.fcr-sample-card .fcr-sample-info {
    margin: 0 0 12px 0;
    font-size: 12px;
    color: #6d4c41;
}
.fcr-sample-card .fcr-sample-info code {
    background: #fff;
    padding: 1px 4px;
    border-radius: 3px;
    border: 1px solid #ffd180;
    font-size: 11px;
}
.fcr-sample-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}
.fcr-sample-grid > div {
    background: #fff;
    border: 1px solid #ffe0b2;
    border-radius: 6px;
    padding: 8px 10px;
}
.fcr-sample-grid label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    color: #8d6e63;
    margin-bottom: 4px;
    letter-spacing: 0.3px;
}
.fcr-sample-grid span {
    font-size: 16px;
    font-weight: 600;
    color: #3e2723;
}
.fcr-sample-grid input[type="number"] {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    color: #3e2723;
}
.fcr-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}
.btn-fcr-primary {
    padding: 8px 14px;
    background: #ff9800;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
}
.btn-fcr-primary:hover {
    background: #f57c00;
}
.fcr-badge {
    display: inline-block;
    background: #d32f2f;
    color: #fff;
    font-size: 10px;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
    letter-spacing: 0.4px;
}
.fcr-badge--ok {
    background: #2e7d32;
}
.fcr-badge--warn {
    background: #ef6c00;
}
.fcr-warnings {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.fcr-warnings .fcr-warning {
    background: #ffe0b2;
    border-left: 3px solid #fb8c00;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    color: #4e342e;
}
.fcr-preview-table {
    margin-top: 8px;
    max-height: 280px;
    overflow: auto;
    border: 1px solid #ffe0b2;
    border-radius: 4px;
    background: #fff;
}
.fcr-preview-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}
.fcr-preview-table th, .fcr-preview-table td {
    padding: 4px 8px;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
    white-space: nowrap;
}
.fcr-preview-table th {
    background: #fff3e0;
    color: #5d4037;
    position: sticky;
    top: 0;
    font-weight: 600;
}
.fcr-preview-empty {
    padding: 12px;
    text-align: center;
    color: #8d6e63;
    font-size: 12px;
}
.rf-input-disabled-note {
    display: block;
    margin-top: 2px;
    font-size: 10px;
    color: #d84315;
    font-style: italic;
}

