:root {
    /* Paleta Institucional Verde Cooperativa (Ley 127-64 Dominican Standard) */
    --gemacoop-primary: #155e2b;
    --gemacoop-primary-dark: #0d3d1e;
    --gemacoop-primary-light: #22c55e;
    --gemacoop-secondary: #f59e0b;
    --gemacoop-accent: #1e7e34;
    --gemacoop-surface: #ffffff;
    --gemacoop-background: #f4f7f5;
    --gemacoop-text-primary: #1e293b;
    --gemacoop-text-muted: #64748b;
    --gemacoop-danger: #dc2626;
    --gemacoop-warning: #f59e0b;
    --gemacoop-sidebar-width: 270px;
    --gemacoop-header-height: 64px;

    /* Menú Verde Cooperativo */
    --coop-sidebar-bg: #0d3d1e;
    --coop-sidebar-header-bg: #092813;
    --coop-sidebar-dropdown-bg: #061d0e;
    --coop-sidebar-text: #d1fae5;
    --coop-sidebar-text-muted: #86efac;
    --coop-sidebar-border: rgba(255, 255, 255, 0.08);
}



body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--gemacoop-background);
    color: var(--gemacoop-text-primary);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}



/* ==========================================================================
   LAYOUT GENERAL & SIDEBAR TOGGLEABLE (ADMINKIT PATTERN)
   ========================================================================== */
.gemacoop-app {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
}



/* Sidebar Contenedor en Verde Cooperativo */
.gemacoop-sidebar {
    width: var(--gemacoop-sidebar-width);
    min-width: var(--gemacoop-sidebar-width);
    max-width: var(--gemacoop-sidebar-width);
    background: var(--coop-sidebar-bg);
    color: var(--coop-sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    transition: margin-left 0.25s ease-in-out, transform 0.25s ease-in-out;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.25);
    border-right: 1px solid rgba(0, 0, 0, 0.2);
}



/* Estado Colapsado (Desktop) */
.gemacoop-sidebar.collapsed {
    margin-left: calc(-1 * var(--gemacoop-sidebar-width));
}



/* Contenido Principal Adaptable */
.gemacoop-main {
    flex: 1;
    margin-left: var(--gemacoop-sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    transition: margin-left 0.25s ease-in-out;
}



.gemacoop-main.sidebar-collapsed {
    margin-left: 0;
}



/* Versión Móvil: Sidebar Off-canvas */
@media (max-width: 991.98px) {
    .gemacoop-sidebar {
        margin-left: 0;
        transform: translateX(-100%);
    }



    .gemacoop-sidebar.mobile-open {
        transform: translateX(0);
    }



    .gemacoop-main {
        margin-left: 0 !important;
    }



    .gemacoop-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(2px);
        z-index: 1030;
    }


}



/* Header / Topbar */
.gemacoop-header {
    height: var(--gemacoop-header-height);
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}



.sidebar-toggle-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--gemacoop-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    transition: background 0.2s ease, color 0.2s ease;
}



.sidebar-toggle-btn:hover {
    background: #ecfdf5;
    color: #0d3d1e;
}



.gemacoop-content {
    flex: 1;
    padding: 1.5rem;
}



/* ==========================================================================
   SIDEBAR COMPONENTS & MULTI-LEVEL COOPERATIVE ACCORDION
   ========================================================================== */
.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}



/* Sidebar Brand */
.sidebar-brand {
    height: var(--gemacoop-header-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    background: var(--coop-sidebar-header-bg);
    border-bottom: 1px solid rgba(245, 158, 11, 0.3);
    color: #ffffff;
    text-decoration: none;
    transition: background 0.2s ease;
}



.sidebar-brand:hover {
    background: #061f0f;
    color: #ffffff;
}



.sidebar-brand-logo {
    height: 38px;
    width: auto;
    border-radius: 6px;
    background: #ffffff;
    padding: 2px;
}



.sidebar-brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.01em;
}



.sidebar-brand-sub {
    font-size: 0.68rem;
    font-weight: 600;
    color: #fbbf24;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}



/* Scroll Area de la Navegación */
.sidebar-nav-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0;
}



.sidebar-nav-container::-webkit-scrollbar {
    width: 5px;
}



.sidebar-nav-container::-webkit-scrollbar-track {
    background: transparent;
}



.sidebar-nav-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}



.sidebar-nav-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}



/* Enlaces directos de primer nivel (ej: Panel Principal) */
.sidebar-item {
    position: relative;
}



.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: var(--coop-sidebar-text);
    text-decoration: none;
    font-size: 0.865rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}



.sidebar-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}



.sidebar-link.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
    border-left-color: #fbbf24;
    font-weight: 600;
}



.sidebar-icon {
    font-size: 1.1rem;
    color: #86efac;
    flex-shrink: 0;
}



/* ==========================================================================
   NIVEL 1: MÓDULO COLAPSABLE (Sistema de Cooperativa, Administrador)
   ========================================================================== */
.sidebar-module-item {
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
}



.sidebar-module-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    border-top: 1px solid var(--coop-sidebar-border);
    border-bottom: 1px solid var(--coop-sidebar-border);
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1.25rem;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: background 0.2s ease;
}



.sidebar-module-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}



.sidebar-module-btn.expanded {
    background: rgba(0, 0, 0, 0.2);
    border-left: 3px solid #fbbf24;
}



.module-icon {
    font-size: 1rem;
    color: #fbbf24;
}



.module-title {
    color: #ffffff;
}



.module-chevron {
    font-size: 0.75rem;
    color: #fbbf24;
    transition: transform 0.25s ease-in-out;
}



.module-chevron.rotated {
    transform: rotate(180deg);
}



.sidebar-categories {
    margin-top: 2px;
}



/* ==========================================================================
   NIVEL 2: CATEGORÍA COLAPSABLE (Registros, Procesos, Consultas, etc.)
   ========================================================================== */
.category-toggle-btn {
    width: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 1.5rem;
}



.category-toggle-btn:focus {
    outline: none;
}



.category-toggle-btn.expanded {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.07);
}



.category-badge {
    background: var(--coop-sidebar-header-bg);
    color: #fbbf24;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 50rem;
    border: 1px solid rgba(251, 191, 36, 0.3);
}



.sidebar-chevron {
    font-size: 0.75rem;
    color: #86efac;
    transition: transform 0.25s ease-in-out;
}



.sidebar-chevron.rotated {
    transform: rotate(180deg);
    color: #fbbf24;
}



/* ==========================================================================
   NIVEL 3: SUB-OPCIONES / PANTALLAS
   ========================================================================== */
.sidebar-dropdown {
    background: var(--coop-sidebar-dropdown-bg);
    padding: 0.35rem 0;
    border-left: 2px solid rgba(245, 158, 11, 0.4);
    margin-left: 1.5rem;
    margin-right: 0.5rem;
    border-radius: 0.375rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}



.sidebar-subitem {
    position: relative;
}



.sidebar-sublink {
    display: flex;
    align-items: center;
    padding: 0.45rem 1rem 0.45rem 0.85rem;
    color: #a7f3d0;
    text-decoration: none;
    font-size: 0.815rem;
    font-weight: 400;
    transition: all 0.2s ease;
    border-radius: 0.25rem;
    margin: 1px 0.35rem;
}



.sidebar-sublink:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.09);
}



.sidebar-sublink.active {
    color: #ffffff;
    background: rgba(34, 197, 94, 0.3);
    border-left: 3px solid #4ade80;
    font-weight: 600;
}



.sublink-bullet {
    font-size: 0.35rem;
    margin-right: 0.6rem;
    color: #86efac;
    opacity: 0.7;
    flex-shrink: 0;
}



.sidebar-sublink.active .sublink-bullet {
    color: #fbbf24;
    opacity: 1;
    transform: scale(1.4);
}



/* Footer del Sidebar */
.sidebar-footer {
    padding: 0.85rem 1.25rem;
    background: var(--coop-sidebar-header-bg);
    border-top: 1px solid var(--coop-sidebar-border);
    margin-top: auto;
}



/* ==========================================================================
   COMPONENTES DE NEGOCIO (COOPERATIVA)
   ========================================================================== */
.card-gemacoop {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}



.card-gemacoop .card-header {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}



.btn-gemacoop-primary {
    background-color: var(--gemacoop-primary);
    border-color: var(--gemacoop-primary);
    color: #ffffff;
    font-weight: 500;
}



.btn-gemacoop-primary:hover {
    background-color: var(--gemacoop-accent);
    border-color: var(--gemacoop-accent);
    color: #ffffff;
}



.btn-gemacoop-secondary {
    background-color: var(--gemacoop-secondary);
    border-color: var(--gemacoop-secondary);
    color: #212529;
    font-weight: 600;
}



.btn-gemacoop-secondary:hover {
    background-color: #d97706;
    border-color: #d97706;
    color: #ffffff;
}



.tenant-badge {
    background: rgba(21, 94, 43, 0.08);
    color: var(--gemacoop-primary);
    border: 1px solid rgba(21, 94, 43, 0.22);
    border-radius: 0.65rem;
    padding: 0.25rem 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 40px;
    max-height: 48px;
    transition: all 0.2s ease-in-out;
}

.tenant-badge:hover {
    background: rgba(21, 94, 43, 0.12);
    border-color: rgba(21, 94, 43, 0.35);
}

.tenant-name-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: left;
    line-height: 1.15;
    max-width: 440px;
}

.tenant-line-1 {
    font-size: 0.775rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
}

.tenant-line-2 {
    font-size: 0.715rem;
    font-weight: 600;
    opacity: 0.92;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
}

@media (max-width: 768px) {
    .tenant-name-container {
        max-width: 250px;
    }
    .tenant-line-1 {
        font-size: 0.72rem;
    }
    .tenant-line-2 {
        font-size: 0.66rem;
    }
}

/* ==========================================================
   SWITCH DE TIPO DE TRANSACCIÓN TRI-ESTADO (Null: Gris, 0: Verde, 1: Azul Claro)
   ========================================================== */
.ssi-titr-switch-group {
    display: inline-flex;
    align-items: center;
    background-color: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 9999px;
    padding: 3px;
    height: 36px;
    box-sizing: border-box;
    user-select: none;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ssi-titr-btn {
    border: none;
    outline: none;
    background: transparent;
    padding: 0 0.75rem;
    min-width: 65px;
    height: 28px;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ssi-titr-btn:hover:not(.active-null):not(.active-0):not(.active-1) {
    color: #0f172a;
    background-color: rgba(0, 0, 0, 0.04);
}

/* Estado Null / Vacío: Gris Claro */
.ssi-titr-btn.active-null {
    background-color: #64748b !important;
    color: #ffffff !important;
    box-shadow: 0 2px 4px rgba(100, 116, 139, 0.3);
}

/* Estado 0: Verde Seagreen */
.ssi-titr-btn.active-0 {
    background-color: seagreen !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(46, 139, 87, 0.35);
}

/* Estado 1: Azul Claro */
.ssi-titr-btn.active-1 {
    background-color: #0ea5e9 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(14, 165, 233, 0.35);
}

/* SweetAlert2 Modal Z-Index (Debe ser mayor que GenericModal z-index: 10040) */
.swal2-container {
    z-index: 20000 !important;
}