/* Fulfilment v2. Mobile first: phones get a bottom nav and card lists; from 900 px a top nav. 16 px side gutter. */
:root {
  --header: #10291d; --primary: #0f6e56; --primary-dark: #083815; --bg: #faf9f5; --surface: #fff; --surface2: #f1efe8;
  --border: #d3d1c7; --text: #1a1a1a; --muted: #5f5e5a; --danger: #a32d2d; --warn: #935b0c; /* amber dark enough for text on white and on #fbf1df, and white text on it (AA) */ --ok-bg: #eef4ee;
  --radius: 10px; --gutter: 16px; --nav-h: 58px;
  --font: 'Sarabun', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 15px/1.5 var(--font); color: var(--text); background: var(--bg); overflow-x: hidden; }
h1, h2, h3, h4, b, strong, th { font-weight: 600; }
h2 { font-size: 20px; margin: 0; } h3 { font-size: 17px; margin: 0; }
a { color: var(--primary); }
.olink { font-weight: 600; }
.muted, .sub { color: var(--muted); font-size: 13px; }
.sub { margin: 4px 0 10px; }
.pre { white-space: pre-line; }
main { padding: 14px var(--gutter) calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 1400px; margin: 0 auto; }

/* ── header + nav ── */
.top { position: sticky; top: 0; z-index: 50; background: var(--header); color: #fff; display: flex; align-items: center; gap: 12px;
  padding: 8px var(--gutter); border-bottom: 3px solid #2e7d57; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; }
.brand img { height: 24px; display: block; }
.brand .sep { width: 1px; height: 22px; background: #ffffff4d; }
.brand h1 { font-size: 16px; margin: 0; color: #e6f2ea; letter-spacing: .03em; }
.refresh { margin-left: auto; background: #ffffff22; color: #fff; border: 1px solid #ffffff55; border-radius: 8px; padding: 6px 10px; font: inherit; cursor: pointer; }
.refresh .lb { display: none; }
.who { font-size: 13px; color: #cfe3d6; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Phone: bottom tab bar, icons over short labels. */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom); overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
/* Eight tabs share 360 px: equal widths, small labels, never a sideways scroll. */
.nav a { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: var(--nav-h);
  padding: 6px 1px; color: var(--muted); text-decoration: none; font-size: 10px; border-top: 3px solid transparent; }
.nav .lb-short { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a.on { color: var(--primary); border-top-color: var(--primary); font-weight: 600; }
.nav .ic { line-height: 0; } .nav .ic svg { width: 22px; height: 22px; }
.nav .lb { display: none; }
body.sales .nav a { font-size: 12px; }
@media (min-width: 900px) {
  :root { --gutter: 24px; }
  main { padding-bottom: 32px; }
  .brand img { height: 32px; }
  .brand h1 { font-size: 18px; }
  .nav { position: static; order: 2; background: transparent; border: 0; padding: 0; margin-left: 16px; overflow: visible; }
  .nav a { flex: 0 0 auto; flex-direction: row; min-height: 0; padding: 8px 10px; color: #cfe3d6; font-size: 14px; border-top: 0; border-bottom: 3px solid transparent; border-radius: 0; }
  .nav a.on { color: #fff; border-bottom-color: #9fd3c0; }
  .nav .ic, .nav .lb-short { display: none; }
  .nav .lb { display: inline; }
  .refresh { order: 3; } .refresh .lb { display: inline; }
  .who { order: 4; max-width: 160px; }
}

/* Quick search (staff): an icon that opens a full-width bar on narrow screens, an inline box from 1200 px. */
.qs-wrap { margin-left: auto; position: relative; }
.qs-wrap ~ .refresh { margin-left: 0; }
.qs-btn { background: #ffffff22; color: #fff; border: 1px solid #ffffff55; border-radius: 8px; padding: 6px 9px; cursor: pointer; line-height: 0; }
.qs-btn svg { width: 18px; height: 18px; }
.qs { display: none; }
.qs.open { display: block; position: fixed; left: 0; right: 0; top: 0; z-index: 70; background: var(--header); padding: 8px var(--gutter); }
.qs-row { display: flex; gap: 8px; align-items: center; }
.qs input { flex: 1; min-width: 0; min-height: 38px; border-color: #ffffff55; }
.qs-x { background: none; border: 0; color: #fff; font: inherit; font-size: 15px; padding: 6px; cursor: pointer; }
.qs-list { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; margin-top: 6px; max-height: 70dvh; overflow-y: auto; }
.qs-list .h { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 6px 12px 2px; }
.qs-list a { display: flex; gap: 10px; justify-content: space-between; padding: 9px 12px; color: inherit; text-decoration: none; min-height: 40px; }
.qs-list a span:last-child { color: var(--muted); font-size: 13px; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.qs-list a:hover, .qs-list a:focus, .qs-list a.first { background: var(--ok-bg); outline: none; }
.qs-list .none { padding: 10px 12px; color: var(--muted); }
@media (min-width: 900px) { .qs-wrap { order: 3; } }
@media (min-width: 1200px) {
  .qs-btn, .qs-x { display: none; }
  .qs, .qs.open { display: block; position: static; padding: 0; background: none; width: 230px; }
  .qs-list { position: absolute; right: 0; width: 360px; }
}

/* ── page ── */
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar .search { flex: 1 1 220px; }
.empty { text-align: center; color: var(--muted); padding: 32px 10px; }
.error { background: #fdecea; color: var(--danger); border: 1px solid #f0c4be; border-radius: 8px; padding: 9px 12px; margin: 8px 0; white-space: pre-line; }
.error.inline { display: inline-block; margin: 0 8px 0 0; padding: 6px 10px; font-size: 13px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.pill { display: inline-block; background: var(--ok-bg); color: var(--primary-dark); border-radius: 6px; padding: 1px 8px; font-size: 12px; }
/* Shared pill colours, one meaning each (screens add only prefixed ones of their own). All text ≥ 4.5:1. */
.pill.wait { background: #fdf3e3; color: #8a5300; }     /* waiting: Waitlist */
.pill.ready { background: #e6f0fb; color: #1c4f86; }    /* next step open: Pending */
.pill.mut { background: var(--surface2); color: var(--muted); }
.pill.batch { background: #e6f1fb; color: #0c447c; }    /* a batch / StockID */
.pill.truck { background: #fdf1e1; color: #7a4a0c; }

/* ── inputs ── */
input, select, textarea { font: inherit; font-size: 16px; /* no iOS zoom */ width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text); }
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9fd3c0; border-color: var(--primary); }
.field { display: block; margin: 0 0 12px; }
.field .lbl { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field .req { color: var(--danger); font-weight: 400; }
.field .hint { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 12px; background: var(--surface); }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 6px; font: inherit; font-size: 14px; color: var(--muted); cursor: pointer; min-height: 42px; }
.seg button.on { background: var(--primary); color: #fff; font-weight: 600; }

/* ── buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 8px; padding: 8px 14px;
  min-height: 42px; font: inherit; font-size: 15px; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--primary); color: #fff; font-weight: 600; }
.btn.ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; font-weight: 600; }
.btn.link { background: none; border: 0; color: inherit; text-decoration: underline; padding: 0; min-height: 0; }
.btn.icon { padding: 6px 10px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn[aria-busy=true] { cursor: progress; }
.busy-wrap { display: inline-flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }

/* ── tables: scroll inside their box; with .cards each row is a card on phones ── */
.tbl-wrap .scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tbl { border-collapse: collapse; width: 100%; font-size: 14px; }
.tbl th { text-align: left; background: var(--surface2); color: var(--muted); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; padding: 8px 10px; white-space: nowrap; }
.tbl td { padding: 9px 10px; border-top: 1px solid var(--surface2); vertical-align: top; white-space: nowrap; }
.tbl td.wrap { white-space: normal; min-width: 140px; }
.tbl .n { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td, .tbl tr.click:focus td { background: #f2f8f1; }
.more { display: flex; justify-content: center; margin: 12px 0; }
@media (max-width: 899px) {
  .tbl-wrap .scroll:has(.cards) { overflow: visible; background: none; border: 0; }
  .tbl.cards thead { display: none; }
  .tbl.cards, .tbl.cards tbody, .tbl.cards tr, .tbl.cards td { display: block; width: 100%; }
  .tbl.cards tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 8px; }
  .tbl.cards td { border: 0; padding: 3px 0; display: flex; gap: 10px; white-space: normal; text-align: right; justify-content: space-between; min-width: 0; }
  .tbl.cards td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; flex: none; }
  .tbl.cards td > * { overflow-wrap: anywhere; }
}

/* Table card(row): the compact summary replaces the key/value card on phones. */
.tbl .tbl-card { display: none; }
.tc1 { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; min-width: 0; }
.tc1 .grow { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.tc2 { color: var(--muted); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
@media (max-width: 899px) {
  .tbl.has-card td:not(.tbl-card) { display: none; }
  .tbl.has-card td.tbl-card { display: block; text-align: left; padding: 2px 0; }
  .tbl.has-card td.tbl-card::before { content: none; }
}

/* ── overlays ── */
.modal { border: 0; border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 2 * var(--gutter))); max-height: 88dvh; display: flex; flex-direction: column; }
.modal:not([open]) { display: none; }
.modal::backdrop { background: #0008; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--surface2); }
.modal-head h3 { flex: 1; }
.modal-body { padding: 14px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--surface2); }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); z-index: 1000;
  display: grid; gap: 8px; width: min(480px, calc(100vw - 2 * var(--gutter))); pointer-events: none; }
.toast { background: #222; color: #fff; border-left: 4px solid var(--primary); border-radius: 8px; padding: 10px 14px; pointer-events: auto; }
.toast.bad { border-left-color: #e07a72; }
.toast a { color: #9fd3c0; }
@media (min-width: 900px) { .toasts { bottom: 20px; } }

/* ── sign-in gate ── */
.gate { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: var(--gutter); }
.gate-card { max-width: 420px; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 0 22px 24px; text-align: center; overflow: hidden; }
.gate-head { background: var(--header); margin: 0 -22px 18px; padding: 16px; }
.gate-head img { height: 34px; }
.gate .sprout { display: block; margin: 0 auto 4px; }
.gate h2 { color: var(--header); margin-bottom: 10px; }
.gate p { color: var(--muted); }
.gate .note { color: #888780; font-size: 13px; overflow-wrap: anywhere; }
