:root {
    /* --- PALETA CORPORATIVA (Basada en #067b3b) --- */
    --primary: #067b3b;          /* Verde Institucional */
    --primary-dark: #045227;     /* Verde oscuro (hover y textos fuertes) */
    --primary-light: #f0fdf4;    /* Verde menta muy claro (fondos suaves) */
    --accent: #10b981;           /* Esmeralda vibrante (para degradados y detalles) */
    
    /* --- NEUTROS Y FONDOS --- */
    --bg-body: #f1f5f9;          /* Gris neutro (fondo general) */
    --bg-card: #ffffff;          /* Blanco (tarjetas) */
    --bg-sidebar: #022c22;       /* Verde muy oscuro/negro (barra lateral) */
    --bg-sidebar-header: rgba(0, 0, 0, 0.3);
    --bg-input: #f8fafc;         /* Gris casi blanco (inputs) */
    --bg-hover: rgba(255, 255, 255, 0.1); /* Hover en sidebar */
    
    /* --- BORDES --- */
    --border-light: #e2e8f0;     /* Bordes sutiles */
    --border-dark: #14532d;      /* Bordes oscuros sutiles para el sidebar */
    --border-focus: rgba(6, 123, 59, 0.3); /* Anillo de foco (verde transparente) */

    /* --- TEXTOS --- */
    --text-main: #334155;        /* Texto principal (gris plomo) */
    --text-muted: #64748b;       /* Texto secundario */
    --text-sidebar: #ecfdf5;     /* Texto en sidebar (blanco menta) */
    --text-sidebar-hover: #ffffff;
    --text-inverse: #ffffff;

    /* --- ESTADOS (ALERTAS / ROLES) --- */
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --error-border: #fecaca;
    
    --success-bg: #dcfce7;
    --success-text: #045227;
    --success-border: #86efac;

    --danger-btn: #dc2626;       /* Botón logout (rojo) */
    --danger-btn-hover: #b91c1c;
}

/* =========================================================
   Tablas ordenables (estilo unificado)
   Uso: <table class="table-sortable"> ... <th data-sort-type="text|num|date"> ...
   ========================================================= */

table.table-sortable thead th.th-sortable{
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    position: relative;
    padding-right: 26px; /* espacio para indicador */
}

table.table-sortable thead th.th-sortable::after{
    content: "⇅";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: .85em;
    opacity: .35;
}

table.table-sortable thead th.th-sortable[data-sort-dir="asc"]::after{
    content: "▲";
    opacity: .75;
}

table.table-sortable thead th.th-sortable[data-sort-dir="desc"]::after{
    content: "▼";
    opacity: .75;
}

table.table-sortable thead th.th-sortable:focus{
    outline: 2px solid rgba(6,123,59,.35);
    outline-offset: 2px;
    border-radius: 6px;
}

.table-filter-bar{
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px;
}

.table-filter-label{
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 800;
    color: var(--text-muted);
}

.table-filter-input{
    min-height: 42px;
    min-width: min(100%, 260px);
    padding: 0 14px;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: #fff;
    color: var(--text-main);
}

.table-filter-input:focus{
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--border-focus);
}

.table-filter-count{
    color: var(--text-muted);
    font-size: .86rem;
    font-weight: 700;
}

table.table-sortable thead th.th-sortable::after{
    content: "\21C5";
}

table.table-sortable thead th.th-sortable[data-sort-dir="asc"]::after{
    content: "\25B2";
}

table.table-sortable thead th.th-sortable[data-sort-dir="desc"]::after{
    content: "\25BC";
}

/* --- RESET Y BASE --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

body {
    background: var(--bg-body);
    color: var(--text-main);
    overflow: hidden; /* El scroll lo manejan los contenedores internos */
}

/* --- LAYOUT LOGIN --- */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--bg-sidebar), #064e3b);
}

.login-container {
    background: var(--bg-card);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.6s ease-out;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h2 {
    color: var(--primary);
    font-size: 1.8rem;
    font-weight: 700;
}

.login-header p {
    color: var(--text-muted);
}

.login-logo-img {
    max-height: 70px;
    width: auto;
    margin-bottom: 1rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* --- FORMULARIOS --- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-input);
    color: var(--text-main);
    transition: all 0.3s ease;
}

.form-control:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--border-focus);
    background: var(--bg-card);
}

/* --- BOTONES --- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.85rem;
    background: linear-gradient(to right, var(--primary), var(--accent));
    color: var(--text-inverse);
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--border-focus);
}


/* --- LOGIN: BOTÓN A ANCHO COMPLETO --- */
.login-container .btn-primary {
    width: 100%;
}
/* --- CAPTCHA --- */
.captcha-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 1.5rem;
    background: var(--bg-input);
    padding: 10px;
    border-radius: 8px;
    align-items: center;
}

.captcha-img {
    border-radius: 6px;
    border: 1px solid var(--border-light);
}

/* --- ALERTS --- */
.alert {
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    text-align: center;
    border: 1px solid transparent;
}

.alert-error {
    background-color: var(--error-bg);
    color: var(--error-text);
    border-color: var(--error-border);
}

/* --- PORTAL / DASHBOARD LAYOUT --- */
.portal-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* --- SIDEBAR BASE --- */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: var(--text-inverse);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-dark);
    flex-shrink: 0;
    /* Nuevas propiedades para la animación */
    transition: all 0.3s ease-in-out;
    white-space: nowrap; /* Evita que el texto se rompa al cerrar */
    overflow: hidden;    /* Oculta lo que no cabe */
    position: relative;
    z-index: 50;
}

/* --- SIDEBAR COLAPSADO (CLASE ACTIVA CON JS) --- */
.sidebar.collapsed {
    width: 0;
    padding: 0;
    border-right: none;
    opacity: 0; /* Ayuda a la transición visual */
}

.sidebar-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1.5rem 1rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 1rem;
}

.sidebar-version {
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.70);
    padding: 0.15rem 0.55rem;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.15);
    line-height: 1.1;
}

.sidebar-logo img {
    max-width: 100%;
    height: auto;
    max-height: 60px;
    object-fit: contain;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: var(--bg-sidebar-header);
}

.user-info-mini {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar-mini {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    flex-shrink: 0; /* Evita que el avatar se aplaste */
}

.user-details h3 {
    font-size: 0.95rem;
    color: var(--text-inverse);
    margin: 0;
}

.user-details span {
    font-size: 0.75rem;
    color: #a7f3d0;
    text-transform: uppercase;
}

.nav-menu {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.nav-group-title {
    padding: 1rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #6ee7b7;
    letter-spacing: 0.05em;
    font-weight: 700;
}



/* --- SIDEBAR: GRUPOS COLAPSABLES --- */
.nav-group {
    margin-top: 6px;
}

.nav-group-title-toggle {
    width: 100%;
    border: none;
    background: transparent;
    color: #6ee7b7;
    padding: 1rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.nav-group-title-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
}

.nav-group-title-toggle .caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #ecfdf5;
    transition: transform 0.15s ease;
}

.nav-group.is-collapsed .nav-group-title-toggle .caret {
    transform: rotate(-90deg);
}

.nav-group-items {
    padding-bottom: 6px;
}

.nav-group.is-collapsed .nav-group-items {
    display: none;
}
.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-sidebar);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-sidebar-hover);
}

.nav-item.active {
    background: rgba(6, 123, 59, 0.25);
    border-left-color: var(--accent);
    color: #ffffff;
}

.nav-icon {
    margin-right: 12px;
    display: flex;
    align-items: center;
    flex-shrink: 0; /* El icono no debe encogerse */
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.btn-logout-mini {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 0.6rem;
    background: var(--danger-btn);
    color: var(--text-inverse);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-logout-mini:hover {
    background: var(--danger-btn-hover);
}

/* --- ÁREA PRINCIPAL --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    position: relative; /* Necesario para el botón flotante */
    transition: margin-left 0.3s ease-in-out;
}

#app-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* --- BOTÓN DE MENÚ (TOGGLE) --- */
.menu-toggle-btn {
    position: absolute;
    top: 2px;
    left: 2px;
    z-index: 1000; /* Siempre visible por encima del iframe */
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    padding: 0;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.menu-toggle-btn:hover {
    background: var(--primary);
    color: var(--text-inverse);
    transform: scale(1.05);
}

/* --- ESTILOS IFRAME CONTENIDO --- */
.welcome-body {
    background: var(--bg-card);
    padding: 40px;
    overflow-y: auto;
}

.welcome-card {
    max-width: 800px;
    margin: 0 auto;
}

.welcome-title {
    color: var(--text-main);
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.welcome-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 40px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-box {
    padding: 20px;
    border-radius: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.2rem;
    color: var(--text-main);
    font-weight: 600;
}

.stat-value.highlight {
    color: var(--primary);
}

.admin-notice {
    background: var(--primary-light);
    border-left: 4px solid var(--primary);
    padding: 15px;
    border-radius: 0 8px 8px 0;
}

.admin-notice h4 {
    margin: 0 0 5px 0;
    color: var(--primary-dark);
}

.admin-notice p {
    margin: 0;
    color: var(--primary-dark);
    font-size: 0.9rem;
}



/* ========================================================================== */
/* APP PAGES (APLICACIONES EN IFRAME / VISTA COMPLETA)                         */
/* ========================================================================== */

html.app-html {
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
    background: var(--bg-body);
}

body.app-body {
    overflow-y: auto !important;
    overflow-x: hidden;
    height: auto !important;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    padding-bottom: 100px;
    box-sizing: border-box;
    background:
        radial-gradient(circle at top left, rgba(6, 123, 59, 0.14), transparent 30%),
        linear-gradient(180deg, #f7fcf8 0%, var(--bg-body) 100%);
}

.app-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0;
}

/* --- CABECERA CORPORATIVA --- */
.header-top,
header.header-intranet-top {
    background:
        linear-gradient(135deg, rgba(2, 44, 34, 0.96), rgba(6, 123, 59, 0.94)),
        linear-gradient(135deg, rgba(16, 185, 129, 0.08), transparent);
    border-radius: 24px;
    padding: 22px 28px;
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    color: white;
    box-shadow: 0 22px 40px rgba(2, 31, 18, 0.14);
    width: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.header-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.header-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-weight: 800;
    color: rgba(236, 253, 245, 0.82);
}

.header-eyebrow::before {
    content: "";
    width: 18px;
    height: 1px;
    background: rgba(255, 255, 255, 0.45);
}

.header-title {
    margin: 0;
    font-size: clamp(1.45rem, 2vw, 1.85rem);
    line-height: 1.1;
    color: white;
    font-weight: 900;
}

.header-subtitle {
    margin: 0;
    color: rgba(236, 253, 245, 0.88);
    font-size: 0.96rem;
}

.header-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    margin-top: 4px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.14);
    font-size: 0.88rem;
}

.header-info h2,
.header-titles h2,
header.header-intranet-top .header-left h2 {
    margin: 0;
    font-size: 1.6rem;
    color: white;
}

.header-info p,
.header-titles p,
header.header-intranet-top .header-left p {
    margin: 5px 0 0 0;
    opacity: 0.9;
    font-size: 0.9rem;
}

/* Contenedor para acciones a la derecha de la cabecera (botón volver, navegación, etc.) */
.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.header-icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    text-decoration: none;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.header-icon-link:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.28);
}

.header-icon-link--brand {
    width: auto;
    min-width: 62px;
    padding: 0 14px;
}

.header-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.header-logo {
    width: auto;
    height: 28px;
    object-fit: contain;
}

.btn-back-main,
.btn-back-dashboard {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: 0.3s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-back-main:hover,
.btn-back-dashboard:hover {
    background: white;
    color: var(--primary-dark);
}

/* --- NAV CABECERA (ENTREGAS) --- */
.header-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.header-nav a {
    color: white;
    text-decoration: none;
    font-weight: 700;
    padding: 8px 12px;
    border-radius: 10px;
    transition: 0.2s;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.header-nav a:hover,
.header-nav a.active {
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary-dark);
}

/* --- TARJETAS / SECCIONES --- */
.card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    border: 1px solid var(--border-light);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    width: 100%;
    box-sizing: border-box;
}

.card-title {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 1.1rem;
    font-weight: 800;
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

/* --- TABLAS (APPS) --- */
.table-wrapper,
.table-responsive {
    width: 100%;
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid var(--border-light);
}

.app-body table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.app-body th {
    background: #f8fafc;
    color: var(--text-main);
    padding: 15px;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.75rem;
    border-bottom: 2px solid var(--border-light);
    text-align: left;
    white-space: nowrap;
}

.app-body td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.92rem;
}

.app-body tr:hover td {
    background-color: var(--primary-light);
}

/* --- BADGES --- */
.badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 800;
    display: inline-block;
}

.badge-Pendiente { background: #fef3c7; color: #92400e; }
.badge-Tramitado { background: #dcfce7; color: #166534; }
.badge-Rechazado { background: #fee2e2; color: #991b1b; }


/* --- UTILIDADES --- */
.opacity-30 { opacity: 0.3; }
.opacity-40 { opacity: 0.4; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* --- BOTONES (APPS) --- */
.btn-primary-intranet {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary-intranet:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-intranet {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-intranet:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #64748b;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-secondary:hover { filter: brightness(0.95); transform: translateY(-1px); }

.btn-danger {
    background: #dc2626;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}

.btn-danger:hover { filter: brightness(0.95); transform: translateY(-1px); }

.btn-icon {
    padding: 8px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid rgba(15, 23, 42, 0.12);
    cursor: pointer;
}

.btn-icon:hover { background: rgba(15, 23, 42, 0.04); }

/* Botón de gestión (delegados) */
.btn-manage {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 800;
    transition: 0.2s;
}

.btn-manage:hover {
    background: var(--primary);
    color: white;
}

/* --- INPUT FILE (ENLACES) --- */
.app-body input[type="file"] {
    padding: 10px;
    background: var(--bg-input);
    border: 2px dashed var(--border-light);
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}

/* --- MODALES (GENÉRICO) --- */
.overlay,
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
}

.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95%;
    max-width: 700px;
    background: white;
    border-radius: 16px;
    z-index: 1000;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Algunos modales (compras) se renderizan con display:block. */
.modal.is-open { display: block; }

/* Estado abierto: usado por apps/compras (JS añade class="open" al overlay) */
.modal-overlay.open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open .modal {
    display: block;
}

.modal-header {
    background: var(--primary);
    color: white;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 25px;
    max-height: 75vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 15px 25px;
    background: #f8fafc;
    border-top: 1px solid var(--border-light);
    text-align: right;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* --- KPIs / STATS --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.kpi-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    text-align: center;
    border-left: 5px solid var(--primary);
}

.kpi-card .label {
    font-size: 0.75rem;
    font-weight: 900;
    color: var(--text-muted);
    text-transform: uppercase;
}

.kpi-card .value {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--primary);
    margin-top: 5px;
}

.card-filters {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    margin-bottom: 25px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.filter-grid {
    display: flex;
    gap: 20px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 900;
    margin-bottom: 8px;
    color: var(--text-main);
}

.pill {
    background: #e2e8f0;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.link-detail {
    color: var(--primary);
    font-weight: 900;
    text-decoration: none;
}

.link-detail:hover { text-decoration: underline; }

/* --- GRID DE ENLACES (LINKS / NNTT / NOVEDADES) --- */
.enlaces-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

/* --- AGRUPACIÓN DESPLEGABLE DE ENLACES --- */
.link-groups {
    display: grid;
    gap: 14px;
}

.link-group {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.link-group summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(180deg, rgba(6,123,59,0.10), rgba(6,123,59,0.04));
    border-bottom: 1px solid rgba(148,163,184,0.25);
    font-weight: 1000;
    color: var(--text-main);
}

.link-group summary::-webkit-details-marker { display: none; }

.link-group .group-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.link-group .group-count {
    background: #e2e8f0;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 1000;
    color: #0f172a;
}

.link-group summary::after {
    content: "▾";
    font-size: 1.05rem;
    opacity: 0.8;
    transition: transform 0.15s ease;
}

.link-group[open] summary::after {
    transform: rotate(180deg);
}

.link-group .group-content {
    padding: 16px;
}

/* --- GESTIÓN DE ENLACES (ADMIN) --- */
.admin-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    margin: 14px 0 18px;
}

.admin-toolbar .hint {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.04);
}

.admin-table th,
.admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(148,163,184,0.18);
    vertical-align: top;
}

.admin-table th {
    text-align: left;
    font-weight: 1000;
    background: #f8fafc;
}

/*
   Tablas de administración
   Importante: NO aplicar estilos de input "de texto" a checkboxes/radios.
   Si no, se desalinean (por ejemplo, width:100%) y separan el texto del label.
*/
.admin-table td input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.admin-table td select,
.admin-table td textarea {
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border-light);
    background: #ffffff;
    font-size: 0.95rem;
    line-height: 1.2;
    box-sizing: border-box;
}

.admin-table td textarea {
    resize: vertical;
    min-height: 44px;
}

.admin-table td input[type="checkbox"],
.admin-table td input[type="radio"] {
    width: auto;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    margin: 0;
}

.admin-table td label {
    font-size: 0.92rem;
    line-height: 1.2;
}

/* Acciones (Actualizar/Eliminar) y checkboxes dentro de tablas */
.admin-table .ge-actions,
.admin-table .ga-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-table .ge-check {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 900;
    white-space: nowrap;
}

.admin-table .ge-check.del {
    color: #b91c1c;
}

/* Asa de arrastre */
.admin-table td.ge-handle,
.admin-table td.ga-handle {
    vertical-align: middle;
    text-align: center;
    font-size: 18px;
    color: var(--text-muted);
    cursor: grab;
    user-select: none;
}

.admin-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    background: #ffffff;
    font-weight: 900;
    cursor: pointer;
    text-decoration: none;
}

.btn-mini.primary {
    background: rgba(6,123,59,0.12);
    border-color: rgba(6,123,59,0.25);
    color: var(--primary);
}

.btn-mini.danger {
    background: rgba(220,38,38,0.10);
    border-color: rgba(220,38,38,0.25);
    color: #dc2626;
}

.enlace-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-decoration: none;
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.enlace-card:hover {
    transform: translateY(-2px);
    border-color: rgba(16, 185, 129, 0.45);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
}

.enlace-card img {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    object-fit: cover;
}

.enlace-card h3 {
    margin: 0;
    color: var(--text-main);
    font-weight: 900;
    font-size: 1.05rem;
}

.enlace-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.4;

}

.enlace-titulo {
    margin: 0;
    color: var(--text-main);
    font-weight: 900;
    font-size: 1.05rem;
}

.aviso-vpn {
    margin-top: 10px;
    background: #fef3c7;
    color: #92400e;
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- LISTÍN (ACORDEONES) --- */
.search-container { position: relative; margin-bottom: 25px; width: 100%; }
.search-container .search-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 1rem; }
.search-container input {
    width: 100%;
    padding: 15px 15px 15px 45px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    font-size: 1.05rem;
    outline: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
}

.sector-wrapper {
    background: white;
    border-radius: 12px;
    margin-bottom: 15px;
    border: 1px solid var(--border-light);
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.sector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 18px 25px;
    background: var(--primary-light);
    color: var(--primary-dark);
    transition: background 0.2s;
}

.sector-header:hover { background: #e2e8f0; }

.sector-content { display: none; padding: 25px; border-top: 1px solid #eee; background: #fff; }
.sector-content.active { display: block !important; }

.contact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.contact-card {
    background: #f8fafc;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 20px;
    transition: 0.2s;
}

.contact-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.contact-name { font-weight: 900; color: var(--text-main); font-size: 1.05rem; margin-bottom: 8px; }
.contact-info { font-size: 0.92rem; color: var(--text-muted); line-height: 1.7; }

.admin-btns {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px dashed #cbd5e1;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.btn-edit-small {
    color: #2563eb;
    font-size: 0.75rem;
    font-weight: 900;
    cursor: pointer;
    text-transform: uppercase;
}

.btn-delete-small {
    color: #dc2626;
    font-size: 0.75rem;
    font-weight: 900;
    cursor: pointer;
    background: none;
    border: none;
    text-transform: uppercase;
}


/* --- BANCOS (CONVERSOR) --- */
.app-bancos #formulario label {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin: 10px 0;
    font-weight: 800;
    color: var(--text-main);
}

.app-bancos #formulario input[type="text"] {
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--bg-input);
    outline: none;
}

.app-bancos #formulario textarea {
    width: 100%;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--bg-input);
    outline: none;
}

.app-bancos #formulario input[type="button"],
.app-bancos #formulario input[type="reset"] {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    font-weight: 900;
    cursor: pointer;
}

.app-bancos #formulario input[type="button"]:hover,
.app-bancos #formulario input[type="reset"]:hover {
    background: var(--primary-dark);
}
/* --- ACCESO DENEGADO (app_guard) --- */
.centered-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg-body);
}

.msg-card {
    width: 100%;
    max-width: 760px;
    background: white;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: 0 20px 30px rgba(0,0,0,0.08);
    overflow: hidden;
}

/* Variantes (feedback rápido) */
.msg-card.success {
    border-color: var(--success-border);
    background: var(--success-bg);
}

.msg-card.error {
    border-color: var(--error-border);
    background: var(--error-bg);
}

.msg-header {
    padding: 18px 22px;
    background: linear-gradient(135deg, var(--bg-sidebar), var(--primary));
    color: white;
    font-weight: 900;
}

.msg-body {
    padding: 22px;
    color: var(--text-main);
}

.msg-actions {
    padding: 16px 22px 22px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.msg-actions a {
    text-decoration: none;
}

/* --- FOOTER FIJO EN APPS --- */
.app-body footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(2, 44, 34, 0.96);
    color: white;
    padding: 12px;
    font-size: 0.85rem;
    z-index: 900;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
}

.footer-inner {
    width: min(1180px, calc(100% - 24px));
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.footer-copy {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.footer-copy a {
    color: #d1fae5;
    font-weight: 700;
    text-decoration: none;
}

.footer-copy a:hover {
    color: #ffffff;
}

.footer-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    height: 34px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.footer-brand img {
    height: 20px;
    width: auto;
    object-fit: contain;
}

@media (max-width: 720px) {
    .header-top,
    header.header-intranet-top {
        padding: 20px;
        border-radius: 20px;
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .footer-inner {
        flex-direction: column;
        justify-content: center;
        text-align: center;
    }
}

/* --- APP: PERMISOS --- */
[x-cloak] { display: none !important; }

.app-permisos .perm-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-permisos .perm-dashboard,
.app-permisos .perm-calendar-page,
.app-permisos .perm-reports,
.app-permisos .perm-add {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.app-permisos .perm-lead {
    margin: 0 0 10px 0;
    color: var(--text-muted);
    font-weight: 700;
}

.app-permisos .perm-search-input { padding-left: 45px; }

/* Colores de tipos (sin Tailwind) */
.app-permisos .perm-color-vacaciones { background: #10b981; }
.app-permisos .perm-color-asuntos    { background: #f59e0b; }
.app-permisos .perm-color-baja       { background: #8b5cf6; }
.app-permisos .perm-color-extra      { background: #0ea5e9; }
.app-permisos .perm-color-sinsueldo  { background: #64748b; }

/* Resumen de ausencias */
.app-permisos .perm-today-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.app-permisos .perm-today-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 10px 12px;
}

.app-permisos .perm-today-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    color: white;
}

.app-permisos .perm-today-name { font-weight: 900; color: var(--text-main); }
.app-permisos .perm-today-type { font-size: 0.85rem; color: var(--text-muted); font-weight: 800; }

/* Tarjetas de empleados */
.app-permisos .perm-employee-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.app-permisos .perm-employee-card {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.app-permisos .perm-employee-card:hover {
    transform: translateY(-2px);
    border-color: rgba(16, 185, 129, 0.45);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
}

.app-permisos .perm-employee-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-permisos .perm-employee-info h3 {
    margin: 0;
    color: var(--text-main);
    font-weight: 900;
    font-size: 1.05rem;
}

.app-permisos .perm-employee-arrow {
    margin-left: auto;
    font-weight: 900;
    color: var(--primary);
}

.app-permisos .perm-empty {
    margin-top: 10px;
    padding: 12px;
    border: 1px dashed var(--border-light);
    border-radius: 12px;
    color: var(--text-muted);
    font-weight: 800;
    text-align: center;
    background: rgba(255, 255, 255, 0.75);
}

/* Calendario: cabecera empleado */
.app-permisos .perm-emp-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.app-permisos .perm-title {
    margin: 8px 0 0 0;
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--text-main);
}

.app-permisos .perm-subtitle {
    margin: 4px 0 0 0;
    color: var(--text-muted);
    font-weight: 800;
}

.app-permisos .perm-month-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-permisos .perm-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid var(--border-light);
    color: var(--text-main);
    text-decoration: none;
    font-weight: 900;
    transition: 0.2s;
}

.app-permisos .perm-nav-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.app-permisos .perm-month-label {
    font-weight: 900;
    color: var(--text-main);
    padding: 6px 10px;
    border-radius: 12px;
    background: #f1f5f9;
    border: 1px solid var(--border-light);
}

/* Selector de tipos */
.app-permisos .perm-type-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.app-permisos .perm-type-pill { position: relative; }
.app-permisos .perm-type-pill input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.app-permisos .perm-type-pill-ui {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border-light);
    border-radius: 999px;
    padding: 8px 12px;
    font-weight: 900;
    background: #ffffff;
    cursor: pointer;
    transition: 0.2s;
    user-select: none;
}

.app-permisos .perm-type-pill:hover .perm-type-pill-ui {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

.app-permisos .perm-type-pill input:checked + .perm-type-pill-ui {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.20);
}

.app-permisos .perm-type-pill--erase .perm-type-pill-ui {
    background: #fff5f5;
    border-color: rgba(220, 38, 38, 0.25);
    color: #991b1b;
}

.app-permisos .perm-type-pill--erase input:checked + .perm-type-pill-ui {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
    border-color: rgba(220, 38, 38, 0.55);
}

.app-permisos .perm-type-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.app-permisos .perm-type-count {
    margin-left: 2px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 0.75rem;
    font-weight: 900;
}

.app-permisos .perm-type-separator { flex-basis: 100%; height: 0; }
.app-permisos .perm-type-erase { font-size: 1rem; }

/* Calendario */
.app-permisos .perm-calendar-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.app-permisos .perm-weekday {
    text-align: center;
    font-weight: 900;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 6px 0;
}

.app-permisos .perm-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.app-permisos .perm-day {
    position: relative;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: #ffffff;
    min-height: 86px;
    padding: 10px;
    cursor: pointer;
    user-select: none;
    transition: 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.app-permisos .perm-day--blank {
    background: transparent;
    border: 1px dashed rgba(0, 0, 0, 0.08);
    cursor: default;
}

.app-permisos .perm-day--weekend {
    background: #f1f5f9;
    color: var(--text-muted);
    cursor: not-allowed;
}

.app-permisos .perm-day--holiday {
    background: #fff7ed;
    border-color: rgba(245, 158, 11, 0.35);
    cursor: not-allowed;
}

.app-permisos .perm-day--empty:hover {
    border-color: rgba(16, 185, 129, 0.45);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.app-permisos .perm-day-number { font-weight: 900; color: var(--text-main); }

.app-permisos .perm-day--assigned {
    color: white;
    border-color: rgba(0, 0, 0, 0.08);
}

.app-permisos .perm-day--assigned .perm-day-number { color: rgba(255, 255, 255, 0.95); }

.app-permisos .perm-day-label {
    font-size: 0.75rem;
    font-weight: 900;
    opacity: 0.95;
}

.app-permisos .perm-day-label--holiday {
    font-size: 0.72rem;
    font-weight: 900;
    color: #92400e;
}

.app-permisos .perm-day.is-selected {
    outline: 3px solid rgba(16, 185, 129, 0.55);
    outline-offset: 2px;
}

.app-permisos .perm-day--weekend.is-selected,
.app-permisos .perm-day--holiday.is-selected,
.app-permisos .perm-day--blank.is-selected {
    outline: none;
}

/* Botón flotante */
.app-permisos .perm-save-fab {
    position: fixed;
    right: 18px;
    bottom: 70px;
    z-index: 950;
}

.app-permisos .perm-save-btn {
    border-radius: 14px;
    padding: 12px 16px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

.app-permisos .perm-save-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.app-permisos .perm-save-count {
    margin-left: 8px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    padding: 2px 10px;
    font-weight: 900;
}

/* Toast */
.app-permisos .perm-toast {
    position: fixed;
    left: 18px;
    bottom: 70px;
    z-index: 950;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    color: white;
    font-weight: 900;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

.app-permisos .perm-toast--success { background: #16a34a; }
.app-permisos .perm-toast--error   { background: #dc2626; }

/* Formularios / filtros */
.app-permisos .perm-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.app-permisos .perm-form .form-group { margin-bottom: 0; }

.app-permisos .perm-form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.app-permisos .perm-radio-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.app-permisos .perm-radio {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    font-weight: 800;
    color: var(--text-main);
}

.app-permisos .perm-alert {
    border-radius: 12px;
    padding: 12px 14px;
    font-weight: 800;
    margin-bottom: 10px;
}

.app-permisos .perm-alert ul { margin: 0; padding-left: 18px; }

.app-permisos .perm-alert--error {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.app-permisos .perm-search-form {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.app-permisos .perm-search-form .search-container {
    flex: 1;
    min-width: 240px;
}

/* Informes */
.app-permisos .perm-filters {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.app-permisos .perm-filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.app-permisos .perm-filters-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.app-permisos .perm-filters-actions {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.app-permisos .perm-mode {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.app-permisos .perm-mode-option { position: relative; }
.app-permisos .perm-mode-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.app-permisos .perm-mode-option span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-light);
    background: white;
    font-weight: 900;
    cursor: pointer;
    user-select: none;
}

.app-permisos .perm-mode-option input:checked + span {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.20);
}

.app-permisos .perm-pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.app-permisos .perm-pill-check { position: relative; }
.app-permisos .perm-pill-check input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.app-permisos .perm-pill-check span {
    display: inline-flex;
    padding: 7px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-light);
    background: white;
    font-weight: 800;
    color: var(--text-main);
    cursor: pointer;
    user-select: none;
}

.app-permisos .perm-pill-check input:checked + span {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.app-permisos .perm-min-input { max-width: 140px; }

.app-permisos .perm-report-days { display: flex; flex-direction: column; gap: 18px; }

.app-permisos .perm-report-day {
    border: 1px solid var(--border-light);
    border-radius: 14px;
    background: #ffffff;
    padding: 14px;
}

.app-permisos .perm-report-day-title {
    font-weight: 900;
    color: var(--text-main);
    margin-bottom: 10px;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.app-permisos .perm-report-day-num { color: var(--text-muted); }

.app-permisos .perm-report-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.app-permisos .perm-report-item {
    display: flex;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 10px 12px;
    background: #fff;
}

.app-permisos .perm-report-bar {
    width: 10px;
    height: 38px;
    border-radius: 999px;
    flex-shrink: 0;
}

.app-permisos .perm-report-name { font-weight: 900; color: var(--text-main); }
.app-permisos .perm-report-detail { color: var(--text-muted); font-weight: 800; font-size: 0.85rem; }

.app-permisos .perm-total-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 900;
}

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

/* --- RESPONSIVE / MOBILE --- */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        height: 100%;
        z-index: 999;
        /* En móvil, por defecto está oculto (transform) */
        transform: translateX(-100%);
        width: 260px; /* Ancho fijo */
        opacity: 1; /* Asegurar opacidad base */
    }

    /* En móvil, la clase .collapsed hará que se MUESTRE (Invertimos lógica o usamos active)
       Para simplificar con el JS que usa 'toggle', definamos esto:
       
       JS por defecto: Si no tiene 'collapsed', desktop se ve.
       JS si tiene 'collapsed', desktop se oculta.
       
       Para Mobile, necesitamos que funcione igual:
       Si NO tiene collapsed -> Se ve (cubriendo pantalla).
       Si tiene collapsed -> Se oculta.
    */
    
    .sidebar {
        /* Estado visible en móvil */
        transform: translateX(0);
        box-shadow: 2px 0 10px rgba(0,0,0,0.5);
    }
    
    .sidebar.collapsed {
        /* Estado oculto en móvil */
        transform: translateX(-100%);
        width: 260px; /* Mantener ancho para que la transición de transform funcione bien */
    }
    
    /* El botón toggle en móvil debe estar siempre accesible */
    .menu-toggle-btn {
        left: 10px;
        top: 10px;
    }
}

/* =========================================================
   Unificacion visual de modulos PHP del portal
   ========================================================= */

:root {
    --app-shell-width: min(1180px, calc(100% - 32px));
    --app-card-radius: 24px;
    --app-card-border: rgba(15, 23, 42, 0.08);
    --app-card-shadow: 0 18px 36px rgba(2, 31, 18, 0.08);
    --app-card-shadow-strong: 0 24px 48px rgba(2, 31, 18, 0.14);
}

.app-body {
    padding: 24px 16px 110px;
    color: #173227;
}

.app-container {
    width: var(--app-shell-width) !important;
    max-width: var(--app-shell-width) !important;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.header-top,
header.header-intranet-top {
    border-radius: 30px;
    padding: 24px 28px;
    margin-bottom: 18px;
    box-shadow: var(--app-card-shadow-strong);
}

.header-actions {
    gap: 10px;
}

.header-icon-link,
.btn-back-main,
.btn-back-dashboard {
    border-radius: 999px;
}

.card {
    border-radius: var(--app-card-radius);
    border: 1px solid var(--app-card-border);
    box-shadow: var(--app-card-shadow);
    padding: 24px;
    margin-bottom: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 249, 0.96));
}

.card-title {
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(6, 123, 59, 0.12);
    color: var(--primary-dark);
    font-size: 1.08rem;
}

.app-body .form-control,
.app-body input[type="text"],
.app-body input[type="number"],
.app-body input[type="email"],
.app-body input[type="password"],
.app-body input[type="date"],
.app-body select,
.app-body textarea {
    border-radius: 14px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.app-body textarea {
    min-height: 120px;
}

.app-body .form-control:focus,
.app-body input:focus,
.app-body select:focus,
.app-body textarea:focus {
    border-color: rgba(6, 123, 59, 0.34);
    box-shadow: 0 0 0 4px rgba(6, 123, 59, 0.1);
}

.btn-primary,
.btn-primary-intranet,
.btn-intranet {
    border-radius: 14px;
    box-shadow: 0 12px 24px rgba(6, 123, 59, 0.18);
}

.btn-secondary,
.btn-danger {
    border-radius: 14px;
}

.app-body .table-wrapper,
.app-body .table-responsive {
    border-radius: 18px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.app-body table {
    border-radius: 18px;
    overflow: hidden;
}

.app-results-list {
    list-style: none;
    padding-left: 0;
    display: grid;
    gap: 10px;
}

.app-results-list li {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: baseline;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(6, 123, 59, 0.05);
    border: 1px solid rgba(6, 123, 59, 0.1);
}

.app-results-actions {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

.app-chart-card {
    padding: 22px;
}

.app-examen-card,
.app-examen-notes {
    max-width: 940px;
    margin-left: auto;
    margin-right: auto;
}

.app-examen-notes {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 249, 0.97)),
        radial-gradient(circle at top right, rgba(6, 123, 59, 0.08), transparent 42%);
}

.app-examen-list {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 8px;
    color: var(--text-main);
}

.app-examen-form {
    display: grid;
    gap: 24px;
}

.app-examen-grid,
.app-examen-2col {
    display: grid;
    gap: 18px 20px;
}

.app-examen-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.app-examen-2col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
}

.app-examen-panel {
    display: grid;
    gap: 18px;
    padding: 20px;
    border-radius: 22px;
    border: 1px solid rgba(6, 123, 59, 0.1);
    background:
        linear-gradient(180deg, rgba(244, 251, 247, 0.9), rgba(255, 255, 255, 0.96)),
        radial-gradient(circle at top left, rgba(6, 123, 59, 0.08), transparent 38%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.app-examen-panel-title {
    font-size: 1rem;
    font-weight: 900;
    color: var(--primary-dark);
    letter-spacing: 0.01em;
}

.app-examen-field {
    display: grid;
    gap: 8px;
    align-content: start;
}

.app-examen-field label {
    display: block;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1.35;
    color: var(--text-main);
}

.app-body .app-examen-field input[type="number"] {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    font-size: 1rem;
    font-weight: 700;
    color: #173227;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.app-body .app-examen-field input[type="number"]:hover {
    transform: translateY(-1px);
}

.app-body .app-examen-field input.automatica {
    border-color: rgba(217, 119, 6, 0.24);
    background:
        linear-gradient(180deg, rgba(254, 249, 195, 0.96), rgba(253, 230, 138, 0.72));
    color: #713f12;
}

.app-body .app-examen-field input.automatica:focus {
    border-color: rgba(217, 119, 6, 0.45);
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16);
}

.app-body .app-examen-field input.calculada,
.app-body .app-examen-field input[readonly] {
    border-color: rgba(100, 116, 139, 0.22);
    background:
        linear-gradient(180deg, rgba(241, 245, 249, 0.98), rgba(226, 232, 240, 0.92));
    color: #334155;
}

.app-body .app-examen-field input[readonly] {
    cursor: default;
}

.app-examen-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: flex-start;
}

.app-examen-actions .btn-intranet {
    min-width: 220px;
}

.app-examen-result {
    border-radius: 18px;
    padding: 16px 18px;
}

@media (max-width: 768px) {
    .app-body {
        padding: 18px 10px 90px;
    }

    .app-container {
        width: min(1180px, calc(100% - 10px)) !important;
        max-width: min(1180px, calc(100% - 10px)) !important;
    }

    .header-top,
    header.header-intranet-top {
        padding: 20px 18px;
        border-radius: 24px;
    }

    .card {
        padding: 18px;
        border-radius: 20px;
    }

    .app-examen-2col,
    .app-examen-grid {
        grid-template-columns: 1fr;
    }

    .app-examen-panel {
        padding: 16px;
        border-radius: 18px;
    }

    .app-body .app-examen-field input[type="number"] {
        min-height: 46px;
    }
}
