/* PO-only density and responsive columns. Line items remain the original grid. */
#view-vendors:has([data-vendors-panel="purchased"]:not([hidden])) { max-width: none; }
[data-po-browse-panel], #poBrowsePanel { min-width: 0; container-type: inline-size; }
:is([data-po-browse-panel], #poBrowsePanel) .toolbar { flex-wrap: wrap; gap: 8px; }
:is([data-po-browse-panel], #poBrowsePanel) .search-wrap { flex: 1 1 240px; min-width: 120px; max-width: 490px; }
:is([data-po-browse-panel], #poBrowsePanel) .toolbar-actions { flex-wrap: wrap; gap: 8px; min-width: 0; }
:is([data-po-browse-panel], #poBrowsePanel) .toolbar-actions :is(input, select) { min-height: 30px; max-width: 100%; }
:is([data-po-browse-panel], #poBrowsePanel) .toolbar-actions select { width: 144px; }
.po-list { min-width: 0; width: 100%; gap: 8px; }
.po-list .po-register-header, .po-list .po-header.po-register-row {
  grid-template-columns: minmax(156px, 1.35fr) 70px minmax(120px, 2fr) 104px minmax(62px, .7fr) 76px 83px 118px minmax(66px, .7fr) 76px 160px;
  gap: 0; padding: 0 6px; width: 100%; box-sizing: border-box;
}
.po-list .po-register-header { display: grid; border-radius: 3px; font-size: 10px; font-weight: 500; }
.po-list .po-register-header > div { padding: 6px 5px; min-width: 0; overflow-wrap: anywhere; }
.po-list .po-register-header > :nth-child(7) { text-align: right; }
.po-list .po-block { min-width: 0; border-radius: 3px; overflow: visible; box-shadow: none; }
.po-list .po-register-header > :nth-child(10) { text-transform: none; }
.po-list .po-block.collapsed .po-toggle-triangle { border: 0; border-top: 4px solid transparent; border-bottom: 4px solid transparent; border-left: 6px solid var(--ink); }
.po-list .po-block:not(.collapsed) .po-toggle-triangle { border: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 6px solid var(--ink); }
:is([data-po-browse-panel], #poBrowsePanel) .upload-status:empty { display: none; }
.po-list .po-header { min-height: 66px; border-bottom: 1px solid var(--line); }
.po-list .po-block.collapsed .po-header { border-bottom: 0; }
.po-list .po-cell { display: block; min-width: 0; padding: 7px 5px; overflow: visible; overflow-wrap: anywhere; white-space: normal; font-size: 12px; }
.po-list .po-cell::before { display: none; }
.po-list .po-title { display: flex; gap: 6px; flex-wrap: wrap; }
.po-list .po-title strong { font-size: 13px; }
.po-list .po-line-count { font-size: 11px; white-space: normal; }
.po-list .po-toggle-icon { flex: 0 0 18px; width: 18px; }
.po-list .po-pdf-button { padding: 3px 4px; min-height: 22px; }
.po-list .po-status-select { font-size: 11px; min-height: 28px; padding: 2px 3px; }
.po-list .po-total-cell { text-align: right; }
.po-list .po-eta-cell > span { display: block; }
.po-list :is(.po-read-text, .po-text-button, .po-tracking-link) { min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; overflow: visible; font-size: 12px; }
.po-list .po-tracking-stack { gap: 3px; }
.po-list :is(.po-emailed-note, .po-tracking-carrier) { font-size: 11px; white-space: normal; }
.po-action-strip { display: flex; align-items: center; justify-content: flex-end; gap: 4px; width: 150px; margin-left: auto; }
.po-action-strip .mini-button { height: 30px; min-height: 30px; padding: 0; border-radius: 4px; }
.po-action-strip .po-receive-button { flex: 0 0 82px; width: 82px; font-size: 11px; white-space: nowrap; }
.po-action-strip .icon-only { display: inline-flex; flex: 0 0 30px; align-items: center; justify-content: center; width: 30px; min-width: 30px; }
.po-action-strip svg, .po-drawer-icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.po-payment-badge { display: inline-block; border: 0; border-radius: 3px; padding: 4px 7px; font-size: 11px; font-weight: 700; line-height: 1.25; cursor: pointer; text-align: left; max-width: 100%; }
.po-payment-unpaid, .po-payment-none { background: #ebebee; color: #62616c; }
.po-payment-deposit { background: #eaf1fb; color: #32659b; }
.po-payment-partial { background: #fff3df; color: #996000; }
.po-payment-paid { background: #e8f3ec; color: #267d50; }
.po-payment-detail, .po-qb-cell small { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; line-height: 1.35; }
.po-qb-synced { color: #267d50; font-weight: 600; }
.po-qb-changes { color: #996000; font-weight: 600; }
.po-qb-unsent { color: var(--muted); }
.po-list .po-lines { min-width: 0; width: 100%; overflow: visible; }
.po-list .po-lines[hidden] { display: none; }
.po-list .po-line { min-width: 0; width: 100%; box-sizing: border-box; grid-template-columns: minmax(85px, .8fr) minmax(100px, 4fr) repeat(3, minmax(60px, .7fr)) repeat(2, minmax(62px, .7fr)); gap: 6px; padding: 7px 10px; }
.po-list .po-line > div { min-width: 0; overflow-wrap: anywhere; white-space: normal; }
.po-list .po-line > :nth-last-child(-n+2) { text-align: right; }
.po-list .po-line .sku { white-space: normal; }
.po-list .po-danger-actions { display: flex; flex-wrap: wrap; }
/* At narrower desktops, secondary cells move to consistent sublines. */
@container (max-width: 1280px) {
  .po-list .po-register-header, .po-list .po-header.po-register-row {
    grid-template-columns: minmax(130px, 1.2fr) minmax(100px, 1.5fr) 102px 84px 80px 112px 72px 160px;
  }
  .po-list .po-register-header > :is(:nth-child(2), :nth-child(5), :nth-child(9)) { display: none; }
  .po-list .po-title { grid-area: 1 / 1; }
  .po-list .po-date-cell { grid-area: 2 / 1; }
  .po-list .po-vendor-cell { grid-area: 1 / 2; }
  .po-list .po-terms-cell { grid-area: 2 / 2; }
  .po-list .po-status-cell { grid-area: 1 / 3 / 3 / 4; }
  .po-list .po-eta-cell { grid-area: 1 / 4; }
  .po-list .po-tracking-cell { grid-area: 2 / 4; }
  .po-list .po-total-cell { grid-area: 1 / 5 / 3 / 6; }
  .po-list .po-payment-cell { grid-area: 1 / 6 / 3 / 7; }
  .po-list .po-qb-cell { grid-area: 1 / 7 / 3 / 8; }
  .po-list .po-actions-cell { grid-area: 1 / 8 / 3 / 9; }
  .po-list :is(.po-date-cell, .po-terms-cell, .po-tracking-cell) { padding-top: 0; color: var(--muted); font-size: 11px; }
  .po-list .po-terms-cell::before { display: inline; content: "Terms: "; text-transform: none; font-weight: 400; }
  .po-list .po-tracking-cell::before { display: inline; content: "Tracking: "; text-transform: none; font-weight: 400; }
}
@container (max-width: 890px) {
  .po-list .po-register-header { display: none; }
  .po-list .po-header.po-register-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr) 160px; align-items: center; padding: 5px; }
  .po-list .po-title { grid-area: 1 / 1; }
  .po-list .po-vendor-cell { grid-area: 1 / 2; }
  .po-list .po-status-cell { grid-area: 1 / 3; }
  .po-list .po-actions-cell { grid-area: 1 / 4 / 3 / 5; }
  .po-list .po-date-cell { grid-area: 2 / 1; }
  .po-list .po-terms-cell { grid-area: 2 / 2 / 3 / 4; }
  .po-list .po-eta-cell { grid-area: 3 / 1; }
  .po-list .po-tracking-cell { grid-area: 4 / 1; }
  .po-list .po-total-cell { grid-area: 3 / 2 / 5 / 3; text-align: left; }
  .po-list .po-payment-cell { grid-area: 3 / 3 / 5 / 4; }
  .po-list .po-qb-cell { grid-area: 3 / 4 / 5 / 5; }
  .po-list :is(.po-eta-cell, .po-total-cell, .po-qb-cell)::before { display: block; content: attr(data-label); font-size: 10px; color: var(--muted); margin-bottom: 3px; }
  .po-list .po-line { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) repeat(3, minmax(0, 1fr)); }
  .po-list .po-line > :nth-child(2) { grid-column: 2 / -1; }
  .po-list .po-line > :nth-child(3) { grid-column: 1; }
}
@container (max-width: 520px) {
  .po-list .po-header.po-register-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .po-list .po-cell { grid-area: auto; }
  .po-list .po-title, .po-list .po-vendor-cell, .po-list .po-actions-cell { grid-column: 1 / -1; }
  .po-list .po-actions-cell { grid-row: 8; }
  .po-list .po-action-strip { margin-left: 0; }
  .po-list .po-line { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .po-list .po-line > :nth-child(2) { grid-column: 2 / -1; }
  .po-list .po-line > :nth-child(3) { grid-column: 1; }
  :is([data-po-browse-panel], #poBrowsePanel) .drop-upload { flex-wrap: wrap; }
  :is([data-po-browse-panel], #poBrowsePanel) .toolbar-actions { width: 100%; }
}
.po-more-menu { position: fixed; inset: auto; margin: 0; padding: 5px; width: 244px; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow-y: auto; border: 1px solid var(--line); border-radius: 5px; background: white; box-shadow: 0 8px 28px #0002; z-index: 10001; }
.po-more-menu button { display: block; width: 100%; min-height: 34px; text-align: left; padding: 7px 9px; white-space: normal; background: white; border: 0; font-size: 12px; border-radius: 3px; }
.po-more-menu button:hover { background: #f9eef2; }
.po-more-menu .danger-outline-button { color: #b83242; }
dialog.po-payment-drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: 430px; max-width: 100vw; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; padding: 0; background: #fff; color: var(--text); box-shadow: -6px 0 30px #0002; overflow-y: auto; overflow-x: hidden; }
dialog.po-payment-drawer::backdrop { background: #16161d26; backdrop-filter: none; }
.po-payment-drawer * { box-sizing: border-box; min-width: 0; letter-spacing: 0; }
.po-payment-drawer header { display: flex; gap: 12px; justify-content: space-between; padding: 22px 24px 18px; border-bottom: 1px solid var(--line); }
.po-payment-drawer h2 { font-size: 20px; line-height: 1.3; margin: 0 0 5px; overflow-wrap: anywhere; }
.po-payment-drawer h3 { font-size: 14px; margin: 0 0 16px; }
.po-drawer-vendor { margin: 0 0 12px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.po-drawer-icon { display: inline-flex; justify-content: center; align-items: center; background: white; border: 1px solid var(--line); border-radius: 4px; height: 32px; width: 32px; flex: 0 0 32px; }
.po-drawer-content { padding: 18px 24px 30px; font-size: 13px; }
.po-drawer-totals { display: grid; gap: 14px; }
.po-drawer-totals > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.po-drawer-totals span, .po-drawer-terms span { color: var(--muted); font-size: 12px; }
.po-drawer-totals strong { font-size: 20px; overflow-wrap: anywhere; }
.po-drawer-totals .po-payment-balance { display: block; background: #fcf1f5; padding: 14px; border-radius: 4px; }
.po-payment-balance strong { display: block; font-size: 24px; }
.po-drawer-terms { margin: 20px 0; overflow-wrap: anywhere; }
.po-drawer-terms span { display: block; margin-bottom: 6px; }
.po-payment-history { border-top: 1px solid var(--line); padding-top: 18px; }
.po-payment-entry { border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 18px; overflow-wrap: anywhere; }
.po-payment-entry > div:first-child { display: flex; gap: 12px; justify-content: space-between; }
.po-payment-entry p { margin: 7px 0; line-height: 1.45; color: var(--muted); }
.po-payment-entry small { display: block; font-size: 11px; color: var(--muted); }
.po-payment-entry details { margin-top: 10px; font-size: 11px; }
.po-payment-entry details p { white-space: pre-wrap; }
.po-payment-entry.voided > div:first-child { text-decoration: line-through; color: var(--muted); }
.po-payment-entry-actions { display: flex; gap: 12px; margin-top: 8px; }
.po-payment-entry-actions button { border: 0; background: transparent; font-size: 11px; padding: 3px 0; color: #6c5461; text-decoration: underline; }
.po-payment-form fieldset { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 12px; padding: 0; margin: 0; border: 0; }
.po-payment-form label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 400; text-transform: none; }
.po-payment-form input, .po-payment-form select, .po-payment-form textarea { width: 100%; font: inherit; color: var(--text); padding: 9px 10px; border: 1px solid #d7d6dc; border-radius: 4px; background: white; min-height: 38px; }
.po-payment-form input[type=date] { cursor: pointer; }
.po-payment-form textarea { min-height: 70px; resize: vertical; }
.po-payment-wide { grid-column: 1 / -1; }
.po-payment-form button[type=submit] { width: 100%; margin-top: 16px; min-height: 40px; }
.po-payment-after { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 12px; }
.po-payment-after strong { color: #267d50; }
.po-payment-after strong.negative { color: #ae243a; }
.po-payment-feedback { margin: 12px 0; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.po-payment-feedback:empty { display: none; }
.po-payment-feedback.error { background: #fff0f1; padding: 10px; border: 1px solid #e4adb5; color: #a32535; }
.po-payment-feedback.success { color: #267d50; }
@media (max-width: 560px) {
  dialog.po-payment-drawer { width: 100vw; }
  .app-shell:has(#view-vendors.active) { grid-template-columns: minmax(0, 1fr); }
  .app-shell:has(#view-vendors.active) .app-sidebar { width: 100%; }
  #view-vendors .sub-tabs { display: flex; flex-wrap: wrap; width: 100%; }
  #view-vendors .sub-tab { flex: 1 1 auto; min-width: 0; }
  :is([data-po-browse-panel], #poBrowsePanel) .search-wrap { flex: 0 0 auto; width: 100%; }
}
@media (min-width: 561px) and (max-width: 1180px) {
  .app-shell:has(#view-vendors.active) .app-sidebar .main-nav { grid-template-columns: minmax(0, 1fr); }
}
