/* ==========================================================================
   1. CONTRATO BASE Y VARIABLES GLOBALES (SISTEMA DE DISEÑO)
   ========================================================================== */

:root {
    /* Identidad de Marca */
    --color-primario: #003785;      /* Azul oscuro profundo */
    --color-secundario: #f7fafc;    
    --color-alerta: #d32f2f;        /* Rojo potente */
    --color-exito: #4caf50;         

    /* Fondos y Superficies */
    --bg-pantalla: #f7f9fa;         
    --bg-tarjeta: #ffffff;          

    /* Jerarquía de Textos */
    --texto-titulo: #1a2a3a;        
    --texto-cuerpo: #2c3e50;        
    --texto-mutado: #718096;        
    --texto-etiquetas: #4a5568;
    --texto-alerta: #d32f2f;     

    /* Estructura y Bordes */
    --borde-suave: #eef2f5;         
    --borde-input: #cbd5e0;         
    --sombra-foco: rgba(26, 42, 58, 0.08); 

    /* Tipografía Maestra */
    --fuente-formal: "Arial", sans-serif;
}

/* ==========================================================================
   2. RESETEO UNIVERSAL Y LIENZO BASE
   ========================================================================== */

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

html, body {
    height: 100%;
    font-family: var(--fuente-formal);
    background-color: var(--bg-pantalla);
    color: var(--texto-cuerpo);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ==========================================================================
   3. TIPOGRAFÍA Y ENLACES MAESTROS
   ========================================================================== */

a {
    color: var(--color-primario);
    text-decoration: none;
    transition: color 0.2s ease, text-decoration 0.2s ease;
}

a:hover {
    color: var(--color-alerta);
    text-decoration: none;
}

a.btn:hover {
    text-decoration: none;
}

.texto-parrafo {
    font-size: 15px;
    line-height: 1.6;
    margin-top: 0;
    margin-bottom: 15px;
}
.texto-parrafo:last-child { margin-bottom: 0; }
.texto-pequeno { font-size: 13px; color: var(--texto-alerta); }

.texto-h1, .texto-h2, .texto-h3 {
    color: var(--texto-titulo);
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 15px;
    letter-spacing: -0.3px;
}
.texto-h1 { font-size: 28px; }
.texto-h2 { font-size: 22px; }
.texto-h3 { font-size: 16px; color: var(--texto-etiquetas); text-transform: uppercase; }

.texto-cita {
    margin: 20px 0;
    padding: 15px 20px;
    border-left: 4px solid var(--color-primario);
    background-color: var(--color-secundario);
    font-style: italic;
    color: var(--texto-etiquetas);
    border-radius: 0 6px 6px 0;
}

.lista-estandar { margin: 15px 0 15px 20px; padding: 0; line-height: 1.6; }
.lista-estandar li { margin-bottom: 8px; }
strong { font-weight: 700; color: var(--texto-titulo); }
em { font-style: italic; }

.link-inline { border-bottom: 1px solid var(--borde-input); font-weight: 600; }
.link-inline:hover { color: var(--color-alerta); border-bottom-color: var(--color-alerta); }
.link-destacado, .link-alerta { font-size: 14px; font-weight: 700; color: var(--texto-mutado); }
.link-destacado:hover { color: var(--color-primario); text-decoration: underline; }
.link-alerta:hover { color: var(--color-alerta); text-decoration: underline; }
.texto-interactivo { cursor: pointer; padding: 4px 8px; margin-left: -8px; border-radius: 4px; transition: all 0.2s ease; }
.texto-interactivo:hover { background-color: var(--borde-suave); color: var(--color-primario); }

/* ==========================================================================
   4. SISTEMA DE LAYOUT CORPORATIVO (TOPBAR ESCRITORIO / SIDEBAR MÓVIL)
   ========================================================================== */

/* En escritorio, el layout es de bloques apilados (Topbars) */
.layout-sistema {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%; /* Mejor usar 100% que 100vw para evitar scrollbar innecesario */
}

/* Forzamos que el sidebar no deje espacio abajo */
.sidebar-lateral {
    flex-shrink: 0; /* Impide que el menú se aplaste */
    background-color: var(--color-primario); 
    color: #ffffff;
    display: flex;
    flex-direction: row; 
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    height: 70px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    /* Eliminamos el position: sticky aquí y lo dejamos fijo al top del body */
    position: fixed; 
    top: 0;
    width: 100%;
    z-index: 1000;
}

.sidebar-brand {
    display: flex;
    align-items: center;
}

/* --- ESTILO PARA EL NOMBRE DEL USUARIO AL INICIO --- */
.nombre-usuario-inicio {
    font-family: Arial, sans-serif;
    font-size: 16px;
    color: var(--texto-cuerpo);
    margin: 20px 40px; /* Margen para alinearlo con el contenido */
    padding: 0;
}

.brand-titulo {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #ffffff;
    margin: 0;
}

.sidebar-menu {
    padding: 0;
}

.sidebar-menu ul {
    list-style: none;
    display: flex;
    flex-direction: row; /* Enlaces horizontales */
    gap: 15px;
    margin: 0;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: #cbd5e0;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.menu-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #ffffff;
    text-decoration: none;
}

/* Foco de enlace activo para el modo horizontal */
.menu-link.activa {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}


/* --- CONTENEDOR OPERATIVO DERECHO --- */
.contenedor-operativo {
    margin-top: 10px; /* IMPORTANTE: Esto empuja el contenido para que no quede detrás del menú fijo */
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* --- TOPBAR DE IDENTIDAD (Usuario y Rol) --- */
.topbar-superior {
    height: 70px;
    background-color: var(--bg-tarjeta);
    border-bottom: 1px solid var(--borde-suave);
    display: flex;
    justify-content: flex-start; /* Cambiamos space-between por flex-start */
    align-items: center;
    padding: 0 40px;
    gap: 30px; /* Añade espacio entre el botón hamburguesa y el usuario */
    position: sticky;
    top: 0;
    z-index: 900;
}

/* El botón hamburguesa está APAGADO en escritorio */
.btn-hamburguesa {
    font-size: 24px;
    cursor: pointer;
    color: var(--texto-titulo);
    display: none; 
    padding: 5px;
    transition: color 0.2s ease;
}

.btn-hamburguesa:hover {
    color: var(--color-alerta);
}

.topbar-usuario {
    display: flex;
    align-items: center;
    gap: 15px;
}

.usuario-nombre {
    font-size: 14px;
    font-weight: 600;
    color: var(--texto-cuerpo);
}

.role-badge {
    background-color: var(--color-alerta);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

/* --- LIENZO DE CONTENIDO --- */
.contenido-principal {
    padding: 10px;
    flex: 1;
    background-color: var(--bg-pantalla);
}

/* ==========================================================================
   5. MÓDULOS UNIVERSALES (COMPARTIDOS)
   ========================================================================== */

.modulo-contenedor {
    background-color: var(--bg-tarjeta);
    width: 100%;
    max-width: 1100px; 
    margin: 0 auto 20px auto; 
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--borde-suave);
    overflow: hidden;
}

.modulo-contenedor.ancho-login { 
	max-width: 450px;
	margin-top: 30px;
}
	
.modulo-contenedor.ancho-registro { 
	max-width: 800px;
	margin-top: 30px;
}

.modulo-header {
    background-color: var(--color-secundario);
    padding: 10px 40px;
    border-bottom:;
}

.modulo-titulo {
    font-size: 24px;
    font-weight: 400;
    color: var(--texto-titulo);
    margin: 0 0 0 0;
    letter-spacing: -0.5px;
}

.modulo-subtitulo {
    font-size: 14px;
    color: var(--texto-mutado);
    margin: 0;
    line-height: 1.5;
}

.modulo-body {
    padding: 25px;
}

.modulo-acciones {
    border-top: 1px solid var(--borde-suave);
    padding-top: 30px;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

.modulo-acciones.con-boton-ancho .btn {
    width: 100%;
}

@media (max-width: 480px) {
    /* --- TÍTULOS Y SUBTÍTULOS DE MÓDULOS POTENCIADOS EN MÓVILES --- */
    .modulo-titulo {
        font-size: 1.75rem !important; /* Incrementado para mayor impacto visual */
        letter-spacing: -0.3px !important;
    }

    .modulo-subtitulo {
        font-size: 1.1rem !important; /* Subtítulos más legibles y claros */
        line-height: 1.4 !important;
    }
}
/* ==========================================================================
   6. COMPONENTES INTERNOS: FORMULARIOS
   ========================================================================== */

.form-estructura { display: flex; flex-direction: column; gap: 35px; }
.form-seccion {
    border: 1px solid var(--borde-suave);
    border-radius: 8px;
    padding: 25px;
    margin: 0;
    background-color: var(--bg-tarjeta);
}
.form-leyenda {
    font-size: 14px;
    font-weight: 600;
    color: var(--texto-etiquetas);
    padding: 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.auth-grid-login { display: grid; grid-template-columns: 1fr; gap: 20px; }
.auth-grid-register { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.span-2, .auth-full-width { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }

.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--texto-etiquetas); }
.form-control {
    width: 100%;
    height: 44px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    background-color: var(--bg-tarjeta);
    border: 1px solid var(--borde-input);
    border-radius: 6px;
    color: var(--texto-cuerpo);
    transition: all 0.2s ease;
    box-sizing: border-box;
}
.form-control:hover { border-color: var(--texto-mutado); }
.form-control:focus { outline: none; border-color: var(--color-primario); box-shadow: 0 0 0 3px var(--sombra-foco); }

.form-textarea { height: auto; resize: vertical; min-height: 100px; }
.form-output { font-weight: 700; color: var(--color-primario); }
.form-range { height: 44px; accent-color: var(--color-primario); cursor: pointer; }
.form-color { width: 100%; height: 44px; padding: 2px; border: 1px solid var(--borde-input); border-radius: 6px; background: none; cursor: pointer; }
.form-file { font-size: 13px; color: var(--texto-mutado); padding-top: 8px; }

.option-box { justify-content: center; }
.form-label-opciones { font-size: 12px; font-weight: 600; color: var(--texto-mutado); text-transform: uppercase; margin-bottom: 2px; }
.option-row { display: flex; align-items: center; gap: 10px; height: 44px; }
.form-checkbox, .form-radio { width: 16px; height: 16px; accent-color: var(--color-primario); cursor: pointer; }
.form-label-inline { font-size: 13px; color: var(--texto-etiquetas); cursor: pointer; }

/* --- RESPONSIVO LOGIN Y REGISTER: Una columna y textos potentes en pantallas pequeñas --- */
@media (max-width: 480px) {
    .auth-grid-login,
    .auth-grid-register {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .auth-grid-register .span-2, 
    .auth-grid-register .auth-full-width {
        grid-column: span 1 !important;
    }

    .form-label {
        font-size: 1.1rem !important;
        font-weight: 700 !important;
    }

    .form-control {
        font-size: 1.1rem !important;
        height: 48px !important;
        padding: 10px 14px !important;
    }
}

/* ==========================================================================
   ESTRUCTURA BASE .stat-card - MODERNA
   ========================================================================== */
.contenedor-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 20px;
    padding: 20px;
    width: 100%;
}

.stat-card {
    display: flex;
    background-color: #edfffa;
    border-radius: 16px; /* Bordes ligeramente más redondeados para modernidad */
    border: 1px solid rgba(0, 0, 0, 0.08); /* Borde sutil y elegante */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.03); /* Sombra ligera inicial */
    overflow: hidden;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); /* Transición más orgánica */
    box-sizing: border-box;
    align-items: center;
}

.stat-card:hover {
    transform: translateY(-1px) scale(1.01); /* Elevación con ligero zoom */
    border-color: var(--color-primario);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.08); /* Sombra más pronunciada al interactuar */
}

/* --- VARIANTES --- */
/* Horizontal: 4 por fila */
.stat-card.horizontal {
    flex-direction: row;
    height: 99px;
    flex: 0 0 calc(25% - 15px);
}

/* Vertical y Cuadrada: 6 por fila */
.stat-card.vertical, 
.stat-card.cuadrada {
    flex-direction: column;
    flex: 0 0 calc(13.66% - 15px);
}

.stat-card.vertical { height: 180px; }
.stat-card.cuadrada { aspect-ratio: 1 / 1; justify-content: center; padding: 15px; }

/* --- ESTRUCTURA INTERNA --- */
.stat-icon {
    display: flex; align-items: center; justify-content: center;
    color: #003785; position: relative;
    opacity: 0.9;
}

.horizontal .stat-icon { width: 90px; height: 100%; font-size: 33px; }
.vertical .stat-icon, .cuadrada .stat-icon { width: 100%; height: 60%; font-size: 28px; }

.stat-info { 
    flex: 1; display: flex; flex-direction: column; 
    align-items: center; justify-content: center; text-align: center; padding: 10px; 
}
.stat-title { 
    font-size: 11px; 
    color: #000000; 
    text-transform: uppercase; 
    font-weight: 700; 
    letter-spacing: 0.8px; /* Mejora la legibilidad */
}
.stat-number { 
    font-size: 22px; 
    font-weight: 800; 
    color: var(--texto-titulo); 
    line-height: 1; 
    margin-top: 4px;
}

/* --- RESPONSIVO DEFINITIVO: 1 tarjeta por fila, rectangulares, menor separación icono-texto y número maximizado --- */
@media (max-width: 600px) {
    .contenedor-stats {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 15px !important;
        width: 100% !important;
        padding: 5px !important;
    }

    .stat-card,
    .stat-card.horizontal, 
    .stat-card.vertical, 
    .stat-card.cuadrada { 
        width: 100% !important;
        max-width: 100% !important;
        flex: none !important;
        aspect-ratio: 2.5 / 1 !important; /* Altura equivalente al 40% del ancho */
        height: auto !important;
        gap: 5px !important; /* Menor separación entre el icono y el texto */
    }
    
    /* Icono con tamaño proporcional y destacado */
    .stat-card .stat-icon {
        font-size: 2.8rem !important;
    }

    /* Título con tamaño potente y legible */
    .stat-card .stat-info .stat-title {
        font-size: 1.15rem !important;
        font-weight: 700 !important;
    }
    
    /* Número maximizado (cubre tanto la clase .stat-number como etiquetas p) */
    .stat-card .stat-info .stat-number,
    .stat-card .stat-info p {
        font-size: 2rem !important;
        font-weight: 800 !important;
        margin-top: 2px !important;
        line-height: 1 !important;
    }
}

/* --- Ficha Técnica de Usuario (Nueva Forma: Paneles Modulares Sectorizados) --- */
.ficha-usuario-card {
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-top: 4px solid #1a2a3a; /* Anclaje visual superior en azul profundo */
    border-radius: 8px;
    padding: 25px;
    color: #1e293b;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.ficha-top-section {
    display: flex;
    gap: 25px;
    align-items: center;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.ficha-foto-box {
    flex: 0 0 130px;
    text-align: center;
    background: #f8fafc;
    border-radius: 8px;
    padding: 30px 20px;
    border: 1px solid #cbd5e1;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.ficha-foto-box i {
    font-size: 60px;
    color: #003785; /* Azul profundo corporativo */
}

.ficha-data-box {
    flex: 1;
}

.ficha-nombre {
    font-size: 26px;
    font-weight: 700;
    margin: 0 0 5px 0;
    color: #003785;
}

.ficha-subtitulo-perfil {
    font-size: 14px;
    color: #64748b;
    margin: 0 0 10px 0;
    font-weight: 500;
}

.ficha-meta-bar {
    font-size: 13px;
    color: #334155;
    margin-bottom: 0;
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    display: inline-block;
}

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

.ficha-stat-item {
    background: #f8fafc;
    padding: 14px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid #cbd5e1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.ficha-stat-item i {
    font-size: 20px;
    color: #003785; /* Azul profundo corporativo para los iconos */
}

.ficha-stat-content .stat-label {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.ficha-stat-content .stat-value {
    font-size: 14px;
    font-weight: bold;
    color: #0f172a;
    margin-top: 2px;
}

.ficha-footer-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    background: #f8fafc;
    padding: 18px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.ficha-footer-item {
    background: #ffffff;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.ficha-footer-item .footer-label {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.ficha-footer-item .footer-value {
    font-size: 16px;
    font-weight: bold;
    color: #0f172a;
    margin-top: 4px;
}

/* --- Responsividad para Ficha Técnica (Fuentes e Iconos Ampliados en Móviles) --- */
@media (max-width: 768px) {
    .ficha-top-section {
        flex-direction: column;
        text-align: center;
    }

    .ficha-foto-box {
        width: 100%;
        box-sizing: border-box;
        padding: 35px 20px;
    }

    /* Icono principal más grande en móviles */
    .ficha-foto-box i {
        font-size: 75px !important;
    }

    /* Nombre principal ampliado */
    .ficha-nombre {
        font-size: 1.85rem !important;
    }

    /* Subtítulo ampliado */
    .ficha-subtitulo-perfil {
        font-size: 1rem !important;
    }

    /* Meta bar ampliada */
    .ficha-meta-bar {
        font-size: 0.95rem !important;
    }

    .ficha-grid-stats {
        grid-template-columns: 1fr;
    }

    /* Iconos de estadísticas ampliados en móviles */
    .ficha-stat-item i {
        font-size: 26px !important;
    }

    /* Etiquetas y valores de estadísticas ampliados */
    .ficha-stat-content .stat-label {
        font-size: 0.8rem !important;
    }

    .ficha-stat-content .stat-value {
        font-size: 1.1rem !important;
    }

    .ficha-footer-stats {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Etiquetas y valores del footer ampliados */
    .ficha-footer-item .footer-label {
        font-size: 0.8rem !important;
    }

    .ficha-footer-item .footer-value {
        font-size: 1.2rem !important;
    }
}

/* ==========================================================================
   7. COMPONENTES INTERNOS: TABLAS
   ========================================================================== */

.tabla-body-scroll { width: 100%; overflow-x: auto; padding: 20px 5px; }
.tabla-maestra { 
	width: 100%; 
	border-collapse: separate; 
    border-spacing: 0 6px; /* 6px de separación entre filas */
	text-align: center; 
}
.tabla-maestra th {
    background-color: var(--bg-tarjeta);
    color: var(--texto-etiquetas);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 18px 10px;
    border-bottom: 1px solid var(--color-primario);
    white-space: nowrap;
}
.tabla-maestra td {
    padding: 8px 10px;
    font-size: 14px;
    border-bottom: 1px solid var(--borde-suave);
    vertical-align: middle;
}
.texto-destacado { font-weight: 600; color: var(--texto-titulo); }
.fila-datos { 
    transition: background-color 0.2s ease; 
    
}

.fila-datos-competidores{ 
    transition: background-color 0.2s ease; 
    background-color: #ffffff; /* Fondo suave aplicado */
    border-color: var(--texto-mutado);
}

.fila-datos:hover {
    cursor: pointer;
    background-color: var(--bg-pantalla);
}

.col-derecha { text-align: right; }
.col-izquierda { text-align: left;}

.tabla-leyenda { caption-side: bottom; padding: 20px 0 10px 0; font-size: 13px; color: var(--texto-mutado); text-align: center; }
.tabla-maestra tfoot { background-color: var(--bg-tarjeta); }
.fila-totales td { font-size: 16px; color: var(--color-primario); border-top: 2px solid var(--color-primario); border-bottom: none; padding: 20px 10px; }


.url-contenedor {
    display: block;
    max-width: 400px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 480px) {
    .url-contenedor {
        max-width: 120px;
    }
}

/* ==========================================================================
   8. BOTONES UNIFICADOS Y ACCIONES (UI KIT)
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
    box-sizing: border-box;
}

.btn:active:not(:disabled) { transform: scale(0.98); box-shadow: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--sombra-foco); }

.btn-primario { background-color: var(--color-primario); color: var(--bg-tarjeta); }
.btn-primario:hover { opacity: 0.9; box-shadow: 0 4px 12px rgba(26, 42, 58, 0.2); transform: translateY(-1px); }

.btn-secundario { background-color: var(--color-secundario); color: var(--texto-etiquetas); border: 1px solid var(--borde-input); }
.btn-secundario:hover { background-color: var(--borde-suave); color: var(--color-primario); border-color: var(--texto-mutado); }

.btn-alerta { background-color: var(--color-alerta); color: var(--bg-tarjeta); }
.btn-alerta:hover { background-color: #b71c1c; box-shadow: 0 4px 12px rgba(211, 47, 47, 0.2); transform: translateY(-1px); }

.btn:disabled, .btn-deshabilitado {
    background-color: var(--borde-suave) !important;
    color: var(--texto-mutado) !important;
    border-color: var(--borde-suave) !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

.modulo-acciones-top {
    display: flex;
    flex-wrap: wrap; /* Permite que bajen si no hay espacio */
    gap: 9px;       /* Separa los botones tanto horizontal como VERTICALMENTE */
    margin-bottom: 15px; /* Despegado de la tabla o contenido inferior */
}
.acciones-centradas {
        justify-content: center;
    }

.filtro-dinamico-grupo {
    display: inline-flex;
    align-items: center;
}

/* El select estilizado formal */
.select-dinamico {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--texto-cuerpo);
    background-color: #ffffff;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.select-dinamico:focus {
    border-color: var(--color-primario);
}

/* La etiqueta activa con estética premium */
.tag-dinamico {
    display: inline-flex;
    align-items: center;
    background-color: var(--color-primario); /* Tu azul oscuro profundo #1a2a3a */
    color: #ffffff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    animation: fadeIn 0.2s ease forwards;
}

/* Botón (X) de remover */
.tag-btn-remove {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 16px;
    font-weight: bold;
    margin-left: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0 2px;
    transition: color 0.2s ease;
}

.tag-btn-remove:hover {
    color: var(--color-alerta); /* Rojo potente #d32f2f al pasar el mouse */
}

/* Forzar que en pantallas muy chicas los botones ocupen todo el ancho si se desea */
@media (max-width: 576px) {
    .modulo-acciones-top {
        flex-direction: column; /* Uno abajo del otro estricto */
        gap: 9px;
    }
    
    .modulo-acciones-top .btn {
        width: 100%;       /* Ocupan el 100% de la pantalla del celular */
        text-align: center; /* Centra el texto dentro del botón */
        justify-content: center;
    }
    .filtro-dinamico-grupo, 
    .select-dinamico, 
    .tag-dinamico {
        width: 100%;
    }
    .select-dinamico,
    .tag-dinamico {
        justify-content: space-between;
    }
}

/* ==========================================================================
   9. CLASES AUXILIARES GLOBALES
   ========================================================================== */

.margen-superior-amplio { margin-top: 25px; }
.flex-gap-20 { display: flex; gap: 20px; }

/* ==========================================================================
   10. MEDIA QUERIES (TRANSMUTACIÓN DE TOPBAR A SIDEBAR)
   ========================================================================== */

@media (max-width: 1024px) {
    .form-grid { grid-template-columns: repeat(3, 1fr); }
    .span-4 { grid-column: span 3; }
}

@media (max-width: 768px) {
    /* --- TRANSFORMACIÓN DEL MENÚ: DE TOPBAR A SIDEBAR OCULTO Y AMPLIADO --- */
    .layout-sistema {
        display: block;
    }
    
    .sidebar-lateral {
        position: fixed;
        left: -300px; /* Ancho ampliado a 300px para ocultarlo correctamente */
        top: 0;
        width: 300px; /* Sidebar más grande y cómodo en responsive */
        height: 100vh;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        padding: 0;
        z-index: 1000;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-bottom: none;
        border-right: 1px solid rgba(255, 255, 255, 0.05);
    }
    
    .sidebar-lateral .menu-link {
        font-size: 1.6rem !important; /* Puedes subirlo a 1.2rem o 1.3rem según prefieras */
    }

    .sidebar-brand {
        height: 70px;
        padding: 0 30px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        font-size: 1.2rem !important;
    }
    
    .sidebar-menu {
        padding: 25px 15px;
    }

    .sidebar-menu ul {
        flex-direction: column;
        gap: 8px;
    }

    .menu-link.activa {
        background-color: rgba(255, 255, 255, 0.1);
    }

    /* --- GATILLO Y OVERLAY: Apertura y Cierre 100% CSS --- */
    
    /* 1. Capa de fondo invisible por defecto */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.4); /* Oscurece levemente el fondo al abrir */
        z-index: 999; /* Justo debajo del sidebar (que tiene 1000) */
    }

    /* 2. Muestra el overlay cuando el checkbox está activo */
    .control-sidebar-check:checked ~ .sidebar-overlay {
        display: block;
    }

    /* 3. Desliza el Sidebar a la posición 0 (Apertura) */
    .control-sidebar-check:checked ~ .layout-sistema .sidebar-lateral {
        left: 0;
    }

    .btn-hamburguesa {
        display: inline-block;
    }

    .topbar-superior { padding: 0 20px; }
    .contenido-principal { padding: 20px 10px; }
    .modulo-body { padding: 25px; }
    .modulo-header { padding: 20px; }
    
    .form-grid { grid-template-columns: repeat(2, 1fr); }
    .span-3, .span-4 { grid-column: span 2; }
    .auth-grid-register { grid-template-columns: 1fr; }
    .auth-full-width { grid-column: span 1; }
    
    .tabla-body-scroll {
        width: 100%;
        overflow-x: auto;
        display: block;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {
    .modulo-header { padding: 20px; }
    .modulo-body { padding: 15px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid > * { grid-column: span 1 !important; }
    
    .modulo-acciones {
        flex-direction: column-reverse;
        width: 100%;
    }
    .btn { width: 100%; }
}

/* --- COMPONENTE MODAL / POPUP --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(26, 42, 58, 0.6);
    z-index: 2000;
    justify-content: center;
    align-items: flex-start; /* Corregido: Alinea al inicio para evitar que el título se corte arriba */
    overflow-y: auto;        /* Permite scroll vertical si el contenido supera el alto de la pantalla */
    padding: 40px 10px;      /* Espaciado superior e inferior para pantallas grandes */
}

/* --- LÓGICA GENERAL PARA OTRAS PÁGINAS (Uso de ~) --- */
#modal-nuevo-admin:checked ~ .modal-overlay {
    display: flex;
}
#modal-nuevo-profesor:checked ~ .modal-overlay {
    display: flex;
}
#modal-lista-competidores:checked ~ .modal-overlay {
    display: flex;
}
#modal-nuevo-evento:checked ~ .modal-overlay {
    display: flex;
}

/* --- LÓGICA DE AISLAMIENTO PARA MÚLTIPLES MODALES EN UNA PÁGINA --- */
.contenedor-modal-aislado input[type="checkbox"]:checked ~ .modal-overlay {
    display: flex !important;
}

.modal-contenedor-popup {
    width: 100%;
    max-width: 500px;
    margin: 0 auto; /* Centrado horizontal */
    animation: fadeIn 0.3s ease;
}

#modal-nueva-disciplina:checked ~ .modal-overlay {
    display: flex;
}

.fila-adicional-espacio {
    margin-top: 20px;
}

/* --- AJUSTE CORREGIDO PARA PANTALLAS PEQUEÑAS --- */
@media (max-width: 768px) {
    .modal-overlay {
        overflow-y: auto; 
        align-items: flex-start; 
        padding-top: 20px;
        padding-bottom: 20px;
    }

    .modal-contenedor-popup {
        width: 95% !important;
        margin: 0 auto !important;
        padding: 10px;
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   ACORDEONES E INTERNAS MINI
   ========================================================================== */
.contenido-acordeon {
    padding: 10px; 
    background: #ffffff;
    border-bottom: 1px solid var(--borde-suave);
    border-left: 1px solid var(--borde-suave); 
    border-right: 1px solid var(--borde-suave);
}

.tabla-competidores-mini {
    margin: 0 auto; /* Centrada en lugar de tirada a la derecha */
    width: 100%;    /* Ocupa el 100% del contenedor del acordeón en móviles */
    border-collapse: collapse;
}

.tabla-competidores-mini .fila-mini:nth-child(even) {
    background-color: #f8f9fa;
}

.tabla-competidores-mini .fila-mini td {
    padding: 10px;
    font-size: 12px;
    color: #4a5568;
    border-bottom: 1px solid #edf2f7;
}

/* Ajuste específico para las mini tablas dentro de acordeones en pantallas pequeñas */
@media (max-width: 600px) {
    .contenido-acordeon {
        padding: 8px;
    }
    .tabla-competidores-mini .fila-mini td {
        padding: 8px 4px; /* Más compacto para evitar saltos de línea feos */
        font-size: 11px;
    }
}

/* ==========================================================================
   CATÁLOGO DE EVENTOS ANTERIORES (BURBUJAS RECTANGULARES VERTICALES)
   ========================================================================== */
.contenedor-catalogo-eventos {
    display: grid;
    /* Configuración por defecto: Máximo 5 columnas simétricas en pantallas grandes */
    grid-template-columns: repeat(auto-fill, minmax(calc(20% - 16px), 1fr));
    gap: 20px;
    padding: 10px 0;
    width: 100%;
}

.tarjeta-evento-burbuja {
    background-color: #ffffff;
    border: 1px solid #cbd5e0;
    border-radius: 12px;
    padding: 30px 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    text-decoration: none; /* Elimina el subrayado de enlace */
    
    /* COMPORTAMIENTO VERTICAL */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.tarjeta-evento-burbuja:hover {
    transform: translateY(-4px);
    border-color: var(--color-alerta, #d32f2f);
    box-shadow: 0 6px 15px rgba(26, 42, 58, 0.1);
    text-decoration: none; 
}

/* EL ICONO CIRCULAR (BURBUJA CON FLYER) */
.burbuja-flyer {
    width: 99px;
    height: 99px;
    border-radius: 50%;
    background-color: #f1f5f9;
    border: 2px solid #cbd5e0;
    overflow: hidden; /* Recorta la imagen perfectamente en círculo */
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    position: relative;
    transition: border-color 0.2s ease;
}

.tarjeta-evento-burbuja:hover .burbuja-flyer {
    border-color: var(--color-alerta, #d32f2f);
}

/* Control del formato de la imagen interna */
.burbuja-flyer img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Adapta la imagen sin deformarla */
    position: absolute;
    top: 0;
    left: 0;
}

/* Icono de respaldo si no hay imagen cargada */
.burbuja-flyer .de-respaldo {
    font-size: 28px;
    color: var(--texto-mutado, #718096);
    z-index: 1;
}

/* CONTENEDOR INFERIOR DE TEXTOS */
.info-evento-burbuja {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.nombre-evento-burbuja {
    font-size: var(--fuente-pequena, 13px);
    color: var(--texto-titulo, #1a2a3a);
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.2;
    /* Control de texto largo para que no rompa la tarjeta vertical */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fecha-evento-burbuja {
    font-size: 11px;
    color: var(--texto-mutado, #718096);
    font-weight: 500;
}

/* RESPONSIVE: Forzar exactamente 2 columnas en pantallas pequeñas/medianas */
@media (max-width: 768px) {
    .contenedor-catalogo-eventos {
        grid-template-columns: repeat(2, 1fr); /* 2 tarjetas exactas por fila */
        gap: 12px;
    }
    
    .burbuja-flyer {
        width: 75px; /* Ligeramente más compacto en móviles */
        height: 75px;
    }
}

/* ==========================================================================
   FORMULARIO EDICIÓN ADMINISTRADORES (ESTILOS COMPLEMENTARIOS UNIFICADOS)
   ========================================================================== */
.modulo-contenedor-acotado {
    max-width: 600px;
    margin: 0 auto;
}

.alerta-error-sistema {
    background-color: rgba(211, 47, 47, 0.1);
    color: var(--color-alerta);
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--color-alerta);
    margin-bottom: 15px;
    font-size: 13px;
    font-weight: 600;
}

.topbar-superior .role-badge {
    background-color: var(--color-primario);
    color: #ffffff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 15fpx;
    font-weight: 700;
    text-transform: uppercase;
}

.contenedor-roles-seleccion {
    background-color: var(--color-secundario);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--borde-suave);
    margin-top: 10px;
}

.contenedor-roles-seleccion .label-destacado {
    margin-bottom: 8px;
    display: block;
    font-weight: 700;
}

.grupo-checkbox-roles {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 5px;
}

.opcion-checkbox-rol {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--texto-cuerpo);
    font-weight: 600;
    cursor: pointer;
}

.acciones-espaciado-superior {
    margin-top: 20px;
}
