/* swatch-a: review fixes (Swatching board, Dispatch dialog, Reply card, branded email table) */

/* ---------- Swatching board ---------- */
/* Every column header the same height, whether or not it has a Slips link */
.swcolh { box-sizing: border-box; height: 44px; min-height: 44px; padding: 0 4px; }
.swcolh h2 { line-height: 1.2; white-space: nowrap; }
.swcolh .link { min-height: 44px; display: inline-flex; align-items: center; }
/* Tags sit on their own tidy line and shorten rather than wrap */
.swtags { display: flex; flex-wrap: nowrap; gap: 4px; min-width: 0; overflow: hidden; }
.swtags .swtag { flex: 0 1 auto; min-width: 0; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 18px; }
.swtags .swtag.red { flex-shrink: 0.5; }
/* Carrier and tracking on Dispatched cards */
.swship { display: flex; align-items: center; gap: 5px; flex-basis: 100%; min-width: 0; font-size: 0.8125rem; color: var(--grey-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swship .ic, .swship svg { flex: none; width: 14px; height: 14px; color: var(--muted); }
/* Quiet "Move back" at the end of the card's info line */
.swfoot .swback { margin-left: auto; font-size: 0.8125rem; white-space: nowrap; }
@media (pointer: coarse) { .swfoot .swback { min-height: 44px; margin: -10px 0; display: inline-flex; align-items: center; } }
/* Card actions: main button on the left, quiet links on the right */
.swacts { flex-wrap: wrap; row-gap: 2px; }
.swlinks { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.swlinks .link.small { min-height: 32px; display: inline-flex; align-items: center; }
.swlinks .link.small svg { width: 13px; height: 13px; margin-right: 3px; }
@media (pointer: coarse) { .swlinks .link.small, .swacts .btn.small { min-height: 44px; } }

/* ---------- Dispatch dialog (same form as the request's Dispatched answer) ---------- */
.swdlg.swdisp { top: 4vh; width: min(620px, calc(100% - 32px)); max-height: 92vh; overflow-y: auto; overscroll-behavior: contain; }
.swdlg .rchoices { margin-top: 2px; }
.swdlg .respform { margin: 0; padding: 0; background: none; max-width: none; }
.swdlg .formact { flex-wrap: wrap; }
.swdlg .swkam { margin: -4px 0 0; }
@media (max-width: 640px) { .swdlg.swdisp { top: 8px; max-height: calc(100dvh - 16px); } }

/* ---------- Reply form (request page and Dispatch dialog) ---------- */
.rchoice { min-height: 44px; line-height: 1.2; }
.rchoice:focus-visible { outline: 2px solid var(--blue-btn); outline-offset: 2px; }
.rfields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 12px; }
.rfields .fld { min-width: 0; margin: 0; }
#resp-prev { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; min-width: 0; }
.rcust { padding-top: 12px; border-top: 1px solid var(--divider); min-width: 0; }
.rcust .chkl { min-height: 44px; flex-wrap: wrap; }
.rsent { border: 0; margin: 0 0 10px; padding: 0; min-width: 0; display: flex; flex-direction: column; }
.rsent legend { padding: 0; margin-bottom: 2px; font-size: 0.8125rem; font-weight: 600; color: var(--grey-ink); }
.rsent .chkl { min-height: 40px; align-items: center; }
.rsent .chkl > span { min-width: 0; overflow-wrap: anywhere; }
.rsend { flex-wrap: wrap; margin-top: 14px; row-gap: 4px; }
.rheld { flex: 1 1 200px; }
.rheld.off { display: none; }
.cmail, .cmail .bmail { min-width: 0; max-width: 100%; }

@media (max-width: 640px) {
  .rchoices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 8px; }
  .rchoice { width: 100%; min-width: 0; padding: 6px 10px; border-radius: 12px; font-size: 0.875rem; white-space: normal; overflow-wrap: anywhere; }
  .respform { padding: 12px; }
  .rfields { grid-template-columns: minmax(0, 1fr); }
  .cmail .csubj { flex-direction: column; align-items: stretch; gap: 4px; }
  .rsend .btn.primary { flex: 1 1 100%; justify-content: center; }
  .rheld { flex-basis: 100%; }
  .rsend { row-gap: 0; }
}

/* ---------- Branded email: item table ---------- */
.bm-tt { margin: 0 0 6px; font-size: 0.875rem; font-weight: 600; color: #212121; }
.bm-gw { max-width: 100%; overflow-x: auto; margin: 4px 0 18px; }
.bm-gw .bm-grid { margin: 0; }
.bm-grid th, .bm-grid td { overflow-wrap: normal; }

/* ---------- Phase 2: calmer cards ---------- */
.swcard { cursor: pointer; }
.swcard.locked { cursor: pointer; }
.swcard .swmain:hover b { text-decoration: none; }
/* Wording about dragging only where there is a mouse */
.swtouchonly { display: none; }
@media (pointer: coarse), (hover: none) { .swdragonly { display: none; } .swtouchonly { display: inline; } .swcard { cursor: default; } }
.swmore10 { align-self: center; min-height: 36px; font-size: 0.8125rem; }
.swempty { padding: 10px 8px; }

/* ---------- Agent D design pass (swatching.js): stages as tabs on phones ---------- */
.swstagetabs { display: none; }
@media (max-width: 599px) {
  .swstagetabs { display: flex; margin-bottom: 12px; }
  .swboard { display: block; overflow: visible; }
  .swboard .swcol { display: none; min-height: 0; }
  .swboard .swcol.cur { display: flex; }
}

/* Every board dialog scrolls inside itself, so a long backorder list still reaches the buttons */
.swdlg { max-height: calc(82vh - 16px); overflow-y: auto; overscroll-behavior: contain; }
.swdlg.swsplitdlg { top: 6vh; width: min(560px, calc(100% - 32px)); max-height: 88vh; }
@media (max-width: 640px) { .swdlg.swsplitdlg { top: 8px; max-height: calc(100dvh - 16px); } }
/* Backorder by quantity: "Short 1 of 3" beside the item */
.swsplitrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 2px 0; }
.swsplitq input, .rsentq input { width: 4.2em; margin: 0 4px; padding: 4px 6px; }
.rsentrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
/* Point of Sale at a glance, and finding an order */
.swstats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 4px 0 14px; }
.swstat { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; font: inherit; color: var(--ink); text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; min-width: 0; }
button.swstat, a.swstat { cursor: pointer; }
button.swstat:hover, a.swstat:hover { border-color: var(--ink-3, #999); }
.swstat b { font-size: 1.6rem; line-height: 1.15; font-weight: 700; }
.swstat span { font-size: .875rem; font-weight: 600; }
.swstat small { font-size: .75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.swstat.red b { color: var(--red, #B3261E); }
.swstat.amber b { color: var(--amber-ink, #8A5A00); }
.swstat.good b { color: var(--good, #1E7B4A); }
.swstat.on { border-color: var(--accent, #3B5BA9); box-shadow: inset 0 0 0 1px var(--accent, #3B5BA9); }
.swtools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0 0 12px; }
.swtools .searchbar { flex: 1 1 320px; max-width: 460px; }
.swhidden { white-space: nowrap; }
@media (max-width: 1100px) { .swstats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .swstats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .swstat { padding: 7px 9px; border-radius: 10px; } .swstat b { font-size: 1.2rem; } .swstat span { font-size: .75rem; line-height: 1.2; } .swstat small { display: none; }
  .swtools .searchbar { flex-basis: 100%; max-width: none; }
  .swtools .filters { overflow-x: auto; max-width: 100%; }
}

/* Point of Sale list view, pick list and invoices (swatching.js, 10 Oct 2026) */
.swstats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.swboard.sw3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.swtabbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 12px; border-bottom: 1px solid var(--line); }
.swtabs { border-bottom: 0; overflow-x: auto; scrollbar-width: none; }
.swtabs .tab.bad, .swtabs .tab.bad .n { color: var(--red); }
.swview { display: inline-flex; gap: 2px; padding: 2px; margin-bottom: 6px; border: 1px solid var(--line); border-radius: var(--r-pill, 999px); }
.swview .tab { min-height: 30px; padding: 0 12px; border-radius: var(--r-pill, 999px); border: 0; }
.swview .tab[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.swbulk { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; min-height: 44px; padding: 6px 12px; margin-bottom: 8px; border-radius: var(--r-sm, 8px); }
.swbulk.on { background: color-mix(in srgb, var(--blue-btn) 10%, transparent); position: sticky; top: 0; z-index: 2; }
.swlist { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card, 12px); overflow: hidden; }
.swrow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 8px 14px; padding: 10px 14px; border-left: 3px solid transparent; }
.swrow + .swrow { border-top: 1px solid var(--line); }
.swrow.urgent { border-left-color: var(--red); }
.swrow.late { background: color-mix(in srgb, var(--red) 5%, transparent); }
.swrow.on { background: color-mix(in srgb, var(--blue-btn) 8%, transparent); }
.swrow:not(:has(.swck)) { grid-template-columns: minmax(0, 1fr) auto auto; }
.swck { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; cursor: pointer; }
.swck input { width: 18px; height: 18px; }
.swrmain { display: flex; flex-direction: column; gap: 2px; min-width: 0; color: inherit; text-decoration: none; }
.swrmain:hover b, .swrmain:focus-visible b { text-decoration: underline; }
.swr1 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.swr1 .qk { font-size: 0.8125rem; color: var(--muted); }
.swr2 { font-size: 0.875rem; color: var(--grey-ink, var(--muted)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swrtags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 6px; max-width: 320px; }
.swracts { display: flex; align-items: center; gap: 6px; }
.swtag.blue { background: color-mix(in srgb, var(--blue-btn) 12%, transparent); color: var(--blue-btn); }
.swcon { padding: 12px 14px; margin: 4px 0 14px; border: 1px solid var(--line); border-left: 3px solid var(--blue-btn); border-radius: var(--r-sm, 8px); }
.swcon .fld { margin: 0 0 10px; max-width: 320px; }
.swcon .fld:last-child { margin-bottom: 0; }
.swauto .swautoh { margin: 0 0 6px; }
.swauto .swautol { margin: 4px 0 10px; padding-left: 18px; }
.swauto .swautol li { margin: 2px 0; }
.swauto .err { display: block; margin: 8px 0 0; }
.swman { margin: 8px 0 0; }
.swman .link { text-decoration: underline; text-underline-offset: 2px; }
.swcon + .swman, .cfwarn + .swman { margin-top: 0; }
.swpickdlg.swdlg { top: 5vh; width: min(760px, calc(100% - 32px)); max-height: 90vh; overflow-y: auto; }
.swpick { width: 100%; border-collapse: collapse; font-size: 0.875rem; margin: 10px 0 4px; }
.swpick th, .swpick td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--divider, var(--line)); vertical-align: top; }
.swpick th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.swpick .n { text-align: right; }
@media (max-width: 760px) {
  .swrow { grid-template-columns: auto minmax(0, 1fr); }
  .swrow:not(:has(.swck)) { grid-template-columns: minmax(0, 1fr); }
  .swrtags, .swracts { grid-column: 2 / -1; justify-content: flex-start; max-width: none; }
  .swrow:not(:has(.swck)) .swrtags, .swrow:not(:has(.swck)) .swracts { grid-column: 1 / -1; }
  .swr2 { white-space: normal; }
  .swboard.sw3 { display: block; }
  .swpickdlg.swdlg { top: auto; bottom: 0; left: 0; right: 0; width: auto; transform: none; border-radius: 16px 16px 0 0; max-height: 92vh; }
}
