.purchasing-page { color: #203344; padding: 1.15rem; }
.purchasing-page * { box-sizing: border-box; }
.purchasing-hero {
    align-items: flex-start;
    background: radial-gradient(circle at 88% 10%, rgba(103,216,182,.24), transparent 32%), linear-gradient(128deg,#15384d,#176b68);
    border-radius: 18px;
    color: #fff;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 22px 24px;
}
.purchasing-hero h1 { font-size: 1.75rem; font-weight: 950; letter-spacing: -.035em; margin: 0; }
.purchasing-hero p { color: #d2e9e8; margin: 5px 0 0; max-width: 720px; }
.mode-strip { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.mode-badge { background: #ffffff1c; border: 1px solid #ffffff42; border-radius: 999px; font-size: .67rem; font-weight: 900; padding: 6px 9px; white-space: nowrap; }
.mode-badge.test { background: #dff8e8; border-color: #b9e6ca; color: #1b6840; }
.purchasing-toolbar { align-items: center; background: #fff; border: 1px solid #d7e1e7; border-radius: 13px; display: flex; gap: 9px; margin-bottom: 14px; padding: 11px; }
.purchasing-toolbar input,.purchasing-toolbar select { border: 1px solid #bdcbd4; border-radius: 8px; min-height: 40px; padding: 8px 10px; }
.purchasing-toolbar input { flex: 1; }
.po-button { border: 0; border-radius: 8px; display: inline-flex; font-size: .76rem; font-weight: 900; justify-content: center; padding: 10px 13px; text-decoration: none; }
.po-button.primary { background: #176b68; color: #fff; }
.po-button.secondary { background: #e7eff3; color: #254d63; }
.po-button.test { background: #e3f5ea; color: #17613c; }
.po-button.danger { background: #fae6e3; color: #9d332b; }
.po-button:hover { filter: brightness(.96); }
.po-notice { border-radius: 10px; margin-bottom: 13px; padding: 11px 13px; }
.po-notice.success { background: #e4f5e9; color: #1d6940; }
.po-notice.error { background: #fde8e6; color: #98342e; }
.po-reference-health { background:#fff; border:1px solid #d7e1e7; border-radius:13px; margin-bottom:14px; padding:12px; }
.po-reference-health > header { align-items:center; display:flex; gap:12px; justify-content:space-between; margin-bottom:10px; }
.po-reference-health h2 { font-size:.86rem; font-weight:950; margin:0; }
.po-reference-health p { color:#6d818d; font-size:.68rem; margin:3px 0 0; }
.po-reference-grid { display:grid; gap:7px; grid-template-columns:repeat(7,minmax(85px,1fr)); }
.po-reference-stat { border:1px solid #dbe4e8; border-left:4px solid #d09b2c; border-radius:8px; padding:8px 9px; }
.po-reference-stat.ready { border-left-color:#23825c; }
.po-reference-stat.missing { background:#fff8ea; }
.po-reference-stat strong,.po-reference-stat span,.po-reference-stat small { display:block; }
.po-reference-stat strong { font-size:.92rem; }
.po-reference-stat span { color:#4d6674; font-size:.61rem; font-weight:900; text-transform:uppercase; }
.po-reference-stat small { color:#7b8c95; font-size:.57rem; margin-top:2px; }
.po-reference-error { background:#fde9e7; border-radius:7px; color:#943932; font-size:.67rem; margin-top:8px; padding:8px 9px; }
.po-list { background: #fff; border: 1px solid #d7e1e7; border-radius: 14px; overflow: hidden; }
.po-list-head { align-items: center; display: grid; gap: 13px; grid-template-columns: minmax(240px,1.4fr) minmax(150px,.75fr) 120px minmax(155px,.7fr) minmax(155px,.7fr) 110px 76px; padding: 12px 15px; }
.po-list-head { background: #f1f6f8; color: #607886; font-size: .64rem; font-weight: 950; letter-spacing: .06em; text-transform: uppercase; }
.po-list-row { align-items: center; border-top: 1px solid #e2e9ed; display: grid; grid-template-columns: minmax(0,1fr) 76px; padding-right: 15px; }
.po-list-main { align-items: center; color: inherit; display: grid; gap: 13px; grid-template-columns: minmax(240px,1.4fr) minmax(150px,.75fr) 120px minmax(155px,.7fr) minmax(155px,.7fr) 110px; padding: 12px 15px; text-decoration: none; }
.po-list-main:hover { color: inherit; }
.po-remove-button { background: #fff; border: 1px solid #d7a7a1; border-radius: 8px; color: #a13b31; cursor: pointer; font-size: .72rem; font-weight: 850; min-height: 34px; padding: 6px 9px; }
.po-remove-button:hover { background: #fff0ee; border-color: #bd5b50; color: #862d25; }
.po-list-row:hover { background: #f5fafb; color: inherit; }
.po-list-row strong { color: #175c7b; }
.po-muted { color: #70838e; font-size: .7rem; }
.po-number { font-weight: 900; }
.status-pill { border-radius: 999px; display: inline-flex; font-size: .64rem; font-weight: 950; padding: 5px 8px; text-transform: uppercase; }
.status-pill.draft,.status-pill.not-sent,.status-pill.skipped { background: #e8eef2; color: #526b79; }
.status-pill.pushing,.status-pill.sending { background: #fff1cc; color: #87620c; }
.status-pill.synced,.status-pill.created { background: #ddf3e6; color: #1f7044; }
.status-pill.partial { background: #fff0d6; color: #8d5c08; }
.status-pill.failed { background: #fbe4e2; color: #a13a33; }
.po-empty { color: #73858f; padding: 45px; text-align: center; }
.intake-workbench { display: grid; gap: 14px; grid-template-columns: minmax(330px,460px) minmax(0,1fr); }
.intake-editor { min-width: 0; }
.intake-panel { background: #fff; border: 1px solid #d7e1e7; border-radius: 14px; overflow: hidden; }
.intake-panel > header { background: #f2f7f8; border-bottom: 1px solid #dde6ea; padding: 12px 14px; }
.intake-panel > header h2 { font-size: .95rem; font-weight: 950; margin: 0; }
.intake-panel > header p { color: #6f838f; font-size: .69rem; margin: 3px 0 0; }
.intake-body { padding: 14px; }
.document-panel { align-self: start; position: sticky; top: 12px; }
.document-frame { background: #edf2f4; border: 1px solid #d3dee3; border-radius: 9px; height: 580px; overflow: hidden; }
.document-frame iframe,.document-frame img { border: 0; height: 100%; object-fit: contain; width: 100%; }
.document-empty { align-items: center; color: #768a95; display: flex; flex-direction: column; height: 100%; justify-content: center; padding: 30px; text-align: center; }
.document-empty strong { color: #31566b; }
.upload-form { display: grid; gap: 8px; margin-top: 10px; }
.upload-form input[type=file] { border: 1px dashed #a9bcc7; border-radius: 8px; padding: 9px; width: 100%; }
.po-ocr-setup { background:#fff4d8; border:1px solid #ead49b; border-radius:8px; color:#765712; display:grid; font-size:.68rem; gap:2px; margin-top:10px; padding:9px 10px; }
.form-grid { display: grid; gap: 11px; grid-template-columns: repeat(4,minmax(0,1fr)); }
.po-field { min-width: 0; position: relative; }
.po-field.span-2 { grid-column: span 2; }
.po-field.span-4 { grid-column: 1/-1; }
.po-field label { color: #546d7b; display: block; font-size: .62rem; font-weight: 950; letter-spacing: .04em; margin-bottom: 4px; text-transform: uppercase; }
.po-field input,.po-field select,.po-field textarea { border: 1px solid #b9c9d2; border-radius: 8px; min-height: 39px; padding: 8px 9px; width: 100%; }
.po-field textarea { min-height: 74px; }
.reference-results { background: #fff; border: 1px solid #b9c9d2; border-radius: 8px; box-shadow: 0 10px 24px #24455722; display: none; left: 0; max-height: 230px; overflow: auto; position: absolute; right: 0; top: 64px; z-index: 20; }
.reference-results.open { display: block; }
.reference-result { background: #fff; border: 0; border-top: 1px solid #e5ecef; display: block; padding: 9px; text-align: left; width: 100%; }
.reference-result:first-child { border: 0; }
.reference-result:hover { background: #edf7f6; }
.reference-result strong { display: block; font-size: .76rem; }
.reference-result small { color: #71838e; }
.matched-value { color: #26704c; font-size: .63rem; font-weight: 850; margin-top: 3px; }
.lines-wrap { overflow: auto; }
.po-lines { border-collapse: separate; border-spacing: 0; min-width: 1280px; table-layout: fixed; width: 100%; }
.po-lines th { background: #eef4f6; color: #58707e; font-size: .57rem; letter-spacing: .045em; padding: 6px; text-transform: uppercase; }
.po-lines td { border-top: 1px solid #e2eaee; padding: 5px 6px; vertical-align: top; }
.po-lines input,.po-lines select { border: 1px solid #bdcbd4; border-radius: 7px; font-size: .72rem; min-height: 32px; padding: 5px 6px; width: 100%; }
.po-lines th:nth-child(1),.po-lines .include { width: 44px; }
.po-lines th:nth-child(2),.po-lines .part { width: 145px; }
.po-lines th:nth-child(3),.po-lines .desc { width: 220px; }
.po-lines th:nth-child(4),.po-lines .qty { width: 82px; }
.po-lines th:nth-child(5),.po-lines .cost { width: 92px; }
.po-lines th:nth-child(6),.po-lines .amount { width: 88px; }
.po-lines th:nth-child(7),.po-lines .match { width: 190px; }
.po-lines th:nth-child(8),.po-lines .m1-job-cell { width: 265px; }
.po-lines th:nth-child(9),.po-lines .tax-cell { width: 125px; }
.po-lines th:nth-child(10) { width: 30px; }
.po-lines .match { position: relative; }
.m1-job-detail { color:#526b79; display:grid; font-size:.6rem; gap:1px; margin-top:3px; min-height:14px; }
.m1-job-detail strong { color:#23586f; font-size:.64rem; line-height:1.2; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.m1-job-detail small { color:#7a8d98; font-size:.55rem; }
.line-bulk-tools { align-items:end; background:#eaf4f7; border-bottom:1px solid #d7e5ea; display:grid; gap:9px; grid-template-columns:minmax(220px,1fr) minmax(280px,420px) auto; padding:8px 12px; }
.line-bulk-tools label { color:#315a6d; display:block; font-size:.67rem; font-weight:950; }
.line-bulk-tools small { color:#718590; display:block; font-size:.59rem; margin-top:2px; }
.line-bulk-tools select { border:1px solid #aec2cd; border-radius:7px; min-height:34px; padding:6px 8px; width:100%; }
.po-section-title { font-size:.92rem; margin:11px 0 6px; }
.po-intake-edit .intake-panel > header { padding:9px 12px; }
.po-intake-edit .intake-body { padding:10px 12px; }
.po-intake-edit .form-grid { gap:7px 9px; }
.po-intake-edit .po-field input,.po-intake-edit .po-field select { min-height:34px; padding:6px 8px; }
.po-intake-edit .po-field textarea { min-height:48px; padding:6px 8px; }
.po-intake-edit .target-grid { margin-bottom:8px; }
.line-amount { display: block; font-weight: 900; padding-top: 9px; text-align: right; }
.line-remove { background: #fae7e4; border: 0; border-radius: 7px; color: #9a352e; font-weight: 900; padding: 8px; }
.editor-actions { align-items: center; border-top: 1px solid #e0e8ec; display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; margin-top: 13px; padding-top: 13px; }
.editor-actions .group { display: flex; flex-wrap: wrap; gap: 8px; }
.po-total { font-size: 1.05rem; font-weight: 950; }
.target-grid { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; margin-bottom: 14px; }
.target-card { border: 1px solid #d7e2e7; border-radius: 12px; padding: 12px; }
.target-card h3 { font-size: .8rem; font-weight: 950; margin: 0; }
.target-number { color: #176b68; font-size: 1.15rem; font-weight: 950; margin: 8px 0 2px; }
.target-error { background: #fce9e7; border-radius: 7px; color: #92352f; font-size: .7rem; margin-top: 7px; padding: 7px; }
.attempts { font-size: .72rem; width: 100%; }
.attempts td,.attempts th { border-top: 1px solid #e2e9ed; padding: 7px; text-align: left; }
.attempts th { color: #617987; font-size: .6rem; text-transform: uppercase; }
.locked-note { background: #fff2d6; border-radius: 9px; color: #81590f; margin-bottom: 12px; padding: 10px; }
.advanced { border: 1px solid #dce5e9; border-radius: 9px; margin-top: 12px; padding: 8px 10px; }
.advanced summary { color: #245d78; cursor: pointer; font-size: .72rem; font-weight: 900; }
.advanced .form-grid { margin-top: 10px; }
.source-chip { background: #e9f0f3; border-radius: 999px; color: #617683; font-size: .55rem; font-weight: 900; padding: 3px 6px; }
.ocr-confidence { color: #6a7f8b; font-size: .56rem; }
.purchasing-page input:disabled,.purchasing-page select:disabled,.purchasing-page textarea:disabled { background: #eef2f4; color: #526570; }
.danger-note { color: #9c352e; font-size: .68rem; margin-top: 6px; }

@media (max-width: 1100px) {
    .intake-workbench { grid-template-columns: 1fr; }
    .document-panel { position: static; }
    .document-frame { height: 450px; }
    .po-list-head { grid-template-columns: minmax(220px,1.3fr) 130px 100px minmax(140px,.7fr) minmax(140px,.7fr) 76px; }
    .po-list-head > *:nth-child(6) { display: none; }
    .po-list-main { grid-template-columns: minmax(220px,1.3fr) 130px 100px minmax(140px,.7fr) minmax(140px,.7fr); }
    .po-list-main > *:last-child { display: none; }
}
@media (max-width: 1350px) {
    .line-bulk-tools { grid-template-columns:1fr minmax(250px,1fr); }
    .line-bulk-tools .po-button { grid-column:2; }
}
@media (max-width: 760px) {
    .purchasing-page { padding: 10px; }
    .purchasing-hero { display: block; }
    .mode-strip { justify-content: flex-start; margin-top: 12px; }
    .purchasing-toolbar { align-items: stretch; display: grid; }
    .po-list-head { display: none; }
    .po-list-row { grid-template-columns: minmax(0,1fr) 76px; }
    .po-list-main { display: grid; grid-template-columns: 1fr 1fr; }
    .po-list-main > div:first-child { grid-column: 1/-1; }
    .po-reference-health > header { align-items:stretch; flex-direction:column; }
    .po-reference-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .form-grid { grid-template-columns: 1fr 1fr; }
    .po-field.span-4 { grid-column: 1/-1; }
    .target-grid { grid-template-columns: 1fr; }
    .document-frame { height: 360px; }
    .line-bulk-tools { align-items:stretch; grid-template-columns:1fr; }
    .line-bulk-tools .po-button { grid-column:1; }
}
@media (max-width: 480px) {
    .form-grid { grid-template-columns: 1fr; }
    .po-field.span-2,.po-field.span-4 { grid-column: 1; }
    .po-list-row { grid-template-columns: minmax(0,1fr) 76px; }
    .po-list-main { grid-template-columns: 1fr; }
}
