/* Purchase Receipts — structure; reuses Procurement list/detail chrome from ordering.css */

.hub-main:has(#purchase-receipts-panel:not([hidden])) {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.hub-main:has(#purchase-receipts-panel:not([hidden])) > .subnav {
  flex: 0 0 auto;
}

.hub-main:has(#purchase-receipts-panel:not([hidden])) > .stage {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding-bottom: 8px;
}

#purchase-receipts-panel:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.pr {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  font-size: 0.95rem;
}

.pr > .list-head {
  margin-bottom: 0;
  flex: 0 0 auto;
}

.pr > .list-head.is-compact h2 {
  font-size: 1.25rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.pr .ord-po-workspace {
  flex: 1 1 auto;
  min-height: 0;
}

/* List scrolls sideways when columns are wider than the pane (TABLES.md). */
.pr .ord-po-list {
  min-width: 0;
  overflow: auto;
}

.pr .ord-po-table {
  overflow-x: auto;
}

.pr-help {
  margin: 0 0 8px;
  font-size: 0.875rem;
  color: var(--muted);
}

.pr-grn {
  margin: 4px 0 0;
  font-size: 0.95rem;
  color: var(--brand);
  letter-spacing: 0.01em;
}

.pr-grn strong {
  font-weight: 700;
}

.pr-detail .ord-po-detail-head {
  margin-bottom: 8px;
}

/*
 * Receipt lines are 7 columns. Ordering’s `.ord-po-detail .ord-guide-*` rule
 * forces an 8/9-column PO layout — beat it with higher specificity.
 * Columns: code | description | price | ordered | received | this delivery | this £
 */
.pr .ord-po-detail .pr-lines-table.ord-guide-table > .ord-guide-head,
.pr .ord-po-detail .pr-lines-table.ord-guide-table > .ord-guide-row {
  grid-template-columns:
    88px
    minmax(140px, 1.4fr)
    72px
    64px
    72px
    120px
    84px;
  gap: 2px 8px;
}

.pr .ord-po-detail .pr-lines-table.ord-guide-table > .ord-guide-head > span:nth-child(3),
.pr .ord-po-detail .pr-lines-table.ord-guide-table > .ord-guide-head > span:nth-child(4),
.pr .ord-po-detail .pr-lines-table.ord-guide-table > .ord-guide-head > span:nth-child(5),
.pr .ord-po-detail .pr-lines-table.ord-guide-table > .ord-guide-head > span:nth-child(6),
.pr .ord-po-detail .pr-lines-table.ord-guide-table > .ord-guide-head > span:nth-child(7) {
  text-align: center;
}

.pr-ordered-qty,
.pr-received-qty,
.pr-unit-price,
.pr-received-total {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-align: center;
}

.pr .ord-po-detail .pr-lines-table .ord-qty-stepper {
  justify-self: stretch;
  width: 100%;
  max-width: 120px;
  justify-content: flex-end;
}

.pr-lines-table .ord-guide-row.is-short .pr-ordered-qty {
  color: var(--warning);
}

.pr-lines-table .ord-guide-row.is-over .ord-qty {
  border-color: var(--warning);
}

.pr-detail-foot {
  margin-top: 10px;
}

.pr-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 28px;
  align-items: baseline;
}

.pr-receipt-total strong {
  color: var(--brand);
}

.pr-note-fields {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  max-width: 36rem;
}

.pr-note-field {
  display: grid;
  gap: 6px;
  margin-top: 0;
  max-width: 36rem;
}

.pr-note-field > span {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.pr-note-field textarea,
.pr-note-field input[type="text"] {
  font: inherit;
  font-family: var(--font-body);
  font-size: 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--field-radius);
  background-color: var(--surface-2);
  color: var(--ink);
  padding: 8px 10px;
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
  background-clip: padding-box;
}

.pr-note-field textarea {
  min-height: 64px;
  resize: vertical;
}

.pr-note-field textarea:focus,
.pr-note-field input[type="text"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.ord-pill.pr-status-awaiting {
  background: #2a2a2a;
  color: #d4d4d4;
  border-color: #3a3a3a;
}

.ord-pill.pr-status-partial {
  background: #3a2a14;
  color: #f0c078;
  border-color: #6a4a22;
}

.ord-pill.pr-status-received {
  background: #143028;
  color: #7ddeb0;
  border-color: #1f4a38;
}

html[data-theme="light"] .ord-pill.pr-status-awaiting {
  background: #eef0f3;
  color: #2a2e33;
  border-color: #d5d8de;
}

html[data-theme="light"] .ord-pill.pr-status-partial {
  background: #fff1e0;
  color: #8a3d00;
  border-color: #f0c48a;
}

html[data-theme="light"] .ord-pill.pr-status-received {
  background: #e5f6ec;
  color: #0a6b34;
  border-color: #b7e4c7;
}

.ord-pill.pr-status-closed {
  background: #2a2a2a;
  color: #d4d4d4;
  border-color: #3a3a3a;
}

html[data-theme="light"] .ord-pill.pr-status-closed {
  background: #eef0f3;
  color: #2a2e33;
  border-color: #d5d8de;
}

html[data-theme="light"] .ord-pill.pr-status-backorder {
  background: #f3e8ff;
  color: #4c2d8a;
  border-color: #d4c4f5;
}

.ord-pill.pr-status-backorder {
  background: #2a2040;
  color: #d4c4f5;
  border-color: #4c3a6a;
}

.pr-status-stack {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  align-items: center;
}

.pr-already {
  display: block;
  font-size: 0.78rem;
  margin-top: 2px;
}

.pr-grn-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 4px;
  font-size: 0.86rem;
  color: var(--ink-muted, #4b5563);
}

.pr-grn-list li {
  margin: 0;
}

.pr-closed-banner {
  margin-bottom: 12px;
}

#pr-close-layer .ord-sendback-field select,
#pr-close-layer .ord-sendback-field input[type="date"] {
  font: inherit;
  font-family: var(--font-body);
  font-size: 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--field-radius);
  background-color: var(--surface-2);
  color: var(--ink);
  padding: 8px 10px;
  width: 100%;
  box-shadow: none;
  background-clip: padding-box;
}

#pr-close-layer .ord-sendback-field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 8px center;
}

#pr-close-layer .ord-sendback-field select:focus,
#pr-close-layer .ord-sendback-field input[type="date"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
