/* Stock Desk. Tokens and components follow the prototype Flex reviewed
   (stock-desk-source/prototype), on one 4px spacing scale. */
:root {
  --ink: #171717; --ink-2: #2D2D2D; --mute: #636363; --line: #E0E0E0; --soft: #EEEEEE;
  --panel: #F3F3F3; --paper: #FAFAFA; --white: #FFFFFF;
  --purple: #944FA8; --purple-d: #7E3F91; --purple-l: #C9A6D3; --purple-wash: #F8F1FA;
  --ok: #276C44; --ok-bg: #E7F2EB; --other: #2F6F73; --other-bg: #E4F0F0;
  --water: #2B5F9E; --water-bg: #E6EDF7; --prod: #855600; --prod-bg: #F6EEDC; --none: #575757; --none-bg: #ECECEC;
  --warn: #8A5A00; --warn-bg: #FBF8EF; --warn-line: #EFE4C7; --bad: #B3261E; --bad-bg: #FCEFEE; --bad-line: #F2D5D2;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --r: 8px; --r-card: 10px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --display: "Poppins", system-ui, sans-serif; --body: "Outfit", system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.5;
  font-variant-numeric: lining-nums tabular-nums; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.01em; line-height: 1.15; }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; background: var(--ink); color: var(--white); min-height: 60px;
  display: flex; align-items: center; padding: 0 var(--s6); gap: var(--s6); }
.brand { font-family: var(--display); font-weight: 600; font-size: 17px; display: flex; align-items: center; gap: var(--s3); white-space: nowrap; }
.brand i { width: 8px; height: 8px; border-radius: 50%; background: var(--purple); }
.top nav { display: flex; gap: var(--s1); align-self: stretch; }
.top nav button { background: none; border: 0; color: #BDBDBD; padding: 0 var(--s4); cursor: pointer; font-size: 15px; font-weight: 500;
  position: relative; transition: color 150ms ease-out; min-height: 44px; }
.top nav button:hover, .top nav button[aria-selected="true"] { color: var(--white); }
.top nav button[aria-selected="true"]::after { content: ""; position: absolute; left: var(--s4); right: var(--s4); bottom: 0; height: 3px;
  background: var(--purple); border-radius: 3px 3px 0 0; }
.top .right { margin-left: auto; display: flex; align-items: center; gap: var(--s4); font-size: 13px; color: #BDBDBD; }
.fresh { display: flex; align-items: center; gap: var(--s2); white-space: nowrap; background: none; border: 0; color: inherit; font-size: 13px;
  cursor: pointer; min-height: 40px; padding: 0 var(--s2); border-radius: 6px; transition: background 150ms ease-out, color 150ms ease-out; }
.fresh:hover { background: #2B2B2B; color: var(--white); }
.fresh i { width: 8px; height: 8px; border-radius: 50%; background: #8A8A8A; }
.fresh.ok i { background: #5FB77F; box-shadow: 0 0 0 3px rgba(95,183,127,.18); }
.fresh.stale i { background: #E0A43A; box-shadow: 0 0 0 3px rgba(224,164,58,.2); }

main { max-width: 1240px; margin: 0 auto; padding: var(--s6) var(--s6) var(--s8); }
.view.on { animation: enter 200ms ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.eyebrow { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--purple); font-weight: 500; margin-bottom: var(--s2); }
.h1 { font-size: 28px; font-weight: 700; }
.sub { color: var(--mute); font-size: 15px; margin-top: var(--s1); max-width: 64ch; }

/* buttons */
.btn { white-space: nowrap; min-height: 52px; padding: 0 var(--s5); border: 0; border-radius: var(--r); background: var(--purple); color: var(--white);
  font-weight: 500; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  transition: background 150ms ease-out, transform 120ms ease-out; }
.btn:hover { background: var(--purple-d); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.sm { min-height: 40px; padding: 0 var(--s4); font-size: 14px; }
.btn.ghost { background: var(--white); color: var(--ink); border: 1px solid #CFCFCF; }
.btn.ghost:hover { background: var(--panel); }
.btn.dark { background: #2B2B2B; color: var(--white); border: 1px solid #3D3D3D; }
.btn.dark:hover { background: #363636; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* search */
.search { margin-top: var(--s5); display: flex; gap: var(--s3); max-width: 760px; align-items: flex-end; }
.search > input { flex: 1; min-width: 0; height: 52px; border: 1px solid #CFCFCF; background: var(--white); border-radius: var(--r);
  padding: 0 var(--s4) 0 var(--s7); font-size: 18px; transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23636363' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 16px center; }
.search input:focus, .search select:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(148,79,168,.15); }
.search.product { max-width: 1040px; }
.field { display: flex; flex-direction: column; gap: var(--s1); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mute); font-weight: 500; }
.field input, .field select { height: 52px; border: 1px solid #CFCFCF; background: var(--white); border-radius: var(--r); padding: 0 var(--s3);
  font-size: 16px; letter-spacing: 0; text-transform: none; color: var(--ink); }
.field input { width: 88px; }
.field select { min-width: 200px; }

/* lists under the search */
.list { margin-top: var(--s6); max-width: 760px; }
.list h2 { font-size: 13px; font-family: var(--body); font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mute); margin-bottom: var(--s2); }
.list button { width: 100%; display: grid; grid-template-columns: 200px minmax(0, 1fr) auto; gap: var(--s4); text-align: left; background: none; border: 0;
  border-top: 1px solid var(--line); padding: var(--s3) var(--s1); cursor: pointer; font-size: 15px; transition: background 150ms ease-out; min-height: 48px; align-items: center; }
.list button:last-child { border-bottom: 1px solid var(--line); }
.list button:hover { background: var(--panel); }
.list .q { font-weight: 600; font-family: var(--display); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .m { color: var(--mute); }

/* result card */
.card { background: var(--white); border: 1px solid #DADADA; border-radius: var(--r-card); overflow: hidden; margin-top: var(--s5); }
.card-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s5); padding: var(--s5) var(--s5) var(--s4); border-bottom: 1px solid var(--line); }
.card-head h2 { font-weight: 600; font-size: 22px; }
.card-head .m { color: var(--mute); font-size: 14px; margin-top: var(--s1); display: flex; flex-wrap: wrap; gap: 0 var(--s4); }
.card-head .r { text-align: right; color: var(--mute); font-size: 13px; }
.card-head .r b { display: block; color: var(--ink); font-family: var(--display); font-weight: 600; font-size: 15px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mute); padding: var(--s3); border-bottom: 1px solid var(--line); }
td { padding: var(--s3); border-bottom: 1px solid var(--soft); vertical-align: top; font-size: 15px; line-height: 1.4; }
th:first-child, td:first-child { padding-left: var(--s5); }
th:last-child, td:last-child { padding-right: var(--s5); text-align: right; }
th:last-child { white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.qty { text-align: right; width: 56px; }
th.qty { text-align: right; }
.sku { display: block; font-size: 12px; color: var(--mute); letter-spacing: 0.03em; margin-top: 2px; }
.chip { display: inline-block; font-size: 13px; font-weight: 500; padding: 2px var(--s2); border-radius: 5px; white-space: nowrap; }
.c-ok { color: var(--ok); background: var(--ok-bg); } .c-other { color: var(--other); background: var(--other-bg); }
.c-water { color: var(--water); background: var(--water-bg); } .c-prod { color: var(--prod); background: var(--prod-bg); } .c-none { color: var(--none); background: var(--none-bg); }
.where { max-width: 52ch; }
.where small { display: block; color: var(--mute); font-size: 13px; margin-top: 2px; }
.date { font-weight: 600; font-family: var(--display); font-size: 14px; white-space: nowrap; }
.date.nodate { font-family: var(--body); font-weight: 400; color: var(--mute); }
tr.held td { background: var(--purple-wash); }
tr.held td:first-child { box-shadow: inset 4px 0 0 var(--purple); }

.sum { display: grid; grid-template-columns: minmax(200px, 1fr) 2fr auto; gap: var(--s5); align-items: center; padding: var(--s5); background: var(--panel); }
.sum .k { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mute); }
.sum .v { font-family: var(--display); font-weight: 600; font-size: 20px; margin-top: 2px; }
.sum .v small { display: block; font-family: var(--body); font-weight: 400; font-size: 13px; color: var(--mute); }
.steps { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin-top: var(--s1); font-size: 14px; }
.steps b { font-family: var(--display); font-weight: 600; }

.extra { padding: var(--s4) var(--s5); border-top: 1px solid var(--line); font-size: 14px; }
.extra h3 { font-family: var(--body); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mute); font-weight: 500; margin-bottom: var(--s2); }
.extra ul { list-style: none; display: grid; gap: var(--s1); }
.notes { background: var(--warn-bg); border-top: 1px solid var(--warn-line); }
.notes summary { cursor: pointer; color: var(--warn); font-weight: 500; min-height: 32px; display: flex; align-items: center; }
.notes ul { margin-top: var(--s2); color: var(--ink-2); }
.foot-note { margin-top: var(--s3); color: var(--mute); font-size: 13px; }

/* loading, empty, error */
.skel { margin-top: var(--s5); border: 1px solid var(--line); border-radius: var(--r-card); background: var(--white); padding: var(--s5); }
.skel div { height: 14px; border-radius: 4px; background: linear-gradient(90deg, #EFEFEF, #F7F7F7, #EFEFEF); background-size: 200% 100%; animation: sh 1s linear infinite; margin: var(--s3) 0; }
@keyframes sh { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty { margin-top: var(--s5); padding: var(--s6); border: 1px dashed #CFCFCF; border-radius: var(--r-card); color: var(--mute); max-width: 760px; }
.empty b { color: var(--ink); display: block; font-family: var(--display); font-weight: 600; margin-bottom: var(--s1); }
.empty.bad b { color: var(--bad); }

/* drawer and toast */
.scrim { position: fixed; inset: 0; background: rgba(23,23,23,.35); z-index: 20; animation: fade 200ms ease-out; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: var(--white); z-index: 21; display: flex; flex-direction: column;
  box-shadow: -12px 0 40px rgba(0,0,0,.12); animation: slide 240ms ease-out; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(100%); } }
.drawer header { padding: var(--s5); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.drawer header h2 { font-size: 18px; }
.x { width: 44px; height: 44px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--mute); display: grid; place-items: center; }
.x:hover { background: var(--panel); color: var(--ink); }
.drawer .email { margin: var(--s5); padding: var(--s4) var(--s5); border-left: 3px solid var(--purple); background: var(--paper); font-family: var(--body);
  font-size: 15px; line-height: 1.55; white-space: pre-wrap; color: var(--ink-2); flex: 1; overflow: auto; }
/* the formatted email: the same spacing it gets when pasted */
.drawer .email:has(p) { white-space: normal; }
.email > * + * { margin-top: var(--s3); }
.email b { font-weight: 600; color: var(--ink); }
.email ul { padding-left: var(--s5); }
.email li + li { margin-top: 2px; }
.drawer footer { padding: 0 var(--s5) var(--s5); display: flex; gap: var(--s3); align-items: center; font-size: 14px; color: var(--ok); }
.drawer footer.bad { color: var(--bad); }
.toast { position: fixed; left: 50%; top: 76px; transform: translate(-50%, -8px); background: var(--ink); color: var(--white); padding: var(--s2) var(--s4);
  border-radius: var(--r); font-size: 14px; opacity: 0; transition: opacity 180ms ease-out, transform 180ms ease-out; z-index: 30; pointer-events: none; max-width: calc(100% - 32px); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; } }

@media (max-width: 960px) {
  .top { flex-wrap: wrap; padding: 0 var(--s4); gap: 0 var(--s4); }
  .top nav { order: 3; width: 100%; overflow-x: auto; margin: 0 calc(var(--s4) * -1); padding: 0 var(--s2); }
  .top .right { min-height: 52px; }
  main { padding: var(--s5) var(--s4) var(--s7); }
  .search.product { flex-wrap: wrap; }
  .search.product > input { flex-basis: 100%; }
  .sum { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .fresh #fresh-text { display: none; }
  .list button { grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--s3); }
  .list button > span:nth-child(2) { grid-column: 1 / -1; grid-row: 2; color: var(--ink-2); }
  .search { flex-wrap: wrap; }
  .search > input { flex-basis: 100%; }
  .search .btn { flex: 1; }
  .card-head { flex-direction: column; align-items: flex-start; }
  .card-head .r { text-align: left; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table, tbody, tr, td { display: block; }
  tr { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--soft); display: grid; grid-template-columns: 1fr auto; gap: var(--s1) var(--s3); }
  td, th:first-child, td:first-child, td:last-child { padding: 0; border: 0; text-align: left; }
  td.prod { grid-column: 1 / -1; }
  td.qty { width: auto; text-align: left; grid-column: 1; }
  td.qty::before { content: "Qty "; color: var(--mute); }
  td.status { grid-column: 2; grid-row: 2; justify-self: end; }
  td.where { grid-column: 1 / -1; }
  td.ready { grid-column: 1 / -1; }
  td.ready::before { content: "Ready to dispatch: "; color: var(--mute); font-weight: 400; font-family: var(--body); }
  tr.held td:first-child { box-shadow: none; }
  tr.held { box-shadow: inset 4px 0 0 var(--purple); background: var(--purple-wash); }
  .field select { min-width: 0; width: 100%; }
  .field:has(select) { flex: 1; }
}

/* customer portal: calmer than the staff desk, one narrow column */
body.portal .ptop { background: var(--white); border-bottom: 1px solid var(--line); }
.pwrap { max-width: 760px; margin: 0 auto; padding: 0 var(--s5); }
.ptop .pwrap { min-height: 60px; display: flex; align-items: center; }
body.portal main.pwrap { padding-top: var(--s7); padding-bottom: var(--s8); }
.pform { margin-top: var(--s5); display: grid; grid-template-columns: 1fr 1.4fr auto; gap: var(--s3); align-items: start; }
.pform .btn { margin-top: 26px; }
.pfield { display: flex; flex-direction: column; gap: var(--s1); font-size: 14px; font-weight: 500; color: var(--ink-2); }
.pfield input, body.portal .pfield textarea { border: 1px solid #CFCFCF; border-radius: var(--r); padding: 0 var(--s4); font-size: 16px; background: var(--white); font-weight: 400;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out; }
.pfield input { height: 52px; }
.pfield input:focus, body.portal .pfield textarea:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(148,79,168,.15); }
.pfield input[aria-invalid="true"], body.portal .pfield textarea[aria-invalid="true"] { border-color: var(--bad); }
.pfield .err { color: var(--bad); font-size: 13px; font-weight: 400; min-height: 20px; }
.pbanner { padding: var(--s4) var(--s5); background: var(--other-bg); color: var(--other); display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); align-items: baseline; }
.pbanner b { font-family: var(--display); font-weight: 600; font-size: 16px; }
.plines { list-style: none; }
.plines li { display: grid; grid-template-columns: 1fr auto; gap: var(--s1) var(--s4); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--soft); align-items: start; }
.plines li:last-child { border-bottom: 0; }
.plines b { font-weight: 500; }
.plines .q { color: var(--mute); margin-left: var(--s2); white-space: nowrap; }
.plines p { grid-column: 1 / -1; color: var(--ink-2); font-size: 15px; }
.psum { padding: var(--s5); background: var(--panel); font-family: var(--display); font-weight: 600; font-size: 17px; border-top: 1px solid var(--line); }
@media (max-width: 720px) {
  .pform { grid-template-columns: 1fr; gap: 0; }
  .pform .btn { width: 100%; margin-top: var(--s2); }
  body.portal main.pwrap { padding-top: var(--s6); }
}

.extra .code { color: var(--mute); font-size: 13px; margin-left: var(--s1); }

/* data health panel */
.health { padding: var(--s2) var(--s5) var(--s5); overflow: auto; flex: 1; }
.health section { padding: var(--s4) 0; border-bottom: 1px solid var(--soft); }
.health section:last-child { border-bottom: 0; }
.health h3 { font-family: var(--body); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mute); font-weight: 500; margin-bottom: var(--s2); }
.health table td { padding: var(--s2) 0; border-bottom: 1px solid var(--soft); font-size: 15px; }
.health table td:first-child { padding-left: 0; }
.health table td:last-child { padding-right: 0; text-align: right; }
.health table tr:last-child td { border-bottom: 0; }
.health .stale { color: var(--warn); font-weight: 500; }
.health .never { color: var(--mute); }
.health p { font-size: 15px; color: var(--ink-2); }
.health p + p { margin-top: var(--s2); }
.health code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--panel); padding: 1px var(--s1); border-radius: 4px; }
.health ul { padding-left: var(--s4); display: grid; gap: var(--s2); font-size: 14px; color: var(--ink-2); }
.health table + p { margin-top: var(--s3); }
.ptop .pwrap { justify-content: space-between; }
.lform { grid-template-columns: 1fr auto; max-width: 560px; }
.porders { list-style: none; margin-top: var(--s5); border-top: 1px solid var(--line); }
.porders button { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: var(--s4); min-height: 56px; padding: var(--s3) var(--s2);
  background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; text-align: left; font-size: 16px; transition: background 150ms ease-out; }
.porders button:hover { background: var(--panel); }
.porders b { font-family: var(--display); font-weight: 600; }
.porders .m { color: var(--mute); font-size: 14px; }
.pnote { margin-top: var(--s5); padding: var(--s4) var(--s5); border-radius: var(--r-card); background: var(--ok-bg); color: var(--ok); }
body.portal .pnote.bad { background: var(--bad-bg); color: var(--bad); }
.pact { margin-top: var(--s5); }
@media (max-width: 720px) { .pact .btn { width: 100%; } }

/* portal order page: the order card first, then delivery, payments and
   terms as their own smaller cards, so each reads as one job. Scoped to
   the portal: the desk shares some of these class names. */
body.portal .ptop .pwrap { gap: var(--s4); }
body.portal .ptop .brand { min-width: 0; }
body.portal #p-brand { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--s2); }
body.portal #p-brand .psub { font-family: var(--body); font-weight: 500; font-size: 15px; color: var(--mute); }
body.portal main a { color: var(--purple-d); text-underline-offset: 3px; border-radius: 4px; }
body.portal main a:hover { text-decoration-thickness: 2px; }
body.portal a[href^="tel:"] { white-space: nowrap; }
body.portal a.back { text-decoration: none; }
body.portal a.back:hover { text-decoration: underline; text-decoration-thickness: 1px; }
body.portal .pmanual { display: inline-flex; align-items: center; gap: var(--s2); min-height: 40px; font-size: 14px; font-weight: 500; }
body.portal .pmanual svg { flex: none; }
body.portal .plines .pmanual { grid-column: 1 / -1; justify-self: start; margin: calc(var(--s2) * -1) 0 calc(var(--s3) * -1); }
body.portal .psent li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 var(--s4); }
body.portal .psent .pmanual { min-height: 32px; }

body.portal .psec { padding: var(--s5); }
body.portal .psec h2 { font-size: 18px; font-weight: 600; }
body.portal .psec h2 + p { margin-top: var(--s1); }
body.portal .psec p { color: var(--ink-2); max-width: 64ch; }
body.portal .psec h3 { font-family: var(--body); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mute); font-weight: 500; margin: var(--s5) 0 var(--s2); }
body.portal .psec .m { color: var(--mute); font-size: 14px; }
body.portal .psec .pnote { margin-top: var(--s4); padding: var(--s3) var(--s4); color: var(--ok); max-width: none; }
body.portal .psec .pnote.bad { color: var(--bad); }
body.portal main .pnote a { color: inherit; }
body.portal .pnote:focus, body.portal .empty:focus { outline: none; }
body.portal .pnote:focus-visible, body.portal .empty:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }

/* payments: a receipt, the figure still to pay carries the weight; one
   right edge with the invoice row below it */
body.portal .pledger { margin-top: var(--s4); }
body.portal .pledger div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); padding: var(--s2) 0; border-bottom: 1px solid var(--soft); }
body.portal .pledger dt { color: var(--ink-2); }
body.portal .pledger dd { font-family: var(--display); font-weight: 500; white-space: nowrap; }
body.portal .pledger .owing { border-bottom: 0; padding-top: var(--s3); }
body.portal .pledger .owing dt { color: var(--ink); font-weight: 600; }
body.portal .pledger .owing dd { font-weight: 600; font-size: 20px; }
body.portal .ppays { list-style: none; font-size: 15px; color: var(--ink-2); }
body.portal .ppays li { display: flex; justify-content: space-between; gap: var(--s4); padding: var(--s1) 0; }
body.portal .ppays li span:last-child { white-space: nowrap; }
body.portal .pledger + .m, body.portal .ppays + .m { margin-top: var(--s3); }
body.portal .pinv { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s3) var(--s4); }
body.portal .pinv b { display: block; font-family: var(--display); font-weight: 600; font-size: 15px; }
body.portal .pinv .m { display: block; }
body.portal .psec > :not(h2) + .pinv { margin-top: var(--s5); padding-top: var(--s5); border-top: 1px solid var(--line); }
body.portal .psec > h2 + .pinv { margin-top: var(--s3); }

/* delivery booking */
body.portal .pdl { margin-top: var(--s4); display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s2) var(--s5); font-size: 15px; }
body.portal .pdl dt { color: var(--mute); }
body.portal .pdl dd { color: var(--ink); overflow-wrap: anywhere; }
body.portal .pdl dd.pre { white-space: pre-line; }
body.portal .pdl dd span { display: block; }
body.portal .pedit { margin-top: var(--s4); display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); }
body.portal .pform.dform { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2) var(--s4); margin-top: var(--s4); }
body.portal .dform .wide, body.portal .dform .pfoot { grid-column: 1 / -1; }
body.portal .dform .pfoot { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s1); }
body.portal .pform.dform .btn { margin-top: 0; }
body.portal .pfield label { cursor: pointer; }
body.portal .pfield .opt, body.portal .pfield .phint { font-weight: 400; color: var(--mute); }
body.portal .pfield .phint { font-size: 13px; }
body.portal .pfield input { min-width: 0; }
body.portal .pfield textarea { min-height: 112px; resize: vertical; padding: var(--s3) var(--s4); font-family: var(--body); line-height: 1.5; color: var(--ink); }
/* iOS draws its own rounded, centred date box: match the other inputs */
body.portal .pfield input[type="date"] { -webkit-appearance: none; appearance: none; }
body.portal .pfield input[type="date"]::-webkit-date-and-time-value { text-align: left; }

/* warranty, returns and terms: one row each, opened on demand. The row
   bleeds into the card padding so its focus ring clears the text. */
body.portal .pacc { margin-top: var(--s4); border-top: 1px solid var(--soft); }
body.portal .pacc details { border-bottom: 1px solid var(--soft); }
body.portal .pacc details:last-child { border-bottom: 0; }
body.portal .pacc summary { list-style: none; cursor: pointer; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  margin: 0 calc(var(--s2) * -1); padding: 0 var(--s2); font-weight: 500; transition: color 150ms ease-out; }
body.portal .pacc summary::-webkit-details-marker { display: none; }
body.portal .pacc summary::after { content: ""; flex: none; width: 8px; height: 8px; border-right: 2px solid var(--mute); border-bottom: 2px solid var(--mute);
  transform: translateY(-2px) rotate(45deg); transition: transform 150ms ease-out; }
body.portal .pacc details[open] summary::after { transform: translateY(2px) rotate(-135deg); }
body.portal .pacc summary:hover { color: var(--purple-d); }
body.portal .pacc details > div { padding: 0 0 var(--s4); font-size: 15px; }
body.portal .pacc details a { display: inline-flex; align-items: center; min-height: 40px; font-weight: 500; font-size: 14px; }

@media (max-width: 720px) {
  body.portal .pform.dform { grid-template-columns: 1fr; gap: 0; }
  body.portal .dform .pfoot .btn { flex: 1 1 100%; }
  body.portal .pdl { grid-template-columns: 1fr; gap: 0; }
  body.portal .pdl dd + dt { margin-top: var(--s3); }
  body.portal .pedit .btn, body.portal .pinv .btn { width: 100%; }
  /* thumb-sized targets */
  body.portal .pmanual, body.portal .psent .pmanual, body.portal .pacc details a, body.portal a.back, body.portal .btn.sm { min-height: 44px; }
}
@media (max-width: 480px) {
  body.portal .pwrap { padding: 0 var(--s4); }
  body.portal #p-brand { flex-direction: column; gap: 0; line-height: 1.25; }
  body.portal #p-brand .psub { font-size: 13px; }
}

/* product overview */
.overview { display: grid; grid-template-columns: 1fr 2fr; gap: var(--s5); }
.overview ul { list-style: none; display: grid; gap: var(--s1); font-size: 14px; }
.overview b { font-family: var(--display); font-weight: 600; }
.overview .m { color: var(--mute); font-size: 14px; }
.overview p + p, .overview ul + p { margin-top: var(--s2); }
@media (max-width: 720px) { .overview { grid-template-columns: 1fr; } }

/* Back to the previous search or list */
.back { display: inline-flex; align-items: center; gap: var(--s1); min-height: 40px; margin-top: var(--s5); padding: 0 var(--s2) 0 0;
  background: none; border: 0; color: var(--purple-d); font-weight: 500; font-size: 15px; cursor: pointer; border-radius: 6px; }
.back:hover { text-decoration: underline; text-underline-offset: 3px; }
.back + .card, .back + .empty { margin-top: var(--s3); }

/* paste a list */
.paste { margin-top: var(--s5); max-width: 760px; display: grid; gap: var(--s3); }
.paste textarea { width: 100%; min-height: 176px; resize: vertical; border: 1px solid #CFCFCF; border-radius: var(--r); background: var(--white);
  padding: var(--s3) var(--s4); font: 400 16px/1.5 var(--body); color: var(--ink); transition: border-color 150ms ease-out, box-shadow 150ms ease-out; }
.paste textarea:focus, .paste select:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(148,79,168,.15); }
.paste textarea::placeholder { color: #8C8C8C; }
.hint { font-size: 14px; color: var(--mute); max-width: 64ch; }
.paste-row { display: flex; gap: var(--s3); align-items: flex-end; }
.notice { margin-top: var(--s5); padding: var(--s4) var(--s5); border: 1px solid var(--warn-line); background: var(--warn-bg); border-radius: var(--r-card);
  font-size: 15px; color: var(--ink-2); max-width: 760px; }
.notice b { display: block; color: var(--warn); font-family: var(--display); font-weight: 600; margin-bottom: var(--s1); }
.notice ul, .empty .unread { margin-top: var(--s2); padding-left: var(--s5); display: grid; gap: 2px; font: 14px/1.5 var(--mono); color: var(--ink-2); overflow-wrap: anywhere; }
.notice + .notice { margin-top: var(--s3); }
td.ready .est { display: block; font-size: 13px; color: var(--mute); margin-top: 2px; white-space: nowrap; }

/* dates that moved */
.dsum { margin-top: var(--s5); font-size: 17px; color: var(--ink-2); max-width: 72ch; }
.dsum b { font-family: var(--display); font-weight: 600; color: var(--ink); }
.dsum b.later { color: var(--warn); }
.dtable td.ord { width: 180px; }
.dtable td.ord a { font-family: var(--display); font-weight: 600; font-size: 14px; color: var(--purple-d); text-underline-offset: 3px; border-radius: 4px; }
.dtable td.ord a:hover { text-decoration-thickness: 2px; }
.dtable td.was .date { color: var(--mute); font-weight: 500; text-decoration: line-through; text-decoration-color: #B5B5B5; }
.dtable td.by small { display: block; font-size: 13px; color: var(--mute); margin-top: 2px; }
.shift { display: inline-block; font-size: 13px; font-weight: 500; padding: 2px var(--s2); border-radius: 5px; white-space: nowrap;
  color: var(--warn); background: var(--warn-bg); border: 1px solid var(--warn-line); }
.shift.lost { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-line); }
.card > p.extra { color: var(--mute); }
.track { margin-top: var(--s7); max-width: 760px; }
.track h2 { font-size: 13px; font-family: var(--body); font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mute); margin-bottom: var(--s2); }
.track p { font-size: 15px; color: var(--ink-2); max-width: 72ch; }
.track p b { font-family: var(--display); font-weight: 600; color: var(--ink); }
.track p.m { color: var(--mute); }
.track p + p, .track table + p { margin-top: var(--s3); }
.bysource { margin-top: var(--s4); }
.bysource th, .bysource td { padding: var(--s2) var(--s3) var(--s2) 0; }
.bysource th:first-child, .bysource td:first-child { padding-left: 0; }
.bysource .n { text-align: right; width: 88px; }

@media (max-width: 720px) {
  /* the bar bleeds to both screen edges, so it is that much wider too */
  .top nav { width: calc(100% + var(--s4) * 2); }
  .top nav button { padding: 0 var(--s3); font-size: 14px; }
  .top nav button[aria-selected="true"]::after { left: var(--s3); right: var(--s3); }
  .paste-row .btn { flex: 1; }
  .dtable td.ord { width: auto; grid-column: 1; }
  .dtable td.by { grid-column: 2; grid-row: 1; text-align: right; }
  .dtable td.prod { grid-column: 1 / -1; }
  .dtable td.was { grid-column: 1; }
  .dtable td.now { grid-column: 2; text-align: right; }
  .dtable td.was::before { content: "Was "; color: var(--mute); }
  .dtable td.now::before { content: "Now "; color: var(--mute); }
  /* the by-source table is small and numeric: it stays a table */
  .bysource { display: table; }
  .bysource thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; display: table-header-group; }
  .bysource tbody { display: table-row-group; }
  .bysource tr { display: table-row; padding: 0; border: 0; }
  .bysource th, .bysource td, .bysource td:first-child, .bysource td:last-child { display: table-cell; padding: var(--s2) var(--s3) var(--s2) 0; border-bottom: 1px solid var(--soft); }
  .bysource .n { width: 64px; text-align: right; }
}

/* the shared, read-only copy */
.share-tag { font-size: 13px; color: #BDBDBD; border: 1px solid #3D3D3D; border-radius: 6px; padding: var(--s1) var(--s2); white-space: nowrap; }

/* stock by branch on product lookups: Cin7's on hand and available */
.stocktab { margin-top: var(--s1); font-size: 14px; }
.stocktab th, .stocktab td { padding: var(--s1) var(--s3) var(--s1) 0; border-bottom: 1px solid var(--soft); font-size: 14px; }
.stocktab th { font-size: 12px; padding-bottom: var(--s2); white-space: nowrap; }
.stocktab th:first-child, .stocktab td:first-child { padding-left: 0; }
.stocktab th:last-child, .stocktab td:last-child { padding-right: 0; }
.stocktab .n { text-align: right; width: 84px; font-family: var(--display); font-weight: 600; }
.stocktab th.n { font-family: var(--body); font-weight: 500; }
.stocktab .neg { color: var(--bad); }
.stocktab tr.more td { color: var(--mute); font-weight: 400; font-family: var(--body); }
.stocktab tfoot td { border-bottom: 0; border-top: 1px solid var(--line); font-weight: 600; }
.stocktab + .m { margin-top: var(--s2); font-size: 13px; }
.overview { grid-template-columns: minmax(280px, 1fr) 2fr; }

/* the supply sheets, opened from the Dates tab */
.sheetlinks { margin-top: var(--s4); display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-size: 14px; }
.sheetlinks > span { color: var(--mute); margin-right: var(--s1); }
.sheetlinks a { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 var(--s3); border: 1px solid #CFCFCF; border-radius: var(--r);
  background: var(--white); color: var(--ink); font-weight: 500; text-decoration: none; transition: background 150ms ease-out, border-color 150ms ease-out; }
.sheetlinks a:hover { background: var(--panel); border-color: #BDBDBD; }
.sheetlinks a svg { color: var(--mute); }
a.srclink { color: var(--purple-d); text-underline-offset: 2px; }
a.srclink:hover { text-decoration-thickness: 2px; }

@media (max-width: 720px) {
  .overview { grid-template-columns: 1fr; }
  /* the stock table is small and numeric: it stays a table */
  .stocktab { display: table; width: 100%; }
  .stocktab thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; display: table-header-group; }
  .stocktab tbody { display: table-row-group; }
  .stocktab tfoot { display: table-footer-group; }
  .stocktab tr { display: table-row; padding: 0; border: 0; }
  .stocktab th, .stocktab td, .stocktab td:first-child, .stocktab td:last-child { display: table-cell; padding: var(--s1) var(--s3) var(--s1) 0; border-bottom: 1px solid var(--soft); }
  .stocktab .n { width: 72px; text-align: right; }
}

/* each line's network on hand and available, and the link to its stock by branch */
.stockline { display: block; font-size: 13px; color: var(--mute); margin-top: 2px; }
.stockline b { font-family: var(--display); font-weight: 600; color: var(--ink-2); }
.stockline b.neg { color: var(--bad); }
a.prodlink { color: var(--ink); text-decoration: underline; text-decoration-color: #C4C4C4; text-underline-offset: 3px; border-radius: 2px; }
a.prodlink:hover { color: var(--purple-d); text-decoration-color: currentColor; }

/* payments pasted from the sales channel */
.c-enter { color: var(--purple-d); background: var(--purple-wash); }
.paytable th:last-child, .paytable td:last-child { text-align: left; }
.paytable td.pay { width: 260px; }
.paytable td.rep { width: 200px; }
.paytable td.cin7 { width: 240px; }
.paytable .amt { display: block; font-family: var(--display); font-weight: 600; font-size: 16px; white-space: nowrap; }
.paytable .amt.neg { color: var(--mute); }
.paytable .bank { display: block; font-size: 13px; color: var(--mute); margin-top: var(--s1); overflow-wrap: anywhere; }
.paytable td.who b { display: block; font-weight: 500; }
.paytable small { display: block; font-size: 13px; color: var(--mute); margin-top: 2px; }
.paytable small.why { color: var(--ink-2); }
.paytable span.why { display: block; font-size: 14px; color: var(--ink-2); }
.paytable .none { color: var(--mute); }
.paytable td.cin7 .chip + small { margin-top: var(--s1); }
.paytable td.cin7 small { color: var(--ink-2); }
a.doclink { display: inline-block; margin-top: 2px; font-family: var(--display); font-weight: 600; font-size: 14px; color: var(--purple-d);
  text-underline-offset: 3px; border-radius: 4px; }
a.doclink:hover { text-decoration-thickness: 2px; }
.opts { list-style: none; display: grid; gap: var(--s2); margin-top: var(--s2); }
.opts small { margin-top: 0; }
/* the payments still to enter carry the accent, so the eye lands on them */
.paytable tr.p-enter td:first-child { box-shadow: inset 4px 0 0 var(--purple); }
.paysum { grid-template-columns: 1fr auto; }
.paysum p { font-size: 15px; color: var(--ink-2); max-width: 64ch; }
.paysum b { font-weight: 600; color: var(--ink); }

@media (max-width: 720px) {
  .paytable td.pay, .paytable td.who, .paytable td.rep, .paytable td.cin7 { width: auto; grid-column: 1 / -1; }
  /* status straight under the amount, then whose it is */
  .paytable td.cin7 { grid-row: 2; }
  .paytable td.who { grid-row: 3; }
  .paytable td.rep { grid-row: 4; }
  .paytable td.rep::before { content: "Sales person: "; color: var(--mute); }
  .paytable td.rep small { display: inline; margin-left: var(--s1); }
  .paytable td.rep small::before { content: "("; } .paytable td.rep small::after { content: ")"; }
  .paytable tr.p-enter td:first-child { box-shadow: none; }
  .paytable tr.p-enter { box-shadow: inset 4px 0 0 var(--purple); }
  .paysum .btn { width: 100%; }
}
