:root {
    --primary: #4a5fc1;
    --primary-dark: #3a4ca0;
    --sidebar-bg: #1e2538;
    --sidebar-hover: #2b3348;
    --sidebar-text: #c8cee0;
    --sidebar-active: #4a5fc1;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Roboto, sans-serif;
    background: #f4f6fb;
    margin: 0;
}

/* ===== LOGIN ===== */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4a5fc1 0%, #6a4fc1 100%);
    padding: 20px;
}
.login-card {
    background: #fff;
    border-radius: 18px;
    padding: 40px 35px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo {
    width: 70px; height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6a4fc1);
    color: #fff;
    display: inline-flex;
    align-items: center; justify-content: center;
    font-size: 34px;
}

/* ===== LAYOUT ===== */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1050;
    transition: transform .25s ease;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 20px;
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,.07);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-brand i { font-size: 26px; color: #7c8cf0; }
.sidebar-nav { padding: 12px 0; flex: 1; }
.sidebar-nav .nav-section {
    padding: 14px 20px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #6d7690;
    font-weight: 600;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: all .15s;
}
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav a.active {
    background: var(--sidebar-hover);
    color: #fff;
    border-left-color: var(--primary);
}
.sidebar-nav a i { font-size: 17px; width: 20px; text-align: center; }

/* Main */
.main-wrap {
    flex: 1;
    margin-left: 250px;
    display: flex;
    flex-direction: column;
    transition: margin-left .25s ease;
}
.topbar {
    background: #fff;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 6px rgba(0,0,0,.05);
    position: sticky;
    top: 0;
    z-index: 1040;
}
.topbar h5 { margin: 0; font-weight: 600; color: #2c3654; }
.btn-toggle {
    display: none;
    background: none; border: none;
    font-size: 24px; color: #2c3654;
}
.user-chip {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px;
    background: #f4f6fb;
    border-radius: 20px;
    font-size: 13px;
    color: #2c3654;
}
.user-chip i { font-size: 20px; color: var(--primary); }

.content { padding: 22px; flex: 1; }

/* Overlay para mobile */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1045;
}
.sidebar-overlay.show { display: block; }

/* Cards resumen */
.stat-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 4px 14px rgba(0,0,0,.05);
    transition: transform .15s, box-shadow .15s;
    height: 100%;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.stat-card .icon {
    width: 54px; height: 54px;
    border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 26px; color: #fff;
    flex-shrink: 0;
}
.stat-card .icon.bg-1 { background: linear-gradient(135deg, #4a5fc1, #7c8cf0); }
.stat-card .icon.bg-2 { background: linear-gradient(135deg, #16a085, #48c9b0); }
.stat-card .icon.bg-3 { background: linear-gradient(135deg, #e67e22, #f39c12); }
.stat-card .icon.bg-4 { background: linear-gradient(135deg, #c0392b, #e74c3c); }
.stat-card .icon.bg-5 { background: linear-gradient(135deg, #8e44ad, #9b59b6); }
.stat-card .icon.bg-6 { background: linear-gradient(135deg, #2980b9, #3498db); }
.stat-card .num { font-size: 26px; font-weight: 700; color: #2c3654; line-height: 1; }
.stat-card .lbl { font-size: 13px; color: #7f8aa3; margin-top: 4px; }

/* Card genérica */
.card-modern {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(0,0,0,.05);
    overflow: hidden;
    border: none;
}
.card-modern .card-header {
    background: #fff;
    border-bottom: 1px solid #eef0f7;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.card-modern .card-header h6 { margin: 0; font-weight: 600; color: #2c3654; }
.card-modern .card-body { padding: 20px; }

/* Tablas */
.table-modern { margin: 0; }
.table-modern thead th {
    background: #f8f9fd;
    color: #56617a;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: .4px;
    border-bottom: 1px solid #eef0f7;
    padding: 12px 14px;
    font-weight: 600;
}
.table-modern tbody td {
    padding: 12px 14px;
    border-color: #f0f2f8;
    vertical-align: middle;
    font-size: 14px;
    color: #3a4256;
}
.table-modern tbody tr:hover { background: #fafbff; }

/* Botones pequeños */
.btn-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0;
    font-size: 14px;
}

/* Responsive */
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-wrap { margin-left: 0; }
    .btn-toggle { display: inline-flex; }
    .content { padding: 15px; }
}

/* Print */
@media print {
    .sidebar, .topbar, .no-print, .btn-toggle { display: none !important; }
    .main-wrap { margin-left: 0 !important; }
    .content { padding: 0 !important; }
    body { background: #fff; }
}
/* ====== REPORTES ====== */
.report-header {
    background: #fff;
    border-radius: 14px;
    padding: 18px 22px;
    margin-bottom: 16px;
    box-shadow: 0 4px 14px rgba(0,0,0,.05);
}
.report-header .inst-name {
    font-weight: 700;
    color: #2c3654;
    font-size: 17px;
    margin: 0;
}
.report-header .inst-sub {
    font-size: 12px;
    color: #7f8aa3;
    margin: 2px 0 0;
}
.report-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 8px 0 0;
}
.report-meta {
    font-size: 12.5px;
    color: #56617a;
    margin: 4px 0 0;
}
.report-meta strong { color: #2c3654; }

.filter-bar {
    background: #fff;
    border-radius: 14px;
    padding: 14px 18px;
    margin-bottom: 16px;
    box-shadow: 0 4px 14px rgba(0,0,0,.05);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: end;
}
.filter-bar .form-label { font-size: 12px; }
.filter-bar .form-select, .filter-bar .form-control { font-size: 13px; }

.report-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 13px;
}
.report-table th {
    background: #f0f3fb;
    color: #3a4ca0;
    font-weight: 600;
    padding: 9px 8px;
    border: 1px solid #d8deef;
    text-align: center;
    font-size: 12px;
}
.report-table td {
    padding: 7px 8px;
    border: 1px solid #e2e7f2;
    color: #2c3654;
}
.report-table tbody tr:nth-child(even) { background: #fafbff; }
.report-table tbody tr:hover { background: #eef2ff; }
.report-table .num { text-align: center; }
.report-table .estado-retirado { color: #c0392b; font-weight: 700; font-size: 11px; }

/* Estadísticas */
.stat-nivel-table { width: 100%; border-collapse: collapse; background: #fff; }
.stat-nivel-table th {
    background: linear-gradient(135deg, #4a5fc1, #6a4fc1);
    color: #fff; padding: 12px; text-align: center;
    font-size: 12.5px; text-transform: uppercase; letter-spacing: 1px;
}
.stat-nivel-table td {
    padding: 11px 14px; border: 1px solid #e2e7f2;
    font-size: 13.5px; color: #2c3654;
}
.stat-nivel-table .nivel-name {
    background: #eef2ff; font-weight: 600; color: #3a4ca0;
    text-align: left; vertical-align: middle;
}
.stat-nivel-table .num { text-align: center; }
.stat-nivel-table .total-nivel {
    background: #e8f4fd; font-weight: 700; color: #2980b9;
    font-size: 15px; text-align: center; vertical-align: middle;
}
.stat-nivel-table .total-general {
    background: linear-gradient(135deg, #16a085, #48c9b0);
    color: #fff; font-weight: 700; font-size: 15px;
    text-align: center;
}

@media print {
    .report-header, .filter-bar { box-shadow: none; border-radius: 0; margin-bottom: 8px; }
    .filter-bar { display: none !important; }
    .report-table, .stat-nivel-table { font-size: 11px; }
    .report-table th, .report-table td { padding: 5px 4px; }
    @page { margin: 12mm 8mm; }
}

/* Fix para que el contenido ocupe todo el ancho */
.main-wrap {
    min-width: 0; /* permite que flexbox respete el 100% */
    width: 100%;
}
.content {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}
.content .row {
    margin-left: 0;
    margin-right: 0;
}
.content .row > [class*="col-"] {
    padding-left: 8px;
    padding-right: 8px;
}

/* Asegurar que el sidebar no se superponga al contenido en desktop */
@media (min-width: 992px) {
    .sidebar { transform: translateX(0); }
    .main-wrap { margin-left: 250px; }
}
@media (max-width: 991px) {
    .main-wrap { margin-left: 0; }
}
/* ====== FIRMAS DE REPORTES ====== */
.firmas-container {
    display: flex;
    justify-content: space-around;
    gap: 40px;
    margin-top: 70px;
    margin-bottom: 20px;
    page-break-inside: avoid;
}
.firma {
    text-align: center;
    flex: 1;
    max-width: 280px;
}
.firma .linea {
    border-top: 1px solid #333;
    margin-bottom: 6px;
    padding-top: 4px;
}
.firma .nombre {
    font-size: 12px;
    font-weight: 600;
    color: #2c3654;
}
.firma .cargo {
    font-size: 11px;
    color: #56617a;
    margin-top: 2px;
}

@media print {
    .firmas-container { margin-top: 60px; }
}

/* ====== IMPRESIÓN COMPACTA PARA ESTADÍSTICAS ====== */
@media print {
    /* Reducir márgenes de página al mínimo */
    @page {
        margin: 8mm 6mm;
    }

    /* Cabecera del reporte más compacta */
    .report-header {
        padding: 6px 10px !important;
        margin-bottom: 4px !important;
    }
    .report-header .inst-name { font-size: 13px !important; }
    .report-header .inst-sub  { font-size: 9px !important; margin: 0 !important; }
    .report-header .report-title { font-size: 12px !important; margin: 2px 0 !important; }
    .report-header .report-meta  { font-size: 9.5px !important; margin: 1px 0 !important; }

    /* Tabla de estadísticas ultra compacta */
    .stat-nivel-table th {
        padding: 4px 6px !important;
        font-size: 10px !important;
        letter-spacing: 0.3px !important;
    }
    .stat-nivel-table td {
        padding: 3px 6px !important;
        font-size: 10.5px !important;
        line-height: 1.1 !important;
    }
    .stat-nivel-table .nivel-name { font-size: 10.5px !important; }
    .stat-nivel-table .total-nivel {
        font-size: 11px !important;
        padding: 3px 6px !important;
    }
    .stat-nivel-table .total-general {
        font-size: 11.5px !important;
        padding: 4px 6px !important;
    }

    /* Reducir bloque de barras de progreso */
    .mt-4 { margin-top: 8px !important; }
    .mt-4 h6 { font-size: 10px !important; margin-bottom: 6px !important; }
    .mb-2 { margin-bottom: 4px !important; }
    .progress { height: 6px !important; }
    .progress + .d-flex,
    .mb-2 .d-flex { margin-bottom: 1px !important; font-size: 9.5px !important; }

    /* Firma más cerca */
    .firmas-container {
        margin-top: 25px !important;
        margin-bottom: 5px !important;
    }
    .firma .nombre { font-size: 10px !important; }
    .firma .cargo  { font-size: 9px !important; }

    /* Evitar saltos innecesarios dentro de la tabla */
    .stat-nivel-table tr { page-break-inside: avoid; }

    /* Quitar sombras y bordes redondeados que consumen tinta */
    .card-modern,
    .report-header {
        box-shadow: none !important;
        border-radius: 0 !important;
    }
}