/* ================================================================
   Gesaprov HCM — Design System
   ================================================================ */

/* ── Reset & Variables ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --navy-900: #0a0f1e;
    --navy-800: #0f172a;
    --navy-700: #1e293b;
    --navy-600: #334155;
    --blue-600:  #2563eb;
    --blue-500:  #3b82f6;
    --blue-400:  #60a5fa;
    --cyan-500:  #06b6d4;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-900: #0f172a;
    --white:     #ffffff;
    --red-600:   #dc2626;
    --red-100:   #fee2e2;
    --green-600: #16a34a;
    --green-100: #dcfce7;
    --amber-600: #d97706;
    --amber-100: #fef3c7;

    --radius-sm: 0.375rem;
    --radius:    0.625rem;
    --radius-lg: 1rem;
    --radius-xl: 1.25rem;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
    --shadow:    0 4px 16px rgba(15,23,42,.08);
    --shadow-lg: 0 12px 40px rgba(15,23,42,.14);
    --shadow-xl: 0 24px 80px rgba(15,23,42,.18);

    --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --sidebar-w: 260px;
    --topbar-h:  64px;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); color: var(--slate-700); background: var(--slate-100); }
a    { color: inherit; text-decoration: none; }
img  { max-width: 100%; display: block; }

h1 { font-size: 1.625rem; font-weight: 700; color: var(--navy-800); line-height: 1.25; }
h2 { font-size: 1.25rem;  font-weight: 700; color: var(--navy-800); line-height: 1.3;  }
h3 { font-size: 1.05rem;  font-weight: 600; color: var(--navy-700); }

/* ================================================================
   AUTH LAYOUT
   ================================================================ */
.auth-body {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--white);
}

.auth-brand {
    background: linear-gradient(155deg, var(--navy-900) 0%, var(--navy-800) 50%, #0d1f4a 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 4rem 3rem;
    position: relative;
    overflow: hidden;
    gap: 2.5rem;
}
.auth-brand::before {
    content: '';
    position: absolute;
    width: 480px; height: 480px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37,99,235,.22) 0%, transparent 70%);
    top: -130px; right: -100px;
    pointer-events: none;
}
.auth-brand::after {
    content: '';
    position: absolute;
    width: 320px; height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(6,182,212,.14) 0%, transparent 70%);
    bottom: -80px; left: -60px;
    pointer-events: none;
}
.auth-brand-logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 1;
}
.auth-brand-icon {
    width: 54px; height: 54px;
    background: linear-gradient(135deg, var(--blue-500), var(--cyan-500));
    border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    box-shadow: 0 8px 28px rgba(59,130,246,.45);
}
.auth-brand-name {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--white);
    letter-spacing: -0.02em;
}
.auth-brand-name span { color: var(--blue-400); }
.auth-brand-tagline {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--white);
    line-height: 1.45;
    text-align: center;
    position: relative;
    z-index: 1;
    max-width: 320px;
}
.auth-brand-tagline small {
    display: block;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--slate-400);
    margin-top: 0.5rem;
    line-height: 1.6;
}
.auth-brand-features {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
    z-index: 1;
    align-self: stretch;
    max-width: 340px;
}
.auth-brand-features li {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    color: var(--slate-300);
    font-size: 0.9rem;
}
.auth-check {
    flex-shrink: 0;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: rgba(37,99,235,.3);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.65rem;
    color: var(--blue-400);
    border: 1px solid rgba(59,130,246,.4);
}

.auth-form-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 4rem 3rem;
    background: var(--white);
}
.auth-form-inner {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}
.auth-form-header { display: flex; flex-direction: column; gap: 0.4rem; }
.auth-form-header h1 { font-size: 1.875rem; }
.auth-form-header p  { color: var(--slate-500); font-size: 0.9rem; }

.auth-footer {
    text-align: center;
    color: var(--slate-400);
    font-size: 0.8rem;
    margin-top: 0.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--slate-100);
}

@media (max-width: 768px) {
    .auth-body { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
    .auth-form-panel { padding: 2rem 1.5rem; }
}

/* ================================================================
   APP LAYOUT
   ================================================================ */
.app-body {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
}

.sidebar {
    background: var(--navy-800);
    color: var(--white);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 1.375rem 1.25rem 1.125rem;
    border-bottom: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}
.sidebar-brand-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.sidebar-brand-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--blue-500), var(--cyan-500));
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}
.sidebar-brand-text { line-height: 1.2; }
.sidebar-brand-text strong { display: block; font-size: 0.95rem; font-weight: 700; color: var(--white); }
.sidebar-brand-text small  { font-size: 0.68rem; color: var(--slate-400); text-transform: uppercase; letter-spacing: .06em; }

.sidebar-section { padding: 1.25rem 0.875rem 0.75rem; flex: 1; }
.sidebar-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--slate-500);
    padding: 0 0.5rem;
    margin-bottom: 0.5rem;
}
.sidebar-nav { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius);
    color: var(--slate-400);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all .15s ease;
}
.sidebar-nav a:hover  { background: rgba(255,255,255,.07); color: var(--white); }
.sidebar-nav a.active { background: rgba(59,130,246,.2); color: var(--blue-400); }
.nav-icon { font-size: 0.95rem; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
    padding: 1rem 0.875rem;
    border-top: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}
.sidebar-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue-500), var(--cyan-500));
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700; color: var(--white);
    flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name  { font-size: 0.82rem; font-weight: 600; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role  { font-size: 0.68rem; color: var(--slate-500); }
.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.55rem 0.875rem;
    background: rgba(220,38,38,.1);
    border: 1px solid rgba(220,38,38,.2);
    border-radius: var(--radius);
    color: #fca5a5;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    font-family: var(--font);
}
.sidebar-logout:hover { background: rgba(220,38,38,.22); color: var(--white); }

.app-main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    /* Sin esto, una tabla ancha estira la columna de la cuadrícula y toda la
       página se desborda (en vez de desplazarse dentro de su tarjeta). */
    min-width: 0;
    background: #f5f7fb;
}
.app-topbar {
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 1px solid var(--slate-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}
.app-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--slate-500);
}
.app-breadcrumb strong { color: var(--slate-700); font-weight: 600; }
.app-topbar-right { display: flex; align-items: center; gap: 0.875rem; }
.app-company-badge {
    font-size: 0.78rem;
    color: var(--slate-600);
    background: var(--slate-100);
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--slate-200);
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-content {
    flex: 1;
    min-width: 0;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ================================================================
   COMPONENTS
   ================================================================ */

/* Page header */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.page-header h1 { margin-bottom: 0.2rem; }
.page-header .subtitle { color: var(--slate-500); font-size: 0.875rem; }
.page-header-actions { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius-xl);
    border: 1px solid var(--slate-200);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}
.card-stat { position: relative; overflow: hidden; }
.stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    margin-bottom: 1rem;
}
.stat-icon.blue  { background: rgba(59,130,246,.1); color: var(--blue-600); }
.stat-icon.green { background: rgba(22,163,74,.1);  color: var(--green-600); }
.stat-icon.amber { background: rgba(217,119,6,.1);  color: var(--amber-600); }
.stat-icon.navy  { background: rgba(15,23,42,.07);  color: var(--navy-700); }
.stat-title { font-size: 0.75rem; font-weight: 700; color: var(--slate-500); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 0.5rem; }
.stat-value { font-size: 2.1rem; font-weight: 800; color: var(--navy-800); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--slate-400); margin-top: 0.375rem; }

/* Grids */
.grid   { display: grid; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gap-16 { gap: 1rem; }
.gap-20 { gap: 1.25rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.575rem 1.125rem;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: all .15s ease;
    white-space: nowrap;
    line-height: 1.4;
}
.btn-primary  { background: var(--blue-600); color: var(--white); border-color: var(--blue-600); box-shadow: 0 2px 6px rgba(37,99,235,.28); }
.btn-primary:hover  { background: #1d4ed8; border-color: #1d4ed8; box-shadow: 0 4px 14px rgba(37,99,235,.4); transform: translateY(-1px); }
.btn-secondary { background: var(--white); color: var(--slate-700); border-color: var(--slate-300); }
.btn-secondary:hover { background: var(--slate-50,#f8fafc); border-color: var(--slate-400); }
.btn-danger  { background: var(--white); color: var(--red-600); border-color: rgba(220,38,38,.3); }
.btn-danger:hover  { background: var(--red-100); border-color: rgba(220,38,38,.5); }
.btn-ghost   { background: transparent; color: var(--slate-500); border-color: transparent; }
.btn-ghost:hover { background: var(--slate-100); color: var(--slate-700); }
.btn-sm, .btn-small { padding: 0.375rem 0.875rem; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn-lg   { padding: 0.8rem 1.5rem; font-size: 0.95rem; width: 100%; }

/* Forms */
.form-card  { display: flex; flex-direction: column; gap: 1.25rem; }
.form-grid  { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-size: 0.825rem; font-weight: 600; color: var(--slate-700); }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.65rem 0.875rem;
    font-family: var(--font);
    font-size: 0.9rem;
    color: var(--navy-800);
    background: var(--white);
    border: 1.5px solid var(--slate-300);
    border-radius: var(--radius);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.form-group input::placeholder { color: var(--slate-400); }
.form-error { color: var(--red-600); font-size: 0.78rem; }
.form-hint  { color: var(--slate-400); font-size: 0.78rem; }
textarea    { min-height: 100px; resize: vertical; }
.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 0.875rem;
    border-top: 1px solid var(--slate-200);
}

/* Alerts */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    border: 1px solid transparent;
    line-height: 1.5;
}
.alert-danger  { background: var(--red-100);   color: #991b1b; border-color: rgba(220,38,38,.2); }
.alert-success { background: var(--green-100); color: #166534; border-color: rgba(22,163,74,.2); }
.alert-warning { background: var(--amber-100); color: #92400e; border-color: rgba(217,119,6,.2); }
.alert-info    { background: rgba(59,130,246,.07); color: #1d4ed8; border-color: rgba(59,130,246,.18); }

/* Tables */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--slate-200); }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--slate-500);
    background: var(--slate-100);
    border-bottom: 1px solid var(--slate-200);
    white-space: nowrap;
}
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: #f8fafe; }
.table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--slate-100);
    color: var(--slate-700);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: 0.5rem; align-items: center; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}
.badge::before  { content: '●'; font-size: .45rem; }
.badge-green { background: var(--green-100); color: #15803d; }
.badge-red   { background: var(--red-100);   color: #b91c1c; }
.badge-amber { background: var(--amber-100); color: #b45309; }
.badge-blue  { background: rgba(59,130,246,.1); color: #1d4ed8; }
.badge-gray  { background: var(--slate-200); color: var(--slate-600); }

/* Checkbox grid */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 0.6rem;
}
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.625rem 0.875rem;
    background: var(--white);
    border: 1.5px solid var(--slate-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color .15s, background .15s;
    font-size: 0.85rem;
}
.checkbox-item:has(input:checked) {
    border-color: var(--blue-500);
    background: rgba(59,130,246,.04);
    color: var(--blue-600);
}
.checkbox-item input[type=checkbox] { accent-color: var(--blue-600); width: 14px; height: 14px; flex-shrink: 0; }

/* Misc */
.section-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.inline-form     { display: inline-block; margin: 0; }
.text-muted      { color: var(--slate-400); font-size: 0.85rem; }
.divider         { border: none; border-top: 1px solid var(--slate-200); margin: 0.25rem 0; }
.empty-state     { text-align: center; padding: 3rem 1rem; color: var(--slate-400); }
.empty-state-icon { font-size: 2.5rem; margin-bottom: 0.875rem; }

/* Responsive */
@media (max-width: 1024px) {
    .app-body { grid-template-columns: 1fr; }
    .sidebar  { min-height: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; }
    .sidebar-section { padding: 0.5rem 0.875rem; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-footer { width: 100%; }
    .app-content { padding: 1rem; }
    .form-grid { grid-template-columns: 1fr; }
    .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 640px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
    .app-content { padding: 0.875rem; }
    .app-topbar { padding: 0 1rem; }
}

/* ================================================================
   PRINT STYLES — Optimizado para impresion y PDF
   ================================================================ */
@media print {
    .sidebar, .app-topbar, .portal-nav, .portal-header,
    .btn, .form-actions, .page-header-actions, .table-actions,
    #btnAuto, #searchWrapper, [id="dlgCorrect"] {
        display: none !important;
    }
    body, .app-body { grid-template-columns: 1fr !important; }
    .app-main { min-height: auto; }
    .app-content { padding: 0 !important; }
    .card { break-inside: avoid; box-shadow: none; border: 1px solid #e2e8f0; }
    .table { font-size: 11px; }
    .table th, .table td { padding: .4rem .5rem; }
    .badge { border: 1px solid currentColor; }
    h1 { font-size: 1.25rem; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr) !important; }
    .stat-value { font-size: 1.5rem !important; }
    @page { margin: 1.5cm; size: A4; }
    .print-header { display: block !important; }
}
.print-header { display: none; }
/* ============================================================
   Ayuda contextual por pantalla (App\Helpers\Help)
   Se inyecta desde el layout; no requiere marcado en las vistas.
   ============================================================ */
.help-panel {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: .875rem;
    margin-bottom: 1.25rem;
    overflow: hidden;
}
.help-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .75rem 1rem;
    background: none;
    border: 0;
    cursor: pointer;
    font: inherit;
    color: #0369a1;
    text-align: left;
}
.help-toggle:hover { background: rgba(186, 230, 253, .35); }
.help-icon { font-size: 1.05rem; line-height: 1; }
.help-title { flex: 1; font-weight: 700; font-size: .875rem; }
.help-chevron { font-size: .8rem; transition: transform .15s ease; }
.help-panel.is-collapsed .help-chevron { transform: rotate(-90deg); }
.help-panel.is-collapsed .help-body { display: none; }

.help-body { padding: 0 1rem 1rem; font-size: .84rem; color: #0c4a6e; line-height: 1.55; }
.help-intro { margin: 0 0 .875rem; }
.help-block { margin-bottom: .875rem; }
.help-block:last-child { margin-bottom: 0; }
.help-block h4 {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #0284c7;
    margin: 0 0 .375rem;
    font-weight: 700;
}
.help-steps { margin: 0; padding-left: 1.15rem; }
.help-steps li { margin-bottom: .25rem; }

.help-fields { margin: 0; display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: .3rem .875rem; }
.help-fields dt { font-weight: 600; color: #075985; }
.help-fields dd { margin: 0; }

.help-warn { background: #fffbeb; border: 1px solid #fde68a; border-radius: .625rem; padding: .625rem .875rem; color: #92400e; }
.help-warn h4 { color: #b45309; }
.help-warn ul { margin: 0; padding-left: 1.15rem; }
.help-warn li { margin-bottom: .2rem; }

.help-tip { margin: .75rem 0 0; padding-top: .625rem; border-top: 1px dashed #bae6fd; }

@media (max-width: 640px) {
    .help-fields { grid-template-columns: 1fr; gap: .1rem; }
    .help-fields dd { margin-bottom: .45rem; }
}

@media print { .help-panel { display: none !important; } }

/* ============================================================
   Menu lateral con grupos plegables (App\Helpers\Menu)
   ============================================================ */
.nav-group { margin-bottom: .15rem; }

.nav-group-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .55rem .75rem;
    background: none;
    border: 0;
    border-radius: .5rem;
    cursor: pointer;
    font: inherit;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #94a3b8;
    text-align: left;
    transition: background .12s, color .12s;
}
.nav-group-toggle:hover { background: rgba(148,163,184,.1); color: #e2e8f0; }
.nav-group-toggle:focus-visible { outline: 2px solid #60a5fa; outline-offset: -2px; }

.nav-group-icon   { font-size: .95rem; line-height: 1; flex-shrink: 0; }
.nav-group-label  { flex: 1; min-width: 0; }
.nav-group-chevron{ font-size: .7rem; transition: transform .18s ease; flex-shrink: 0; }

/* Plegado: se anima la altura para que no salte de golpe */
.nav-group-body {
    overflow: hidden;
    max-height: 60rem;
    transition: max-height .22s ease;
}
.nav-group:not(.is-open) .nav-group-body { max-height: 0; }
.nav-group:not(.is-open) .nav-group-chevron { transform: rotate(-90deg); }

/* El grupo abierto se marca con una guia vertical */
.nav-group.is-open > .nav-group-toggle { color: #e2e8f0; }
.nav-group.is-open > .nav-group-body { border-left: 1px solid rgba(148,163,184,.18); margin-left: 1.05rem; }
.nav-group.is-open > .nav-group-body > li > a { padding-left: .85rem; }

/* Grupos destacados (HSEQ, RRHH Colombia) */
.nav-group.is-accent > .nav-group-toggle { color: #fca5a5; border-left: 2px solid #dc2626; }
.nav-group.is-accent.is-open > .nav-group-toggle {
    background: linear-gradient(90deg, rgba(220,38,38,.16), transparent);
}

/* Enlaces a portales externos */
.sidebar-nav a.is-externo { color: #60a5fa; }

/* Un grupo plegado que contiene la pantalla activa no deberia existir, pero si
   el usuario lo cierra a mano se le deja una marca para no perder el rastro */
.nav-group:not(.is-open) > .nav-group-toggle.has-active::after {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #60a5fa;
    flex-shrink: 0;
}

@media print { .nav-group { display: none; } }

/* ============================================================
   Refinamientos de acabado
   ============================================================ */

/* --- Tablas -------------------------------------------------
   Encabezado fijo al desplazar listados largos y aviso visual de
   que la tabla continua hacia los lados. */
.table-wrapper {
    max-height: none;
    background:
        linear-gradient(to right, var(--white) 30%, rgba(255,255,255,0)) left center,
        linear-gradient(to left,  var(--white) 30%, rgba(255,255,255,0)) right center,
        radial-gradient(farthest-side at 0 50%,   rgba(15,23,42,.10), transparent) left center,
        radial-gradient(farthest-side at 100% 50%, rgba(15,23,42,.10), transparent) right center;
    background-repeat: no-repeat;
    background-size: 42px 100%, 42px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
}
.table thead th { position: sticky; top: 0; z-index: 2; }

/* Cifras alineadas: los digitos ocupan el mismo ancho y las columnas
   numericas se leen de un vistazo. */
.table td, .stat-value, .table th { font-variant-numeric: tabular-nums; }

/* Fila con enlace: toda la fila responde, no solo el texto */
.table tbody tr:hover { background: #f6f9ff; }

/* --- Estado vacio -------------------------------------------
   En una tabla ancha el td ocupa todo el ancho y el contenido centrado
   quedaba fuera de la pantalla: parecia que la tabla estaba en blanco.
   Se ancla a la izquierda y acompana el desplazamiento horizontal. */
.table .empty-state {
    position: sticky;
    left: 0;
    width: fit-content;
    min-width: min(100%, 32rem);
    margin: 0;
}
.empty-state { padding: 3.25rem 1.25rem; }
.empty-state-icon {
    width: 64px; height: 64px;
    margin: 0 auto 1rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.75rem;
    background: var(--slate-100);
    border-radius: 50%;
}
.empty-state p { color: var(--slate-500); font-weight: 600; font-size: .9rem; }
.empty-state p + p { color: var(--slate-400); font-weight: 400; font-size: .82rem; margin-top: .25rem; }

/* --- Encabezado de pagina ----------------------------------- */
.page-header { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--slate-200); }
/* Sin font-size a proposito: el tamano base ya se reduce en pantallas
   pequenas y esta regla, mas especifica, anularia ese ajuste. */
.page-header h1 { letter-spacing: -.02em; }
/* El subtitulo tambien funciona fuera del encabezado */
.subtitle { color: var(--slate-500); font-size: .875rem; }

/* --- Tarjetas ----------------------------------------------- */
.card { transition: box-shadow .16s ease, transform .16s ease, border-color .16s ease; }
/* Solo las tarjetas dentro de un enlace se elevan: las demas no invitan a hacer clic */
a > .card:hover {
    box-shadow: 0 10px 28px rgba(15,23,42,.10);
    border-color: var(--slate-300);
    transform: translateY(-2px);
}
a:has(> .card) { text-decoration: none; display: block; }

/* --- Foco visible -------------------------------------------
   Necesario para navegar con teclado y lectores de pantalla. */
.btn:focus-visible,
.sidebar-nav a:focus-visible,
.table a:focus-visible,
.help-toggle:focus-visible,
.nav-group-toggle:focus-visible {
    outline: 2px solid var(--blue-500);
    outline-offset: 2px;
    border-radius: var(--radius);
}
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

/* --- Badges -------------------------------------------------- */
.badge { font-variant-numeric: tabular-nums; letter-spacing: .01em; }

/* --- Formularios --------------------------------------------- */
.form-group small { color: var(--slate-400); font-size: .75rem; line-height: 1.45; }
.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled { background: var(--slate-100); color: var(--slate-400); cursor: not-allowed; }
/* Marca los obligatorios sin depender de escribir * a mano */
.form-group input:required:invalid:not(:placeholder-shown) { border-color: rgba(220,38,38,.45); }

/* --- Respeto a la preferencia de menos movimiento ------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
    a > .card:hover, .btn-primary:hover { transform: none; }
}

/* --- Pantallas angostas -------------------------------------- */
@media (max-width: 640px) {
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header-actions { width: 100%; }
    .page-header-actions .btn { flex: 1; justify-content: center; }
    .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .stat-value { font-size: 1.6rem; }
}
@media (max-width: 420px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* --- .data-table ---------------------------------------------
   Nomina y reportes usaban esta clase, que nunca tuvo estilos: esas
   tablas se veian sin bordes, sin relleno y sin encabezado destacado.
   Comparte el aspecto de .table y suma lo propio de un reporte:
   columnas numericas a la derecha y totales resaltados. */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table thead th {
    padding: .75rem 1rem;
    text-align: left;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--slate-500);
    background: var(--slate-100);
    border-bottom: 1px solid var(--slate-200);
    white-space: nowrap;
    position: sticky; top: 0; z-index: 2;
}
.data-table td {
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--slate-100);
    color: var(--slate-700);
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
}
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover { background: #f6f9ff; }
.data-table tbody tr:last-child td { border-bottom: none; }
/* Cifras a la derecha: se comparan de un vistazo */
.data-table td.num, .data-table th.num { text-align: right; }
.data-table tfoot td, .data-table tr.total td {
    background: var(--slate-100);
    font-weight: 700;
    color: var(--navy-800);
    border-top: 2px solid var(--slate-300);
}
.data-table .empty-state { position: sticky; left: 0; width: fit-content; min-width: min(100%, 32rem); margin: 0; }

@media print {
    .data-table thead th { position: static; }
}
