/* =========================================================
   ASTRU INVOICE — FOCUSED REVIEW WORKSPACE
   ========================================================= */

.review-focus-mode .app-shell {
    grid-template-columns: minmax(0, 1fr);
}

.review-focus-mode .app-sidebar {
    display: none;
}

.review-focus-mode .app-content {
    padding: 18px 22px 30px;
}

.review-focus-mode .app-header {
    min-height: 72px;
}

.review-focus-mode .workspace-name {
    min-width: 210px;
}

.review-header {
    max-width: 1800px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 22px;
    margin: 0 auto 14px;
}

.review-header h1 {
    margin: 0;
    color: var(--astru-ink);
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(29px, 3vw, 40px);
    font-weight: 600;
    letter-spacing: -.025em;
}

.review-header .muted {
    margin: 5px 0 0;
    color: var(--astru-muted);
    font-size: 13px;
}

.review-badges {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.review-badges .badge {
    display: inline-flex;
    align-items: center;
    min-height: 31px;
    padding: 6px 11px;
    border: 1px solid var(--astru-border);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .035em;
    text-transform: uppercase;
}

.review-badges .status-ready {
    color: #275b39;
    background: #dfeee2;
}

.review-badges .status-needs_review {
    color: #815817;
    background: #f7eacb;
}

.review-badges .status-duplicate {
    color: #8c3e3e;
    background: #f4dede;
}

.confidence-good {
    color: #275b39;
    background: #e3f0e5;
}

.confidence-medium {
    color: #815817;
    background: #f7eacb;
}

.confidence-low {
    color: #8c3e3e;
    background: #f4dede;
}

.validation-panel {
    max-width: 1800px;
    margin: 0 auto 14px;
    padding: 13px 16px;
    color: #754c18;
    background: #fbefd4;
    border: 1px solid #e8ce94;
    border-left: 4px solid var(--astru-gold);
    border-radius: 10px;
}

.validation-panel ul {
    margin: 7px 0 0;
    padding-left: 20px;
}

.review-layout {
    width: 100%;
    max-width: 1800px;
    display: grid;
    grid-template-columns: minmax(480px, 49%) minmax(620px, 51%);
    gap: 16px;
    align-items: start;
    margin: 0 auto;
}

.preview-pane,
.edit-pane {
    min-width: 0;
    padding: 14px;
    background: rgba(255, 255, 255, .96);
    border: 1px solid var(--astru-border);
    border-radius: 15px;
    box-shadow: var(--astru-shadow-md);
}

.preview-pane {
    position: sticky;
    top: 88px;
}

.pane-title {
    min-height: 35px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.pane-title h2 {
    margin: 0;
    color: var(--astru-ink);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 20px;
}

.pane-title a {
    color: var(--astru-forest);
    font-size: 12px;
    font-weight: 750;
    text-decoration: none;
}

.pane-title a:hover {
    color: var(--astru-gold);
}

.invoice-preview {
    width: 100%;
    height: calc(100vh - 165px);
    min-height: 680px;
    border: 1px solid #cfd6cf;
    border-radius: 9px;
    background: #ecefea;
}

.invoice-image-preview {
    width: 100%;
    height: calc(100vh - 165px);
    min-height: 680px;
    object-fit: contain;
    border: 1px solid #cfd6cf;
    border-radius: 9px;
    background: #ecefea;
}

.preview-missing {
    min-height: 640px;
    display: grid;
    place-items: center;
    color: var(--astru-muted);
    background: var(--astru-sage);
    border-radius: 9px;
}

.raw-text-box {
    margin-top: 9px;
    color: var(--astru-muted);
    font-size: 12px;
}

.raw-text-box summary {
    cursor: pointer;
    font-weight: 700;
}

.raw-text-box pre {
    max-height: 260px;
    padding: 12px;
    overflow: auto;
    background: #f2f3ef;
    border-radius: 8px;
}

.edit-pane {
    padding: 15px 17px 20px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
    margin-bottom: 14px;
}

.summary-card {
    padding: 12px 14px;
    background: var(--astru-sage);
    border: 1px solid var(--astru-border);
    border-top: 2px solid var(--astru-gold);
    border-radius: 10px;
}

.summary-card span {
    display: block;
    color: var(--astru-muted);
    font-size: 11px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: .055em;
}

.summary-card strong {
    display: block;
    margin-top: 3px;
    color: var(--astru-forest);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 23px;
}

.total-card {
    background: #f5eddc;
}

.invoice-fields.compact-fields {
    display: grid;
    grid-template-columns: 128px minmax(0, 1fr) 118px minmax(0, 1fr);
    gap: 9px 11px;
    align-items: center;
    margin-bottom: 16px;
    padding: 15px;
    background: #fbfaf6;
    border: 1px solid var(--astru-border);
    border-radius: 11px;
}

.compact-fields label {
    margin: 0;
    color: #56645b;
    font-size: 11px;
    font-weight: 800;
}

.compact-fields input {
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 8px 9px;
    font-size: 12px;
}

.edit-pane > form > h2 {
    margin: 17px 0 9px;
    color: var(--astru-ink);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 21px;
}

.edit-pane .warn {
    margin: 0 0 11px;
    padding: 10px 12px;
    color: #73501d;
    background: #faf0d9;
    border: 1px solid #ead4a5;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.45;
}

.ledger-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: end;
    margin-bottom: 11px;
    padding: 11px;
    background: var(--astru-sage);
    border-radius: 9px;
}

.ledger-tools label {
    grid-column: 1 / -1;
    color: var(--astru-forest);
    font-size: 11px;
}

.ledger-tools input {
    width: 100%;
    margin: 0;
    padding: 9px;
}

.ledger-tools button {
    min-height: 38px;
    padding: 8px 13px;
    color: white;
    background: var(--astru-evergreen);
    border: 1px solid var(--astru-forest);
    border-radius: 7px;
    font-weight: 750;
}

.line-table-wrap {
    width: 100%;
    max-height: 500px;
    overflow: auto;
    border: 1px solid var(--astru-border);
    border-radius: 10px;
}

.line-table {
    min-width: 1280px;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
}

.line-table th,
.line-table td {
    border: 0;
    border-bottom: 1px solid #e5e9e3;
    padding: 7px;
}

.line-table th {
    position: sticky;
    top: 0;
    z-index: 3;
    color: #59675e;
    background: var(--astru-sage);
    font-size: 9px;
    font-weight: 850;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.line-table tbody tr:hover {
    background: #fbf8ef;
}

.line-table input {
    min-width: 76px;
    width: 100%;
    margin: 0;
    padding: 7px;
    font-size: 11px;
}

.line-table td:nth-child(2) input {
    min-width: 230px;
}

.line-table td:nth-child(10) input {
    min-width: 225px;
}

.row-warning {
    background: #fbefd4;
}

.review-actions {
    position: sticky;
    bottom: 0;
    z-index: 8;
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin: 14px -17px -20px;
    padding: 13px 17px;
    background: rgba(247, 244, 236, .96);
    border-top: 1px solid var(--astru-border);
    backdrop-filter: blur(8px);
}

.review-actions .primary-action {
    min-width: 190px;
}

.danger-action {
    margin-top: 10px;
    padding: 8px 12px;
    color: var(--astru-danger);
    background: transparent;
    border: 1px solid #dfc0c0;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 750;
}

@media (max-width: 1450px) {
    .review-layout {
        grid-template-columns: minmax(430px, 47%) minmax(600px, 53%);
    }

    .invoice-fields.compact-fields {
        grid-template-columns: 118px minmax(0, 1fr);
    }
}

@media (max-width: 1050px) {
    .review-focus-mode .app-header {
        position: relative;
    }

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

    .preview-pane {
        position: static;
    }

    .invoice-preview,
    .invoice-image-preview {
        height: 72vh;
        min-height: 550px;
    }
}

@media (max-width: 650px) {
    .review-focus-mode .app-content {
        padding: 15px 10px 24px;
    }

    .review-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .review-badges {
        justify-content: flex-start;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .invoice-fields.compact-fields {
        grid-template-columns: 1fr;
    }

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

    .review-actions .primary-action {
        width: 100%;
    }
}

/* Review workspace width refinement */
.review-focus-mode .app-content {
    padding-left: 14px;
    padding-right: 14px;
}

.review-header,
.validation-panel,
.review-layout {
    max-width: none;
}

.review-layout {
    grid-template-columns: minmax(430px, 42%) minmax(720px, 58%);
    gap: 14px;
}

.preview-pane,
.edit-pane {
    padding: 12px;
}

.edit-pane {
    padding-left: 15px;
    padding-right: 15px;
}

.line-table-wrap {
    max-height: 560px;
}

@media (max-width: 1450px) {
    .review-layout {
        grid-template-columns: minmax(410px, 43%) minmax(650px, 57%);
    }
}

/* =========================================================
   P009 — REVIEW QUICK ACTIONS
   ========================================================= */

.preview-title-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.compact-button {
    min-height: 34px;
    padding: 7px 11px;
    font-size: 11px;
}

/* Full-width editor mode */
.review-layout.preview-collapsed {
    display: block;
}

.review-layout.preview-collapsed .preview-pane {
    display: none;
}

.review-layout.preview-collapsed .edit-pane {
    width: 100%;
    max-width: none;
}

.review-layout.preview-collapsed .invoice-fields.compact-fields {
    grid-template-columns:
        128px minmax(180px, 1fr)
        118px minmax(180px, 1fr)
        110px minmax(170px, 1fr);
}

.review-layout.preview-collapsed .line-table {
    min-width: 100%;
}

.review-layout.preview-collapsed .line-table-wrap {
    max-height: calc(100vh - 400px);
}

/* Quick Actions */
.quick-actions-panel {
    position: sticky;
    top: 78px;
    z-index: 12;
    margin: 0 0 12px;
    padding: 14px;
    background: rgba(247, 244, 236, .97);
    border: 1px solid var(--astru-border);
    border-top: 3px solid var(--astru-gold);
    border-radius: 11px;
    box-shadow: 0 8px 22px rgba(18, 49, 38, .10);
    backdrop-filter: blur(10px);
}

.quick-actions-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 11px;
}

.quick-actions-eyebrow {
    display: block;
    color: var(--astru-gold);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .13em;
}

.quick-actions-heading h3 {
    margin: 2px 0 0;
    color: var(--astru-ink);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 17px;
}

#selected-line-count {
    color: var(--astru-forest);
    font-size: 11px;
}

.selection-actions {
    display: flex;
    gap: 7px;
    margin-bottom: 11px;
}

.quick-action-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
    gap: 12px;
}

.quick-action-group {
    padding: 11px;
    background: white;
    border: 1px solid var(--astru-border);
    border-radius: 9px;
}

.quick-action-group > label {
    margin-bottom: 7px;
    color: var(--astru-forest);
    font-size: 11px;
    font-weight: 850;
}

.quick-action-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.quick-action-controls input,
.quick-action-controls select {
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 9px;
}

.quick-action-group small {
    display: block;
    margin-top: 7px;
    color: var(--astru-muted);
    font-size: 9px;
    line-height: 1.35;
}

/* Selection column */
.line-select-heading,
.line-select-cell {
    width: 42px;
    min-width: 42px;
    text-align: center;
}

.line-select-heading input,
.line-select-cell input {
    width: 17px;
    min-width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--astru-evergreen);
    cursor: pointer;
}

.invoice-line-row:has(.line-selector:checked) {
    background: rgba(238, 242, 234, .52);
}

.invoice-line-row:has(.line-selector:checked):hover {
    background: #f5f0e3;
}

@media (max-width: 1200px) {
    .quick-action-grid {
        grid-template-columns: 1fr;
    }

    .review-layout.preview-collapsed .invoice-fields.compact-fields {
        grid-template-columns: 118px minmax(0, 1fr);
    }
}

@media (max-width: 650px) {
    .quick-actions-panel {
        position: static;
    }

    .quick-actions-heading,
    .selection-actions {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .quick-action-controls {
        grid-template-columns: 1fr;
    }

    .quick-action-controls .button {
        width: 100%;
    }
}

.preview-toggle-button {
    margin-left: auto;
}

@media (max-width: 760px) {
    .preview-toggle-button {
        width: 100%;
        margin-left: 0;
    }
}

/* Review line-table priority layout:
   Select | Ledger | Code | Description | Qty | Unit | Unit Price | Net | VAT Rate | VAT | Gross
*/

.line-table th:nth-child(1),
.line-table td:nth-child(1) {
    width: 34px;
    min-width: 34px;
    max-width: 34px;
}

.line-table th:nth-child(2),
.line-table td:nth-child(2) {
    width: 170px;
    min-width: 170px;
    max-width: 190px;
}

.line-table th:nth-child(3),
.line-table td:nth-child(3) {
    width: 95px;
    min-width: 95px;
    max-width: 110px;
}

.line-table th:nth-child(4),
.line-table td:nth-child(4) {
    width: 390px;
    min-width: 390px;
}

.line-table td:nth-child(2) input {
    width: 100%;
    min-width: 150px;
}

.line-table td:nth-child(3) input {
    width: 88px;
    min-width: 88px;
}

.line-table td:nth-child(4) input {
    width: 100%;
    min-width: 360px;
}

.review-layout.preview-collapsed .line-table th:nth-child(4),
.review-layout.preview-collapsed .line-table td:nth-child(4) {
    width: 520px;
    min-width: 520px;
}

.review-layout.preview-collapsed .line-table td:nth-child(4) input {
    min-width: 490px;
}

/* P009.1 — larger line-item working area */

.review-layout.preview-collapsed .line-table-wrap {
    max-height: 68vh !important;
    min-height: 58vh;
    overflow-y: auto;
    overflow-x: auto;
}

/* Slightly denser rows so more invoices fit on screen */
.line-table th,
.line-table td {
    padding-top: 5px;
    padding-bottom: 5px;
}

.line-table input {
    padding-top: 6px;
    padding-bottom: 6px;
}

/* Keep Delete/action column compact if present */
.line-table th:last-child,
.line-table td:last-child {
    white-space: nowrap;
}

/* P009.2 — restore natural page scrolling in review */

.line-table-wrap {
    max-height: none !important;
    min-height: 0 !important;
    overflow-y: visible !important;
    overflow-x: auto !important;
}

.line-table th {
    position: sticky;
    top: 0;
    z-index: 4;
}

.review-actions {
    position: static !important;
    margin: 14px 0 0 !important;
}

/* P009.3 — Quick Actions should scroll away with the page */
.quick-actions-panel {
    position: static !important;
    top: auto !important;
}

/* P009.3 — keep line-item column headings visible during page scroll */

.line-table thead {
    position: sticky;
    top: 78px;
    z-index: 30;
}

.line-table thead th {
    position: sticky;
    top: 78px;
    z-index: 31;
    background: var(--astru-sage);
    box-shadow: 0 2px 0 rgba(18, 49, 38, 0.12);
}

/* Ensure rows cannot visually bleed through the sticky heading */
.line-table thead th:first-child {
    z-index: 32;
}

/* P009.3b — sticky line headings flush with top of line workspace */
.line-table thead,
.line-table thead th {
    top: 0 !important;
}
