:root {
    --azul-oscuro: #0d47a1;
    --azul-oficial: #1e3a8a;
    --azul-marca: #1E4E8E;
    --azul-hover: #153a6b;
    --naranja-filtros: #ff9800;
    --rojo-tarjeta: #FF4B4B;
    --gris-texto: #475569;
    --fondo-app: #e3f2fd;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--fondo-app);
    margin: 0;
    padding: 0;
    color: #333;
}

.top-bar {
    background-color: var(--azul-oficial);
    padding: 12px;
    text-align: center;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    letter-spacing: 1px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 15px;
}

.header-section {
    text-align: center;
    margin-bottom: 25px;
}

.titulo-principal {
    color: var(--azul-oscuro);
    font-size: 2.8rem;
    font-weight: 900;
    margin: 0 0 10px 0;
    line-height: 1;
    letter-spacing: -1px;
}

.banderas-comunidad {
    font-size: 2.2rem;
    margin-bottom: 10px;
}

.subtitulo {
    color: var(--gris-texto);
    font-size: 1.2rem;
    font-weight: 500;
    margin: 0 0 15px 0;
}

.slogan {
    max-width: 800px;
    margin: 0 auto 25px auto;
    color: #555;
    font-style: italic;
    font-size: 0.95rem;
    line-height: 1.4;
}

/* Grilla Responsiva de Filtros */
.filter-row {
    background-color: #ffffff;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 25px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

@media (max-width: 768px) {
    .filter-row {
        grid-template-columns: 1fr 1fr;
    }
    .titulo-principal { font-size: 2rem; }
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--gris-texto);
    margin-bottom: 5px;
}

.filter-group select, .filter-group input {
    border: 2px solid var(--naranja-filtros);
    border-radius: 8px;
    padding: 8px;
    font-size: 0.9rem;
    outline: none;
    background-color: white;
    box-sizing: border-box;
    width: 100%;
}

/* ==========================================================================
   UNIFICACIÓN Y ARREGLO DE LA GRILLA DE RESULTADOS (EFECTO CORTINA)
   ========================================================================== */

/* 1. El contenedor con altura máxima y scroll de fondo */
.results-box {
    background-color: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    
    max-height: 500px;           /* Altura máxima de la ventana */
    overflow-y: auto;            /* Habilita scroll vertical para las filas */
    overflow-x: auto;            /* Mantiene compatibilidad horizontal en celus */
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 10px;
}

.table-header h3 {
    margin: 0;
    color: var(--azul-oscuro);
}

/* 2. Estructura base de la tabla */
table {
    width: 100%;
    border-collapse: separate;   /* ⬅️ CAMBIO CLAVE: Usamos 'separate' en vez de 'collapse' */
    border-spacing: 0;           /* Esto evita que se rompa el sticky en algunos navegadores */
    text-align: left;
    font-size: 0.95rem;
}

/* 3. Celdas de datos y encabezados generales */
th, td {
    padding: 12px 10px;
    border-bottom: 1px solid #e2e8f0;
}

/* 4. Encabezado FIJO y OPACADO (La Cortina Real) */
table th {
    position: -webkit-sticky;    /* Soporte para navegadores Safari/iOS */
    position: sticky;
    top: -16px;                  /* ⬅️ Ajuste fino para compensar el padding interno del box */
    background-color: #ffffff !important; /* Forzamos el color blanco sólido */
    color: var(--gris-texto);
    font-weight: bold;
    z-index: 999;                /* Prioridad absoluta al frente */
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.08); /* Línea de sombra inferior para separar la cortina del texto */
}

/* 5. Pequeño ajuste para que las filas que suben no pisen el diseño */
table td {
    background-color: transparent;
}

tr:hover {
    background-color: #f1f5f9;
}

/* Buscador de Ficha Individual */
.ficha-section {
    margin-top: 35px;
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    text-align: center;
}

.ficha-section h3 {
    color: var(--azul-oscuro);
    margin-top: 0;
}

.select-ficha {
    width: 100%;
    max-width: 400px;
    border: 2px solid var(--azul-marca);
    border-radius: 8px;
    padding: 10px;
    font-size: 1rem;
    margin-bottom: 15px;
    outline: none;
    box-sizing: border-box; /* Asegura que el tamaño no se deforme en celulares */
}

.btn-ficha {
    background-color: var(--azul-marca);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    max-width: 400px;
    transition: background-color 0.2s;
}

.btn-ficha:hover {
    background-color: var(--azul-hover);
}

/* Modal de Legado Individual */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 10px;
}

.modal-content {
    background-color: white;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    padding: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.status-badge {
    padding: 8px;
    border-radius: 6px;
    font-weight: bold;
    margin-bottom: 15px;
    font-size: 0.9rem;
    text-align: center;
}
.status-provisorio { background-color: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.status-verificado { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }

.grid-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 15px 0;
}

.card-metric {
    border: 1px solid var(--rojo-tarjeta);
    border-radius: 10px;
    padding: 10px;
    text-align: center;
    background-color: rgba(255, 75, 75, 0.05);
}

.card-metric p { margin: 0; font-size: 0.8rem; color: #555; }
.card-metric h3 { margin: 5px 0 0 0; color: var(--rojo-tarjeta); font-size: 1.4rem; }

.footer-wsp {
    text-align: center;
    padding: 20px;
    background-color: #f1f5f9;
    border-radius: 10px;
    margin-top: 40px;
    border: 1px solid #e2e8f0;
}

.btn-wsp {
    background-color: #25d366;
    color: white;
    padding: 12px 28px;
    border-radius: 30px;
    text-decoration: none;
    font-weight: bold;
    display: inline-block;
    margin-top: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.close-button {
    background-color: #64748b;
    color: white;
    border: none;
    padding: 10px;
    width: 100%;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 15px;
}