/* views-supplier — orders (shared PO page), supplier portal and credit partner. All classes prefixed .sp- */

/* ---------- responsive switches ---------- */
.sp-only-narrow { display: none !important; }
@media (max-width: 760px) { .sp-only-wide { display: none !important; } .sp-only-narrow { display: flex !important; } }

/* ---------- orders list ---------- */
.sp-tabs-body { padding-bottom: 0; }
.sp-next { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 550; }
.sp-next.act { color: var(--action); font-weight: 650; }
.sp-next.bad { color: var(--bad); }
.table tr.sp-row-act td:first-child { box-shadow: inset 3px 0 0 var(--action); }
.sp-cards { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.sp-ocard { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: inherit; text-decoration: none !important; }
.sp-ocard.act { border-left: 3px solid var(--action); }
.sp-ocard:active { background: var(--surface-2); }

/* ---------- PO page ---------- */
.sp-po-grid > *, .sp-grid0 > * { min-width: 0; }
.sp-po-sub b { font-weight: 600; color: var(--text-2); }
.sp-actbar .card-head h3 { color: var(--action); }
.sp-act { display: flex; gap: 12px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--border); }
.sp-act:first-child { border-top: 0; }
.sp-act .grow { flex: 1; min-width: 0; }
.sp-act b { display: block; }
@media (max-width: 640px) { .sp-act { flex-wrap: wrap; } .sp-act > .btn, .sp-act > .row { width: 100%; } .sp-act > .btn { justify-content: center; } .sp-act > .row .btn { flex: 1; } }
.sp-steps { padding: 14px 10px 10px; }
.sp-steps .step .tiny { font-weight: 500; margin-top: 1px; }

.sp-po-doc { overflow: hidden; }
.sp-doc-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 18px; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, var(--surface-2), var(--surface)); }
.sp-doc-kicker { font-size: 11px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; color: var(--brand); }
.sp-doc-no { font-size: 24px; font-weight: 750; letter-spacing: -0.02em; font-family: var(--mono); margin: 2px 0; }
.sp-dl { font-size: 12.5px; gap: 4px 12px; grid-template-columns: minmax(70px, auto) 1fr; }
.sp-doc-parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.sp-party h4 { margin-bottom: 4px; }
.sp-party b { display: block; }
.sp-parties { display: flex; flex-direction: column; gap: 14px; }
.sp-doc-lines td:first-child { min-width: 220px; }
.sp-doc-totals { margin-left: auto; width: min(420px, 100%); padding: 10px 20px 14px; display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
.sp-tot { display: flex; justify-content: space-between; gap: 14px; }
.sp-tot .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sp-tot.sub { border-top: 1px solid var(--border); padding-top: 5px; margin-top: 3px; color: var(--text-2); }
.sp-tot.grand { border-top: 2px solid var(--text); padding-top: 7px; margin-top: 4px; font-weight: 750; font-size: 15.5px; }
.sp-doc-totals.sp-in-modal { width: 100%; padding: 4px 0; }
.sp-doc-foot { padding: 12px 20px 16px; border-top: 1px solid var(--border); background: var(--surface-2); }
.sp-doc-foot p { margin-bottom: 4px; }
@media (max-width: 640px) {
  .sp-doc-head, .sp-doc-parties { grid-template-columns: 1fr; padding-left: 14px; padding-right: 14px; }
  .sp-doc-totals { padding: 10px 14px 14px; } .sp-doc-foot { padding: 12px 14px 14px; }
}

.sp-bn { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.sp-bn > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 11px; min-width: 0; }
.sp-bn .strong { font-size: 16px; white-space: nowrap; }

.sp-drop { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.sp-drop:first-child { border-top: 0; }
.sp-drop-head { display: flex; gap: 12px; align-items: flex-start; }
.sp-drop-head .grow { flex: 1; min-width: 0; }
.sp-drop-head .chip { margin-left: 4px; }
.sp-drop-facts { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--text-2); }
.sp-drop-facts span { display: inline-flex; align-items: center; gap: 5px; }
.sp-drop-lines { background: var(--surface-2); border-radius: var(--radius-sm); }
.sp-drop-lines th { background: transparent; }
.sp-drop details > summary { cursor: pointer; font-size: 12.5px; color: var(--muted); font-weight: 600; width: max-content; max-width: 100%; }
.sp-drop details[open] > summary { margin-bottom: 6px; }

.sp-issue, .sp-inv { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.sp-issue:first-child, .sp-inv:first-child { border-top: 0; }
.sp-issue p, .sp-inv p { margin: 0; }
.sp-inv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.sp-inv-grid > div { display: flex; flex-direction: column; background: var(--surface-2); border-radius: var(--radius-xs); padding: 7px 10px; }
.sp-inv-grid .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.sp-inv-grid .sp-inv-total { background: var(--brand-soft); }

/* goods-receipt modal */
.sp-grn { display: flex; flex-direction: column; gap: 10px; }
.sp-grn-line { display: grid; grid-template-columns: minmax(0, 1.6fr) 96px 96px 160px minmax(110px, .8fr); gap: 10px; align-items: end; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.sp-grn-short { align-self: center; padding-top: 18px; }
.sp-grn-sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.sp-grn-sum > div { display: flex; flex-direction: column; }
@media (max-width: 760px) {
  .sp-grn-line { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sp-grn-item { grid-column: 1 / -1; }
  .sp-grn-short { padding-top: 18px; }
  .sp-grn-sum { grid-template-columns: 1fr; }
}
.sp-ro { display: flex; align-items: center; background: var(--surface-2); font-variant-numeric: tabular-nums; }

/* ---------- print just the PO ---------- */
#sp-print-root { display: none; }
@media print {
  body.sp-printing { background: #fff; }
  body.sp-printing > *:not(#sp-print-root) { display: none !important; }
  body.sp-printing #sp-print-root { display: block; }
  #sp-print-root .sp-po-doc { box-shadow: none; border: 1px solid #999; border-radius: 0; }
  #sp-print-root .sp-doc-head, #sp-print-root .sp-doc-foot { background: #fff; }
  #sp-print-root .table-wrap { overflow: visible; }
  #sp-print-root .table th { position: static; }
}

/* ---------- supplier portal ---------- */
.sp-mini { display: inline-block; width: 64px; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; vertical-align: middle; flex: none; }
.sp-mini i { display: block; height: 100%; border-radius: 3px; }
.sp-tf { display: grid; grid-template-columns: minmax(0, 1fr) 64px 44px; gap: 10px; align-items: center; }
.sp-tf .num { text-align: right; }
.sp-w { display: flex; flex-direction: column; gap: 4px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.sp-w .sp-mini { width: 100%; }
.sp-hash { display: flex; flex-direction: column; gap: 4px; }
.sp-hash-v { text-align: left; border: 1px dashed var(--border-strong); background: var(--surface-2); border-radius: var(--radius-xs); padding: 7px 9px; font-size: 11.5px; word-break: break-all; cursor: copy; color: var(--text-2); }
.sp-hash-v:hover { border-color: var(--brand); }
.sp-rfq-areas { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; padding: 14px 18px 18px; border-top: 1px solid var(--border); }
.sp-rfq-areas h4 { margin-bottom: 6px; }
@media (max-width: 760px) { .sp-rfq-areas { grid-template-columns: 1fr; } }
.sp-bid-lines .sp-price { min-width: 150px; max-width: 190px; }
.sp-bid-lines td { vertical-align: middle; }
.sp-bid-sum { display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.sp-sum-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.sp-sum-row.grand { border-top: 1px solid var(--border-strong); padding-top: 7px; font-size: 15px; }
.sp-sum-row.muted { color: var(--muted); }
.sp-sum-factors { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; border-top: 1px dashed var(--border); padding-top: 7px; }
.sp-result { display: flex; gap: 28px; flex-wrap: wrap; }
.sp-result > div { display: flex; flex-direction: column; }
.sp-result small { font-size: 16px; font-weight: 600; color: var(--muted); letter-spacing: 0; }

.sp-day { font-size: 12.5px; font-weight: 650; color: var(--text-2); margin-top: 4px; }
.sp-run.due { border-left: 3px solid var(--action); }
.sp-run-head { display: flex; gap: 16px; align-items: center; padding: 14px 18px; flex-wrap: wrap; }
.sp-run-head .grow { flex: 1; min-width: 240px; }
.sp-run-prog { width: 150px; display: flex; flex-direction: column; gap: 4px; }
.sp-run .table-wrap { border-top: 1px solid var(--border); }
.sp-run-more { padding: 0 18px 12px; }
.sp-run-more > summary { cursor: pointer; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 2px 0 8px; }
.sp-run-more .table-wrap { margin: 0 -18px; }
.sp-map { height: 280px; margin: 0 18px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); z-index: 0; }
.sp-pin { background: transparent; border: 0; }
.sp-pin span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; font-size: 12px; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
@media (max-width: 640px) { .sp-run-prog { width: 100%; } .sp-run-head .grow { min-width: 0; } }

.table tr.sp-row-bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.sp-score { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.sp-fv { min-width: 130px; }
.sp-stoplist { flex-direction: column; border-top: 1px solid var(--border); }
.sp-stop { display: flex; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); }
.sp-stop:first-child { border-top: 0; }
.sp-stop .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sp-seq { width: 22px; height: 22px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 11.5px; display: grid; place-items: center; flex: none; }
.sp-run-more .sp-stoplist { margin: 0 -18px; }
.sp-fv b { white-space: nowrap; }
.sp-factors { flex-direction: column; }
.sp-factor { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; border-top: 1px solid var(--border); }
.sp-factor:first-child { border-top: 0; }
.sp-factor .sp-mini { width: 120px; }
.sp-vis3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; font-size: 11.5px; color: var(--muted); }
.sp-vis3 b { display: block; color: var(--text); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* ---------- credit partner ---------- */
.sp-pay { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.sp-pay > div { display: flex; flex-direction: column; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 11px; }
.sp-pay b { font-size: 16px; font-variant-numeric: tabular-nums; }
.sp-decide { border-color: var(--action-line); box-shadow: 0 0 0 1px var(--action-line) inset, var(--shadow); }
.sp-sum-row .num { white-space: nowrap; }
@media (max-width: 760px) {
  .sp-bid-lines thead { display: none; }
  .sp-bid-lines, .sp-bid-lines tbody { display: block; }
  .sp-bid-lines tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px 10px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--border); }
  .sp-bid-lines tr:last-child { border-bottom: 0; }
  .sp-bid-lines td { display: block; padding: 0; border: 0; }
  .sp-bid-lines td:first-child { grid-column: 1 / -1; }
  .sp-bid-lines td.num { text-align: left; }
  .sp-bid-lines td:last-child { text-align: right; }
  .sp-bid-lines .sp-price { min-width: 0; max-width: none; }
}
