/* =================================================================
   ESTILOS COMPATIBLES CON TAILWIND CSS + ESTILOS PERSONALIZADOS
   ================================================================= */

/* Variables de color originales para compatibilidad */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --background-color: #ecf0f1;
    --text-color: #2c3e50;
    --border-color: #bdc3c7;
    --light-bg: #ffffff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.modal-open {
    overflow: hidden;
}

/* BOTONES COMPATIBLES */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-block;
}

.btn-primary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

/* MODAL */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: var(--light-bg);
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 450px;
    width: 90%;
    animation: slideIn 0.3s ease;
}

.modal-content h2 {
    font-size: 1.8em;
    margin-bottom: 10px;
}

.modal-content p {
    margin-bottom: 10px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* LOADING SPINNER */
.loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1001;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

.loading-spinner p {
    color: white;
    margin-top: 15px;
    font-weight: 600;
    font-size: 1.1em;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* ESTILOS PARA CAMPOS DINÁMICOS COMPATIBILIDAD */
.download-note {
    margin-top: 10px;
    font-size: 0.95em;
}

.download-note a {
    text-decoration: underline;
}

/* CHECKBOX GROUP - Para secciones dinámicas */
.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    padding: 10px;
    background-color: #f8f9fa;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.checkbox-item:hover {
    background-color: #e0f2fe;
    border-color: #0ea5e9;
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin-right: 10px;
    accent-color: #1258e2;
}

.checkbox-item input[type="checkbox"]:checked ~ span {
    font-weight: 600;
    color: #1258e2;
}

.checkbox-item span {
    flex: 1;
    font-weight: 500;
    color: #334155;
}

/* SELECT GROUP - Para secciones dinámicas */
.select-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin: 20px 0;
    padding: 24px;
    background-color: #f8f9fa;
    border-radius: 12px;
    border-left: 4px solid #1258e2;
}

.select-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.select-item label {
    font-weight: 600;
    margin-bottom: 4px;
    color: #334155;
    font-size: 0.95em;
}

.select-item select {
    padding: 10px 12px;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.95em;
    background-color: #ffffff;
    transition: all 0.3s ease;
}

.select-item select:focus {
    outline: none;
    border-color: #1258e2;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(18, 88, 226, 0.1);
}

.select-item input[type="text"] {
    padding: 10px 12px;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.95em;
    background-color: #ffffff;
    transition: all 0.3s ease;
}

.select-item input[type="text"]:focus {
    outline: none;
    border-color: #1258e2;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(18, 88, 226, 0.1);
}

/* FORM GROUP - Para compatibilidad con código dinámico */
.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #334155;
    font-size: 0.95em;
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 10px 12px;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.95em;
    font-family: inherit;
    transition: all 0.3s ease;
    background-color: #f8f9fa;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #1258e2;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(18, 88, 226, 0.1);
}

/* DYNAMIC SECTION - Para compatibilidad con campos dinámicos */
#dynamicSection .bg-white {
    margin-bottom: 20px;
}

/* COMISIÓN DROPDOWN - Mejorado para diseño moderno */
.comision-dropdown {
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    background-color: #f8f9fa;
    transition: all 0.3s ease;
    width: 100%;
    position: relative;
}

.comision-dropdown[open] {
    border-color: #1258e2;
    box-shadow: 0 0 0 3px rgba(18, 88, 226, 0.1);
}

.comision-dropdown summary {
    list-style: none;
    padding: 7px 36px 7px 10px;
    cursor: pointer;
    font-size: 0.85em;
    color: #334155;
    background-color: #f8f9fa;
    border-radius: 8px;
    display: flex;
    align-items: center;
    font-weight: 500;
    position: relative;
}

.comision-dropdown summary::after {
    content: '▼';
    position: absolute;
    right: 12px;
    color: #64748b;
    font-size: 0.7em;
    transition: transform 0.3s ease;
}

.comision-dropdown[open] summary {
    background-color: white;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 8px 8px 0 0;
}

.comision-dropdown[open] summary::after {
    transform: rotate(180deg);
}

.comision-dropdown summary::-webkit-details-marker {
    display: none;
}

/* COMISIÓN LIST - Lista de checkboxes */
.comision-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    max-height: 350px;
    overflow-y: auto;
    background-color: white;
}

/* COMISIÓN ITEM - Cada checkbox individual con ID */
.comision-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 2px 6px;
    background-color: #f8f9fa;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 0.82em;
}

.comision-item:hover {
    background-color: #e0f2fe;
    border-color: #1258e2;
}

.comision-item:has(input[type="checkbox"]:checked) {
    background-color: rgba(18, 88, 226, 0.05);
    border-color: #1258e2;
}

.comision-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.comision-checkbox {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: #1258e2;
    margin: 0;
    flex-shrink: 0;
}

.comision-name {
    font-weight: 500;
    color: #334155;
    flex: 1;
}

.comision-checkbox:checked ~ .comision-name {
    font-weight: 600;
    color: #1258e2;
}

.comision-id-input {
    width: 96px;
    padding: 3px 6px;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.8em;
    background-color: #ffffff;
    transition: all 0.3s ease;
    text-align: center;
}

.comision-id-input:disabled {
    background-color: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
}

.comision-id-input:enabled:focus {
    outline: none;
    border-color: #1258e2;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(18, 88, 226, 0.1);
}

.dark .comision-list {
    background-color: #0f172a;
}

.dark .comision-item {
    background-color: #1e293b;
    border-color: #334155;
}

.dark .comision-item:hover {
    background-color: rgba(96, 165, 250, 0.1);
    border-color: #60a5fa;
}

.dark .comision-item:has(input[type="checkbox"]:checked) {
    background-color: rgba(96, 165, 250, 0.15);
    border-color: #60a5fa;
}

.dark .comision-name {
    color: #e2e8f0;
}

.dark .comision-checkbox:checked ~ .comision-name {
    color: #60a5fa;
}

.dark .comision-id-input {
    background-color: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}

.dark .comision-id-input:disabled {
    background-color: #334155;
    color: #64748b;
}

.dark .comision-id-input:enabled:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

/* COMISIÓN IDS - Contenedor de inputs por comisión */
.comision-ids {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    padding: 12px 0 0;
}

.comision-id-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.comision-id-item label {
    font-weight: 600;
    font-size: 0.9em;
    color: #475569;
}

.comision-id-item input[type="text"] {
    padding: 10px 12px;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.95em;
    background-color: #f8f9fa;
    transition: all 0.3s ease;
}

.comision-id-item input[type="text"]:focus {
    outline: none;
    border-color: #1258e2;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(18, 88, 226, 0.1);
}

/* UTILIDADES */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeInElement 0.3s ease;
}

@keyframes fadeInElement {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* SIDEBAR NAVIGATION ACTIVE STATE */
.nav-link.active {
    background-color: #e0f2fe !important;
    border-left: 3px solid #1258e2;
    padding-left: calc(0.5rem - 3px);
}

.dark .nav-link.active {
    background-color: rgba(18, 88, 226, 0.15) !important;
}

.nav-link.active .w-10 {
    background-color: #1258e2 !important;
}

.nav-link.active .material-icons-outlined {
    color: white !important;
}

.nav-link.active span {
    color: #1258e2 !important;
    font-weight: 700 !important;
}

.dark .nav-link.active span {
    color: #60a5fa !important;
}

/* DYNAMIC SECTION headings */
#dynamicSection h3 {
    font-size: 1.4em;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

#dynamicSection h3::before {
    content: '';
    width: 4px;
    height: 28px;
    background: linear-gradient(180deg, #1258e2 0%, #0ea5e9 100%);
    border-radius: 2px;
}

#dynamicSection .bg-white {
    background-color: white;
    padding: 32px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(18, 88, 226, 0.1);
    margin-bottom: 20px;
}

/* Mejorar el scroll de listas largas */
.comision-list::-webkit-scrollbar {
    width: 8px;
}

.comision-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.comision-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.comision-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Nav container para desktop y mobile */
.nav-container {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Ocultar el boton de cierre fuera de mobile */
.mobile-close-btn {
    display: none;
}

/* Dropdown de funciones */
.funciones-dropdown {
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    background-color: #f8f9fa;
    transition: all 0.3s ease;
    width: 100%;
    position: relative;
}

.funciones-dropdown[open] {
    border-color: #1258e2;
    box-shadow: 0 0 0 3px rgba(18, 88, 226, 0.1);
}

.funciones-dropdown summary {
    list-style: none;
    padding: 12px 40px 12px 16px;
    cursor: pointer;
    font-size: 0.95em;
    color: #334155;
    background-color: #f8f9fa;
    border-radius: 8px;
    display: flex;
    align-items: center;
    font-weight: 500;
    position: relative;
    min-height: 48px;
}

.funciones-dropdown summary::after {
    content: '▼';
    position: absolute;
    right: 16px;
    color: #64748b;
    font-size: 0.7em;
    transition: transform 0.3s ease;
}

.funciones-dropdown[open] summary {
    background-color: white;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 8px 8px 0 0;
}

.funciones-dropdown[open] summary::after {
    transform: rotate(180deg);
}

.funciones-dropdown summary::-webkit-details-marker {
    display: none;
}

.dark .funciones-dropdown {
    border-color: #475569;
    background-color: #1e293b;
}

.dark .funciones-dropdown summary {
    background-color: #1e293b;
    color: #e2e8f0;
}

.dark .funciones-dropdown[open] summary {
    background-color: #0f172a;
    border-bottom-color: #334155;
}

/* Lista de funciones */
.funciones-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    max-height: 350px;
    overflow-y: auto;
    background-color: white;
}

/* Lista de Sub Espacios: sin altura máxima global, cada grupo se expande completo */
#subfuncionCheckboxGroup.funciones-list {
    max-height: none;
    overflow-y: visible;
    gap: 8px;
}

.dark .funciones-list {
    background-color: #0f172a;
}

/* Grupos de funciones dentro del deslizable Sub Espacio */
.subfuncion-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-radius: 8px;
    overflow: hidden;
    border: 1.5px solid #e2e8f0;
    margin-bottom: 4px;
}

.subfuncion-group:last-child {
    margin-bottom: 0;
}

.dark .subfuncion-group {
    border-color: #334155;
}

.subfuncion-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    background-color: #1258e2;
    color: white;
    font-size: 0.78em;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    gap: 8px;
}

.subfuncion-group-header:hover {
    background-color: #0e47c5;
}

.subfuncion-group-header .group-chevron {
    font-size: 1em;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.subfuncion-group.collapsed .group-chevron {
    transform: rotate(-90deg);
}

.subfuncion-group-counter {
    background-color: rgba(255,255,255,0.25);
    border-radius: 20px;
    padding: 1px 7px;
    font-size: 0.85em;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
    margin-left: auto;
}

.subfuncion-group-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background-color: white;
    overflow: visible;
}

.dark .subfuncion-group-body {
    background-color: #0f172a;
}

.subfuncion-group.collapsed .subfuncion-group-body {
    display: none;
}

/* Estilos para checkboxes de funciones */
.funcion-checkbox-item {
    transition: all 0.3s ease;
    margin: 0;
}

.funcion-checkbox-item:has(input:checked) {
    background-color: rgba(18, 88, 226, 0.1) !important;
    border-color: #1258e2 !important;
}

.dark .funcion-checkbox-item:has(input:checked) {
    background-color: rgba(96, 165, 250, 0.2) !important;
    border-color: #60a5fa !important;
}

.funcion-checkbox-item input:checked + span {
    color: #1258e2 !important;
    font-weight: 600;
}

.dark .funcion-checkbox-item input:checked + span {
    color: #60a5fa !important;
}

/* Tarjetas colapsables de funciones */
#dynamicSection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    align-items: start;
}

.function-card {
    transition: all 0.3s ease;
    margin-bottom: 0;
}

.function-card-header {
    position: relative;
}

/* Título de tarjeta más compacto para que no se vea "gordo", sobre todo en móvil */
.function-card-header > div:first-child {
    min-width: 0;
}
.function-card-header h4 {
    font-size: 0.9rem !important;
    line-height: 1.25;
    overflow-wrap: break-word;
}
@media (max-width: 768px) {
    .function-card-header h4 {
        font-size: 0.8rem !important;
    }
}

.function-card-header .material-icons-outlined:last-child {
    transition: transform 0.3s ease;
}

.function-card-body {
    transition: all 0.3s ease;
    overflow: hidden;
}

@media (max-width: 768px) {
    #dynamicSection {
        grid-template-columns: 1fr;
    }
}


/* Responsive para sidebar */
@media (max-width: 1024px) {
    aside {
        width: 250px !important;
    }
}

@media (max-width: 768px) {
    .flex.h-screen {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }
    
    aside {
        width: 100% !important;
        height: auto;
        border-right: none;
        border-bottom: 1px solid rgba(18, 88, 226, 0.1);
    }
    
    aside .p-6 {
        padding: 1rem !important;
    }
    
    aside nav {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        padding: 0;
        overflow-y: auto;
        animation: fadeIn 0.2s ease-out;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    aside nav.mobile-show {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    
    aside nav .nav-container {
        background: white;
        border-radius: 12px;
        padding: 2rem;
        max-width: 90%;
        width: 400px;
        max-height: 80vh;
        overflow-y: auto;
        position: relative;
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        animation: slideUp 0.3s ease-out;
    }
    
    @keyframes slideUp {
        from {
            transform: translateY(20px);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    #sidebarToggle {
        display: block !important;
    }

    .mobile-close-btn {
        display: inline-flex;
    }
    
    aside .p-4.border-t {
        padding: 0.75rem !important;
    }
    
    main {
        flex: 1;
        overflow-y: auto;
        height: auto;
    }
    
    header.sticky {
        position: relative !important;
        padding: 0.75rem 1rem !important;
    }
    
    header .flex {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.25rem;
    }
    
    header h2 {
        font-size: 1.125rem !important;
    }
    
    header p {
        font-size: 0.7rem !important;
    }
    
    .max-w-5xl {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .px-10 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .py-12, .py-6 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
    
    .space-y-16 > * + *, .space-y-8 > * + * {
        margin-top: 1.5rem !important;
    }
    
    .modal-content {
        padding: 20px !important;
        margin: 1rem !important;
    }
    
    .checkbox-group {
        grid-template-columns: 1fr;
    }
    
    .select-group {
        grid-template-columns: 1fr;
        padding: 1rem;
    }
    
    .comision-list {
        gap: 4px;
        padding: 8px;
        max-height: 300px;
    }
    
    .comision-item {
        grid-template-columns: 1fr 72px;
        gap: 6px;
        padding: 3px 6px;
        font-size: 0.8em;
    }
    
    .comision-id-input {
        width: 72px;
        font-size: 0.75em;
        padding: 2px 6px;
    }
    
    .funciones-list {
        gap: 6px;
        padding: 12px;
        max-height: 300px;
    }
    
    .funcion-checkbox-item {
        padding: 10px !important;
        font-size: 0.875rem;
    }
    
    .comision-ids {
        grid-template-columns: 1fr;
    }
    
    #dynamicSection .bg-white {
        padding: 1.25rem !important;
    }
    
    .bg-white.rounded-xl {
        padding: 1.25rem !important;
    }
    
    .grid.grid-cols-1.md\\:grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
    
    /* Botones sticky en móviles */
    .sticky.bottom-0 {
        position: sticky;
        bottom: 0;
        padding: 0.75rem !important;
    }
    
    .sticky.bottom-0 .flex {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .sticky.bottom-0 button {
        width: 100%;
        padding: 0.875rem !important;
    }
}

@media (max-width: 480px) {
    header h2 {
        font-size: 1rem !important;
    }
    
    header p {
        font-size: 0.625rem !important;
    }
    
    .text-xl {
        font-size: 1.125rem !important;
    }
    
    .text-2xl {
        font-size: 1.25rem !important;
    }
    
    .w-8.h-8 {
        width: 1.75rem !important;
        height: 1.75rem !important;
    }
}

#sidebarToggle {
    display: none;
}

/* ================= WIZARD ================= */
.wizard-step { display: none; }
.wizard-step.wizard-active { display: block; animation: fadeInElement 0.25s ease; }

.wizard-progress-track {
    height: 8px;
    background: #e2e8f0;
    border-radius: 9999px;
    overflow: hidden;
}
.dark .wizard-progress-track { background: #1e293b; }
.wizard-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #1258e2, #0ea5e9);
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.wizard-link.wizard-done .step-circle {
    background-color: #16a34a !important;
    color: white !important;
}
.wizard-link.wizard-done .step-icon { display: none !important; }
.wizard-link.wizard-done .step-check { display: block !important; color: white !important; }
.wizard-link.wizard-done .step-status { color: #16a34a !important; }

.wizard-link.wizard-current { background-color: #e0f2fe !important; }
.dark .wizard-link.wizard-current { background-color: rgba(18,88,226,.15) !important; }

.wizard-review-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 4px 12px;
}
.wizard-review-grid dt { font-weight: 600; color: #64748b; font-size: 0.8em; text-transform: uppercase; }
.wizard-review-grid dd { margin: 0; font-weight: 500; }
.wizard-edit-chip {
    font-size: 0.75em;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 9999px;
    background: #eef2ff;
    color: #1258e2;
    border: 1px solid #c7d2fe;
    cursor: pointer;
}
.wizard-edit-chip:hover { background: #e0e7ff; }
.field-error { border-color: #ef4444 !important; box-shadow: 0 0 0 3px rgba(239,68,68,.12) !important; }

/* ================= Selección en cascada (mobile-first) ================= */
.casc-label {
    font-size: 0.8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #64748b;
    margin: 0;
}
.dark .casc-label { color: #94a3b8; }
.casc-l1-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 12px;
    font-size: 1em;
    font-weight: 700;
    border-radius: 12px;
    border: 2px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    cursor: pointer;
}
.dark .casc-l1-btn { background: #1e293b; border-color: #475569; color: #e2e8f0; }
.casc-l1-btn .material-icons-outlined { font-size: 1.4rem; }
.casc-l1-btn.active { border-color: #1258e2; background: rgba(18,88,226,.08); color: #1258e2; }
.dark .casc-l1-btn.active { color: #93c5fd; border-color: #60a5fa; background: rgba(96,165,250,.12); }
.casc-count {
    background: #1258e2;
    color: #fff;
    border-radius: 20px;
    padding: 1px 9px;
    font-size: 0.78em;
    font-weight: 700;
}
.casc-l2-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 12px 8px;
    font-size: 0.95em;
    font-weight: 700;
    border-radius: 10px;
    border: 2px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    cursor: pointer;
}
.dark .casc-l2-btn { background: #1e293b; border-color: #475569; color: #e2e8f0; }
.casc-l2-btn.active { border-color: #1258e2; background: #1258e2; color: #fff; }
.casc-l2-btn.active .casc-count { background: rgba(255,255,255,.28); }
.casc-count-inline {
    background: #eef2ff;
    color: #1258e2;
    border: 1px solid #c7d2fe;
    border-radius: 20px;
    padding: 1px 10px;
    font-size: 0.78em;
    font-weight: 700;
}
.dark .casc-count-inline { background: rgba(96,165,250,.12); color: #93c5fd; border-color: #60a5fa; }
.casc-mini-btn {
    font-size: 0.8em;
    font-weight: 700;
    color: #1258e2;
    background: #eef2ff;
    border: 1.5px solid #c7d2fe;
    border-radius: 9999px;
    padding: 4px 14px;
    cursor: pointer;
}
.casc-mini-btn:hover { background: #e0e7ff; }
.dark .casc-mini-btn { color: #93c5fd; background: rgba(96,165,250,.12); border-color: #60a5fa; }
.func-group-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    max-height: min(320px, 40vh);
    overflow-y: auto;
    background: #fff;
}
.dark .func-group-body { background: #0f172a; }
.func-group-body::-webkit-scrollbar { width: 8px; }
.func-group-body::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 4px; }
.func-group-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.func-group-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    font-size: 0.875em;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    border: 1.5px solid #e2e8f0;
    background: #f8fafc;
    color: #334155;
}
.dark .func-group-row { background: #1e293b; border-color: #334155; color: #e2e8f0; }
.func-group-row:hover { border-color: #1258e2; background: rgba(18,88,226,.05); }
.func-group-row.added { border-color: #1258e2; background: rgba(18,88,226,.08); font-weight: 600; color: #1258e2; }
.dark .func-group-row.added { color: #93c5fd; border-color: #60a5fa; background: rgba(96,165,250,.12); }
.func-group-row .row-label { flex: 1; }
.func-group-row .material-icons-outlined { font-size: 1.15rem; color: #cbd5e1; flex-shrink: 0; }
.func-group-row.added .material-icons-outlined { color: #1258e2; }
.dark .func-group-row.added .material-icons-outlined { color: #60a5fa; }

.func-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8em;
    font-weight: 600;
    padding: 5px 6px 5px 12px;
    border-radius: 9999px;
    background: #eef2ff;
    color: #1e40af;
    border: 1.5px solid #c7d2fe;
    max-width: 100%;
}
.func-chip-sub { background: #ecfdf5; color: #166534; border-color: #a7f3d0; }
.func-chip span.chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.func-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 9999px;
    background: rgba(0,0,0,.08);
    cursor: pointer;
    flex-shrink: 0;
}
.func-chip-remove:hover { background: rgba(0,0,0,.18); }
.func-chip-remove .material-icons-outlined { font-size: 0.9rem; }
.func-chips-empty { font-size: 0.85em; color: #94a3b8; }

/* ================= SLEEK: densidad general ================= */
/* --- Sidebar compacto: entra sin scroll --- */
#mainSidebar .p-6 { padding: 0.75rem 1rem !important; }
#mainSidebar img { width: 3rem !important; height: 3rem !important; }
#mainSidebar h1 { font-size: 0.85rem !important; }
#mainSidebar .text-sm { font-size: 0.75rem !important; }
#sidebarNav { padding: 0.5rem !important; }
#sidebarNav .nav-link { padding: 0.375rem 0.5rem !important; }
#sidebarNav .gap-3 { gap: 0.5rem !important; }
#sidebarNav .w-10 { width: 2.25rem !important; height: 2.25rem !important; }
#sidebarNav .text-xl { font-size: 1.05rem !important; }
#sidebarNav .text-sm { font-size: 0.8rem !important; }
#sidebarNav .mt-6 { margin-top: 0.75rem !important; }
#sidebarNav .bg-amber-50 { padding: 0.5rem 0.75rem !important; }
#mainSidebar .p-4.border-t { padding: 0.5rem !important; }

/* --- Formulario compacto: menos aire vertical --- */
#licenseForm.space-y-8 > * + * { margin-top: 1.25rem !important; }
#licenseForm .p-5 { padding: 1rem !important; }
#licenseForm .gap-4 { gap: 0.75rem !important; }
#licenseForm .space-y-2 > * + * { margin-top: 0.375rem !important; }
#licenseForm .mb-4 { margin-bottom: 0.75rem !important; }
#licenseForm h3.text-xl { font-size: 1.1rem !important; }
#licenseForm .w-8.h-8 { width: 1.75rem !important; height: 1.75rem !important; font-size: 0.8rem !important; }
#licenseForm input[type="text"],
#licenseForm input[type="email"],
#licenseForm input[type="tel"],
#licenseForm input[type="date"],
#licenseForm select {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}
#licenseForm h4.uppercase { font-size: 0.72rem !important; }

/* --- Tarjetas dinámicas compactas --- */
#dynamicSection .function-card-header { padding: 0.65rem 0.75rem !important; }
#dynamicSection .function-card-body { padding: 0.75rem !important; }

/* --- Barra de acciones compacta --- */
#wizardActionBar > div { padding: 0.65rem 1rem !important; }
#wizardBackBtn, #wizardNextBtn, #wizardSubmitBtn {
    padding-top: 0.6rem !important;
    padding-bottom: 0.6rem !important;
}
#wizardNextBtn, #wizardSubmitBtn {
    padding-left: 1.75rem !important;
    padding-right: 1.75rem !important;
    font-size: 0.95rem !important;
}

/* --- Solo escritorio: sidebar angosto y header/contenedor ajustados --- */
@media (min-width: 769px) {
    #mainSidebar { width: 17rem; }
    #sidebarNav { overflow-y: visible; }
    main > header {
        padding-top: 0.65rem !important;
        padding-bottom: 0.65rem !important;
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }
    main > header h2.text-2xl { font-size: 1.2rem !important; }
    #wizardStepTitle { font-size: 0.82rem !important; }
    #wizardStepHint { font-size: 0.72rem !important; }
    main > header .mt-3 { margin-top: 0.4rem !important; }
    .wizard-content-spacer {
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
        padding-top: 1rem !important;
    }
}

/* ================= Perfil habitual (carga rápida) ================= */
.profile-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: #eff6ff;
    border: 1.5px solid #bfdbfe;
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 0.9em;
    color: #1e3a8a;
}
.dark .profile-banner { background: rgba(18,88,226,.12); border-color: #1e40af; color: #bfdbfe; }
.profile-banner p { margin: 0; flex: 1 1 200px; }
.profile-banner .btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-btn-primary {
    background: #1258e2; color: #fff; font-weight: 700; font-size: 0.85em;
    padding: 8px 16px; border-radius: 8px; border: none; cursor: pointer;
}
.profile-btn-primary:hover { background: #0e47c5; }
.profile-btn-ghost {
    background: transparent; color: #64748b; font-size: 0.85em;
    padding: 8px 12px; border-radius: 8px; border: none; cursor: pointer; text-decoration: underline;
}
.profile-btn-ghost:hover { color: #334155; }

/* La barra sticky no debe tapar el final del formulario (paso Funciones) */
.wizard-content-spacer { padding-bottom: 12rem !important; }
.wizard-step.wizard-active { padding-bottom: 1rem; }
main { scroll-padding-bottom: 12rem; }
#wizardActionBar { pointer-events: none; }
#wizardActionBar > div { pointer-events: auto; }

/* Listas desplegables: altura limitada al viewport para que no queden bajo la barra */
.funciones-list, .comision-list { max-height: min(350px, 42vh); }
/* Sub-espacios: el contenedor acompaña la página; cada tarjeta-grupo tiene su propio scroll interno */
#subfuncionCheckboxGroup.funciones-list { max-height: none; overflow-y: visible; }
.subfuncion-group-body { max-height: min(320px, 40vh); overflow-y: auto; }
.subfuncion-group-body::-webkit-scrollbar { width: 8px; }
.subfuncion-group-body::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 4px; }
.subfuncion-group-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* En móvil: barra fija siempre visible + botones ordenados en 2 filas compactas */
@media (max-width: 768px) {
    #wizardActionBar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 60 !important;
        padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom)) !important;
    }
    #wizardActionBar > div { border-radius: 1rem 1rem 0 0 !important; padding: 0.5rem 0.75rem !important; }
    /* Aplana los 2 grupos para ordenar los 3 botones en grilla */
    #wizardActionBar > div > .flex { display: grid !important; grid-template-columns: auto 1fr !important; gap: 0.35rem !important; align-items: center !important; }
    #wizardActionBar > div > .flex > div { display: contents !important; }
    /* Botones a la mitad en móvil, flecha y texto en la misma línea */
    #wizardBackBtn { grid-column: 1 !important; grid-row: 1 !important; width: auto !important; flex: none !important; flex-direction: row !important; align-items: center !important; gap: 0.35rem !important; padding: 0.32rem 0.7rem !important; font-size: 0.8rem !important; border-radius: 0.6rem !important; white-space: nowrap !important; }
    #wizardNextBtn, #wizardSubmitBtn { grid-column: 2 !important; grid-row: 1 !important; width: 100% !important; flex: none !important; flex-direction: row !important; align-items: center !important; justify-content: center !important; gap: 0.35rem !important; padding: 0.32rem 0.7rem !important; font-size: 0.8rem !important; border-radius: 0.6rem !important; white-space: nowrap !important; }
    #wizardBackBtn .material-icons-outlined,
    #wizardNextBtn .material-icons-outlined,
    #wizardSubmitBtn .material-icons-outlined { font-size: 1rem !important; }
    #wizardClearBtn { grid-column: 1 / -1 !important; grid-row: 2 !important; justify-self: center !important; font-size: 0.72em !important; padding: 0.1rem 0.5rem !important; }
    .wizard-content-spacer { padding-bottom: 10rem !important; }
    main { scroll-padding-bottom: 10rem; }
}
