﻿/* =========================================================
   DMB FinCore - Notas Fiscais
   Escopo: somente pÃ¡ginas com .invoices-page
   ========================================================= */

.invoices-page {
    width: 100%;
}

.invoices-page .invoice-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.64);
    backdrop-filter: blur(4px);
}

.invoices-page .invoice-modal {
    width: min(1480px, 96vw);
    max-height: calc(100vh - 3rem);
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.34);
}

.invoices-page .invoice-modal > .section-title {
    position: sticky;
    top: 0;
    z-index: 4;
    margin: -1px -1px 1rem;
    padding: 0.25rem 0 1rem;
    background: #ffffff;
}

.invoices-page .invoice-modal-feedback {
    display: grid;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.invoices-page .field-validation-message {
    display: block;
    margin-top: 0.2rem;
    color: #b91c1c;
    font-size: 0.78rem;
    font-weight: 750;
    line-height: 1.3;
}

.invoices-page .form-field:has(.field-validation-message) > input,
.invoices-page .form-field:has(.field-validation-message) > select,
.invoices-page .form-field:has(.field-validation-message) > textarea {
    border-color: #ef4444;
}

.invoices-page .invoice-xml-validated {
    display: grid;
    gap: 0.2rem;
    margin-top: 1rem;
    padding: 0.9rem 1rem;
    border: 1px solid #86efac;
    border-radius: 12px;
    color: #166534;
    background: #f0fdf4;
}

.invoices-page .invoice-xml-validated span {
    color: #39734c;
}

.invoices-page .invoice-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.invoices-page .invoice-pagination .btn {
    min-width: 46px;
    padding: 0.55rem 0.75rem;
    font-size: 1.25rem;
}

.invoices-page .invoice-pagination .btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.invoices-page .invoice-payment-option {
    padding: 0;
}

.invoices-page .invoice-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    min-height: 72px;
    padding: 0.9rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #f8fbff;
    cursor: pointer;
}

.invoices-page .invoice-checkbox-label input[type="checkbox"] {
    flex: 0 0 22px;
    width: 22px;
    min-width: 22px;
    height: 22px;
    min-height: 22px;
    margin: 0;
    padding: 0;
    accent-color: #1d4ed8;
    box-shadow: none;
}

.invoices-page .invoice-checkbox-label span {
    display: grid;
    gap: 0.2rem;
}

.invoices-page .invoice-checkbox-label strong {
    color: #0b1f3a;
}

.invoices-page .invoice-checkbox-label small,
.invoices-page .manual-invoice-items-header small,
.invoices-page .form-field > small {
    color: #64748b;
}

.invoices-page .invoice-installment-controls {
    display: grid;
    grid-template-columns: minmax(140px, 240px) auto;
    gap: 0.75rem;
    align-items: center;
}

.invoices-page .invoice-total-document-row {
    display: grid;
    grid-template-columns: minmax(420px, 1.2fr) minmax(260px, 0.8fr);
    gap: 1rem;
    align-items: start;
}

.invoices-page .invoice-total-field,
.invoices-page .invoice-main-document-field {
    min-width: 0;
}

.invoices-page .invoice-main-document-field input[type="file"] {
    width: 100%;
    min-height: 46px;
    padding: 0.55rem;
    border: 1px dashed #93c5fd;
    border-radius: 10px;
    background: #f8fbff;
}

.invoices-page .manual-invoice-items {
    padding: 1rem;
    border: 1px solid #bfdbfe;
    border-radius: 16px;
    background: #f8fbff;
}

.invoices-page .manual-invoice-items-header,
.invoices-page .manual-invoice-item-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.invoices-page .manual-invoice-items-header > div {
    display: grid;
    gap: 0.25rem;
}

.invoices-page .manual-invoice-items-list {
    display: grid;
    gap: 0.85rem;
    margin-top: 1rem;
}

.invoices-page .manual-invoice-item {
    padding: 1rem;
    border: 1px solid #d7e2f1;
    border-radius: 14px;
    background: #ffffff;
}

.invoices-page .manual-invoice-item-title {
    margin-bottom: 0.8rem;
}

.invoices-page .manual-invoice-item-grid {
    display: grid;
    grid-template-columns: 2fr 1fr repeat(4, minmax(120px, 1fr));
    gap: 0.75rem;
    align-items: end;
}

.invoices-page .manual-item-remove {
    border: 0;
    color: #b91c1c;
    background: transparent;
    font-weight: 800;
    cursor: pointer;
}

.invoices-page .manual-item-remove:disabled {
    color: #94a3b8;
    cursor: not-allowed;
}

.invoices-page .manual-item-total {
    min-height: 70px;
    justify-content: center;
    padding: 0.65rem 0.8rem;
    border: 1px solid #dbe3ef;
    border-radius: 10px;
    background: #eff6ff;
}

.invoices-page .manual-item-total strong {
    display: block;
    margin-top: 0.3rem;
    color: #0b1f3a;
    font-size: 1rem;
}

.invoices-page .manual-rateio-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #dbe3ef;
}

.invoices-page .manual-rateio-header > div {
    display: grid;
    gap: 0.2rem;
}

.invoices-page .manual-rateio-header small {
    color: #64748b;
}

.invoices-page .manual-rateio-list {
    display: grid;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.invoices-page .manual-rateio-row {
    display: grid;
    grid-template-columns: 1fr 0.7fr 1.4fr auto;
    gap: 0.75rem;
    align-items: end;
    padding: 0.8rem;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    background: #f8fbff;
}

.invoices-page .manual-rateio-remove {
    min-height: 46px;
    padding: 0.6rem 0.8rem;
    border: 0;
    color: #b91c1c;
    background: transparent;
    font-weight: 800;
    cursor: pointer;
}

.invoices-page .grouped-invoices-controls,
.invoices-page .grouped-bills-header {
    display: grid;
    grid-template-columns: minmax(240px, 0.6fr) minmax(280px, 1fr);
    gap: 1rem;
    align-items: end;
    margin-bottom: 1rem;
}

.invoices-page .grouped-total-card {
    display: grid;
    gap: 0.25rem;
    min-height: 72px;
    padding: 0.9rem 1rem;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    background: #eff6ff;
}

.invoices-page .grouped-total-card span {
    color: #64748b;
}

.invoices-page .grouped-total-card strong {
    color: #0b1f3a;
    font-size: 1.3rem;
}

.invoices-page .grouped-note-list {
    display: grid;
    gap: 0.8rem;
    margin-bottom: 1.25rem;
}

.invoices-page .grouped-note-card {
    display: grid;
    grid-template-columns: 180px minmax(360px, 1fr) minmax(300px, auto);
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    border: 1px solid #d7e2f1;
    border-radius: 14px;
    background: #f8fbff;
}

.invoices-page .grouped-note-summary {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    color: #475569;
}

.invoices-page .grouped-note-summary strong {
    color: #0b1f3a;
}

.invoices-page .grouped-note-warning {
    display: block;
    margin-top: 0.45rem;
    color: #9a5b00;
    font-weight: 700;
    line-height: 1.35;
}

.invoices-page .manual-installments-table th:last-child,
.invoices-page .manual-installments-table td:last-child {
    width: 34%;
    min-width: 280px;
}

.invoices-page .installment-file-cell {
    vertical-align: middle;
}

.invoices-page .installment-file-cell input[type="file"] {
    width: 100%;
    min-height: 46px;
    padding: 0.55rem;
    border: 1px dashed #93c5fd;
    border-radius: 10px;
    background: #f8fbff;
}

.invoices-page .installment-file-cell small {
    display: block;
    margin-top: 0.35rem;
    color: #047857;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.invoices-page .installment-file-cell .installment-file-required {
    color: #b91c1c;
}

@media (max-width: 1200px) {
    .invoices-page .manual-invoice-item-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .invoices-page .manual-item-description {
        grid-column: span 2;
    }

    .invoices-page .grouped-note-card {
        grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.4fr);
    }

    .invoices-page .grouped-note-summary {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    .invoices-page .manual-rateio-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .invoices-page .invoice-modal-overlay {
        align-items: stretch;
        padding: 0.5rem;
    }

    .invoices-page .invoice-modal {
        width: 100%;
        max-height: calc(100vh - 1rem);
    }

    .invoices-page .table-footer {
        align-items: center;
        flex-direction: column;
        gap: 0.75rem;
    }

    .invoices-page .manual-invoice-items-header {
        align-items: stretch;
        flex-direction: column;
    }

    .invoices-page .manual-invoice-item-grid,
    .invoices-page .invoice-installment-controls,
    .invoices-page .invoice-total-document-row {
        grid-template-columns: 1fr;
    }

    .invoices-page .manual-item-description {
        grid-column: auto;
    }

    .invoices-page .manual-rateio-header,
    .invoices-page .grouped-note-summary {
        align-items: stretch;
        flex-direction: column;
    }

    .invoices-page .manual-rateio-row,
    .invoices-page .grouped-invoices-controls,
    .invoices-page .grouped-bills-header,
    .invoices-page .grouped-note-card {
        grid-template-columns: 1fr;
    }

    .invoices-page .grouped-note-summary {
        grid-column: auto;
    }
}

.xml-import-card,.invoice-items-card{margin-top:24px}.xml-file-field{grid-column:1/-1}.xml-file-field input[type=file]{width:100%;padding:14px;border:1px dashed #9db6da;border-radius:12px;background:#f7faff}.import-processing{color:#315b9b;font-weight:700}.xml-preview{display:grid;grid-template-columns:repeat(6,minmax(120px,1fr));gap:12px;margin-top:18px}.xml-preview>div,.rateio-value{display:flex;flex-direction:column;gap:4px;padding:14px;border:1px solid #d7e2f1;border-radius:12px;background:#f8fbff}.xml-preview span,.rateio-value span,.invoice-item-summary span{font-size:.78rem;color:#607493}.xml-preview strong{color:#081f3d}.xml-preview small{color:#607493}.import-warnings{margin-top:12px;padding:12px 16px;border-radius:12px;background:#fff7dd;color:#805800}.import-warnings p{margin:3px 0}.invoice-item{margin-top:18px;border:1px solid #d7e2f1;border-radius:16px;overflow:hidden}.invoice-item-summary{display:grid;grid-template-columns:2fr repeat(5,1fr) auto;gap:14px;align-items:center;padding:18px;background:#f8fbff}.invoice-item-summary>div{display:flex;flex-direction:column;gap:3px}.compact-table th,.compact-table td{padding:12px 16px}.link-action{border:0;background:none;color:#1757d5;font-weight:700;cursor:pointer;margin-right:10px}.link-action.danger{color:#c72c2c}.rateio-form{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;padding:18px;border-top:1px solid #d7e2f1}.rateio-value{justify-content:center}.rateio-actions{grid-column:1/-1;display:flex;justify-content:flex-end;gap:10px}.add-allocation{margin:14px 18px}
.allocation-feedback{margin:14px 0 4px}

.invoices-page .import-warnings {
    border: 1px solid #f6d77a;
}

.invoices-page .import-warnings strong {
    display: block;
    margin-bottom: 0.4rem;
}

@media(max-width:1100px){.xml-preview{grid-template-columns:repeat(3,1fr)}.invoice-item-summary{grid-template-columns:repeat(3,1fr)}.rateio-form{grid-template-columns:1fr 1fr}}
@media(max-width:700px){.xml-preview,.invoice-item-summary,.rateio-form{grid-template-columns:1fr}.rateio-actions{grid-column:auto}.invoice-items-card{padding:14px}}

.invoices-page .module-header {
    align-items: flex-start;
}

.invoices-page .module-header-actions {
    flex-shrink: 0;
}

.invoices-page .summary-card {
    min-height: 104px;
}

.invoices-page .summary-card > div:last-child {
    flex: 1;
    text-align: center;
}

.invoices-page .summary-card strong {
    margin-top: 0.45rem;
    font-size: clamp(1.35rem, 1.8vw, 1.75rem);
    white-space: nowrap;
}

.invoices-page .summary-icon svg {
    width: 25px;
    height: 25px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.invoices-page .summary-icon.pending {
    color: #b45309;
    background: #fef3c7;
}

.invoices-page section.filter-card.invoice-filter-dialog {
    display: block !important;
    width: 100%;
    margin: 0 0 1rem;
    padding: 1.25rem;
}

.invoices-page .invoice-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.invoices-page .invoice-filter-header h2 {
    margin: 0;
    color: #0b1f3a;
    font-size: 1.5rem;
}

.invoices-page .invoice-dialog-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid #bfdbfe;
    border-radius: 14px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.invoices-page .invoice-filter-dialog .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.invoices-page .invoice-filter-dialog .filter-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.invoices-page .feature-card,
.invoices-page .form-section,
.invoices-page .feature-filters,
.invoices-page .feature-table-card {
    border-color: #dbe3ef;
}

.invoices-page .feature-table tbody tr:hover {
    background: #f8fbff;
}

.invoices-page .feature-status-active,
.invoices-page .status-active {
    color: #059669;
    font-weight: 900;
}

.invoices-page .feature-status-inactive,
.invoices-page .status-inactive {
    color: #64748b;
    font-weight: 900;
}

.invoices-page .feature-money-positive {
    color: #047857;
    font-weight: 900;
}

.invoices-page .feature-money-negative {
    color: #dc2626;
    font-weight: 900;
}

/* A tabela segue o mesmo padrão aprovado em Unidades. */
.invoices-page .table-card,
.invoices-page .table-responsive,
.invoices-page .app-table {
    overflow: visible;
}

.invoices-page .app-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.invoices-page .app-table th,
.invoices-page .app-table td {
    padding-right: 0.55rem;
    padding-left: 0.55rem;
    overflow-wrap: anywhere;
}

.invoices-page .app-table th {
    white-space: normal;
}

.invoices-page .invoice-list-table th:nth-child(1) { width: 20%; }
.invoices-page .invoice-list-table th:nth-child(2) { width: 20%; }
.invoices-page .invoice-list-table th:nth-child(3) { width: 16%; }
.invoices-page .invoice-list-table th:nth-child(4) { width: 12%; }
.invoices-page .invoice-list-table th:nth-child(5) { width: 14%; }
.invoices-page .invoice-list-table th:nth-child(6) { width: 11%; }

.invoices-page .app-table td {
    vertical-align: middle;
}

.invoices-page .invoice-list-table th:nth-child(6),
.invoices-page .invoice-list-table td:nth-child(6) {
    min-width: 0;
    text-align: center;
}

.invoices-page .invoice-list-table th:last-child,
.invoices-page .invoice-list-table td:last-child {
    width: 7%;
    min-width: 62px;
    text-align: center;
}

.invoices-page .invoice-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 78px;
    max-width: 100%;
    padding: 0.38rem 0.75rem;
    border-radius: 999px;
    font-size: 0.86rem;
    font-weight: 800;
    line-height: 1;
    white-space: normal;
    pointer-events: none;
    user-select: none;
}

.invoices-page .invoice-status-badge.active {
    color: #047857;
    background: #d1fae5;
}

.invoices-page .invoice-status-badge.inactive {
    color: #b91c1c;
    background: #fee2e2;
}

.invoices-page .invoice-status-badge.pending {
    color: #92400e;
    background: #fef3c7;
}

.invoices-page .invoice-status-badge.neutral {
    color: #475569;
    background: #e2e8f0;
}

.invoices-page .actions-cell {
    position: relative;
    z-index: 1;
    overflow: visible;
}

.invoices-page .invoice-actions-menu {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.invoices-page .kebab-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 42px;
    padding: 0 0 0.15rem;
    border: 1px solid #bfdbfe;
    border-radius: 14px;
    background: #ffffff;
    color: #1d4ed8;
    font-size: 1.6rem;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    box-shadow: none;
}

.invoices-page .kebab-button:hover {
    background: #eff6ff;
    border-color: #1d4ed8;
}

.invoices-page .kebab-menu {
    position: absolute;
    top: calc(100% + 0.45rem);
    right: 0;
    left: auto;
    z-index: 130;
    min-width: 190px;
    padding: 0.45rem;
    border: 1px solid #dbeafe;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.18);
    transform: none;
}

.invoices-page .app-table tbody tr:nth-last-child(-n + 2) .kebab-menu {
    top: auto;
    bottom: calc(100% + 0.45rem);
}

.invoices-page .kebab-menu button {
    width: 100%;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #0b1f3a;
    padding: 0.75rem 0.9rem;
    text-align: center;
    font-size: 0.96rem;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}

.invoices-page .kebab-menu button:hover {
    background: #eff6ff;
    color: #1d4ed8;
}

.invoices-page .actions-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    border: 0;
    background: transparent;
    cursor: default;
}

.invoices-page .app-table tbody tr {
    position: relative;
    z-index: 0;
}

.invoices-page .app-table tbody tr.actions-row-open {
    z-index: 110;
}

.invoices-page .actions-cell.is-open,
.invoices-page .actions-cell.is-open .invoice-actions-menu {
    z-index: 120;
}

@media (max-width: 760px) {
    .invoices-page .feature-title {
        font-size: 2.25rem;
    }

    .invoices-page .module-header-actions,
    .invoices-page .module-header-actions .btn {
        width: 100%;
    }

    .invoices-page .actions-cell {
        width: 72px;
        min-width: 72px;
    }

    .invoices-page .invoice-filter-dialog { padding: 1rem; }
    .invoices-page .invoice-filter-dialog .filter-grid { grid-template-columns: 1fr; }
    .invoices-page .invoice-filter-dialog .filter-actions { grid-column: auto; flex-direction: column-reverse; }
    .invoices-page .invoice-filter-dialog .filter-actions .btn { width: 100%; }
}
.invoice-boleto-upload-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 0.9rem;
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #bfdbfe;
    border-radius: 16px;
    background: #f8fbff;
}

.invoice-boleto-upload-card > div:first-child {
    display: grid;
    grid-column: 1 / -1;
    gap: 0.2rem;
}

.invoice-boleto-upload-card small {
    color: #64748b;
}
