#finanzas {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#finanzas .content-header {
    flex-shrink: 0;
}

#finanzas .content-header-sub {
    margin: 4px 0 0;
    font-size: 13px;
    color: #6b7280;
    font-weight: 400;
}

.finanzas-page {
    padding: 20px 32px 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.finanzas-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.finanzas-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.finanzas-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.finanzas-tab {
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
}

.finanzas-tab:hover {
    color: #111827;
    border-color: #d1d5db;
}

.finanzas-tab.active {
    color: #1d4ed8;
    background: #eff6ff;
    border-color: #93c5fd;
    font-weight: 600;
}

.finanzas-select {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 10px;
    background: #fff;
}

.finanzas-kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.finanzas-kpi {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: visible;
    position: relative;
}

.finanzas-kpi:has(.ins-info:hover),
.finanzas-kpi:has(.ins-info:focus-visible),
.finanzas-kpi:has(.ins-info-open) {
    z-index: 4;
}

.finanzas-kpi-label {
    display: inline-flex;
    align-items: center;
    color: #6b7280;
    font-size: 12px;
}

#finanzas .ins-info-tip,
.ins-info-tip-live {
    width: 280px;
    font-family: 'Inter', sans-serif;
}

.finanzas-kpi-value {
    font-size: 22px;
    color: #111827;
}

.finanzas-kpi-hint {
    color: #9ca3af;
    font-size: 12px;
}

.finanzas-kpi.kpi-warn .finanzas-kpi-value { color: #b54708; }
.finanzas-kpi.kpi-ok .finanzas-kpi-value { color: #027a48; }

.finanzas-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 16px;
    align-items: stretch;
}

.finanzas-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    min-width: 0;
    overflow: hidden;
}

.finanzas-card h3 {
    margin: 0 0 12px;
    font-size: 15px;
    color: #111827;
}

/* Tablas: ancho por contenido para que no se solapen celdas (p. ej. Próximas presentaciones) */
#finanzas .table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    max-height: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

#finanzas .table-wrapper table,
#finanzas table.table-clean {
    table-layout: auto;
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

#finanzas .table-wrapper th,
#finanzas .table-wrapper td {
    width: 1%;
    min-width: 0;
    max-width: none;
    white-space: nowrap;
    box-sizing: border-box;
    overflow: hidden;
    vertical-align: middle;
}

.finanzas-card-wide {
    grid-column: 1 / -1;
}

.finanzas-note,
.finanzas-loading,
.finanzas-error {
    color: #6b7280;
    font-size: 13px;
}

.finanzas-alert {
    background: #fffaeb;
    border: 1px solid #fec84b;
    color: #93370d;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
}

.finanzas-alert a,
.finanzas-iva-banner-link {
    color: #2563eb;
    font-weight: 600;
    text-decoration: none;
}

.finanzas-toggles {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: #374151;
}

.finanzas-manual-form,
.finanzas-liq-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.finanzas-manual-form {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.finanzas-manual-form input,
.finanzas-manual-form select,
.finanzas-liq-form input,
.finanzas-liq-form select {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 10px;
}

.finanzas-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.finanzas-card-header h3 {
    margin: 0;
}

.finanzas-fiscal-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    font-size: 13px;
}

.config-form-hint {
    margin: 0 0 8px;
    font-size: 12px;
    color: #6b7280;
}

.finanzas-tabs-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.finanzas-mobile-filter-btn {
    display: none;
}

@media (max-width: 900px) {
    .finanzas-kpis,
    .finanzas-grid,
    .finanzas-liq-form,
    .finanzas-manual-form {
        grid-template-columns: 1fr;
    }

    .finanzas-page {
        padding: 16px;
    }
}

@media (max-width: 768px) {
    #finanzas .content-header {
        display: none;
    }

    .finanzas-page {
        padding: 12px 0 16px;
    }

    .finanzas-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0 0 8px;
    }

    .finanzas-tabs-row {
        padding: 0 16px 8px;
    }

    .finanzas-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 6px;
    }

    .finanzas-tabs::-webkit-scrollbar {
        display: none;
    }

    .finanzas-tab {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 8px 12px;
        border: none;
        border-radius: 999px;
        background: #f5f5f7;
        color: #1d1d1f;
        font-size: 13px;
    }

    .finanzas-tab.active {
        background: #1d1d1f;
        color: #fff;
        border-color: transparent;
    }

    .finanzas-filters {
        display: none !important;
    }

    .finanzas-mobile-filter-btn {
        display: inline-flex;
        flex-shrink: 0;
    }

    .finanzas-body {
        padding: 0 16px;
    }
}
