/* =============================================
   RESET Y BASE
   ============================================= */
* {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    background: #f8f9fa;
    color: #222222;
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

/* =============================================
   HEADER PREMIUM
   ============================================= */
.header-premium {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    background: linear-gradient(135deg, #1a3a5c 0%, #2a5f7a 100%);
    border-bottom: 3px solid #4a9bc7;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.15);
}

.header-content {
    padding: 8px 20px;
    color: #ffffff;
}

.header-content .header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.header-content h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #ffffff;
}

.header-content h2 i {
    color: #4a9bc7;
    margin-right: 6px;
}

.header-content .subtitle {
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    margin-left: 8px;
}

.header-content .badge-version {
    background: rgba(255, 255, 255, 0.12);
    padding: 1px 10px;
    border-radius: 12px;
    font-size: 10px;
    color: #4a9bc7;
    border: 1px solid rgba(74, 155, 199, 0.25);
}

.header-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    padding: 3px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: 3px;
}

.header-info .info-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
}

.header-info .info-item i {
    color: #4a9bc7;
    font-size: 12px;
}

.header-info .info-item strong {
    color: #ffffff;
    font-weight: 600;
}

.header-info .info-item .uep-nombre {
    color: #4a9bc7;
    font-weight: 400;
}

.header-info .info-divider {
    color: rgba(255, 255, 255, 0.15);
    font-size: 14px;
}

.totales-header {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 3px 0;
}

.totales-header .total-item {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
}

.totales-header .total-item .label {
    font-weight: 400;
    opacity: 0.7;
}

.totales-header .total-item .value {
    font-weight: 700;
}

.totales-header .total-item .value.aut {
    color: #4a9bc7;
}

.totales-header .total-item .value.acr {
    color: #28a745;
}

/* =============================================
   LAYOUT PRINCIPAL
   ============================================= */
.padding-top-header {
    padding-top: 95px;
}

.main-container {
    width: 100%;
    max-width: 100% !important;
    margin: 0;
    padding: 0 5px 60px 5px;
}

.padding-bottom-footer {
    padding-bottom: 55px !important;
}

/* =============================================
   TABLA MODERNA
   ============================================= */
.table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    width: 100%;
    padding: 0;
    margin: 0;
    -webkit-overflow-scrolling: touch;
}

.table-wrapper::-webkit-scrollbar {
    height: 10px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: #4a9bc7;
    border-radius: 5px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #1a3a5c;
}

.table-modern {
    width: 100%;
    min-width: 1200px;
    font-size: 13px;
    color: #222222;
    border-collapse: collapse;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    table-layout: fixed;
}

.table-modern thead th {
    background: #f8f9fa;
    color: #1a3a5c;
    font-weight: 600;
    font-size: 11px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    border-bottom: 2px solid #dee2e6;
    padding: 6px 6px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-modern tbody td {
    padding: 5px 6px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
    white-space: nowrap;
    font-size: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-weight: 400;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-modern tbody tr:hover {
    background: #f8f9fa;
}

/* =============================================
   COLUMNAS
   ============================================= */
.table-modern .col-rubro {
    width: 4%;
    min-width: 40px;
    max-width: 55px;
    text-align: center;
}

.table-modern .col-recurso {
    width: 4%;
    min-width: 35px;
    max-width: 50px;
    text-align: center;
    font-weight: 400;
}

.table-modern .col-nombre {
    width: 16%;
    min-width: 100px;
    max-width: 150px;
    font-weight: 400;
    text-align: left;
}

.table-modern .col-grupo {
    width: 10%;
    min-width: 80px;
    max-width: 120px;
    font-weight: 400;
    text-align: left;
}

.table-modern .col-mes {
    width: 4.5%;
    min-width: 45px;
    max-width: 60px;
    text-align: right;
    font-size: 11px;
}

.table-modern .col-total {
    width: 5%;
    min-width: 70px;
    max-width: 90px;
    text-align: right;
    font-size: 12px;
}

/* =============================================
   BADGES / LABELS
   ============================================= */
.badge-rubro-modern {
    font-size: 12px;
    font-weight: 400;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    display: inline-block;
    padding: 1px 5px;
    color: #1a3a5c;
    text-align: center;
    background: transparent !important;
}

.label-grupo {
    font-size: 11px;
    font-weight: 400;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: transparent !important;
    color: #6c757d;
    padding: 1px 3px;
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* =============================================
   MONTOS Y FILAS ESPECIALES
   ============================================= */
.table-modern .monto {
    text-align: right;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    font-weight: 400;
    white-space: nowrap;
    padding-right: 4px;
}

.table-modern .monto-positivo {
    color: #1a3a5c;
    font-weight: 400;
}

.table-modern .monto-cero {
    color: #cccccc;
    font-weight: 400;
}

.table-modern .subtotal-row {
    background: #f0f4f8 !important;
}

.table-modern .subtotal-row td {
    font-size: 12px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.table-modern .subtotal-row td.monto {
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.table-modern .total-row {
    background: #f8f9fa !important;
    border-top: 2px solid #1a3a5c;
}

.table-modern .total-row td {
    font-size: 13px;
    font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.table-modern .total-row td.monto {
    font-weight: 700;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* =============================================
   SECTION HEADER
   ============================================= */
.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 5px;
    margin: 20px 0 12px;
    border-bottom: 2px solid #e9ecef;
}

.section-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1a3a5c;
}

.section-header i {
    color: #4a9bc7;
    font-size: 18px;
}

.section-header .badge-count {
    background: #e9ecef;
    color: #1a3a5c;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

/* =============================================
   FOOTER CONTROL
   ============================================= */
.footer-control {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: #ffffff;
    border-top: 2px solid #4a9bc7;
    box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.08);
    padding: 4px 12px;
    min-height: 38px;
}

.footer-control .control-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.footer-control .control-group .form-group {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 3px;
}

.footer-control .control-group label {
    font-weight: 600;
    color: #1a3a5c;
    font-size: 11px;
    margin: 0;
    white-space: nowrap;
}

.footer-control .form-control {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 12px;
    padding: 2px 6px;
    height: 28px;
    background: #ffffff;
    transition: border-color 0.2s;
}

.footer-control .form-control:focus {
    border-color: #4a9bc7;
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 155, 199, 0.1);
}

.footer-control .btn-consultar-modern {
    background: linear-gradient(135deg, #1a3a5c, #2a5f7a);
    color: #ffffff;
    border: none;
    padding: 3px 14px;
    height: 28px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 12px;
    transition: all 0.2s;
    white-space: nowrap;
    cursor: pointer;
}

.footer-control .btn-consultar-modern:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 58, 92, 0.3);
}

.footer-control .btn-consultar-modern i {
    margin-right: 3px;
    font-size: 11px;
}

.footer-control .btn-outline {
    background: transparent;
    color: #1a3a5c;
    border: 1px solid #dee2e6;
    padding: 3px 10px;
    height: 28px;
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.2s;
    white-space: nowrap;
    cursor: pointer;
}

.footer-control .btn-outline:hover {
    background: #f8f9fa;
    border-color: #4a9bc7;
}

.footer-control .btn-outline i {
    margin-right: 3px;
    font-size: 11px;
}

.footer-control .footer-info {
    color: #6c757d;
    font-size: 10px;
    margin-left: auto;
    white-space: nowrap;
}

.footer-control .footer-info i {
    margin-right: 3px;
}

.footer-control .uep-status {
    font-size: 11px;
    margin-left: 4px;
}

.footer-control .uep-status .encontrada {
    color: #28a745;
}

.footer-control .uep-status .no-encontrada {
    color: #dc3545;
}

.footer-control .uep-status .buscando {
    color: #ffc107;
}

/* =============================================
   SUGERENCIAS UEP
   ============================================= */
.uep-sugerencia {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    max-height: 180px;
    overflow-y: auto;
    z-index: 1001;
    display: none;
    min-width: 280px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 2px;
}

.uep-sugerencia .item {
    padding: 5px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 12px;
    transition: background 0.15s;
}

.uep-sugerencia .item:hover {
    background: #f0f4f8;
}

.uep-sugerencia .item .codigo {
    font-weight: 600;
    color: #1a3a5c;
    font-size: 13px;
}

.uep-sugerencia .item .nombre {
    color: #222222;
    font-size: 12px;
}

.uep-sugerencia .item .ubicacion {
    color: #6c757d;
    font-size: 10px;
}

.uep-sugerencia .item .tipo {
    font-size: 10px;
    color: #6c757d;
    margin-left: 4px;
}

/* =============================================
   LOADER
   ============================================= */
.loader-modern {
    display: none;
    text-align: center;
    padding: 30px 20px;
    background: #ffffff;
    border-radius: 8px;
    margin: 15px 5px;
}

.loader-modern .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e9ecef;
    border-top: 4px solid #4a9bc7;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader-modern .loader-text {
    color: #1a3a5c;
    font-weight: 500;
    font-size: 14px;
}

.loader-modern .loader-subtext {
    color: #6c757d;
    font-size: 12px;
}

/* =============================================
   MENSAJES DE PROGRESO
   ============================================= */
.progress-messages-modern {
    max-height: 120px;
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 4px;
    padding: 8px 12px;
    margin-top: 12px;
    text-align: left;
    font-size: 11px;
}

.progress-messages-modern .mensaje {
    padding: 2px 0;
    border-bottom: 1px solid #e9ecef;
    color: #222222;
}

.progress-messages-modern .mensaje:last-child {
    border-bottom: none;
}

.progress-messages-modern .mensaje-info    { color: #4a9bc7; }
.progress-messages-modern .mensaje-success { color: #28a745; }
.progress-messages-modern .mensaje-warning { color: #856404; }
.progress-messages-modern .mensaje-error   { color: #dc3545; }

/* =============================================
   ERROR
   ============================================= */
.error-modern {
    display: none;
    padding: 15px 20px;
    background: #fff5f5;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    margin: 15px 5px;
    color: #721c24;
}

.error-modern i {
    font-size: 18px;
    margin-right: 8px;
}

.error-modern strong {
    font-size: 14px;
}

/* =============================================
   RESPONSIVE - 768px
   ============================================= */
@media (max-width: 768px) {
    .header-content { padding: 6px 12px; }
    .header-content h2 { font-size: 14px; }
    .header-content .subtitle { font-size: 10px; display: block; margin-left: 0; }
    .header-info { gap: 8px; font-size: 10px; }
    .header-info .info-item { font-size: 10px; }
    .header-info .info-divider { font-size: 10px; }
    .totales-header { gap: 10px; }
    .totales-header .total-item { font-size: 10px; }
    .padding-top-header { padding-top: 90px; }

    .footer-control { padding: 3px 8px; min-height: 34px; }
    .footer-control .control-group { gap: 4px; }
    .footer-control .form-control { font-size: 11px; padding: 1px 4px; height: 24px; width: 70px !important; }
    .footer-control .btn-consultar-modern,
    .footer-control .btn-outline { font-size: 10px; padding: 2px 8px; height: 24px; }
    .footer-control .footer-info { font-size: 9px; }
    .footer-control .control-group label { font-size: 10px; }
    .footer-control .uep-status { font-size: 10px; }
    .padding-bottom-footer { padding-bottom: 50px !important; }

    .uep-sugerencia { min-width: 200px; max-width: 80vw; max-height: 120px; }
    .uep-sugerencia .item { padding: 3px 8px; font-size: 10px; }
    .uep-sugerencia .item .codigo { font-size: 11px; }
    .uep-sugerencia .item .nombre { font-size: 10px; }

    .table-modern { min-width: 1000px; font-size: 10px; }
    .table-modern thead th { font-size: 9px; padding: 4px 4px; }
    .table-modern tbody td { font-size: 10px; padding: 3px 4px; }
    .table-modern .col-rubro { min-width: 30px; }
    .table-modern .col-recurso { min-width: 26px; }
    .table-modern .col-nombre { min-width: 70px; max-width: 100px; }
    .table-modern .col-grupo { min-width: 55px; max-width: 80px; }
    .table-modern .col-mes { min-width: 35px; }
    .table-modern .col-total { min-width: 55px; }
    .table-modern .monto { font-size: 10px; padding-right: 3px; }
    .badge-rubro-modern { font-size: 10px; padding: 0 3px; }
    .label-grupo { font-size: 10px; padding: 0 2px; }
    .table-modern .subtotal-row td { font-size: 10px; }
    .table-modern .total-row td { font-size: 11px; }
    .table-modern .total-row td.monto { font-size: 12px; }
}

/* =============================================
   RESPONSIVE - 480px
   ============================================= */
@media (max-width: 480px) {
    .header-content h2 { font-size: 12px; }
    .header-content .subtitle { font-size: 9px; }
    .header-info { gap: 5px; font-size: 9px; }
    .header-info .info-item { font-size: 9px; }
    .header-info .info-divider { display: none; }
    .totales-header { gap: 5px; }
    .totales-header .total-item { font-size: 9px; }
    .padding-top-header { padding-top: 85px; }

    .footer-control { padding: 2px 5px; min-height: 30px; }
    .footer-control .control-group { gap: 3px; }
    .footer-control .form-control { font-size: 10px; padding: 1px 3px; height: 22px; width: 60px !important; }
    .footer-control .btn-consultar-modern,
    .footer-control .btn-outline { font-size: 9px; padding: 1px 6px; height: 22px; }
    .footer-control .footer-info { font-size: 8px; }
    .footer-control .control-group label { font-size: 9px; }
    .padding-bottom-footer { padding-bottom: 45px !important; }

    .uep-sugerencia { min-width: 180px; max-width: 85vw; max-height: 120px; }
    .uep-sugerencia .item { padding: 3px 8px; font-size: 10px; }
    .uep-sugerencia .item .codigo { font-size: 11px; }
    .uep-sugerencia .item .nombre { font-size: 10px; }

    .table-modern { min-width: 750px; font-size: 9px; }
    .table-modern thead th { font-size: 8px; padding: 3px 2px; letter-spacing: 0; }
    .table-modern tbody td { font-size: 9px; padding: 2px 3px; }
    .table-modern .col-rubro { min-width: 24px; }
    .table-modern .col-recurso { min-width: 20px; }
    .table-modern .col-nombre { min-width: 50px; max-width: 70px; }
    .table-modern .col-grupo { min-width: 40px; max-width: 60px; }
    .table-modern .col-mes { min-width: 28px; }
    .table-modern .col-total { min-width: 45px; }
    .table-modern .monto { font-size: 9px; padding-right: 2px; }
    .badge-rubro-modern { font-size: 9px; padding: 0 2px; }
    .label-grupo { font-size: 9px; padding: 0 1px; }
    .table-modern .subtotal-row td { font-size: 9px; }
    .table-modern .total-row td { font-size: 10px; }
    .table-modern .total-row td.monto { font-size: 11px; }

    .section-header h3 { font-size: 13px; }
    .section-header i { font-size: 15px; }
}

/* =============================================
   IMPRESIÓN
   ============================================= */
@media print {
    .header-premium {
        position: static !important;
        background: #1a3a5c !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .header-content { color: #ffffff !important; }
    .header-content h2 { color: #ffffff !important; }
    .header-content .subtitle { color: rgba(255,255,255,0.7) !important; }
    .header-info .info-item { color: rgba(255,255,255,0.85) !important; }
    .header-info .info-item strong { color: #ffffff !important; }
    .header-info .info-item .uep-nombre { color: #4a9bc7 !important; }
    .totales-header .total-item { color: rgba(255,255,255,0.85) !important; }
    .totales-header .total-item .value.aut { color: #4a9bc7 !important; }
    .totales-header .total-item .value.acr { color: #28a745 !important; }
    .padding-top-header { padding-top: 0 !important; }
    .footer-control { display: none !important; }
    .no-print { display: none !important; }
    .padding-bottom-footer { padding-bottom: 0 !important; }

    .table-modern {
        box-shadow: none !important;
        min-width: 100% !important;
        font-size: 10px !important;
        table-layout: auto !important;
    }
    .table-modern thead th {
        background: #f8f9fa !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        font-size: 9px !important;
    }
    .table-modern tbody td { font-size: 9px !important; }
    .table-modern .total-row {
        background: #f8f9fa !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .table-modern .subtotal-row {
        background: #f0f4f8 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .table-modern .monto { font-size: 9px !important; }
    .table-wrapper { overflow: visible !important; }
    .badge-rubro-modern { font-size: 9px !important; }
    .label-grupo { font-size: 8px !important; }
    .table-modern .col-rubro,
    .table-modern .col-recurso,
    .table-modern .col-nombre,
    .table-modern .col-grupo,
    .table-modern .col-mes,
    .table-modern .col-total {
        min-width: auto !important;
        max-width: none !important;
        width: auto !important;
    }
}