/* =============================================
   GASTOS.CSS - Flujo de Caja - Gastos
   v1.9.4  |  Paleta ROJA  |  Full width
   Tipografía 100% unificada en tabla
   PIA / PIM alineados a la izquierda
   ============================================= */

/* ---------- RESET / BASE ---------- */
* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f7f4f4;
    color: #212529;
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
}

a { color: #a83232; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- HEADER PREMIUM ---------- */
.header-premium {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    background: linear-gradient(135deg, #6b1d1d 0%, #a83232 100%);
    color: #ffffff;
    padding: 10px 18px 12px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .22);
}

.header-content {
    width: 100%;
    margin: 0;
}

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

.header-top h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: .3px;
    color: #ffffff;
}

.header-top h2 i {
    color: #ffb3b3;
    margin-right: 6px;
}

.header-top .subtitle {
    display: block;
    font-size: 10.5px;
    color: #f3d5d5;
    margin-top: 2px;
}

.badge-version {
    display: inline-block;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .25);
    color: #fff0f0;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 10.5px;
    font-weight: 600;
    white-space: nowrap;
}

/* ---------- HEADER INFO ---------- */
.header-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    margin-top: 8px;
    font-size: 11.5px;
    color: #f5dede;
}

.header-info .info-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

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

.header-info .info-item i {
    color: #ffb3b3;
    font-size: 11px;
}

.header-info .info-divider {
    color: rgba(255, 255, 255, .35);
    margin: 0 2px;
}

.header-info .uep-nombre {
    color: #f3d5d5;
    font-size: 10.5px;
    font-style: italic;
    margin-left: 4px;
    max-width: 520px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- HEADER TOTALES ---------- */
.totales-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    margin-top: 9px;
    padding-top: 9px;
    border-top: 1px solid rgba(255, 255, 255, .18);
}

.totales-header .total-item {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    white-space: nowrap;
    padding: 2px 8px;
    border-radius: 4px;
    transition: background .15s ease;
}

.totales-header .total-item .label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: #f3d5d5;
    font-weight: 600;
}

.totales-header .total-item .value {
    font-size: 12.5px;
    font-weight: 700;
    font-family: 'Consolas', 'Courier New', monospace;
}

.totales-header .total-item .value.pia  { color: #ffe08a; }
.totales-header .total-item .value.pim  { color: #ffc26b; }
.totales-header .total-item .value.rec  { color: #ffd6d6; }

.totales-header .total-item.fase-activa {
    background: rgba(255, 255, 255, .15);
    border: 1px solid rgba(255, 255, 255, .3);
}

.totales-header .total-item.fase-activa .label {
    color: #ffffff;
    text-decoration: underline;
}

/* ---------- ESPACIADORES ---------- */
.padding-top-header {
    padding-top: 150px;
}

.padding-bottom-footer {
    padding-bottom: 90px;
}

/* ---------- CONTENEDOR PRINCIPAL ---------- */
.main-container {
    width: 100%;
    margin: 0;
    padding: 0 14px;
    min-height: 55vh;
}

/* ---------- LOADER ---------- */
.loader-modern {
    display: none;
    text-align: center;
    padding: 40px 20px;
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #eee2e2;
    margin: 15px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .04);
}

.loader-modern .spinner {
    width: 46px;
    height: 46px;
    margin: 0 auto 14px;
    border: 4px solid #fbeaea;
    border-top: 4px solid #a83232;
    border-radius: 50%;
    animation: spin .85s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-modern .loader-text {
    font-size: 14px;
    font-weight: 600;
    color: #6b1d1d;
    margin: 0 0 4px;
}

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

/* ---------- MENSAJES DE PROGRESO ---------- */
.progress-messages-modern {
    text-align: left;
    max-width: 720px;
    margin: 18px auto 0;
    padding: 10px 14px;
    background: #fbf7f7;
    border: 1px solid #eee2e2;
    border-radius: 8px;
    max-height: 220px;
    overflow-y: auto;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 11px;
    line-height: 1.55;
}

.progress-messages-modern .mensaje {
    padding: 3px 0;
    border-bottom: 1px dashed #eee2e2;
    word-break: break-word;
}

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

.progress-messages-modern .mensaje-info     { color: #a83232; }
.progress-messages-modern .mensaje-warning  { color: #b8860b; }
.progress-messages-modern .mensaje-error    { color: #7a1010; font-weight: 600; }

/* ---------- ERROR ---------- */
.error-modern {
    display: none;
    padding: 14px 18px;
    background: #fdecea;
    border: 1px solid #f5c6cb;
    border-left: 4px solid #c62828;
    border-radius: 8px;
    color: #7a1a1a;
    font-size: 12.5px;
    margin: 15px 0;
}

.error-modern i {
    color: #c62828;
    font-size: 16px;
    margin-right: 8px;
    vertical-align: middle;
}

/* ---------- SECTION HEADER ---------- */
.section-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    background: linear-gradient(135deg, #fdf3f3 0%, #fbeaea 100%);
    border: 1px solid #f0d4d4;
    border-left: 4px solid #a83232;
    border-radius: 8px;
    padding: 10px 14px;
    margin: 15px 0 12px;
}

.section-header i {
    color: #a83232;
    font-size: 15px;
}

.section-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #6b1d1d;
    letter-spacing: .2px;
}

.section-header .badge-count {
    display: inline-block;
    background: #a83232;
    color: #ffffff;
    padding: 2px 9px;
    border-radius: 12px;
    font-size: 10.5px;
    font-weight: 600;
    margin-left: 4px;
}

.section-header .fase-tag {
    font-size: 11px;
    color: #a83232;
    margin-left: auto;
    font-weight: 700;
    letter-spacing: .4px;
    background: #fdf3f3;
    border: 1px solid #f0c9c9;
    padding: 2px 8px;
    border-radius: 10px;
}

/* =============================================
   TABLA MODERNA - TIPOGRAFÍA 100% UNIFICADA
   Todas las celdas del cuerpo: 11px, sans-serif
   ============================================= */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    background: #ffffff;
    border: 1px solid #eee2e2;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .05);
    margin-bottom: 20px;
}

.table-modern {
    width: 100%;
    border-collapse: collapse;
    min-width: 1100px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 11px;
    line-height: 1.35;
    color: #212529;
    font-variant-numeric: tabular-nums;
}

/* ---------- CABECERAS ---------- */
.table-modern thead th {
    background: #fbeaea;
    color: #6b1d1d;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .2px;
    padding: 8px 6px;
    text-align: center;
    border-bottom: 2px solid #e57373;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}

.table-modern thead tr:first-child th {
    border-bottom: 1px solid #e57373;
}

.table-modern thead th.col-meses-header {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .3px;
}

.table-modern thead th.col-mes {
    font-size: 11px;
    font-weight: 700;
}

.table-modern thead th.col-pia-pim {
    text-align: left;
    padding-left: 10px;
}

/* ---------- CELDAS DEL CUERPO ---------- */
.table-modern tbody td {
    padding: 6px 6px;
    border-bottom: 1px solid #f4eaea;
    vertical-align: middle;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 11px;
    font-weight: 400;
    color: #212529;
    line-height: 1.35;
}

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

/* ---------- COLUMNAS ---------- */
.col-rubro {
    width: 62px;
    text-align: center;
    color: #6b1d1d;
    font-weight: 600;
    font-size: 11px;
    white-space: nowrap;
}

.col-gg {
    width: 110px;
    text-align: center;
    color: #6d4a4a;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: .2px;
    white-space: nowrap;
}

.col-especifica {
    min-width: 240px;
    max-width: 340px;
    text-align: left;
    color: #212529;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.35;
    white-space: normal;
    word-break: break-word;
}

/* ---------- PIA / PIM (izquierda) ---------- */
.col-pia-pim {
    width: 90px;
    text-align: left;
    padding-left: 10px;
    padding-right: 6px;
    color: #6d4a4a;
    font-size: 11px;
    font-weight: 400;
    white-space: nowrap;
}

.col-mes {
    width: 66px;
    text-align: right;
    font-size: 11px;
    font-weight: 400;
    color: #212529;
    white-space: nowrap;
}

.col-total {
    width: 96px;
    text-align: right;
    background: #fdf3f3;
    color: #6b1d1d;
    font-weight: 700;
    font-size: 11px;
    white-space: nowrap;
}

/* ---------- MONTOS ---------- */
.table-modern td.monto,
.table-modern td.col-mes.monto,
.table-modern td.col-total.monto {
    font-size: 11px;
    font-weight: 400;
    text-align: right;
    white-space: nowrap;
    color: #212529;
}

.table-modern td.monto.col-pia-pim,
.table-modern td.col-pia-pim.monto {
    text-align: left;
    padding-left: 10px;
    color: #6d4a4a;
}

.monto-positivo { color: #a83232; }
.monto-cero     { color: #cfc3c3; }

/* ---------- SUBTOTALES ---------- */
.table-modern tr.subtotal-row td {
    background: #fdf3f3;
    color: #6b1d1d;
    border-top: 1px solid #f0c9c9;
    border-bottom: 1px solid #f0c9c9;
    font-size: 11px;
    font-weight: 600;
}

.table-modern tr.subtotal-row td.subtotal-label {
    text-align: right;
    padding-right: 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .2px;
}

.table-modern tr.subtotal-row td.col-pia-pim {
    text-align: left;
    padding-left: 10px;
    font-weight: 600;
}

/* ---------- TOTAL GENERAL ---------- */
.table-modern tr.total-row td {
    background: linear-gradient(135deg, #a83232 0%, #6b1d1d 100%);
    color: #ffffff;
    border-top: 2px solid #6b1d1d;
    font-size: 11px;
    font-weight: 700;
    padding: 10px 6px;
}

.table-modern tr.total-row td.total-label {
    text-align: right;
    padding-right: 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .2px;
}

.table-modern tr.total-row td.col-pia-pim {
    text-align: left;
    padding-left: 10px;
    font-weight: 700;
}

.table-modern tr.total-row td.monto,
.table-modern tr.total-row td.col-mes,
.table-modern tr.total-row td.col-total {
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
}

.table-modern tr.total-row td.col-total {
    background: #6b1d1d;
    font-size: 11px;
}

/* ---------- PIE DEL REPORTE ---------- */
.report-footer {
    text-align: center;
    font-size: 11px;
    color: #6c757d;
    margin-top: 25px;
    padding-top: 12px;
    border-top: 1px solid #eee2e2;
    padding-left: 5px;
    padding-right: 5px;
}

.report-footer i { color: #a83232; }

/* ---------- FOOTER CONTROL ---------- */
.footer-control {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 999;
    background: #ffffff;
    border-top: 1px solid #e8d9d9;
    box-shadow: 0 -3px 10px rgba(0, 0, 0, .07);
    padding: 8px 14px;
}

.footer-control .control-group {
    width: 100%;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
}

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

.footer-control .form-group label {
    margin: 0;
    color: #a83232;
    font-size: 12px;
}

.footer-control .form-control {
    height: 32px;
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid #e0cccc;
    border-radius: 6px;
    background: #ffffff;
    color: #212529;
    outline: none;
    transition: border .15s ease, box-shadow .15s ease;
}

.footer-control .form-control:focus {
    border-color: #a83232;
    box-shadow: 0 0 0 2px rgba(168, 50, 50, .15);
}

/* ---------- BOTONES ---------- */
.btn-consultar-modern {
    background: linear-gradient(135deg, #a83232 0%, #6b1d1d 100%);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 6px 16px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .3px;
    cursor: pointer;
    transition: transform .1s ease, box-shadow .15s ease, opacity .15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-consultar-modern:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(168, 50, 50, .35);
    color: #ffffff;
    text-decoration: none;
}

.btn-consultar-modern:active {
    transform: translateY(0);
    opacity: .9;
}

.btn-consultar-modern i { font-size: 11px; }

.btn-outline {
    background: #ffffff;
    color: #a83232;
    border: 1px solid #a83232;
    border-radius: 6px;
    padding: 6px 11px;
    font-size: 12.5px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-outline:hover {
    background: #a83232;
    color: #ffffff;
    text-decoration: none;
}

.footer-info {
    margin-left: auto;
    font-size: 10.5px;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.footer-info i { color: #a83232; }

.footer-info strong {
    color: #6b1d1d;
    font-weight: 700;
}

/* ---------- UEP STATUS / SUGERENCIAS ---------- */
.uep-status {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    min-width: 0;
}

.uep-status .encontrada    { color: #a83232; }
.uep-status .no-encontrada { color: #dc3545; }
.uep-status .buscando      { color: #b8860b; }

.uep-sugerencia {
    display: none;
    position: absolute;
    bottom: 38px;
    left: 0;
    min-width: 340px;
    max-width: 520px;
    max-height: 320px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #e0cccc;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .15);
    z-index: 1100;
    padding: 4px 0;
}

.uep-sugerencia .item {
    padding: 7px 11px;
    cursor: pointer;
    border-bottom: 1px solid #f4eaea;
    font-size: 11.5px;
    color: #212529;
    transition: background .12s ease;
}

.uep-sugerencia .item:last-child { border-bottom: none; }

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

.uep-sugerencia .item .codigo {
    color: #a83232;
    font-weight: 700;
    font-family: 'Consolas', 'Courier New', monospace;
}

.uep-sugerencia .item .nombre {
    color: #212529;
    font-weight: 500;
}

.uep-sugerencia .item .tipo {
    display: inline-block;
    background: #fbeaea;
    color: #a83232;
    border: 1px solid #f0c9c9;
    padding: 0 5px;
    border-radius: 8px;
    font-size: 9.5px;
    margin-left: 5px;
    vertical-align: middle;
}

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

.uep-sugerencia .item .ubicacion i {
    color: #a83232;
    margin-right: 3px;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 992px) {
    .header-top h2 { font-size: 15px; }
    .header-top .subtitle { font-size: 9.5px; }
    .header-info { font-size: 10.5px; gap: 3px 6px; }
    .header-info .uep-nombre { max-width: 260px; }
    .totales-header { gap: 4px 10px; }
    .totales-header .total-item .label { font-size: 9.5px; }
    .totales-header .total-item .value { font-size: 11.5px; }
    .footer-info { display: none; }
}

@media (max-width: 640px) {
    .header-premium { padding: 8px 10px 10px; }
    .header-top h2 { font-size: 13px; }
    .header-top .subtitle { display: none; }
    .header-info .info-item:nth-child(n+4) { display: none; }
    .totales-header { gap: 3px 8px; }
    .totales-header .total-item { padding: 1px 5px; }
    .totales-header .total-item .label { font-size: 9px; }
    .totales-header .total-item .value { font-size: 10.5px; }

    .main-container { padding: 0 8px; }

    .footer-control { padding: 6px 8px; }
    .footer-control .control-group { gap: 6px; }
    .btn-consultar-modern,
    .btn-outline { padding: 5px 10px; font-size: 11.5px; }
    .footer-control .form-control { height: 30px; font-size: 11.5px; }

    .uep-sugerencia { min-width: 260px; max-width: 90vw; }

    .table-modern { min-width: 1000px; }
}

/* ---------- PRINT ---------- */
@media print {
    .no-print { display: none !important; }

    body {
        background: #ffffff !important;
        font-size: 9px !important;
    }

    .padding-top-header { padding-top: 0 !important; }
    .padding-bottom-footer { padding-bottom: 0 !important; }

    .main-container {
        padding: 0 !important;
        width: 100% !important;
    }

    .section-header {
        background: #ffffff !important;
        border: 1px solid #ccc !important;
        border-left: 3px solid #a83232 !important;
        color: #000 !important;
        page-break-after: avoid;
    }

    .section-header h3 { color: #000 !important; font-size: 11px; }

    .section-header .fase-tag {
        background: #f0e0e0 !important;
        color: #000 !important;
        border: 1px solid #ccc !important;
    }

    .table-wrapper {
        border: 1px solid #999 !important;
        box-shadow: none !important;
        overflow: visible !important;
        page-break-inside: auto;
    }

    .table-modern {
        min-width: 0 !important;
        width: 100% !important;
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
        font-size: 8.5px !important;
    }

    .table-modern thead th,
    .table-modern thead th.col-meses-header,
    .table-modern thead th.col-mes {
        background: #f0e0e0 !important;
        color: #000 !important;
        border-bottom: 1px solid #000 !important;
        position: static !important;
        padding: 3px 2px !important;
        font-size: 8px !important;
        font-weight: 700 !important;
    }

    .table-modern tbody td {
        padding: 2px 3px !important;
        border-bottom: 1px solid #ddd !important;
        font-size: 8px !important;
    }

    .table-modern tr.subtotal-row td {
        background: #f3f3f3 !important;
        color: #000 !important;
    }

    .table-modern tr.total-row td {
        background: #a83232 !important;
        color: #ffffff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .col-rubro    { width: 42px !important; }
    .col-gg       { width: 74px !important; }
    .col-especifica { min-width: 130px !important; max-width: 180px !important; }
    .col-pia-pim  { width: 56px !important; text-align: left !important; padding-left: 6px !important; }
    .col-mes      { width: 40px !important; }
    .col-total    { width: 62px !important; background: #f0e0e0 !important; color: #000 !important; }

    .table-modern tr.total-row td.col-total {
        background: #a83232 !important;
        color: #ffffff !important;
    }

    .loader-modern,
    .error-modern,
    .progress-messages-modern,
    .uep-sugerencia,
    .report-footer {
        display: none !important;
    }
}