/* Каркас учёта «участок → функция → этап» (docs/FLOW.md): экран функции и обзор участков (web/flowpage.js).
   Отдельный файл: общие правила app.css он не переписывает. Цвета — только из переменных app.css (обе темы): тона
   статусов и основания — токены --st-* и --bs-* раздела 16 app.css.
   Вид — подветки дизайна (docs/FLOW-UI.md): статус передаётся рисунком, словом и цветом вместе; основание — формой
   знака (пустой пунктирный круг / залитый круг с галочкой); этапы — шаги в ряд, между ними линия; на узком экране ряд
   прокручивается внутри своего блока, страницу вбок не растягивает. Строки рассчитаны на текст длиннее на треть. */

/* ——— статус операции ——— */
.flow-status { position: relative; display: inline-flex; align-items: center; gap: 5px; min-height: 22px; font-size: 13px; font-weight: 500; line-height: 1.2;
  color: var(--st-tone, var(--text-2)); white-space: nowrap; vertical-align: middle; }
.flow-status .icon { flex: none; }
.flow-status[data-status="draft"] { --st-tone: var(--st-draft); --st-tint: var(--st-draft-tint); }
.flow-status[data-status="approval"] { --st-tone: var(--st-approval); --st-tint: var(--st-approval-tint); }
.flow-status[data-status="rejected"] { --st-tone: var(--st-rejected); --st-tint: var(--st-rejected-tint); }
.flow-status[data-status="silent"] { --st-tone: var(--st-silent); --st-tint: var(--st-silent-tint); }
.flow-status[data-status="posted"] { --st-tone: var(--st-posted); --st-tint: var(--st-posted-tint); }
.flow-status[data-status="none"], .flow-status[data-status="cancelled"] { --st-tone: var(--text-3); font-weight: 400; }
.flow-auto { display: inline-flex; color: var(--link); }
/* в карточке операции статус — на подложке своего тона */
.flow-item .tags-row .flow-status { min-height: 26px; padding: 2px 10px; border-radius: 99px; background: var(--st-tint, var(--surface-2)); font-size: 12.5px; }

/* ——— основание ——— */
.flow-basis { position: relative; display: inline-flex; align-items: center; gap: 5px; min-height: 22px; font-size: 13px; line-height: 1.2; color: var(--text-2); white-space: nowrap; vertical-align: middle; }
.flow-basis-sign { flex: none; }
.flow-basis[data-basis="none"] .flow-basis-sign { color: var(--bs-none); }
.flow-basis[data-basis="present"] .flow-basis-sign { color: var(--bs-has); }
.flow-item .tags-row .flow-basis { min-height: 26px; padding: 2px 10px 2px 8px; border-radius: 99px; background: var(--surface-2); font-size: 12.5px; }

/* очередь: строка, где ход клиента, отмечена полосой его тона слева */
tr[data-turn="client"] > td:first-child { box-shadow: inset 2px 0 0 var(--st-approval); }

/* ——— полоса этапов: шаги в ряд, между шагами линия, которая тянется на свободное место ——— */
.flow-strip-card { padding: 8px 10px; overflow-x: auto; scrollbar-width: none; }
.flow-strip-card::-webkit-scrollbar { display: none; }
.flow-strip { display: flex; align-items: center; gap: 0; list-style: none; margin: 0; padding: 0; min-width: min-content; }
.flow-stage { position: relative; flex: 1 1 auto; min-width: max-content; display: grid; grid-template-columns: minmax(18px, 1fr) auto auto auto; grid-template-rows: auto auto;
  column-gap: 8px; align-items: center; padding: 4px 0; }
.flow-stage:first-child { flex: 0 0 auto; grid-template-columns: auto auto auto; }
.flow-stage::before { content: ''; grid-column: 1; grid-row: 1 / span 2; height: 1px; background: var(--border-strong); }
.flow-stage:first-child::before { display: none; }
/* номер, название с исполнителем под ним, число операций — по последним колонкам: у первого шага линии нет */
.flow-stage-n { grid-column: -4 / span 1; grid-row: 1 / span 2; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.flow-stage-title { grid-column: -3 / span 1; grid-row: 1; font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; }
.flow-stage-who { grid-column: -3 / span 1; grid-row: 2; display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.flow-stage-who .icon { flex: none; }
.flow-stage[data-autonomy="auto"] .flow-stage-who .icon { color: var(--link); }
.flow-stage[data-autonomy="human"] .flow-stage-who { color: var(--text-2); font-weight: 500; }
.flow-stage-count { grid-column: -2 / span 1; grid-row: 1 / span 2; min-width: 24px; height: 24px; box-sizing: border-box; padding: 0 8px; border: 0; border-radius: 99px;
  font: inherit; font-size: 12px; font-weight: 600; line-height: 24px; cursor: pointer; background: var(--warn-tint); color: var(--warn-text); font-variant-numeric: tabular-nums; }
.flow-stage-count:hover { box-shadow: inset 0 0 0 1px currentColor; }
.flow-stage-count:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.flow-stage[data-busy] .flow-stage-n { background: var(--warn-tint); color: var(--warn-text); }
/* этап, по которому отобрана очередь: номер — акцентом, под шагом черта акцента; число — тёмная плашка, как выбранная вкладка */
.flow-stage[data-current] .flow-stage-n { background: var(--brand); color: #fff; }
.flow-stage[data-current] .flow-stage-title { color: var(--accent-fg); font-weight: 600; }
.flow-stage[data-current]::after { content: ''; grid-column: -4 / -1; grid-row: 2; align-self: end; height: 2px; margin-bottom: -4px; border-radius: 2px; background: var(--brand); }
.flow-stage[data-current] .flow-stage-count { background: var(--ink-pill); color: var(--on-ink-pill, #fff); }

/* ——— карточка операции ——— */
.flow-item-title { font-size: 16px; font-weight: 600; margin: 0 0 8px; overflow-wrap: anywhere; }
.flow-item .tags-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.flow-actions { justify-content: flex-start; flex-wrap: wrap; margin: 0 0 4px; }
.flow-refs { margin: 0; padding-left: 18px; }
.flow-basis-form { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: center; }
.flow-basis-form input { flex: 1 1 180px; min-width: 0; }
.flow-item textarea, .modal-panel textarea { width: 100%; }

/* ——— обзор участков ——— */
.flow-areas { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--gap); }
.flow-areas > .card { margin-top: 0; padding: var(--pad) 14px; }
.flow-area-title { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.flow-area-title .icon { flex: none; color: var(--brand); }
.flow-fns { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.flow-fn { display: flex; align-items: center; gap: 6px; min-height: 28px; }
.flow-fn > a:first-child, .flow-fn > span:first-child { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
.flow-fn[data-state="planned"] > span:first-child { color: var(--text-2); }
.flow-fn-mark { font-size: 12px; color: var(--text-2); }
.flow-fn .badge { flex: none; }
.flow-fn-steps { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 6px; color: var(--text-3); flex: none; }
.flow-fn-steps:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.flow-fn-steps:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

@media (max-width: 640px) {
  .flow-areas { grid-template-columns: 1fr; }
}
