/* Submissions of B2B links to CRM (dashboard/views-b2b.mjs, b2b-actions.mjs): the status block and the history inside the scenario step, the status headline
   of one submission (.b2b-now — the one bold place), the step track (.flow reuse), rows, dialog parts.
   Tokens from app.css; colour only for state (amber = someone must act, red only with icon + word). */

/* ---- gate box (token / rights) ----------------------------------------------------------------- */
.b2b-gate { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 12px; margin-top: 14px; padding: 12px 14px; background: var(--tint); border: 1px solid var(--line); border-radius: var(--radius); }
.b2b-gate > svg.lucide { margin-top: 2px; color: var(--muted); }
.b2b-gate > div { min-width: 0; flex: 1 1 280px; }
.b2b-gate strong { display: block; font-size: 14px; }
.b2b-gate p { margin-top: 2px; color: var(--ink-2); font-size: 13.5px; }
.b2b-gate.tone-amber { background: var(--amber-soft); border-color: var(--amber-line); }
.b2b-gate.tone-amber > svg.lucide { color: var(--amber); }
.b2b-gate.tone-red { background: var(--red-soft); border-color: var(--red-line); }
.b2b-gate.tone-red > svg.lucide { color: var(--red); }
/* app.css `.field input:not([type=radio])` outranks `.field [aria-invalid]`: the invalid border is restated here. */
/* Inputs sit under their labels; the arrow and the button align with the inputs, a field error grows below only. */

/* ---- list ---------------------------------------------------------------------------------------- */
.b2b-count { display: inline-grid; min-width: 24px; height: 22px; place-items: center; margin-left: 6px; padding: 0 7px; color: var(--ink-2); background: #e3e9e6; border-radius: 11px; font-size: 12px; font-weight: 650; vertical-align: 1px; }
.b2b-rows { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.b2b-rows > li + li { border-top: 1px solid var(--line-2); }
.b2b-row { display: grid; grid-template-columns: 236px minmax(0, 1fr) minmax(0, 320px) 16px; align-items: center; gap: 6px 18px; min-height: 64px; padding: 12px 16px; }
.b2b-row-what { min-width: 0; display: grid; gap: 2px; }
.b2b-row-what strong { overflow: hidden; font-size: 14.5px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.b2b-row-meta { color: var(--muted); font-size: 12.5px; }
.b2b-row-next { color: var(--ink-2); font-size: 13.5px; }
.b2b-row-chev { color: var(--muted); }
@media (hover: hover) and (pointer: fine) {
  .b2b-row:hover { background: var(--tint); }
  .b2b-row:hover strong { color: var(--green); }
}
.b2b-skel { display: grid; }
.b2b-skel span { height: 64px; background: var(--paper); }
.b2b-skel span::before { content: ""; display: block; width: 46%; height: 12px; margin: 26px 16px; background: var(--line-2); border-radius: 3px; }
.b2b-skel span + span { border-top: 1px solid var(--line-2); }
.b2b-copy { margin-top: 16px; }
.b2b-none { margin-top: 6px; max-width: 64ch; color: var(--muted); font-size: 14px; }
.more-body > .b2b-rows { background: none; border: 0; border-radius: 0; }

/* ---- one submission: status headline (the bold place) -------------------------------------------- */
.b2b-head { margin-bottom: 18px; }
.b2b-now { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 4px 16px; align-items: start; padding: 22px 24px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
.b2b-now-ico { display: grid; place-items: center; height: 28px; color: var(--muted); }
.b2b-now-ico svg.lucide { width: 26px; height: 26px; }
.b2b-now-body { min-width: 0; display: grid; gap: 6px; color: var(--ink); }
.b2b-now-body h2 { font-size: 21px; line-height: 1.3; font-weight: 700; text-wrap: balance; }
.b2b-now-body > p { max-width: 72ch; color: var(--ink-2); font-size: 14.5px; }
.b2b-now-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.b2b-now-acts .btn { min-height: 42px; }
.b2b-irrev { margin-left: 2px; padding: 0 6px; color: var(--ink-2); border: 1px solid var(--field); border-radius: 3px; font-size: 12px; font-weight: 600; }
.b2b-clock { display: grid; justify-items: end; align-content: start; gap: 2px; min-width: 150px; padding-left: 22px; border-left: 1px solid var(--line); text-align: right; }
.b2b-clock b { font-size: 32px; line-height: 1.1; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.b2b-clock span { color: var(--muted); font-size: 12.5px; }
.b2b-now .b2b-clock b { color: var(--ink); }
.b2b-now.tone-amber .b2b-now-ico { color: var(--amber); }
.b2b-now.tone-blue .b2b-now-ico { color: var(--blue); }
.b2b-now.tone-blue .b2b-now-ico svg.lucide { animation: spin 1.6s linear infinite; }
.b2b-now.tone-red .b2b-now-ico { color: var(--red); }
.b2b-now .btn-ghost:hover { background: var(--paper); }
.b2b-now-acts > .btn-quiet-red:first-child { margin-left: -14px; }
.b2b-stale { display: flex; gap: 8px; align-items: flex-start; margin-top: 4px; padding: 8px 10px; background: var(--paper); border: 1px solid; border-radius: var(--radius); font-size: 13.5px; }
.b2b-stale svg.lucide { margin-top: 2px; }
.b2b-stale.tone-amber { color: #5e4209; border-color: var(--amber-line); }
.b2b-stale.tone-amber svg.lucide { color: var(--amber); }
.b2b-stale.tone-red { color: #7c2e2a; border-color: var(--red-line); }
.b2b-stale.tone-red svg.lucide { color: var(--red); }

/* ---- track, channels, rows, details -------------------------------------------------------------- */
.b2b-track { margin-top: 24px; }
.b2b-track .flow-step { padding: 16px 22px; }
.b2b-track .flow-title { font-size: 15.5px; }
.b2b-track .is-fail .flow-n { color: var(--red); background: var(--red-soft); border-color: var(--red); }
.b2b-track .flow-meta { display: flex; }
.b2b-track .flow-state > .b2b-run, .b2b-track .flow-state > .mark { flex: none; }
.b2b-run { display: inline-flex; align-items: center; min-height: 24px; padding: 1px 8px; color: var(--ink-2); background: var(--tint); border: 1px solid var(--line); border-radius: 4px; font-size: 13px; }
.b2b-warn { margin: 0 0 10px; color: #5e4209; background: var(--amber-soft); border-color: var(--amber-line); }
.b2b-warn svg.lucide { color: var(--amber); }
.b2b-tbl td:first-child, .b2b-tbl td:nth-child(2) { font-variant-numeric: tabular-nums; white-space: nowrap; }
.b2b-more { margin-top: 24px; }
.b2b-dl { display: grid; gap: 10px; font-size: 13.5px; }
.b2b-dl > div { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 4px 16px; }
.b2b-dl dt { color: var(--muted); font-weight: 600; }
.b2b-dl dd { min-width: 0; overflow-wrap: anywhere; }
.b2b-codes { display: grid; gap: 2px; }
.b2b-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-top: 16px; }
.b2b-foot .info-line { margin-top: 0; }

.b2b-ch { display: grid; grid-template-columns: minmax(0, 1fr) auto; margin: 0; font-size: 14px; }
.b2b-ch li { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; gap: 12px; padding: 7px 0; }
.b2b-ch li + li { border-top: 1px solid var(--line-2); }
.b2b-ch .muted { text-align: right; }

/* ---- dialog parts ------------------------------------------------------------------------------- */
.b2b-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 10px; padding: 12px 14px; background: var(--tint); border: 1px solid var(--line); border-radius: var(--radius); }
.b2b-pair > div { display: grid; gap: 2px; }
.b2b-pair span { color: var(--muted); font-size: 12px; font-weight: 600; }
.b2b-pair b { font-size: 17px; font-variant-numeric: tabular-nums; }
.b2b-pair > svg.lucide { color: var(--muted); }
.b2b-dlg-sec h3 { margin-bottom: 6px; font-size: 14px; font-weight: 650; }
.b2b-list { display: grid; gap: 4px; padding-left: 18px; list-style: disc; color: var(--ink-2); font-size: 14px; }
.b2b-ack { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; color: #5e4209; background: var(--amber-soft); border: 1px solid var(--amber-line); border-radius: var(--radius); font-size: 14px; font-weight: 600; cursor: pointer; }
.b2b-ack input { width: 20px; height: 20px; flex: none; margin: 0; accent-color: var(--graphite); }

/* The status panel above the rows is one compact block: the next action first, the rest in the disclosure. */
.b2b-status { margin: 0 0 14px; }
.b2b-status .b2b-now { grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 4px 16px; padding: 12px 16px; border-radius: 8px 8px 0 0; }
.b2b-status .b2b-now-ico svg.lucide { width: 22px; height: 22px; }
.b2b-status .b2b-now-body { gap: 2px; }
.b2b-status .b2b-now-body h2 { font-size: 17px; }
.b2b-status .b2b-now-body > p { font-size: 13.5px; }
.b2b-now-side { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 20px; }
.b2b-status .b2b-clock { min-width: 0; padding-left: 20px; }
.b2b-status .b2b-clock b { font-size: 22px; }
.b2b-status .b2b-now-acts { margin: 0; }
.b2b-status .b2b-now-acts .btn { min-height: 40px; }
.b2b-status .b2b-steps { margin-top: -1px; border-radius: 0 0 8px 8px; }
.b2b-status .b2b-steps:not([open]) { display: none; }
.b2b-status:has(.b2b-steps[open]) .b2b-now { border-radius: 8px 8px 0 0; }
.b2b-more-btn { justify-self: start; display: inline-flex; align-items: center; gap: 2px; min-height: 24px; padding: 0; color: var(--ink-2); background: none; border: 0; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
@media (min-width: 769px) {
  .b2b-status .b2b-now-body { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; }
  .b2b-status .b2b-now-body > :not(p, .b2b-more-btn) { flex-basis: 100%; }
}
.b2b-more-btn:hover { color: var(--ink); text-decoration: underline; }
.b2b-more-btn[aria-expanded="true"] .more-chev { transform: rotate(90deg); }
.b2b-sum-line { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin: 0 0 8px; color: var(--ink); font-size: 13px; }
.b2b-sum-line .mark { min-height: 22px; font-size: 12px; }
.b2b-sum-by { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.b2b-row-meta + .b2b-row-meta { margin-top: 0; }
.b2b-imp-sub { display: block; font-size: 12.5px; }
.b2b-status .b2b-foot { margin: 0 0 8px; }
.b2b-status .b2b-foot .info-line { margin: 0; }
.b2b-noapp, .b2b-blocked { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; background: var(--paper); border: 1px solid var(--amber-line); border-radius: var(--radius); color: #5e4209; font-size: 13.5px; }
.b2b-blocked { border-color: var(--red-line); color: #7c2e2a; }
.b2b-noapp svg.lucide, .b2b-blocked svg.lucide { flex: none; margin-top: 2px; color: var(--amber); }
.b2b-blocked svg.lucide { color: var(--red); }
.b2b-blocked ul { display: grid; gap: 2px; margin: 4px 0 0; padding-left: 16px; list-style: disc; }
.b2b-impact-wrap { display: grid; gap: 8px; }
.b2b-impact { display: grid; max-height: 232px; margin: 0; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); font-size: 13.5px; }
.b2b-impact li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; padding: 8px 12px; }
.b2b-impact li + li { border-top: 1px solid var(--line-2); }
.b2b-imp-name { min-width: 0; overflow-wrap: anywhere; }
.b2b-imp-tail { display: inline-flex; align-items: center; gap: 8px; }
.b2b-dlg .dlg-body > .b2b-dlg-sec { overflow-wrap: anywhere; }
@media (max-width: 768px) {
  .b2b-status .b2b-now { padding: 14px; }
  .b2b-status .b2b-now-side { grid-column: 1 / -1; justify-content: stretch; }
  .b2b-status .b2b-now-ico { display: none; }
  .b2b-status .b2b-now { grid-template-columns: minmax(0, 1fr); }
  .b2b-status .b2b-clock { display: flex; align-items: baseline; gap: 8px; padding-left: 0; border-left: 0; text-align: left; }
  .b2b-status .b2b-clock b { font-size: 17px; }
  .b2b-status .b2b-now-acts { width: 100%; }
  .b2b-status .b2b-now-acts .btn { width: 100%; min-height: 44px; }
  .b2b-more-btn { min-height: 44px; }
}
@media (max-width: 1279px) {
  .b2b-row { grid-template-columns: 244px minmax(0, 1fr) 16px; }
  .b2b-row-next { grid-column: 2; grid-row: 2; }
  .b2b-row-chev { grid-column: 3; grid-row: 1 / span 2; }
}
@media (max-width: 767px) {
  .b2b-row { grid-template-columns: minmax(0, 1fr) 16px; gap: 6px 10px; padding: 12px 14px; }
  .b2b-row-mark, .b2b-row-what, .b2b-row-next { grid-column: 1; grid-row: auto; }
  .b2b-row-chev { grid-column: 2; grid-row: 1 / span 3; }
  .b2b-row-what strong { white-space: normal; }
  .b2b-now { grid-template-columns: 26px minmax(0, 1fr); gap: 10px 12px; padding: 16px; }
  .b2b-now-body { grid-column: 2; grid-row: 1; }
  .b2b-now:has(.b2b-clock) .b2b-now-body { grid-column: 1 / -1; grid-row: 2; }
  .b2b-now-acts > .btn-quiet-red:first-child { margin-left: 0; }
  .b2b-tbl tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2px 12px; }
  .b2b-tbl td[data-label="Состояние"], .b2b-tbl td[data-label="Причина"] { grid-column: 1 / -1; }
  .b2b-tbl td[data-label="Состояние"]::before { display: none; }
  .b2b-tbl td[data-label="Причина"]:has(> .muted:only-child) { display: none; }
  .b2b-now-body h2 { font-size: 18px; }
  .b2b-clock { grid-column: 2; grid-row: 1; justify-items: start; align-self: center; min-width: 0; padding-left: 0; border-left: 0; text-align: left; }
  .b2b-clock b { font-size: 24px; }
  .b2b-now-acts .btn { width: 100%; min-height: 44px; white-space: normal; }
  .b2b-track .flow-step { padding: 14px; }
  .b2b-dl > div { grid-template-columns: 1fr; }
  .b2b-foot .btn { width: 100%; }
  .b2b-pair { grid-template-columns: 1fr; }
  .b2b-pair > svg.lucide { transform: rotate(90deg); }
}
@media (prefers-reduced-motion: reduce) {
  .b2b-now.tone-blue .b2b-now-ico svg.lucide { animation: none; }
}
@media (forced-colors: active) {
  .b2b-now, .b2b-rows, .b2b-ack { border: 1px solid CanvasText; }
}

/* Step track and the dialog: neutral steps (the accent is the send button only); a failed step stays red with its icon and word. */
.b2b-track .is-now .flow-n { color: #fff; background: var(--graphite); border-color: var(--graphite); box-shadow: none; }
.b2b-track .is-done .flow-n { color: var(--ink); background: var(--paper); border-color: var(--ink-2); }
.b2b-track .flow-step.is-done:not(:last-child) .flow-rail::after { background: var(--ink-2); }
.b2b-track .chip-now { color: var(--ink); background: var(--tint); border-color: var(--field); }
.b2b-act-notes { flex: 1 1 100%; display: grid; gap: 8px; }
.b2b-act-notes:empty, .b2b-act-notes > [hidden] { display: none; }
.b2b-need { color: var(--ink-2); font-size: 13.5px; font-weight: 600; }
.b2b-act-notes .form-error { margin: 0; }
