.apw {max-width:1800px;margin:0 auto;color:var(--text)}
.apw h1 {font-size:26px;line-height:1.25;margin:8px 0;overflow-wrap:anywhere}.apw h2{font-size:18px;margin:0}.apw h3{font-size:15px;margin:22px 0 12px}
.apw-heading{display:flex;align-items:center;justify-content:space-between;gap:24px;margin-bottom:20px}.apw-heading p{margin:4px 0}.apw-header-amount{margin-left:20px;font-weight:650}.apw-readonly{font-size:12px;color:var(--muted)}
.apw-workspace{display:grid;grid-template-columns:minmax(360px,1fr) minmax(480px,1fr);gap:24px;align-items:start}
.apw-document{position:sticky;top:16px;border:1px solid var(--border);background:white;border-radius:8px;overflow:hidden}.apw-document-heading{padding:14px 16px;display:flex;justify-content:space-between;gap:12px;font-size:13px}.apw-document iframe{width:100%;height:calc(100vh - 220px);min-height:500px;border:0;display:block;background:#eee}
.apw-results{background:white;border:1px solid var(--border);border-radius:8px;padding:20px;min-width:0}.apw-actions{display:flex;gap:10px;flex-wrap:wrap}.apw .button{font-size:13px;padding:10px 15px;min-height:38px;white-space:normal}.apw .button:disabled{opacity:.5;cursor:not-allowed}
.apw-context{font-size:12px;line-height:1.55;color:var(--muted);margin:10px 0 16px}.apw-tabs{display:flex;gap:24px;border-bottom:1px solid var(--border);margin:16px 0 20px}.apw-tabs a{padding:10px 0;color:var(--muted);font-weight:600}.apw-tabs a.active{color:var(--brand-primary);border-bottom:2px solid var(--brand-primary)}
.apw label{display:block;font-size:12px;font-weight:600;color:#51555b}.apw input:not([type=submit]):not([type=checkbox]),.apw select,.apw textarea{display:block;box-sizing:border-box;width:100%;min-width:0;margin-top:5px;border:1px solid #cbd0d5;border-radius:5px;background:white;padding:9px 10px;color:var(--text);font:inherit;font-size:14px}.apw input:focus,.apw textarea:focus,.apw select:focus{outline:2px solid var(--brand-primary);outline-offset:1px}.apw textarea{resize:vertical}.apw .apw-field-grid{display:grid;grid-template-columns:1fr 1fr;gap:13px;margin:12px 0}.apw-amounts{grid-template-columns:repeat(3,1fr)!important}.apw-section-title{display:flex;justify-content:space-between;align-items:center;gap:12px;margin:24px 0 12px}.apw-section-title span{font-size:12px}
.apw-disclosure{border-bottom:1px solid var(--border-soft);padding:13px 0;font-size:13px}.apw-disclosure summary{cursor:pointer;font-weight:600;line-height:1.5}.apw-disclosure summary span{font-size:12px;font-weight:400;color:var(--muted);margin-left:10px}.apw-disclosure form{margin:16px 0}.apw-disclosure pre{max-height:400px;overflow:auto;font-size:12px;background:#f7f7f8;padding:12px}.apw-inline{display:flex;align-items:end;gap:8px}.apw-vendor-result{display:flex;justify-content:space-between;align-items:center;gap:12px}
.apw-line{border-bottom:1px solid var(--border);padding:14px 0}.apw-line-main{display:grid;grid-template-columns:minmax(150px,2fr) repeat(3,minmax(65px,1fr));gap:8px}.apw-line-code{display:grid;grid-template-columns:1fr 1fr;align-items:start;gap:12px;margin-top:10px}.apw-line-code summary{font-size:12px;cursor:pointer;margin-top:24px}.apw-remove{font-weight:400!important;margin-top:10px}.apw-line:has(input[type=checkbox]:checked){opacity:.5}.apw-text-button{background:none;border:0;color:var(--brand-primary);cursor:pointer;font:inherit;font-size:13px}.apw-save{position:sticky;bottom:0;background:white;border-top:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;padding:14px 0;gap:10px}.apw-save span{font-size:12px}.apw-notice,.apw-findings{background:#fff8e9;border-left:3px solid #a87519;padding:12px 16px;margin:12px 0;font-size:13px;line-height:1.55}.apw-findings h3{margin:0 0 8px}.apw-findings ul{padding-left:18px;margin:0}.apw-findings li{margin:5px 0}.apw-totals{display:grid;grid-template-columns:1fr auto;font-size:13px;gap:10px}.apw-totals dd{margin:0;text-align:right;font-variant-numeric:tabular-nums}
.apw-table-wrap{overflow:auto}.apw-table{border-collapse:collapse;width:100%;font-size:13px;background:white}.apw-table th{text-align:left;background:#f5f5f7;font-size:12px;color:var(--muted);font-weight:600;white-space:nowrap}.apw-table th,.apw-table td{padding:12px;border-bottom:1px solid var(--border-soft)}.apw-table small{display:block;color:var(--muted);margin-top:4px}.apw-history{border-bottom:1px solid var(--border);padding:14px 0}.apw-history small{display:block;color:var(--muted);margin:8px 0}.apw-empty{padding:40px 12px;color:var(--muted);text-align:center;line-height:1.6}.apw-empty h2{color:var(--text)}
.apw-upload{border:1px dashed #c3b3c0;background:white;border-radius:8px;padding:20px;margin-bottom:24px}.apw-upload form{display:flex;align-items:center;gap:16px;flex-wrap:wrap}.apw-upload input[type=file]{width:auto!important;margin:0!important}.apw-search{display:flex;align-items:center;gap:12px;margin-bottom:16px}.apw-search input[type=search]{max-width:400px;margin:0!important}.apw-footer{display:flex;justify-content:space-between;margin-top:20px;font-size:13px}.apw-footer span{margin:0 16px}.apw-progress{position:fixed;bottom:20px;right:20px;background:var(--brand-primary-dark);color:white;padding:14px 24px;border-radius:6px;z-index:10}.apw-progress[hidden]{display:none}.apw-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
@media(max-width:1050px){.apw-workspace{grid-template-columns:1fr}.apw-document{position:static}.apw-document iframe{height:55vh;min-height:300px}.apw-heading{align-items:start}.apw-readonly{display:none}}
@media(max-width:600px){.apw-line-main{grid-template-columns:repeat(3,1fr)}.apw-line-description{grid-column:1/-1}.apw-line-code{grid-template-columns:1fr}.apw-amounts{grid-template-columns:1fr 1fr!important}.apw-results{padding:14px}.apw-search{flex-wrap:wrap}}

.apw .apw-review { display:flex; gap:8px; align-items:center; margin:18px 0; }
.apw .apw-review input { width:auto; }

/* Invoice review: neutral groups, color reserved for actions and outcomes. */
.apw-group { padding:18px 0; border-bottom:1px solid var(--border); scroll-margin-top:24px; }
.apw-group > .apw-section-title, .apw-next-steps .apw-section-title { margin:0 0 12px; }
.apw .apw-section-title h3 { margin:0; }
.apw-group .apw-field-grid { margin-bottom:0; }
.apw-tag { display:inline-block; padding:4px 8px; border-radius:4px; background:#f0f1f3; color:#505660; font-size:11px!important; font-weight:600; line-height:1.4; }
.apw-tag--review { background:#fff0ce; color:#79520b; }
.apw-tag--pass { background:#e5f3eb; color:#22643f; }
.apw label.apw-needs-value input { border-color:#c39b4b!important; background:#fffcf5!important; }
.apw-needs-value small { display:block; margin-top:4px; color:#79520b; font-size:11px; }
.apw-vendor-panel { background:#f7f5f8; padding:12px; border-radius:6px; scroll-margin-top:24px; }
.apw-amount-editor { max-width:100%; }
.apw .apw-amount-editor label { display:grid; grid-template-columns:1fr minmax(120px,180px); align-items:center; gap:16px; padding:5px 0; font-weight:400; font-size:13px; }
.apw .apw-amount-editor input { margin:0; text-align:right; font-variant-numeric:tabular-nums; }
.apw .apw-amount-editor .apw-amount-total { border-top:1px solid var(--border); margin-top:8px; padding-top:12px; font-weight:700; }
.apw .apw-line { padding:12px; margin:10px 0; border:1px solid var(--border); border-radius:6px; background:#fcfcfd; }
.apw-line-main { grid-template-columns:minmax(130px,2fr) repeat(3,minmax(55px,1fr)); }
.apw .apw-line input:not([type=checkbox]):not([type=hidden]) { padding:7px 8px; font-size:13px; }
.apw-line-main label:not(:first-child) input { text-align:right; font-variant-numeric:tabular-nums; }
.apw-line-footer { display:flex; justify-content:flex-end; align-items:center; gap:10px; margin-top:8px; }
.apw .apw-line-footer input[type=checkbox] { position:absolute; width:1px; height:1px; padding:0; margin:0; min-height:0; }
.apw .apw-remove-button { font-size:12px; color:#65606a; padding:5px; }
.apw-line-removed .apw-line-main { text-decoration:line-through; }
.apw-removal-note { font-size:11px; color:#79520b; }
.apw .apw-save .button { width:auto; min-width:160px; flex:0 0 auto; }
.apw-save { z-index:2; box-shadow:0 -6px 12px #ffffffd9; }
.apw-outcome { padding:18px; background:#f7f6f8; border:1px solid #ddd7e0; border-radius:6px; margin:0 0 18px; }
.apw-outcome--review { border-left:4px solid #a87519; }
.apw-outcome--error { border-left:4px solid #b34242; background:#fff6f5; }
.apw-outcome--pass { border-left:4px solid #398357; background:#f0f8f3; }
.apw-eyebrow { font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:#62606a; }
.apw-outcome h2 { margin:7px 0; font-size:21px; }
.apw-outcome > summary { cursor:pointer; font-weight:600; color:var(--brand-primary); }
.apw-overages { min-width:900px; }
.apw .apw-overages td:not(:first-child),.apw .apw-overages th:not(:first-child) { text-align:left; }
.apw-outcome p { margin:6px 0 14px; font-size:13px; line-height:1.5; color:#505660; }
.apw-meta { display:flex; justify-content:space-between; gap:12px; font-size:11px; color:#63636c; }
.apw-next-steps { padding:16px; border:1px solid #ead7b0; border-radius:6px; background:#fffdf8; margin:16px 0; }
.apw-next-steps ul { padding:0; margin:0; list-style:none; }
.apw-next-steps li { display:flex; align-items:baseline; justify-content:space-between; gap:18px; padding:9px 0; border-top:1px solid #eee4d1; font-size:13px; line-height:1.5; }
.apw-review-link { font-weight:600; flex-shrink:0; text-decoration:underline; }
.apw .apw-findings--error { background:#fff1ef; border-color:#b34242; color:#803333; }
.apw-totals { gap:0; margin:0; }
.apw-totals dt,.apw-totals dd { padding:8px 0; }
.apw-totals .apw-total-emphasis { border-top:1px solid var(--border); font-weight:700; }
.apw-unknown { color:#85621f; font-size:11px; font-weight:500; }
.apw-system-notes { background:#f4f5f7; border:1px solid #e2e4e8; border-radius:6px; padding:14px; margin:18px 0; font-size:12px; line-height:1.6; }
.apw-system-notes summary { cursor:pointer; font-weight:600; }
.apw-system-notes summary .apw-tag { margin-left:8px; }
.apw-plain-findings { padding-left:18px; font-size:12px; line-height:1.6; color:#61616b; }
.apw-table td { padding:9px 8px; font-variant-numeric:tabular-nums; }
.apw-table td:not(:first-child),.apw-table th:not(:first-child) { text-align:right; }
.apw-table td:first-child { min-width:125px; font-size:12px; }
.apw-table td small { font-size:10px; }
.apw [id^=apw-] { scroll-margin-top:20px; }
@media(max-width:600px) { .apw .apw-amount-editor label { grid-template-columns:1fr 130px; } .apw-line-main { grid-template-columns:repeat(3,1fr); } .apw-meta { flex-wrap:wrap; } }
.apw-quantity-summary { margin-bottom:18px; padding-top:0; }
.apw-quantity-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; margin:0; }
.apw-quantity-grid > div { padding:12px; border:1px solid var(--border); border-radius:6px; background:#fafafb; }
.apw-quantity-grid dt { font-size:12px; font-weight:600; line-height:1.4; }
.apw-quantity-grid small { display:block; margin-top:5px; color:var(--muted); font-size:10px; font-weight:400; }
.apw-quantity-grid dd { margin:12px 0 0; font-size:24px; font-weight:650; font-variant-numeric:tabular-nums; }
.apw-quantity-grid dd.apw-unknown { font-size:18px; }
.apw-quantity-projected { display:flex; justify-content:space-between; gap:12px; padding:12px 0 0; font-size:12px; }
@media(max-width:1250px) { .apw-quantity-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }

/* Compact review panels: editable document values and verified ERP identity. */
.apw-results { background:#fdfcfe; }
.apw-group { margin:14px 0; padding:16px; border:1px solid #e7e2ea; border-radius:8px; background:#f7f5f9; }
.apw-group > .apw-section-title { margin-bottom:10px; }
.apw .apw-section-title h2,.apw .apw-section-title h3 { color:var(--brand-primary); font-size:15px; font-weight:600; }
.apw label { font-weight:500; color:#59606a; }
.apw input:not([type=submit]):not([type=checkbox]):not([type=hidden]),.apw select,.apw textarea { font-weight:400; font-size:13px; padding:7px 9px; min-height:34px; border-color:#d9d5df; }
.apw .apw-field-grid { gap:12px 16px; margin-top:10px; }
.apw .apw-vendor-identity { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:16px; margin:0 0 14px; padding:12px 14px; border:1px solid #dbe7df; border-radius:6px; background:#eff6f1; }
.apw-vendor-identity dt { color:#496353; font-size:11px; margin-bottom:5px; }
.apw-vendor-identity dd { margin:0; font-size:14px; font-weight:500; color:#253e2e; overflow-wrap:anywhere; }
.apw input[readonly] { background:#f0f2f4!important; color:#59606a; border-color:transparent!important; }
.apw .apw-line { background:white; border-color:#e5e1e9; }
.apw .apw-line-code summary { margin-top:19px; }
.apw .apw-table-wrap { border:1px solid #e5e1e9; border-radius:7px; }
.apw-table th { padding:9px 10px; font-size:11px; background:#f1eef4; color:#55505e; }
.apw-table td { padding:10px; border-color:#edeaf0; }
.apw-table tbody tr:hover td { box-shadow:inset 0 0 0 999px #73607c08; }
.apw-quantity-table { min-width:720px; }
.apw-quantity-table thead tr:not(.apw-column-groups) th { white-space:normal; }
.apw-quantity-table td:nth-child(2),.apw-quantity-table thead tr:last-child th:nth-child(2) { background:#f6f0f8; }
.apw-quantity-table td:nth-child(n+3):nth-child(-n+5),.apw-quantity-table thead tr:last-child th:nth-child(n+3):nth-child(-n+5) { background:#f1f6fa; }
.apw-quantity-table td:nth-child(n+6),.apw-quantity-table thead tr:last-child th:nth-child(n+6) { background:#f1f7f3; }
.apw-quantity-table .apw-column-groups th { text-align:center; font-size:10px; letter-spacing:.03em; border-bottom:0; }
.apw-quantity-table .apw-column-groups th:first-child { text-align:left; }
.apw-quantity-table .apw-column-groups th:nth-child(2) { background:#ece1f0; color:#653c72; }
.apw-quantity-table .apw-column-groups th:nth-child(3) { background:#e1ebf3; color:#34586f; }
.apw-quantity-table .apw-column-groups th:nth-child(4) { background:#dfede3; color:#356048; }
@media(max-width:600px) { .apw-group { padding:12px; } .apw .apw-vendor-identity { gap:10px; padding:10px; } }
.apw-discount-question { margin-top:14px; padding:12px; background:#f0eaf4; border-radius:6px; }
.apw-discount-question[hidden] { display:none; }
.apw-discount-question .apw-context { margin:7px 0 0; }

/* Use the available screen for document review, without changing other app pages. */
.app-shell__main:has(.apw-invoice) { max-width:none; padding:24px clamp(16px,2vw,48px); }
.apw-invoice { max-width:none; }
.apw-invoice .apw-workspace { grid-template-columns:minmax(360px,2fr) minmax(520px,3fr); gap:20px; }
.apw-layout-controls { display:flex; justify-content:flex-start; margin:0 0 12px; }
.apw-layout-controls[hidden] { display:none; }
.apw-mobile-switch { display:none; }
.apw-results { container-type:inline-size; }
.apw-invoice .apw-line-main { grid-template-columns:repeat(3,minmax(0,1fr)); }
.apw-invoice .apw-line-description { grid-column:1/-1; }
.apw-invoice .apw-line-sku { grid-column:1; }
.apw-invoice .apw-line-upc { grid-column:2/-1; }
.apw-invoice .apw-line-main .apw-line-sku input,.apw-invoice .apw-line-main .apw-line-upc input { text-align:left; }
.apw-invoice .apw-line-code { display:block; margin-top:8px; }
.apw-invoice .apw-line-code summary { margin-top:0; }
@container (min-width:850px) {
  .apw-invoice .apw-line-main { grid-template-columns:minmax(180px,2fr) minmax(90px,1fr) minmax(130px,1.3fr) repeat(3,minmax(72px,.7fr)); }
  .apw-invoice .apw-line-description,.apw-invoice .apw-line-sku,.apw-invoice .apw-line-upc { grid-column:auto; }
}
@media(min-width:1101px) {
  .apw-invoice.apw-document-hidden .apw-document { display:none; }
  .apw-invoice.apw-document-hidden .apw-workspace { grid-template-columns:minmax(0,1fr); }
}
@media(max-width:1100px) {
  .apw-invoice .apw-workspace { grid-template-columns:minmax(0,1fr); }
  .apw-invoice .apw-document { position:static; }
  .apw-invoice .apw-document iframe { height:70vh; min-height:300px; }
  .apw-desktop-toggle { display:none; }
  .apw-layout-controls { position:sticky; top:0; z-index:3; background:#f7f7f9; padding:8px 0; justify-content:stretch; }
  .apw-mobile-switch { display:flex; width:100%; gap:4px; }
  .apw-mobile-switch button { flex:1; padding:11px; border:1px solid #d9d5df; border-radius:5px; background:white; color:var(--brand-primary); font:inherit; font-size:13px; }
  .apw-mobile-switch button[aria-pressed=true] { background:var(--brand-primary); color:white; }
  .apw-layout-ready:not(.apw-mobile-document) .apw-document { display:none; }
  .apw-layout-ready.apw-mobile-document .apw-results { display:none; }
}
@media(max-width:600px) {
  .app-shell__main:has(.apw-invoice) { padding:16px 12px; }
  .apw-invoice .apw-heading { gap:8px; margin-bottom:12px; }
  .apw-invoice .apw-save { padding-bottom:max(12px,env(safe-area-inset-bottom)); }
  .apw-invoice .apw-save .button { min-width:0; }
}

/* Keep short header values compact while line items retain the full review width. */
.apw-header-panels { display:grid; grid-template-columns:minmax(0,1fr); gap:12px; margin:14px 0; }
.apw-header-panels > .apw-group { margin:0; }
.apw-invoice .apw-amount-editor { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px 18px; }
.apw-invoice .apw-amount-editor label { display:block; padding:0; font-size:12px; }
.apw-invoice .apw-amount-editor input { margin-top:5px; }
.apw-invoice .apw-amount-editor .apw-amount-total { border:0; padding:0; margin:0; color:var(--brand-primary); }
.apw-invoice .apw-amount-total input { border-color:#b5a0be; font-weight:600; }
.apw-invoice .apw-line { display:grid; grid-template-columns:minmax(0,1fr) auto; column-gap:12px; padding:10px; margin:8px 0; }
.apw-invoice .apw-line-main { grid-column:1/-1; }
.apw-invoice .apw-line-code { grid-column:1; }
.apw-invoice .apw-line-footer { grid-column:2; align-self:start; margin-top:4px; }
.apw-invoice .apw-line:has(details[open]) .apw-line-code { grid-column:1/-1; }
@container(min-width:650px) {
  .apw-invoice .apw-amount-editor { grid-template-columns:repeat(3,minmax(0,1fr)); }
}
@container(min-width:900px) {
  .apw-header-panels { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .apw-invoice .apw-amount-editor { grid-template-columns:repeat(6,minmax(0,1fr)); gap:12px; }
}

.apw-invoice .apw-style-match { grid-column:1/-1; margin-top:10px; padding:10px; background:#edf3f7; border-radius:6px; }
.apw-invoice .apw-style-confirm { display:flex; align-items:center; gap:8px; font-size:13px; }
.apw-invoice .apw-style-confirm input { width:16px; min-height:16px; height:16px; margin:0; }

/* Keep comparison status, actions and verification notes in one secondary panel. */
.apw-comparison-section { border-top:1px solid #ddd7e0; margin-top:16px; padding-top:14px; font-size:13px; line-height:1.5; }
.apw-comparison-section h3 { margin:0 0 10px; }
.apw-comparison-section summary { cursor:pointer; font-weight:600; }
.apw-confirmations ul { list-style:none; padding:0; margin:0; }
.apw-confirmations li { display:flex; justify-content:space-between; align-items:baseline; gap:18px; padding:8px 0; }
.apw-confirmations .apw-review-link { flex-shrink:0; }

.apw-item-comparison { margin:20px 0; }
.apw-claim-action { display:flex; align-items:center; flex-wrap:wrap; gap:12px; margin:12px 0; }
.apw-claim-action .button:disabled { cursor:not-allowed; opacity:.65; }
.apw-item-comparison .apw-quantity-table { min-width:1100px; }
.apw-item-comparison .apw-price { background:#f7f4ed !important; }
.apw-item-comparison .apw-cost-match { background:#e7f3eb !important; color:#285c3e; }
.apw-item-comparison .apw-cost-different { background:#fcebea !important; color:#913b37; }
.apw-item-comparison .apw-cost-unknown { background:#f2f3f5 !important; color:#626771; }
.apw-price-total { display:flex; justify-content:space-between; gap:16px; padding:12px 14px; margin-top:10px; border-radius:6px; font-size:13px; }
.apw-price-total small { display:block; margin-top:4px; }
.apw-item-switch { display:none; gap:4px; margin:0 0 12px; }
.apw-item-switch button { border:1px solid #d9d5df; border-radius:5px; padding:8px 16px; background:white; color:var(--brand-primary); font:inherit; font-size:13px; }
.apw-item-switch button[aria-pressed=true] { background:var(--brand-primary); color:white; }
@container (max-width:1199px) {
  .apw-layout-ready .apw-item-switch { display:flex; }
  .apw-layout-ready .apw-item-comparison[data-pricing="false"] .apw-price { display:none; }
  .apw-layout-ready .apw-item-comparison[data-pricing="true"] .apw-qty { display:none; }
  .apw-layout-ready .apw-item-comparison .apw-quantity-table { min-width:720px; }
  .apw-layout-ready .apw-item-comparison[data-pricing="true"] .apw-quantity-table { min-width:560px; }
}
.apw-header-comparison { min-width:480px; }
.apw-header-comparison tbody th { text-align:left; font-weight:500; }
.apw-header-comparison td:nth-child(2) { background:#f6f0f8; }
.apw-header-comparison td:nth-child(3) { background:#f1f6fa; }
.apw-header-comparison .apw-header-match { background:#e7f3eb; color:#285c3e; }
.apw-header-comparison .apw-header-difference { background:#fcebea; color:#913b37; }
.apw-search { flex-wrap:wrap; align-items:flex-end; }
.apw-search select { width:auto; min-width:170px; }
.apw-search input[type=search] { flex:1 1 260px; }
.apw #apw-batch-form { display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin:16px 0; }
.apw-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin:12px 0; }
.apw input[type=checkbox] { display:inline-block; width:16px; height:16px; min-height:0; margin:0 6px 0 0; vertical-align:middle; accent-color:var(--brand-primary); }
.apw-upload .button,.apw-search .button { width:auto; flex:0 0 auto; }
.apw-invoice-list td:first-child,.apw-invoice-list th:first-child { width:44px; min-width:44px; }
.apw-invoice-list td:not(:first-child),.apw-invoice-list th:not(:first-child) { text-align:left; }
.apw-invoice-list td:nth-child(5),.apw-invoice-list th:nth-child(5) { text-align:right; }
@media(max-width:600px) { .apw-grid { grid-template-columns:1fr; } }

/* Production shell compatibility; keep the POC workbench proportions. */
.apw button, .apw input[type=submit] { width:auto; }
.apw input[type=checkbox] { width:16px; height:16px; min-height:0; margin:0; }
.apw [hidden] { display:none!important; }
.apw .apw-tabs { flex-wrap:wrap; }
.apw .apw-results { min-width:0; }
.apw .apw-disclosure pre { white-space:pre-wrap; overflow-wrap:anywhere; }
.apw-extraction-progress { padding:16px; margin:12px 0; border:1px solid var(--border); border-radius:6px; background:#f7f5f9; }
.apw-extraction-progress progress { display:block; width:100%; height:10px; accent-color:var(--brand-primary); }
.apw-extraction-progress p { margin:10px 0 6px; font-weight:600; }
.apw-extraction-progress small { color:var(--muted); margin-right:12px; }
@media (prefers-reduced-motion: reduce) { .apw-extraction-progress progress { animation:none; } }

.apw-claim-form { width:100%; }
.apw-po-reference .apw-table-wrap { max-height:420px; }
.apw-po-reference > summary { cursor:pointer; color:var(--brand-primary-dark); font-size:18px; font-weight:700; }
.apw-po-reference > .apw-section-title { justify-content:flex-end; }
.apw-po-reference-table { min-width:800px; }
.apw .apw-po-reference-table th { position:sticky; top:0; z-index:1; }
.apw .apw-po-reference-table td:nth-child(-n+5),.apw .apw-po-reference-table th:nth-child(-n+5) { text-align:left; }
.apw-po-reference-table td:nth-child(3) { min-width:200px; }

/* Invoice review hierarchy: crisp panels, readable headings and distinct data groups. */
.apw-invoice .apw-results { background:#f0f1f4; border-color:#c5c8d0; }
.apw-invoice .apw-document { border-color:#c5c8d0; }
.apw-invoice .apw-document-heading { border-bottom:1px solid #c5c8d0; font-weight:600; }
.apw-invoice .apw-group { background:#fff; border-color:#c8c5d0; box-shadow:0 1px 2px #24202b08; }
.apw-invoice .apw-section-title h2,
.apw-invoice .apw-section-title h3 { font-size:18px; font-weight:700; line-height:1.35; color:var(--brand-primary-dark); }
.apw-invoice .apw-group > .apw-section-title { padding-bottom:10px; margin-bottom:14px; border-bottom:1px solid #dedbe3; }
.apw-invoice .apw-tabs { border-bottom:2px solid #c8c5d0; gap:20px; }
.apw-invoice .apw-tabs a { padding:10px 8px; }
.apw-invoice .apw-tabs a.active { background:#e9dce7; border-bottom:3px solid var(--brand-primary); border-radius:5px 5px 0 0; color:var(--brand-primary-dark); }
.apw-invoice label { color:#454952; font-weight:600; }
.apw-invoice input:not([type=submit]):not([type=checkbox]):not([type=hidden]),
.apw-invoice select,.apw-invoice textarea { border-color:#b8bbc5; font-size:14px; }
.apw-invoice .apw-line { border-color:#c8c5d0; }
.apw-invoice .apw-vendor-identity { border-color:#b7d5c2; background:#eaf4ed; }
.apw-invoice .apw-vendor-identity dd { font-weight:650; font-size:15px; }
.apw-invoice .apw-amount-total input:not([type=submit]):not([type=checkbox]):not([type=hidden]) { border:2px solid #98708f; background:#faf5f9; font-weight:700; font-size:16px; }
.apw-invoice .apw-quantity-grid > div { border-color:#cbd0d8; background:#f7f8fa; border-top:3px solid #8795a7; }
.apw-invoice .apw-quantity-grid dt { font-size:13px; }
.apw-invoice .apw-quantity-grid dd { font-size:28px; font-weight:700; }
.apw-invoice .apw-quantity-grid dd.apw-unknown { font-size:18px; }
.apw-invoice .apw-quantity-projected { border-top:1px solid #dedbe3; margin-top:12px; font-size:13px; }
.apw-invoice .apw-table-wrap { border-color:#c8c5d0; }
.apw-invoice .apw-table th { background:#e7e4ec; color:#45414d; font-size:12px; font-weight:650; }
.apw-invoice .apw-table td { border-color:#dedfe5; }
.apw-invoice .apw-quantity-table .apw-column-groups th { font-size:11px; font-weight:700; }
.apw-invoice .apw-quantity-table .apw-column-groups th:nth-child(2) { background:#dfcce4; color:#593261; }
.apw-invoice .apw-quantity-table .apw-column-groups th:nth-child(3) { background:#cbdfea; color:#284e66; }
.apw-invoice .apw-quantity-table .apw-column-groups th:nth-child(4) { background:#cce2d3; color:#2c533b; }
.apw-invoice .apw-total-summary tbody tr:last-child > * { border-top:2px solid #b9b3c2; font-weight:700; font-size:14px; }
.apw-invoice .apw-price-total { border:1px solid #c8c5d0; }
.apw-invoice .apw-price-total > strong { font-size:18px; }
.apw-invoice .apw-disclosure { border-bottom-color:#d5d5de; }
.apw-invoice .apw-save { border-top:2px solid #c8c5d0; padding-left:12px; padding-right:12px; }

.apw-bill-assignee { font-size:22px; margin:10px 0 6px; }
.apw-bill-actions-preview { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.apw-bill-actions-preview .apw-totals { grid-template-columns:1fr 1fr; }
@media(max-width:900px) { .apw-bill-actions-preview { grid-template-columns:1fr; } }

/* Quantity reconciliation is independent of the pricing result. */
.apw-item-comparison.apw-quantities-reconciled { border:2px solid #358252; border-radius:8px; padding:16px; }
.apw-quantity-success { background:#d9efdf; color:#205b35; border-left:5px solid #358252; padding:14px 16px; }
.apw-quantity-success strong { display:block; font-size:18px; }
.apw-quantity-success span { display:block; margin-top:5px; font-size:13px; }
.apw-invoice .apw-quantity-table tr.apw-quantity-match td:not(.apw-price) { background:#e2f3e7 !important; color:#205b35; font-weight:600; }
.apw-quantity-table tr.apw-quantity-match td:first-child { border-left:5px solid #358252; }
.apw-quantity-match .apw-tag { margin-top:8px; }

.apw-edi-source { padding: 1rem; max-height: calc(100vh - 220px); overflow: auto; }

.apw.apw-bill-creation { max-width:1100px; }
.apw-bill-creation .apw-table { table-layout:fixed; }
.apw-bill-creation .apw-table td { overflow-wrap:anywhere; }

.apw-invoice .apw-quantity-table td.apw-claim-over-order { background:#fce2e2 !important; color:#a51d26; font-weight:800; }
.apw-claim-over-order small { color:inherit; font-weight:600; }

/* Invoice entry: distinct line cards with separate detail surfaces. */
.apw-invoice [data-ap-workspace-target="lines"] { counter-reset:invoice-line; }
.apw-invoice .apw-line { counter-increment:invoice-line; border:1px solid #b9afbf; border-left:4px solid var(--brand-primary); border-radius:8px; margin:16px 0; padding:12px; box-shadow:0 2px 4px #3020390d; }
.apw-line-heading { grid-column:1/-1; display:flex; align-items:center; gap:12px; padding:8px 12px; margin:-12px -12px 12px; background:#eee5ef; border-bottom:1px solid #cbbbcf; border-radius:4px 7px 0 0; color:#53324f; font-size:12px; }
.apw-line-number::after { content:counter(invoice-line); }
.apw-line-heading span { color:#655c6a; }
.apw-invoice .apw-line:focus-within { border-color:var(--brand-primary); box-shadow:0 0 0 2px #752f6914; }
.apw-invoice .apw-line-description input { font-weight:600; }
.apw-invoice .apw-style-match { background:#edf3f7; border:1px solid #cad8e2; border-left:3px solid #7593a9; padding:10px 12px; }
.apw-invoice .apw-line-code { margin-top:12px; }
.apw-invoice .apw-line-code details { border:1px solid #d4d5dd; border-radius:5px; background:#f6f6f9; }
.apw-invoice .apw-line-code summary { padding:9px 12px; font-weight:600; color:#4e4656; }
.apw-invoice .apw-line-code details[open] summary { border-bottom:1px solid #d4d5dd; background:#ececf1; }
.apw-invoice .apw-line-code details > .apw-field-grid { padding:12px; }
.apw-invoice .apw-line-code details > .apw-context { margin:0 12px 12px; padding-top:10px; border-top:1px solid #dedfe5; overflow-wrap:anywhere; }
.apw-invoice .apw-line-footer { align-self:center; margin-top:12px; }
@container (min-width:550px) {
  .apw-invoice .apw-style-match > .apw-field-grid { grid-template-columns:minmax(0,1.2fr) minmax(0,1fr) minmax(70px,.5fr); gap:12px; }
}
@container (max-width:549px) {
  .apw-invoice .apw-line-code,.apw-invoice .apw-line-footer { grid-column:1/-1; }
  .apw-invoice .apw-style-match > .apw-field-grid { grid-template-columns:minmax(0,1fr); }
}

/* Explicit final BILL decision: preserve native, keyboard-accessible radios. */
.apw .apw-bill-decision { margin:16px 0; padding:12px; border:1px solid #d9d5df; border-radius:6px; }
.apw .apw-bill-decision label { display:flex; align-items:center; gap:9px; margin:10px 0; font-size:14px; }
.apw .apw-bill-decision input[type=radio] { display:inline-block; width:16px; height:16px; min-height:16px; margin:0; padding:0; flex:none; }

/* Invoice identity, milestone coverage and overall state share the header. */
.apw .apw-progress-heading { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; }
.apw-invoice-identity { flex: 0 1 240px; min-width: 0; overflow-wrap: anywhere; }
.apw-header-progress { flex: 1 1 600px; display: flex; flex-wrap: wrap; gap: 20px 28px; list-style: none; margin: 0; padding: 0; }
.apw-header-progress li { min-width: 140px; }
.apw-header-progress li > div { display: flex; gap: 10px; align-items: center; font-size: 18px; }
.apw-header-progress li > span { display: block; margin: 6px 0 0 24px; font-size: 14px; }
.apw-header-progress .ap-progress-dot { width: 14px; height: 14px; flex-basis: 14px; }
.apw-invoice-status { display: grid; gap: 10px; margin-left: auto; max-width: 400px; text-align: right; justify-items: end; }
.apw-invoice-status-actions > strong { font-size: 18px; line-height: 1.35; font-weight: 600; }
.apw-invoice-status small { color: var(--muted); }
.apw-invoice-status form { margin: 0; }
.apw-automation-indicator { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 12px; }
.apw-automation-indicator form { margin: 0; }
.apw-automation-indicator span { display: inline-block; padding: 8px 12px; border: 1px solid #d6bfd7; border-radius: 6px; background: #f3eaf4; color: #622861; font-size: 14px; font-weight: 600; }

/* Bill creation: accounting review with a compact summary and grouped fields. */
.apw-bill-review { container-type: inline-size; }
.apw-bill-review__heading, .apw-bill-review__tools, .apw-bill-review__actions {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.apw-bill-review__heading { align-items: flex-start; margin-bottom: 1.25rem; }
.apw-bill-review__heading h3 { margin: 0 0 .4rem; }
.apw-bill-review__heading p { margin: 0; }
.apw-bill-review__summary { display: grid; grid-template-columns: 1fr 1fr auto; gap: 1.5rem; padding: 1.25rem; background: #fff; border: 1px solid var(--border); border-radius: .5rem; }
.apw-bill-review__summary span { display: block; color: var(--muted); font-size: .85rem; margin-bottom: .4rem; }
.apw-bill-review__summary strong { font-size: 1.1rem; overflow-wrap: anywhere; }
.apw-bill-review__amount { text-align: right; }
.apw-bill-review__amount strong { font-size: 1.65rem; font-variant-numeric: tabular-nums; }
.apw-bill-review__tools { margin: .75rem 0 1.25rem; font-size: .9rem; }
.apw-bill-review__tools .button { font-size: .85rem; padding: .45rem .75rem; }
.apw-bill-review__section { background: #fff; border: 1px solid var(--border); border-bottom: 0; padding: 1.25rem; }
.apw-bill-review__section h4 { color: var(--brand-primary-dark); font-size: 1.05rem; margin: 0 0 1rem; }
.apw-bill-review__section label { display: block; margin: 0 0 .4rem; }
.apw-bill-review__vendor-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 1rem; }
.apw-bill-review__date-grid, .apw-bill-review__accounts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.apw-bill-review__accounts { margin-top: 1rem; }
.apw-bill-review .apw-bill-review__override { display: flex; align-items: center; gap: .5rem; margin-top: 1rem; font-weight: normal; }
.apw-bill-review__override input { flex-shrink: 0; }
.apw-bill-review .apw-bill-review__terms { border: 0; border-top: 1px solid var(--border-soft); padding: 1rem 0 0; margin: 1rem 0 0; min-width: 0; }
.apw-bill-review__terms legend { font-weight: 600; padding: 0 .5rem 0 0; font-size: .95rem; }
.apw-bill-review .apw-totals { grid-template-columns: minmax(10rem, auto) 1fr; gap: .5rem 1.5rem; margin: 0 0 1rem; }
.apw-bill-review .apw-totals dd { text-align: left; }
.apw-bill-review__terms input[type="search"] { margin-bottom: .75rem; }
.apw-bill-review__delivery { display: grid; grid-template-columns: auto 1fr; gap: .6rem 1.5rem; margin: 0; font-size: .9rem; }
.apw-bill-review__delivery dt { color: var(--muted); }
.apw-bill-review__delivery dd { margin: 0; overflow-wrap: anywhere; }
.apw-bill-review__footer { padding: 1.25rem; border: 1px solid var(--border); background: var(--brand-primary-soft); border-radius: 0 0 .5rem .5rem; }
.apw-bill-review__footer p { margin: 0 0 1rem; font-size: .9rem; }
.apw-bill-review__actions { justify-content: flex-start; }
.apw-bill-review [data-freight-exclusion-target][hidden] { display: none; }
.apw-bill-review tr.is-excluded { background: #f5f5f5; color: var(--muted); }
.apw-bill-review tr.is-excluded .apw-creation-line-amount { text-decoration: line-through; }
.apw-bill-review [data-freight-exclusion-target="excluded"] { margin-left: .5rem; font-size: .8rem; }
@container (max-width: 640px) {
  .apw-bill-review__vendor-fields, .apw-bill-review__date-grid, .apw-bill-review__accounts { grid-template-columns: 1fr; }
  .apw-bill-review__summary { grid-template-columns: 1fr 1fr; }
  .apw-bill-review__amount { grid-column: 1 / -1; text-align: left; border-top: 1px solid var(--border-soft); padding-top: .75rem; }
  .apw-bill-review__delivery { grid-template-columns: 1fr; gap: .35rem; }
  .apw-bill-review__delivery dd { margin-bottom: .5rem; }
}

.apw-automation-trigger { background: #f3eaf4; color: #622861; border-color: #d6bfd7; }
.apw-automation-trigger:hover { background: #e6d4e8; border-color: #793477; }

.apw-comparison-refreshed{color:#237246;font-size:13px;line-height:1.55;margin:12px 0;display:flex;align-items:center;gap:8px}

.apw-invoice .apw-section-title .apw-po-creator { color:var(--text); font-size:16px; font-weight:400; }

.apw-header-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; align-items:center; gap:8px; }
.apw-header-actions .button { min-height:40px; margin:0; display:inline-flex; align-items:center; justify-content:center; box-sizing:border-box; }
@media(max-width:640px) {
  .apw-invoice-status { flex-basis:100%; max-width:none; margin-left:0; text-align:left; justify-items:start; }
  .apw-header-actions { justify-content:flex-start; }
}

.apw-header-tasks { width:100%; max-width:400px; border-top:1px solid var(--border); padding-top:10px; text-align:left; }
.apw-header-tasks h2 { margin:0 0 6px; font-size:13px; font-weight:600; color:var(--muted); }
.apw-header-tasks ul { list-style:none; margin:0; padding:0; max-height:180px; overflow-y:auto; }
.apw-header-tasks li { padding:6px 0; overflow-wrap:anywhere; font-size:14px; }
.apw-header-tasks li small { display:block; margin-top:3px; font-size:12px; }
.apw-header-tasks p,.apw-task-history-links { margin:6px 0 0; font-size:12px; }

.apw-terms-choice { display:flex; flex-wrap:wrap; justify-content:flex-end; align-items:center; gap:8px; }
.apw-terms-choice form { margin:0; }
.apw-terms-choice .button { min-height:0; font-size:12px; line-height:1.2; padding:4px 9px; background:#62556b; border-color:#62556b; color:#fff; }
.apw-terms-choice .button:hover:not(:disabled) { background:#4d4056; border-color:#4d4056; color:#fff; }
.apw-terms-choice small { flex-basis:100%; font-weight:400; color:var(--muted); }

.apw-terms-mapping { display:inline-flex; align-items:center; justify-content:center; width:14px; height:14px; margin-left:4px; border-radius:3px; font-size:12px; font-weight:700; vertical-align:middle; }
.apw-terms-mapping.is-mapped { color:#1d6b42; background:#e2f2e8; }
.apw-terms-mapping.is-unmapped { color:#a52b32; background:#fbe8e9; }
.apw-terms-mapping[hidden] { display:none; }

.apw-invoice-status-actions { display:flex; flex-wrap:wrap; align-items:center; justify-content:flex-end; gap:10px; }
.apw-invoice-status-actions .button { min-height:40px; margin:0; }
@media (max-width: 640px) {
  .apw-invoice-status-actions { justify-content:flex-start; }
}
