:root {
    --page-background: #eef1f5;
    --panel-background: #ffffff;
    --header-background: #183b5b;
    --header-border: #102d47;
    --primary: #1f6fa9;
    --primary-hover: #195d8d;
    --border: #d6dde5;
    --border-dark: #bec8d3;
    --text-primary: #1f2933;
    --text-secondary: #637282;
    --table-header: #edf3f8;
    --table-row-hover: #f7fafc;
    --error-background: #fff1f1;
    --error-text: #a12626;
    --shadow: 0 2px 10px rgba(25, 45, 65, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--page-background);
    color: var(--text-primary);
}

/*
 * Author CSS rules such as `.results-state { display: grid; }` can override the
 * browser's default handling of the hidden attribute. This guarantees that
 * loading, empty, table, and pagination states are mutually exclusive.
 */
[hidden] {
    display: none !important;
}

button,
input,
select {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
}

.app-header {
    display: flex;
    align-items: center;
    min-height: 82px;
    padding: 18px 30px;
    background: var(--header-background);
    border-bottom: 1px solid var(--header-border);
    color: #ffffff;
}

.app-header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.app-header p {
    margin: 5px 0 0;
    font-size: 13px;
    color: #c9d8e5;
}

/* Tabs share one shell so future workflows can replace only the content area. */
.tab-navigation {
    display: flex;
    gap: 2px;
    padding: 0 30px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
}

.tab-button {
    min-width: 150px;
    padding: 15px 22px 13px;
    border: 0;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.tab-button.active {
    border-bottom-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.tab-button:disabled {
    color: #a5afb8;
    cursor: not-allowed;
}

.tab-content {
    padding: 24px 30px 30px;
}

.tab-heading {
    margin-bottom: 18px;
}

.tab-heading h2 {
    margin: 0;
    font-size: 22px;
}

.tab-heading p {
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.report-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.filter-panel,
.results-panel {
    background: var(--panel-background);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.filter-panel {
    padding: 20px;
}

.panel-heading {
    padding-bottom: 16px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.panel-heading h3,
.results-header h3 {
    margin: 0;
    font-size: 17px;
}

.panel-heading p,
.results-header p {
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.4;
}

.form-field {
    margin-bottom: 16px;
}

.form-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
}

.form-field input {
    width: 100%;
    height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--border-dark);
    border-radius: 3px;
    color: var(--text-primary);
    background: #ffffff;
}

.form-field select {
    width: 100%;
    height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--border-dark);
    border-radius: 3px;
    color: var(--text-primary);
    background: #ffffff;
}

.form-field select:focus {
    outline: 2px solid rgba(31, 111, 169, 0.2);
    border-color: var(--primary);
}

.form-field input:focus {
    outline: 2px solid rgba(31, 111, 169, 0.2);
    border-color: var(--primary);
}

.filter-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 22px;
}

.filter-actions .button {
    width: 100%;
}

.button {
    min-height: 38px;
    padding: 8px 18px;
    border: 1px solid transparent;
    border-radius: 3px;
    font-weight: 600;
    cursor: pointer;
}

.button:disabled {
    opacity: 0.65;
    cursor: wait;
}

.button-primary {
    background: var(--primary);
    color: #ffffff;
}

.button-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.button-secondary {
    background: #ffffff;
    border-color: var(--border-dark);
    color: var(--text-primary);
}

.results-panel {
    min-width: 0;
    overflow: hidden;
}

.results-header {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.results-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.button-export {
    min-height: 34px;
    padding: 6px 14px;
    font-size: 13px;
}

.results-state {
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    text-align: center;
    color: var(--text-secondary);
}

.results-state.error {
    min-height: 54px;
    margin: 14px 20px;
    border: 1px solid #efb9b9;
    border-radius: 3px;
    background: var(--error-background);
    color: var(--error-text);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    background: #ffffff;
}

th,
td {
    padding: 11px 13px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

th:first-child,
td:first-child {
    border-left: 1px solid var(--border);
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--table-header);
    color: #34495e;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    user-select: none;
}

td {
    font-size: 13px;
    background: #ffffff;
}

tbody tr:nth-child(even) td {
    background: #fbfdff;
}

tbody tr:hover td {
    background: var(--table-row-hover);
}

.sortable-column {
    cursor: pointer;
}

.sortable-column::after {
    content: " \21C5"; /* ? */
    color: #8795a3;
    font-size: 11px;
    font-weight: 400;
}

.sortable-column.sort-asc::after {
    content: " \2191"; /* ? */
    color: var(--primary);
    font-weight: 700;
}

.sortable-column.sort-desc::after {
    content: " \2193"; /* ? */
    color: var(--primary);
    font-weight: 700;
}

.column-resizer {
    position: absolute;
    top: 0;
    right: -3px;
    bottom: 0;
    width: 7px;
    cursor: col-resize;
    z-index: 2;
}

.column-resizer:hover {
    background: rgba(43, 108, 176, 0.18);
}

.column-resizing {
    cursor: col-resize;
    user-select: none;
}

.numeric-column {
    text-align: left;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 850px) {
    .app-header,
    .tab-navigation,
    .tab-content {
        padding-left: 18px;
        padding-right: 18px;
    }

    .report-layout {
        grid-template-columns: 1fr;
    }

    .filter-panel {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .tab-navigation {
        overflow-x: auto;
    }

    .tab-button {
        min-width: 130px;
    }

    .filter-actions {
        flex-direction: column;
    }

    .button {
        width: 100%;
    }
}

/*Date and Pagination CSS */
.field-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
}

.date-range-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.date-range-item label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-secondary);
}

.date-range-item input {
    width: 100%;
    height: 38px;
    padding: 6px 7px;
    border: 1px solid var(--border-dark);
    border-radius: 3px;
    background: #ffffff;
}

.table-container {
    width: 100%;
    max-height: calc(100vh - 330px);
    min-height: 220px;
    overflow-y: auto;
    overflow-x: hidden;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    min-height: 58px;
    padding: 10px 18px;
    border-top: 1px solid var(--border);
    background: #ffffff;
}

.pagination-button {
    min-width: 82px;
    height: 36px;
    padding: 7px 14px;
    border: 1px solid var(--border-dark);
    border-radius: 3px;
    background: #ffffff;
    color: var(--text-primary);
    cursor: pointer;
}

.pagination-button:hover:not(:disabled) {
    background: var(--table-header);
}

.pagination-button:disabled {
    color: #9aa5af;
    background: #f4f6f8;
    cursor: not-allowed;
}

.pagination-info {
    min-width: 105px;
    text-align: center;
    font-size: 13px;
}
/*
 * The upper pagination separates itself from the table with a bottom border.
 * The lower pagination uses a top border to close the results grid.
 */
.pagination-bottom {
    border-top: 1px solid var(--border);
    border-bottom: 0;
}
/* end of date and pagination setup */

/* Invoice Processing styles */
.workflow-tab {
    width: 100%;
}

.invoice-processing-layout {
    display: grid;
    grid-template-columns: 350px minmax(0, 1fr);
    gap: 12px;
    min-height: calc(100vh - 210px);
}

.invoice-sidebar {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 12px;
    min-width: 0;
}

.invoice-queue-panel,
.invoice-list-panel,
.invoice-detail-panel {
    background: var(--panel-background);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.invoice-queue-panel {
    padding: 8px;
}

.invoice-queue-button {
    width: 100%;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-primary);
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.invoice-queue-button:hover {
    background: #f3f7fb;
}

.invoice-queue-button.active {
    background: #dceafb;
    color: #163d61;
}

.queue-count {
    min-width: 30px;
    padding: 3px 9px;
    border-radius: 14px;
    background: #edf2f7;
    color: var(--text-secondary);
    font-size: 12px;
    text-align: center;
}

.invoice-queue-button.active .queue-count {
    background: #ffffff;
    color: var(--primary);
}

.invoice-list-panel {
    min-height: 420px;
    overflow: hidden;
}

.invoice-list-header {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.invoice-list-header h3 {
    margin: 0;
    font-size: 16px;
}

.invoice-refresh-button {
    min-height: 36px;
    padding: 7px 14px;
}

.invoice-list-status {
    padding: 18px;
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
}

.invoice-list-status.error {
    color: var(--error-text);
    background: var(--error-background);
}

.invoice-item-list {
    max-height: calc(100vh - 380px);
    min-height: 340px;
    padding: 8px;
    overflow-y: auto;
}

.invoice-item {
    width: 100%;
    display: block;
    margin-bottom: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #ffffff;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
}

.invoice-item:hover {
    background: #f5f8fc;
    border-color: #aebfd1;
}

.invoice-item.selected {
    background: #e7f0fb;
    border-color: var(--primary);
}

.invoice-item-title {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 700;
}

.invoice-item-description {
    display: block;
    overflow: hidden;
    color: #314559;
    font-size: 12px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.invoice-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 12px;
    margin-top: 7px;
    color: var(--text-secondary);
    font-size: 11px;
}

.invoice-error-message {
    margin-top: 7px;
    color: #a12626;
    font-size: 12px;
    line-height: 1.35;
}

.invoice-detail-panel {
    min-width: 0;
    min-height: 600px;
    overflow: hidden;
}

/*
 * The invoice review form needs more horizontal space than the normal tables,
 * so the sidebar/detail layout stacks earlier when the browser is narrowed.
 */
@media (max-width: 1250px) {
    .invoice-processing-layout {
        grid-template-columns: 1fr;
    }

    .invoice-sidebar {
        grid-template-rows: auto auto;
    }

    .invoice-item-list {
        max-height: 360px;
    }

    .invoice-detail-panel {
        min-height: 450px;
    }
}

.invoice-detail-placeholder {
    min-height: 600px;
    display: grid;
    place-items: center;
    padding: 30px;
    color: var(--text-secondary);
    text-align: center;
}

.invoice-error-frame {
    display: block;
    width: 100%;
    min-height: 100vh;
    border: 0;
    background: #ffffff;
}

/* Payment Processing uses the same report-style layout as Sent to Acumatica. */
.payment-processing-layout {
    display: grid;
    grid-template-columns: 350px minmax(0, 1fr);
    gap: 12px;
    min-height: calc(100vh - 210px);
}

.payment-sidebar {
    display: grid;
    grid-template-rows: auto auto;
    align-content: start;
    gap: 12px;
    min-width: 0;
}

.payment-queue-button {
    width: 100%;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-primary);
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.payment-queue-button:hover {
    background: #f3f7fb;
}

.payment-queue-button.active {
    background: #dceafb;
    color: #163d61;
}

.payment-queue-button.active .queue-count {
    background: #ffffff;
    color: var(--primary);
}

@media (max-width: 1050px) {
    .payment-processing-layout {
        grid-template-columns: 360px minmax(0, 1fr);
    }
}

@media (max-width: 850px) {
    .payment-processing-layout {
        grid-template-columns: 1fr;
    }
}
/* Customer Sync now uses the same two-column queue/report layout as the other tabs. */
.customer-sync-layout {
    display: grid;
    grid-template-columns: 350px minmax(0, 1fr);
    gap: 12px;
    min-height: calc(100vh - 210px);
}

.customer-sidebar {
    display: grid;
    grid-template-rows: auto auto;
    align-content: start;
    gap: 12px;
    min-width: 0;
}

.customer-queue-button {
    width: 100%;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-primary);
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.customer-queue-button:hover {
    background: #f3f7fb;
}

.customer-queue-button.active {
    background: #dceafb;
    color: #163d61;
}

.customer-queue-button.active .queue-count {
    background: #ffffff;
    color: var(--primary);
}

@media (max-width: 1050px) {
    .customer-sync-layout {
        grid-template-columns: 360px minmax(0, 1fr);
    }
}

@media (max-width: 850px) {
    .customer-sync-layout {
        grid-template-columns: 1fr;
    }
}
/*
 * Customer Sync and Payment Processing can hide the second sidebar row when
 * the Errors queue is selected. Without this, CSS Grid stretches the remaining
 * auto row and makes the queue card fill the sidebar height.
 */
.customer-sidebar,
.payment-sidebar {
    align-content: start;
}

/*
 * Keep queue cards at their natural content height even when their parent
 * sidebar stretches to match the report panel height.
 */
.customer-sidebar .invoice-queue-panel,
.payment-sidebar .invoice-queue-panel {
    align-self: start;
}

.invoice-review-host {
    min-height: 600px;
    padding: 20px;
    overflow: auto;
    background: #f4f4f4;
}

.invoice-submit-target {
    width: 0;
    height: 0;
    border: 0;
}

.invoice-review-input-error {
    border-color: #d9534f !important;
    background: #fff5f5 !important;
    outline: 2px solid rgba(217, 83, 79, 0.2);
}

.invoice-review-form {
    width: 100%;
    max-width: none;
    background: #ffffff;
    border: 1px solid #999;
    color: #000000;
}

.invoice-review-header,
.invoice-review-gl-header {
    background: #1f3a50;
    color: #ffffff;
    font-weight: 700;
}

.invoice-review-header {
    padding: 12px 14px;
}

.invoice-review-top-section {
    padding: 14px 18px 18px;
    background: #ffffff;
}

.invoice-review-field-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px 18px;
    align-items: end;
}

.invoice-review-field {
    min-width: 0;
}

.invoice-review-field label {
    display: block;
    margin: 0 0 3px;
    font-size: 12px;
    font-weight: 700;
}

.invoice-review-field input,
.invoice-review-field select {
    width: 100%;
    height: 25px;
    padding: 2px 6px;
    border: 1px solid #999;
    border-radius: 0;
    background: #ffffff;
    color: #000000;
}

.invoice-review-error-box {
    width: 100%;
    margin-top: 16px;
    border: 1px solid #d9534f;
    background: #ffffff;
}

.invoice-review-error-title {
    padding: 10px;
    background: #c04b4b;
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
}

.invoice-review-error-box textarea {
    width: 100%;
    min-height: 100px;
    padding: 8px;
    border: 0;
    resize: vertical;
    font: inherit;
}

.invoice-review-gl-section {
    padding-bottom: 24px;
    background: #878d91;
}

.invoice-review-gl-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
}

.invoice-review-table {
    width: calc(100% - 34px);
    margin: 0 17px;
    table-layout: fixed;
    border-collapse: collapse;
    background: #ffffff;
}

.customer-results-col-id {
    width: 14%;
}

.customer-results-col-name {
    width: 28%;
}

.customer-results-col-credit-code {
    width: 14%;
}

.customer-results-col-credit {
    width: 14%;
}

.customer-results-col-date {
    width: 15%;
}

.error-results-col-customer {
    width: 14%;
}

.error-results-col-error {
    width: 30%;
}

.error-results-col-missing {
    width: 17%;
}

.error-results-col-review {
    width: 14%;
}

.error-results-col-amount {
    width: 12%;
}

.error-results-col-date {
    width: 13%;
}

.invoice-sent-col-id {
    width: 14%;
}

.invoice-sent-col-customer {
    width: 30%;
}

.invoice-sent-col-total {
    width: 13%;
}

.invoice-sent-col-type {
    width: 15%;
}

.invoice-sent-col-released {
    width: 10%;
}

.invoice-sent-col-date {
    width: 18%;
}

.payment-main-col-date {
    width: 13%;
}

.payment-main-col-ref {
    width: 10%;
}

.payment-main-col-customer {
    width: 22%;
}

.payment-main-col-acu {
    width: 14%;
}

.payment-main-col-invoice {
    width: 11%;
}

.payment-main-col-amount {
    width: 11%;
}

.payment-main-col-status {
    width: 8%;
}

/*
 * Keep the desktop GL Line Coding table compact before switching to the
 * tablet/mobile card layout. The action column is wide enough for "Remove"
 * while smaller numeric/code columns give space back first.
 */
.invoice-review-col-branch {
    width: 14%;
}

.invoice-review-col-inventory {
    width: 12%;
}

.invoice-review-col-gl-account {
    width: 12%;
}

.invoice-review-col-description {
    width: 24%;
}

.invoice-review-col-qty {
    width: 7%;
}

.invoice-review-col-uom {
    width: 8%;
}

.invoice-review-col-amount {
    width: 12%;
}

.invoice-review-col-action {
    width: 11%;
}

.invoice-review-table th,
.invoice-review-table td {
    padding: 6px 4px;
    border: 0;
    background: #ffffff;
    color: #000000;
}

.invoice-review-table th {
    position: static;
    text-align: center;
    font-size: 13px;
    text-transform: none;
    letter-spacing: 0;
}

.invoice-review-table input,
.invoice-review-table select {
    width: 100%;
    min-width: 0;
    height: 25px;
    padding: 2px 6px;
    border: 1px solid #999;
    border-radius: 0;
}

.invoice-review-table input,
.invoice-review-table select {
    font-size: 13px;
}

.invoice-review-action-cell {
    text-align: center;
}

.invoice-review-total-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    width: calc(100% - 34px);
    margin: 10px 17px 0;
}

.invoice-review-total-row label {
    color: #ffffff;
    font-weight: 700;
}

.invoice-review-total-row input {
    width: 90px;
    height: 25px;
    border: 1px solid #999;
}

.invoice-review-actions {
    display: flex;
    gap: 8px;
    padding: 12px 17px 0;
}

.invoice-review-add-button,
.invoice-review-remove-button,
.invoice-review-actions button {
    min-height: 28px;
    padding: 4px 9px;
    border: 1px solid #777;
    border-radius: 0;
    background: #d9dedf;
    color: #000000;
    font-weight: 700;
    cursor: pointer;
}

/*
 * The action column should not split "Remove" into multiple lines. Other GL
 * fields are allowed to shrink before the layout switches to tablet/mobile.
 */
.invoice-review-remove-button {
    white-space: nowrap;
    padding-left: 7px;
    padding-right: 7px;
}

@media (max-width: 1350px) {
    .invoice-review-field-grid {
        grid-template-columns: repeat(3, minmax(150px, 1fr));
    }
}

@media (max-width: 1050px) {
    .invoice-review-field-grid {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
    }

    .invoice-review-table colgroup,
    .invoice-review-table thead {
        display: none;
    }

    .invoice-review-table,
    .invoice-review-table tbody {
        display: block;
    }

    .invoice-review-table tr {
        display: grid;
        grid-template-columns: 110px 110px 110px minmax(200px, 1fr) 65px 80px 100px 80px;
        gap: 6px;
        margin-bottom: 10px;
        padding: 8px;
        border: 1px solid #b8b8b8;
        background: #ffffff;
    }

    .invoice-review-table td {
        display: block;
        width: 100%;
        padding: 0;
    }

    .invoice-review-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 3px;
        font-size: 11px;
        font-weight: 700;
        color: #333333;
    }

    .invoice-review-action-cell {
        text-align: left;
    }
}

@media (max-width: 760px) {
    .invoice-review-host {
        padding: 12px;
    }

    .invoice-review-field-grid {
        grid-template-columns: 1fr;
    }

    .invoice-review-table,
    .invoice-review-total-row {
        width: calc(100% - 20px);
        margin-left: 10px;
        margin-right: 10px;
    }

    .invoice-review-table tr {
        grid-template-columns: 1fr 1fr 72px;
    }

    .invoice-review-cell-description {
        grid-column: 1 / -1;
    }

    .invoice-review-cell-branch,
    .invoice-review-cell-inventory,
    .invoice-review-cell-gl-account {
        grid-column: span 1;
    }

    .invoice-review-cell-qty {
        grid-column: span 1;
    }

    .invoice-review-cell-uom {
        grid-column: span 1;
    }

    .invoice-review-cell-amount {
        grid-column: span 1;
    }

    .invoice-review-action-cell {
        grid-column: span 1;
    }

    .invoice-review-actions {
        flex-direction: column;
        padding-left: 10px;
        padding-right: 10px;
    }

    .invoice-review-actions button {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .invoice-review-table tr {
        grid-template-columns: 1fr 1fr;
    }

    .invoice-review-cell-description {
        grid-column: 1 / -1;
    }

    .invoice-review-cell-qty,
    .invoice-review-cell-uom,
    .invoice-review-cell-amount,
    .invoice-review-action-cell {
        grid-column: span 1;
    }
}

/*
 * Modern invoice review styling.
 *
 * This keeps the review form visually aligned with the portal: white cards,
 * rounded panels, blue section headers, soft borders, and consistent buttons.
 */
.invoice-review-host {
    padding: 20px;
    background: #eef1f5;
}

.invoice-review-form {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: var(--shadow);
    color: var(--text-primary);
}

.invoice-review-header {
    padding: 14px 18px;
    background: var(--header-background);
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.invoice-review-top-section {
    padding: 18px;
    background: #ffffff;
}

.invoice-review-field-grid {
    gap: 14px 18px;
}

.invoice-review-field label {
    margin-bottom: 5px;
    color: #34495e;
    font-size: 12px;
    font-weight: 700;
}

.invoice-review-field input,
.invoice-review-field select {
    height: 36px;
    padding: 7px 9px;
    border: 1px solid var(--border-dark);
    border-radius: 5px;
    background: #ffffff;
    color: var(--text-primary);
}

.invoice-review-field input:focus,
.invoice-review-field select:focus,
.invoice-review-table input:focus {
    outline: 2px solid rgba(31, 111, 169, 0.18);
    border-color: var(--primary);
}

.invoice-review-field input[readonly] {
    background: #f4f6f8;
    color: var(--text-secondary);
}

.invoice-review-error-box {
    margin-top: 18px;
    overflow: hidden;
    border: 1px solid #efb9b9;
    border-radius: 8px;
    background: #ffffff;
}

.invoice-review-error-title {
    padding: 10px 12px;
    background: var(--error-background);
    color: var(--error-text);
    font-size: 13px;
    font-weight: 700;
}

.invoice-review-error-box textarea {
    min-height: 90px;
    padding: 10px 12px;
    color: var(--text-primary);
    background: #ffffff;
}

.invoice-review-gl-section {
    padding-bottom: 20px;
    background: #f7fafc;
    border-top: 1px solid var(--border);
}

.invoice-review-gl-header {
    padding: 12px 18px;
    background: var(--table-header);
    border-bottom: 1px solid var(--border);
    color: #34495e;
}

.invoice-review-table {
    width: calc(100% - 36px);
    margin: 16px 18px 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
}

.invoice-review-table th {
    padding: 10px 8px;
    background: var(--table-header);
    color: #34495e;
    font-size: 12px;
    font-weight: 700;
}

.invoice-review-table td {
    padding: 8px;
    border-top: 1px solid var(--border);
    background: #ffffff;
}

.invoice-review-table input,
.invoice-review-table select {
    height: 34px;
    padding: 6px 8px;
    border: 1px solid var(--border-dark);
    border-radius: 5px;
    color: var(--text-primary);
}

.invoice-review-total-row {
    width: calc(100% - 36px);
    margin: 14px 18px 0;
}

.invoice-review-total-row label {
    color: #34495e;
}

.invoice-review-total-row input {
    width: 120px;
    height: 34px;
    padding: 6px 8px;
    border: 1px solid var(--border-dark);
    border-radius: 5px;
    color: var(--text-primary);
    background: #ffffff;
}

.invoice-review-actions {
    padding: 16px 18px 0;
}

.invoice-review-add-button,
.invoice-review-remove-button,
.invoice-review-actions button {
    min-height: 34px;
    padding: 7px 13px;
    border: 1px solid var(--border-dark);
    border-radius: 5px;
    background: #ffffff;
    color: var(--text-primary);
    font-weight: 700;
    cursor: pointer;
}

.invoice-review-add-button:hover,
.invoice-review-remove-button:hover,
.invoice-review-actions button:hover:not(:disabled) {
    background: var(--table-header);
}

.invoice-review-actions button[value="retry_btn"] {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
}

.invoice-review-actions button[value="retry_btn"]:hover:not(:disabled) {
    background: var(--primary-hover);
}

.invoice-review-actions button:disabled {
    opacity: 0.65;
    cursor: wait;
}

.invoice-review-input-error {
    border-color: #d9534f !important;
    background: #fff5f5 !important;
    outline: 2px solid rgba(217, 83, 79, 0.18);
}
.invoice-review-bottom-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: calc(100% - 36px);
    margin: 14px 18px 0;
}

.invoice-review-bottom-row .invoice-review-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
}

.invoice-review-bottom-row .invoice-review-total-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    width: auto;
    margin: 0;
}

@media (max-width: 700px) {
    .invoice-review-bottom-row {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .invoice-review-bottom-row .invoice-review-actions {
        flex-wrap: wrap;
    }

    .invoice-review-bottom-row .invoice-review-total-row {
        justify-content: flex-start;
    }
}

.invoice-review-error-row {
    display: block;
    margin-top: 18px;
}

.invoice-review-error-row .invoice-review-error-box {
    width: 100%;
    margin-top: 0;
}

.invoice-review-form.has-review-message .invoice-review-error-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr);
    gap: 18px;
    align-items: stretch;
}
.invoice-review-response-message {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid #efb9b9;
    border-radius: 8px;
    background: #ffffff;
    color: var(--text-primary);
    visibility: visible;
}

.invoice-review-response-title {
    padding: 10px 12px;
    background: var(--error-background);
    color: var(--error-text);
    font-size: 13px;
    font-weight: 700;
}

.invoice-review-response-list {
    min-height: 90px;
    margin: 0;
    padding: 10px 12px 10px 32px;
    background: #ffffff;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.45;
}

.invoice-review-response-list li {
    margin-bottom: 6px;
}

.invoice-review-response-list li:last-child {
    margin-bottom: 0;
}
/*
 * A successful Retry replaces the original error box and uses the full row.
 */
.invoice-review-form.has-review-success .invoice-review-error-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

.invoice-review-form.has-review-success .invoice-review-error-box {
    display: none;
}

.invoice-review-form.has-review-success .invoice-review-response-message {
    width: 100%;
    border-color: #5ca85c;
}

.invoice-review-form.has-review-success .invoice-review-response-title {
    background: #edf8ed;
    color: #226622;
}

.invoice-review-response-message:not(.validation) .invoice-review-response-list {
    padding-left: 12px;
    list-style: none;
}
