/* FR-216 B2B screens. One section per stage, so the stages built in parallel
   never edit the same lines: add your rules under your own heading only. */

/* ── FR-217 (stage 1): shop account in the approval window ─────────────── */
.b2b-block { border: 1px solid var(--border, #e3e7eb); border-radius: 8px; padding: 12px 14px; margin: 4px 0 18px; }
.b2b-block > .oa-decision-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.b2b-note { font-size: 12px; color: var(--text-dim); line-height: 1.45; margin: 0 0 10px; }
.b2b-warn { font-size: 12px; line-height: 1.45; margin: 0 0 10px; padding: 8px 10px; border-radius: 6px; background: #fff7e6; color: #8a5300; }
.b2b-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.b2b-grid .oa-field-row { margin-bottom: 10px; }
.b2b-grid .b2b-wide { grid-column: 1 / -1; }
.b2b-check { display: flex !important; align-items: center; gap: 8px; color: var(--text) !important; }
.b2b-check input { width: auto !important; margin: 0 !important; }
.b2b-matches { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 12px; }
.b2b-matches .oa-candidate-card { margin-bottom: 0; color: var(--text); }
.b2b-matches input[type="radio"] { width: auto; margin: 3px 0 0; }
.b2b-preview { width: 100%; height: 320px; border: 1px solid var(--border, #e3e7eb); border-radius: 6px; background: #fff; }
.b2b-result-steps { font-size: 12px; color: var(--text-dim); }
@media (max-width: 640px) { .b2b-grid { grid-template-columns: 1fr; } }
/* FR-450: a phone of the form is the standard field (form-fields.js) inside a row of the grid */
.b2b-grid .oa-field-row > .ff-field { margin-bottom: 0; }
.b2b-grid .ff-field .iti { display: block; width: 100%; }
@media (max-width: 640px) { .b2b-grid .ff-field input { font-size: 16px; } }

/* ── FR-228: program application by Org ID — the list's mark (F6: the window of its own, b2b-program-existing.js, is gone) ──── */
.oa-existing-mark { margin-top: 4px; font-size: 12px; }

/* ── FR-218 (stage 2): Organizations tab ─────────────────────────────── */
.b2b-org-filters { align-items: flex-end; padding-top: 12px; padding-bottom: 12px; }
.b2b-org-filters .b2b-filter { flex: 1 1 160px; min-width: 150px; }
.b2b-org-filters select { width: 100%; }
/* FR-599 v2 (UR2-08): the sixth filter (Letter I2) keeps the width of the other five instead of stretching over a second row; .b2b-filter itself is not touched */
.b2b-org-filters .b2b-filter.b2b-filter-i2 { flex: 0 0 160px; }
.b2b-filter-actions { display: flex; gap: 8px; align-items: center; }
@media (max-width: 640px) {
  .b2b-org-filters { gap: 10px; }
  .b2b-org-filters .b2b-filter { flex: 1 1 calc(50% - 10px); min-width: 0; }
  .b2b-org-filters .b2b-filter.b2b-filter-i2 { flex: 1 1 calc(50% - 10px); }
  .b2b-filter-actions { flex: 1 1 100%; }
  .b2b-filter-actions .btn-primary { flex: 1; }
}

.b2b-pager { display: flex; justify-content: center; gap: 10px; margin: 14px 0; }

.b2b-org { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.b2b-org-title { font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.b2b-org .badge { vertical-align: 1px; }
.b2b-org-alert {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 8px 0 4px; padding: 8px 10px; font-size: 13px; line-height: 1.4;
  background: var(--err-bg); border: 1px solid var(--err-border); border-radius: var(--radius);
  overflow-wrap: anywhere;
}
.b2b-org-alert span { flex: 1 1 200px; }
.b2b-retry { padding: 3px 10px; }

.b2b-org-history { margin-top: 10px; font-size: 13px; }
.b2b-org-history > summary { cursor: pointer; color: var(--accent); user-select: none; }
.b2b-history-body { margin-top: 6px; }
.b2b-h-title { font-weight: 600; margin: 10px 0 4px; }
.b2b-h-list { margin: 0; padding-left: 18px; }
.b2b-h-list li { margin: 2px 0; overflow-wrap: anywhere; }
.b2b-h-when { color: var(--text-dim); margin-right: 6px; white-space: nowrap; }
.b2b-resend { padding: 0 6px; font-size: 12px; }
.b2b-shopify-live .b2b-h-list { margin-top: 4px; }

.b2b-window .b2b-langs { display: flex; gap: 16px; margin: 4px 0 8px 24px; }
.b2b-window .b2b-langs .action-check { margin: 0; }
.b2b-orgs-preview-actions { margin: 4px 0 8px; }
.b2b-orgs-preview { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; margin-top: 6px; }
.b2b-orgs-preview-meta { font-size: 13px; margin-bottom: 6px; overflow-wrap: anywhere; }
.b2b-orgs-preview-frame { width: 100%; height: 340px; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
.b2b-orgs-note { font-size: 12px; margin: 8px 0 0; }

/* ── FR-219 (stage 3): Shop employees + tab badges ───────────────────── */
/* the number lives in data-count (b2b-employees.js): the button's text stays its name */
/* FR-249: on the right of the menu's item; a group's button — the sum of its sections */
.tab-btn[data-count]::after, .menu-group-btn[data-count]::after {
  content: attr(data-count);
  display: inline-block; flex-shrink: 0; min-width: 18px; height: 18px; padding: 0 5px; margin-left: auto;
  border-radius: 9px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; vertical-align: 1px;
}
.emp-note { background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 6px; padding: 8px 10px; margin: 8px 0; font-size: 13px; }
.emp-note-ok { background: var(--ok-bg); border-color: var(--ok-border); }
.emp-note-plain { background: #f6f7f9; border-color: var(--border); }
#emp-shopify-off { margin: 0 0 12px; }
.emp-table .badge { margin-top: 3px; }
.emp-more-row { margin-top: 10px; text-align: center; }
.emp-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-bottom: 8px; }
.emp-fact-label { font-size: 12px; color: var(--text-dim); }
.emp-fact-value { font-size: 14px; overflow-wrap: anywhere; }
.emp-hints { margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.emp-hint { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
.emp-hint .badge { flex: none; }
.emp-action { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 12px; }
#emp-modal h3, #emp-add-modal h3 { margin: 12px 0 8px; font-size: 14px; }
#emp-modal .emp-action h3 { margin-top: 0; }
.emp-action-row { display: flex; justify-content: flex-end; }
.emp-details { margin-top: 10px; font-size: 13px; }
.emp-details summary { cursor: pointer; color: var(--text-dim); }
.emp-list { margin: 6px 0 0; padding-left: 18px; color: var(--text-dim); overflow-wrap: anywhere; }
.emp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
.emp-add-search { display: flex; gap: 8px; margin-bottom: 8px; }
.modal-box .emp-add-search input { flex: 1; margin-top: 0; }
.emp-add-locations { max-height: 180px; overflow: auto; margin-bottom: 8px; }
.modal-box .emp-radio { display: flex; gap: 8px; align-items: center; color: var(--text); margin-bottom: 4px; }
.modal-box .emp-radio input { width: auto; margin: 0; }
@media (max-width: 640px) {
  .emp-facts, .emp-grid { grid-template-columns: 1fr; }
}

/* ── FR-220 (stage 4): Program settings ──────────────────────────────── */
/* public/js/b2b-program.js: everything under #tab-b2b-program / #bp-sku-modal, classes bp- */
#tab-b2b-program .small, #tab-b2b-sample-kits .small, #tab-b2b-shopify .small { font-size: 12px; }
#tab-b2b-program .bp-toolbar, #tab-b2b-sample-kits .bp-toolbar, #tab-b2b-shopify .bp-toolbar { flex-wrap: wrap; }
#tab-b2b-program .bp-status, #tab-b2b-sample-kits .bp-status, #tab-b2b-shopify .bp-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 8px; }
#tab-b2b-program .bp-note, #tab-b2b-sample-kits .bp-note, #tab-b2b-shopify .bp-note { margin: 0 0 12px; max-width: 900px; }
#tab-b2b-program .bp-stock-error, #tab-b2b-sample-kits .bp-stock-error, #tab-b2b-shopify .bp-stock-error { max-width: 260px; margin-top: 4px; }
#tab-b2b-program table.bp-skus td, #tab-b2b-sample-kits table.bp-skus td, #tab-b2b-shopify table.bp-skus td { white-space: nowrap; }
#tab-b2b-program table.bp-skus td:nth-child(2), #tab-b2b-sample-kits table.bp-skus td:nth-child(2), #tab-b2b-shopify table.bp-skus td:nth-child(2),
#tab-b2b-program table.bp-skus td:nth-child(9), #tab-b2b-sample-kits table.bp-skus td:nth-child(9), #tab-b2b-shopify table.bp-skus td:nth-child(9) { white-space: normal; min-width: 160px; }

/* settings cards */
#tab-b2b-program .bp-card, #tab-b2b-sample-kits .bp-card, #tab-b2b-shopify .bp-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  max-width: 980px;
}
#tab-b2b-program .bp-card .cs-section-title, #tab-b2b-sample-kits .bp-card .cs-section-title, #tab-b2b-shopify .bp-card .cs-section-title { margin-top: 0; }
#tab-b2b-program .bp-card .table-wrap, #tab-b2b-sample-kits .bp-card .table-wrap, #tab-b2b-shopify .bp-card .table-wrap { border-radius: 6px; }
#tab-b2b-program .bp-card-actions, #tab-b2b-sample-kits .bp-card-actions, #tab-b2b-shopify .bp-card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 10px; }
#tab-b2b-program .bp-field, #tab-b2b-sample-kits .bp-field, #tab-b2b-shopify .bp-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 10px; }
#tab-b2b-program .bp-field input, #tab-b2b-sample-kits .bp-field input, #tab-b2b-shopify .bp-field input,
#tab-b2b-program .bp-field textarea, #tab-b2b-sample-kits .bp-field textarea, #tab-b2b-shopify .bp-field textarea { font-weight: 400; }
#tab-b2b-program .bp-narrow, #tab-b2b-sample-kits .bp-narrow, #tab-b2b-shopify .bp-narrow { max-width: 260px; }
#tab-b2b-program .bp-two, #tab-b2b-sample-kits .bp-two, #tab-b2b-shopify .bp-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#tab-b2b-program textarea, #tab-b2b-sample-kits textarea, #tab-b2b-shopify textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  resize: vertical;
}
#tab-b2b-program textarea.mono, #tab-b2b-sample-kits textarea.mono, #tab-b2b-shopify textarea.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; line-height: 1.5; }
#tab-b2b-program .bp-add, #tab-b2b-sample-kits .bp-add, #tab-b2b-shopify .bp-add { margin-top: 6px; }

#tab-b2b-program .bp-map, #tab-b2b-sample-kits .bp-map, #tab-b2b-shopify .bp-map { display: flex; flex-direction: column; gap: 6px; }
#tab-b2b-program .bp-map-row, #tab-b2b-sample-kits .bp-map-row, #tab-b2b-shopify .bp-map-row { display: grid; grid-template-columns: minmax(0, 1fr) 200px auto; gap: 8px; align-items: center; }
#tab-b2b-program .bp-map-row .icon-btn, #tab-b2b-sample-kits .bp-map-row .icon-btn, #tab-b2b-shopify .bp-map-row .icon-btn { margin-right: 0; }

#tab-b2b-program .bp-reason-block h4, #tab-b2b-sample-kits .bp-reason-block h4, #tab-b2b-shopify .bp-reason-block h4 { margin: 12px 0 6px; font-size: 13px; }
#tab-b2b-program .bp-reasons, #tab-b2b-sample-kits .bp-reasons, #tab-b2b-shopify .bp-reasons { display: flex; flex-direction: column; gap: 6px; }
#tab-b2b-program .bp-reason, #tab-b2b-sample-kits .bp-reason, #tab-b2b-shopify .bp-reason { display: grid; grid-template-columns: 150px minmax(0, 1fr) minmax(0, 1fr) 90px; gap: 8px; align-items: center; }
#tab-b2b-program .bp-reason .icon-btn, #tab-b2b-sample-kits .bp-reason .icon-btn, #tab-b2b-shopify .bp-reason .icon-btn { margin-right: 0; }
/* FR-946: pt and fr of a reason sit under en and es (second row: Portuguese, French) */
#tab-b2b-program .bp-reason-lang-pt, #tab-b2b-sample-kits .bp-reason-lang-pt, #tab-b2b-shopify .bp-reason-lang-pt { grid-column: 2; grid-row: 2; }
#tab-b2b-program .bp-reason-lang-fr, #tab-b2b-sample-kits .bp-reason-lang-fr, #tab-b2b-shopify .bp-reason-lang-fr { grid-column: 3; grid-row: 2; }
/* FR-946: a visible language tag in front of each text of a reason (the placeholder is gone once the field is filled) */
#tab-b2b-program .bp-reason-lang { position: relative; min-width: 0; }
#tab-b2b-program .bp-reason-lang input { width: 100%; box-sizing: border-box; padding-left: 34px; }
#tab-b2b-program .bp-lang-tag { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); font-size: 11px; font-weight: 600; color: var(--text-dim); pointer-events: none; }
#tab-b2b-program .bp-reason-code[readonly], #tab-b2b-sample-kits .bp-reason-code[readonly], #tab-b2b-shopify .bp-reason-code[readonly] { background: #f6f7f9; color: var(--text-dim); }
#tab-b2b-program .bp-reason-fixed, #tab-b2b-sample-kits .bp-reason-fixed, #tab-b2b-shopify .bp-reason-fixed { text-align: center; }

/* the SKU window */
#bp-sku-modal .bp-hint { display: block; margin-top: 3px; font-size: 12px; color: var(--text-dim); }
#bp-sku-modal .bp-check { display: flex; align-items: center; gap: 8px; color: var(--text); }
#bp-sku-modal .bp-check input { width: auto; margin: 0; }

@media (max-width: 760px) {
  #tab-b2b-program .bp-two, #tab-b2b-sample-kits .bp-two, #tab-b2b-shopify .bp-two { grid-template-columns: 1fr; }
  #tab-b2b-program .bp-map-row, #tab-b2b-sample-kits .bp-map-row, #tab-b2b-shopify .bp-map-row { grid-template-columns: 1fr 1fr; }
  #tab-b2b-program .bp-map-row .bp-map-type, #tab-b2b-sample-kits .bp-map-row .bp-map-type, #tab-b2b-shopify .bp-map-row .bp-map-type { grid-column: 1 / -1; }
  #tab-b2b-program .bp-reason, #tab-b2b-sample-kits .bp-reason, #tab-b2b-shopify .bp-reason { grid-template-columns: 1fr auto; }
  #tab-b2b-program .bp-reason-lang, #tab-b2b-sample-kits .bp-reason-lang, #tab-b2b-shopify .bp-reason-lang { grid-column: 1 / -1; grid-row: auto; }
  #tab-b2b-program .bp-reason-code, #tab-b2b-sample-kits .bp-reason-code, #tab-b2b-shopify .bp-reason-code { grid-column: 1; grid-row: 1; }
  #tab-b2b-program .bp-reason .icon-btn, #tab-b2b-sample-kits .bp-reason .icon-btn, #tab-b2b-shopify .bp-reason .icon-btn,
  #tab-b2b-program .bp-reason-fixed, #tab-b2b-sample-kits .bp-reason-fixed, #tab-b2b-shopify .bp-reason-fixed { grid-column: 2; grid-row: 1; }
  #bp-sku-modal .grid2 { grid-template-columns: 1fr; }
}

/* ── FR-272: Organizations → Letters (public/js/b2b-letters.js, classes bl-) ── */
/* T1–T10; they were Program settings' part (FR-220), the look kept */
#tab-b2b-letters .small { font-size: 12px; }
#tab-b2b-letters .bl-note { margin: 0 0 12px; max-width: 900px; }
#tab-b2b-letters .bl-letters-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
#tab-b2b-letters .bl-letter-list { display: flex; flex-direction: column; gap: 14px; }
#tab-b2b-letters .bl-scope { display: flex; flex-direction: column; gap: 4px; }
#tab-b2b-letters .bl-scope-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-dim); }
#tab-b2b-letters .bl-scope-hint { margin-bottom: 2px; }
#tab-b2b-letters .bl-letter-btn {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  color: var(--text);
}
#tab-b2b-letters .bl-letter-btn:hover { background: #f1f3f5; }
#tab-b2b-letters .bl-letter-btn.active { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
#tab-b2b-letters .bl-edited { margin-left: 6px; }
#tab-b2b-letters .bl-letter-editor {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 0;
}
#tab-b2b-letters .bl-letter-editor .cs-section-title { margin-top: 0; }
#tab-b2b-letters .bl-for { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0 0 10px; }
#tab-b2b-letters .bl-badge-all { background: #e0f2fe; color: #075985; border-color: #bae6fd; }
#tab-b2b-letters .bl-lang-tabs { margin-bottom: 10px; }
#tab-b2b-letters .bl-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 10px; }
#tab-b2b-letters .bl-field input,
#tab-b2b-letters .bl-field textarea { font-weight: 400; }
#tab-b2b-letters textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  resize: vertical;
}
#tab-b2b-letters textarea.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; line-height: 1.5; }
#tab-b2b-letters .bl-vars { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
#tab-b2b-letters .bl-var {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #3730a3;
  border-radius: 999px;
  padding: 2px 8px;
  cursor: pointer;
}
#tab-b2b-letters .bl-var:hover { background: #e0e7ff; }
#tab-b2b-letters .bl-sample { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 12px; margin-bottom: 8px; }
#tab-b2b-letters .bl-sample .bl-field { margin-bottom: 0; }
#tab-b2b-letters .bl-sample > .muted { flex-basis: 100%; }
#tab-b2b-letters .bl-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 10px; }
#tab-b2b-letters .bl-preview-subject { margin: 14px 0 6px; font-size: 13px; }
#tab-b2b-letters .bl-preview {
  width: 100%;
  height: 520px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f5f7f9;
}

@media (max-width: 760px) {
  #tab-b2b-letters .bl-letters-grid { grid-template-columns: minmax(0, 1fr); }
  /* FR-599 v2 (AC-127, AC-134): a long sample name must not widen the editor beyond the screen */
  #tab-b2b-letters .bl-sample .bl-field { min-width: 0; max-width: 100%; }
  #tab-b2b-letters .bl-sample select { max-width: 100%; min-width: 0; }
  #tab-b2b-letters .bl-scope { flex-direction: row; flex-wrap: wrap; }
  #tab-b2b-letters .bl-scope-title,
  #tab-b2b-letters .bl-scope-hint { flex: 1 1 100%; }
  #tab-b2b-letters .bl-letter-btn { flex: 1 1 140px; }
  #tab-b2b-letters .bl-preview { height: 420px; }
}

/* ── FR-243: Program settings → Shopify (b2b-program.js, classes bs-) ─── */
#tab-b2b-program .bs-rows, #tab-b2b-sample-kits .bs-rows, #tab-b2b-shopify .bs-rows { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 8px 12px; font-size: 13px; align-items: start; }
#tab-b2b-program .bs-rows > div, #tab-b2b-sample-kits .bs-rows > div, #tab-b2b-shopify .bs-rows > div { min-width: 0; overflow-wrap: anywhere; }
#tab-b2b-program .bs-chips, #tab-b2b-sample-kits .bs-chips, #tab-b2b-shopify .bs-chips { display: flex; flex-wrap: wrap; gap: 4px; }
#tab-b2b-program .bs-chip, #tab-b2b-sample-kits .bs-chip, #tab-b2b-shopify .bs-chip { background: #f1f3f5; border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; font-size: 12px; }
#tab-b2b-program .bs-forms-row, #tab-b2b-sample-kits .bs-forms-row, #tab-b2b-shopify .bs-forms-row { margin-bottom: 4px; overflow-wrap: anywhere; }
#tab-b2b-program table.bs-topics td:first-child, #tab-b2b-sample-kits table.bs-topics td:first-child, #tab-b2b-shopify table.bs-topics td:first-child { white-space: nowrap; }
#tab-b2b-program .bs-others ul, #tab-b2b-sample-kits .bs-others ul, #tab-b2b-shopify .bs-others ul,
#tab-b2b-program .bs-failed ul, #tab-b2b-sample-kits .bs-failed ul, #tab-b2b-shopify .bs-failed ul { margin: 4px 0 0; padding-left: 18px; }
#tab-b2b-program .bs-failed, #tab-b2b-sample-kits .bs-failed, #tab-b2b-shopify .bs-failed { margin-top: 10px; }
#tab-b2b-program #bs-webhook-uri, #tab-b2b-sample-kits #bs-webhook-uri, #tab-b2b-shopify #bs-webhook-uri { overflow-wrap: anywhere; }
@media (max-width: 760px) {
  #tab-b2b-program .bs-rows, #tab-b2b-sample-kits .bs-rows, #tab-b2b-shopify .bs-rows { grid-template-columns: 1fr; gap: 2px; }
  #tab-b2b-program .bs-rows > .muted, #tab-b2b-sample-kits .bs-rows > .muted, #tab-b2b-shopify .bs-rows > .muted { margin-top: 8px; }
}

/* ── FR-221 (stage 5): Chip orders ───────────────────────────────────── */
.co-note-tools { display: flex; flex-direction: column; gap: 6px; margin: -4px 0 12px; }
.co-note-tools .btn { align-self: flex-start; }
.co-note-sent { overflow-wrap: anywhere; }
.co-head { margin-bottom: 10px; }
.co-title { margin: 0 0 6px; font-size: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.co-sub { margin: 0; font-size: 13px; }
.co-back { padding-left: 0; margin-bottom: 6px; }
.co-gap { margin-left: 2px; }
.co-efs-line { margin-bottom: 12px; }
.co-views { flex-wrap: nowrap; gap: 2px; }
.co-views .subtab-btn { padding: 8px 9px; }
.co-efs-line summary { display: inline-block; cursor: pointer; margin-top: 4px; text-decoration: underline; }
.co-efs-more p { margin: 4px 0 0; overflow-wrap: anywhere; }
.co-toolbar { flex-wrap: wrap; }
.co-toolbar .search-box { flex: 1 1 220px; max-width: 360px; }
.co-number { font-weight: 600; font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; }
.co-small { font-size: 12px; margin-top: 4px; }
.co-err-text { color: var(--danger-dark); max-width: 260px; overflow-wrap: anywhere; }
.badge.co-badge-info { background: #eff4ff; color: var(--accent-dark); border: 1px solid #bfd3fb; }

.co-decide { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; padding: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.co-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.co-card { min-width: 0; }
.co-card .cs-card-row { overflow-wrap: anywhere; }
.co-card .table-wrap { margin-bottom: 8px; }
.co-card table { font-size: 12px; }
.co-card th, .co-card td { padding: 6px 8px; }
.co-compare table { table-layout: fixed; }
.co-compare th:first-child { width: 84px; }
.co-compare td { overflow-wrap: anywhere; }
.co-diff td { background: var(--warn-bg); }
.co-diff td:last-child { font-weight: 600; }
.co-legend { margin: 4px 0 0; }
.co-sender { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.co-total td { font-weight: 600; }
.co-comment { white-space: pre-line; }
.co-need-row { padding: 6px 8px; border-radius: 6px; line-height: 1.6; }
.co-need-row .badge { margin-left: 2px; }
.co-need-over { background: var(--err-bg); }
.co-need-maybe { background: var(--warn-bg); }
.co-need-live { margin: 8px 0 12px; }
.co-sku { padding: 6px 0; border-bottom: 1px dashed var(--border); margin-bottom: 6px; }
.co-sku:last-of-type { border-bottom: 0; }
.co-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.co-letter .badge { margin-left: 4px; }
.co-history { margin: 0; padding-left: 18px; font-size: 12px; line-height: 1.5; max-height: 260px; overflow-y: auto; }
.co-history li { margin-bottom: 4px; overflow-wrap: anywhere; }

.co-modal textarea { width: 100%; }
.co-modal .table-wrap { margin-bottom: 10px; }
.co-qty-table { table-layout: fixed; }
.co-qty-table th:nth-child(2) { width: 64px; }
.co-qty-table th:nth-child(3) { width: 112px; }
.co-qty-table td { overflow-wrap: anywhere; }
.co-qty { width: 90px !important; margin-top: 0 !important; }
.co-preview { margin: 10px 0; }
.co-preview .b2b-preview { height: 360px; margin-top: 6px; }
.co-shortage { margin-top: 8px; font-size: 13px; }
.co-shortage ul { margin: 0 0 8px; padding-left: 18px; }

@media (max-width: 900px) { .co-grid { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .co-decide .btn { flex: 1 1 auto; }
  /* the list as cards: number + status on top, then the organization, the boxes, the date */
  .co-list { overflow: visible; }
  .co-list thead { display: none; }
  .co-list table, .co-list tbody { display: block; }
  .co-list tr.co-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .co-list tr.co-row:last-child { border-bottom: 0; }
  .co-list tr.co-row td { display: block; padding: 0; border: 0; }
  .co-list tr.co-row td:nth-child(1) { grid-column: 1 / -1; grid-row: 4; color: var(--text-dim); font-size: 12px; }
  .co-list tr.co-row td:nth-child(2) { grid-column: 1; grid-row: 1; }
  .co-list tr.co-row td:nth-child(3) { grid-column: 1 / -1; grid-row: 2; }
  .co-list tr.co-row td:nth-child(4) { grid-column: 1 / -1; grid-row: 3; }
  .co-list tr.co-row td:nth-child(5) { grid-column: 2; grid-row: 1; text-align: right; }
  .co-list .co-err-text { max-width: 160px; }
  .co-preview .b2b-preview { height: 300px; }
}

/* ── FR-229: Program feedback ────────────────────────────────────────── */
.fb-title { margin: 0 0 6px; }
.fb-filters { margin: 4px 0 10px; }
.fb-toolbar { margin-bottom: 12px; }
.fb-list { display: flex; flex-direction: column; gap: 10px; }
.fb-item { border: 1px solid var(--border, #e3e7eb); border-left-width: 4px; border-radius: 8px; padding: 12px 14px; background: #fff; }
.fb-item.fb-allowed { border-left-color: #2e9e5b; }
.fb-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.fb-who { min-width: 0; overflow-wrap: anywhere; }
.fb-text { margin: 8px 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.fb-meta { font-size: 12px; overflow-wrap: anywhere; }
.fb-empty { margin: 16px 0; }

/* ── FR-238: wholesale applications of stores / distributors (Org approvals) ── */
.oa-wholesale { border: 1px solid var(--border, #e3e7eb); border-radius: 8px; padding: 12px 14px; margin: 0 0 16px; }
.oa-wholesale .oa-field-row { margin-bottom: 8px; }
.oa-wholesale-note { font-size: 12px; line-height: 1.45; margin: 0 0 10px; }

/* FR-274: the applicant changed the application through the confirmation e-mail's link —
   the row's mark and the application window's notice and its Changes block (application-window.js) */
.oa-edited-mark { margin-top: 4px; font-size: 12px; }
.oa-applicant-changes { border-left: 3px solid var(--warn-border); padding-left: 10px; }
.oa-changes-note { margin: 0 0 8px; font-size: 12px; }
.oa-change { margin: 0 0 10px; }
.oa-change-at { font-size: 12px; font-weight: 600; margin: 0 0 4px; }
.oa-change-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.oa-change-table th, .oa-change-table td { text-align: left; vertical-align: top; padding: 4px 6px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; white-space: pre-wrap; }
.oa-change-table th:first-child, .oa-change-table td:first-child { width: 30%; }
.oa-change-from { color: var(--text-dim); text-decoration: line-through; }
@media (max-width: 640px) {
  .oa-change-table thead { display: none; }
  .oa-change-table tr { display: block; padding: 6px 0; border-bottom: 1px solid var(--border); }
  .oa-change-table td { display: block; width: auto !important; border: 0; padding: 2px 0; }
  /* inline-block: the «Was» value's line-through doesn't cross its label */
  .oa-change-table td::before { content: attr(data-label) ': '; display: inline-block; margin-right: 4px; font-weight: 600; color: var(--text-dim); }
}
/* FR-274 (b): a certificate the organization uploaded in the site's dashboard, not reviewed yet */
.b2b-cert-review { margin-left: 6px; }

/* ── FR-276: sample kits from an application (b2b-samples.js, classes sp-) ── */
.sp-mark { margin-top: 4px; font-size: 12px; }
.sp-row-btn { white-space: nowrap; }
.sp-view .oa-decision-title .btn { padding: 4px 12px; font-size: 13px; }
.sp-line { font-size: 13px; padding: 4px 0; overflow-wrap: anywhere; }
.sp-asked { margin-bottom: 10px; }
.sp-asked .cs-card-row { overflow-wrap: anywhere; }
.sp-yes { font-weight: 600; }
.sp-their-text { white-space: pre-line; }
.sp-wh { margin-bottom: 8px; }
.sp-h { margin: 14px 0 8px; }
.sp-card .cs-card-row { overflow-wrap: anywhere; font-size: 13px; }
.sp-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
.sp-card .co-actions { margin-top: 8px; }
.sp-err { margin: 6px 0; overflow-wrap: anywhere; }
.sp-history { margin-top: 8px; }
.sp-history summary { cursor: pointer; }
.sp-label { font-size: 12px; font-weight: 600; color: var(--text-dim); margin: 8px 0 6px; }
.sp-kits { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.sp-kit { display: flex !important; align-items: flex-start; gap: 8px; margin: 0 !important; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; color: var(--text) !important; cursor: pointer; }
.sp-kit input { width: auto !important; margin: 3px 0 0 !important; }
.sp-kit-off { opacity: 0.75; cursor: default; }
.sp-form textarea { width: 100%; }
.sp-note { display: block; margin-top: 4px; }
.sp-letter { display: grid; grid-template-columns: 1fr 140px; gap: 0 12px; margin-top: 10px; }
.sp-bad { border-color: var(--danger) !important; background: var(--err-bg) !important; }
@media (max-width: 640px) {
  .sp-letter { grid-template-columns: 1fr; }
  .sp-modal .co-actions .btn { flex: 1 1 auto; }
}
/* Program settings → Samples (b2b-program.js) */
.sp-set-kit { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.sp-set-grid { display: grid; grid-template-columns: 1fr 1fr 110px; gap: 0 12px; align-items: end; }
.sp-set-grid .b2b-check { margin-bottom: 10px; }
.sp-set-grid .sp-wide { grid-column: 1 / -1; }
.sp-set-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.sp-set-check { font-size: 12px; overflow-wrap: anywhere; }
@media (max-width: 640px) { .sp-set-grid { grid-template-columns: 1fr; } }

/* FR-448: Organizations → Profile changes */
.opr-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin: 0 0 14px; background: var(--panel, #fff); }
.opr-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 8px; }
.opr-org-id, .opr-meta { font-size: 12px; color: var(--text-dim); }
.opr-table-wrap { overflow-x: auto; }
.opr-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.opr-table th, .opr-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; white-space: pre-line; }
.opr-table th:first-child, .opr-table td:first-child { width: 9em; overflow-wrap: normal; word-break: normal; }
.opr-wanted { font-weight: 600; }
.opr-changed { color: #8a5a00; }
.opr-warn { font-size: 12px; color: #8a5a00; margin: 8px 0 0; }
.modal-box label.opr-confirm, .opr-confirm { display: flex; align-items: flex-start; gap: 8px; margin: 10px 0 0; font-size: 13px; color: var(--text); }
.modal-box .opr-confirm input[type="checkbox"], .opr-confirm input[type="checkbox"] { width: auto; margin: 2px 0 0; flex: none; }
.opr-confirm span { flex: 1; min-width: 0; }
.modal-box .opr-table-wrap { margin-bottom: 10px; }
/* FR-1071: the conversation of a «needs info» request (js/request-info.js) */
.opr-thread { margin: 10px 0 0; display: flex; flex-direction: column; gap: 8px; }
.opr-msg { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; background: var(--panel, #fff); }
.opr-msg-ask { border-left: 4px solid #b42318; }
.opr-msg-provide { border-left: 4px solid var(--border); }
.opr-msg-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.opr-msg-text { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.opr-msg-image { display: block; margin-top: 8px; max-width: 100%; max-height: 240px; border: 1px solid var(--border); border-radius: 6px; }
.opr-actions { display: flex; gap: 8px; margin: 12px 0 0; flex-wrap: wrap; }
@media (max-width: 600px) {
  .opr-table thead { display: none; }
  .opr-table tr { display: block; border-bottom: 1px solid var(--border); padding: 4px 0; }
  .opr-table td { display: block; border: 0; padding: 2px 0; }
  .opr-table th:first-child, .opr-table td:first-child { width: auto; overflow-wrap: anywhere; }
  .opr-table td::before { content: attr(data-label) ': '; color: var(--text-dim); font-size: 11px; }
  /* FR-555 R-02: a caption over its value, no colon; the buttons of a decision one under another, full width */
  .opr-kv tr { padding: 6px 0; }
  .opr-kv th, .opr-kv td { display: block; width: auto; padding: 1px 0; border: 0; }
  .opr-kv th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--text-dim); }
  .opr-kv td::before { content: none; }
  .opr-kv td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--text-dim); }
  .opr-actions { flex-direction: column; }
  .opr-actions .btn { width: 100%; text-align: center; }
}

/* ── FR-484 (D-3, AC-22): New admins to verify on a 390 px screen ────── */
/* Only the tab #tab-org-admin-checks, its Remove admin window (.oac-window) and the row in the organization card
   ([data-org-admin-check]); the shared subtab-btn / modal / cs-card / badge rules stay as they are. */
#tab-org-admin-checks .subtabs { flex-wrap: wrap; }
#tab-org-admin-checks .cs-card { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
#tab-org-admin-checks .cs-card .badge { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
#tab-org-admin-checks .cs-card-actions { flex-wrap: wrap; align-items: center; }
.oac-window { box-sizing: border-box; max-width: calc(100vw - 32px); min-width: 0; overflow-wrap: anywhere; }
.oac-window .badge { max-width: 100%; white-space: normal; }
.oac-window .modal-actions { flex-wrap: wrap; }
[data-org-admin-check] { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .oac-window .modal-actions { position: sticky; bottom: 0; background: var(--panel); padding-top: 8px; }
}
@media (max-width: 640px) {
  #tab-org-admin-checks .cs-card-grid { grid-template-columns: minmax(0, 1fr); }
}
/* FR-548: Integration requests - what the person typed is shown as written (line breaks kept), the rows open the card */
.ir-value { white-space: pre-wrap; overflow-wrap: anywhere; }
.ir-row { cursor: pointer; }

/* FR-607: the fields of the Agent approvals windows are 16px on a phone (no zoom on iOS), like the other cs-admin windows */
@media (max-width: 640px) { #aa-confirm-email, #aa-reason { font-size: 16px; } }
/* FR-555 R-12: Join requests - a filter does not wrap its words, the search takes the width it is given */
.ir-chips { flex-wrap: wrap; }
.ir-chips .subtab-btn { white-space: nowrap; padding: 8px 10px; }
.ir-toolbar .search-box { flex: 1 1 260px; min-width: 0; max-width: 420px; }
@media (max-width: 600px) { .ir-toolbar .search-box { flex-basis: 100%; max-width: none; } }
/* FR-749 SHP-09: Resale certificates — the chips and the Open window's two columns. No new colour, font or control:
   the chip is .oa-status-btn, the table is the panel's, the window is .modal-box. */
.cert-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.cert-table td { vertical-align: top; }
.cert-table .badge { margin-top: 2px; }
.cert-open-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.cert-frame { width: 100%; height: 420px; /* FR-961: taller where there is room */ border: 1px solid var(--border); border-radius: 6px; background: #fff; }
@media (min-width: 900px) { .cert-open-grid { grid-template-columns: 3fr 2fr; } .cert-window.modal-box-lg { width: min(1100px, calc(100vw - 48px)); } .cert-frame { height: 60vh; min-height: 360px; } }
@media (max-width: 899px) { .cert-window.modal-box-lg { width: calc(100vw - 16px); max-width: none; } }
.cert-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; margin: 0 0 10px; }
.cert-facts dt { color: var(--text-dim); }
.cert-facts dd { margin: 0; overflow-wrap: anywhere; }
.cert-history h3 { font-size: 14px; margin: 10px 0 6px; }
.cert-events { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.cert-events li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.cert-reason { margin-top: 3px; overflow-wrap: anywhere; }
.cert-no-file { font-weight: 600; margin: 0 0 8px; }
.cert-number { font-size: 18px; margin: 0 0 10px; overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .cert-open-grid { grid-template-columns: 1fr; }
  .cert-frame { height: 65vh; min-height: 320px; } /* FR-961: was 300px */
}

/* FR-958: the file popup (file-popup.js) — the window is .modal-box; only sizes here, the colors are the theme's */
.file-popup-overlay { z-index: 60; }
.file-popup-box { width: min(960px, calc(100vw - 32px)); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.file-popup-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.file-popup-head h2 { margin: 0; overflow-wrap: anywhere; }
.file-popup-body { flex: 1 1 auto; min-height: 0; overflow: auto; text-align: center; }
.file-popup-img { max-width: 100%; max-height: calc(100vh - 190px); object-fit: contain; }
.file-popup-frame { width: 100%; height: calc(100vh - 190px); min-height: 320px; border: 0; }
.file-popup-links { margin: 12px 0 0; font-size: 13px; }
@media (max-width: 600px) {
  .file-popup-overlay { align-items: stretch; }
  .file-popup-box { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; padding: 16px; }
  .file-popup-img, .file-popup-frame { max-height: none; }
  .file-popup-frame { height: 100%; }
}

/* ── FR-997: Notifications tab (the expanded row of the journal) ───────── */
.detail-row > td { background: var(--bg-soft, #f6f8fa); }
.nt-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 10px; }
.nt-facts dt { color: var(--muted, #5b6770); }
.nt-facts dd { margin: 0; overflow-wrap: anywhere; }
.nt-text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 22em; overflow: auto; margin: 4px 0 12px; font: inherit; }
.nt-comments { list-style: none; padding: 0; margin: 4px 0 8px; }
.nt-comments li { margin-bottom: 6px; }
