/* Sơ đồ quy trình (#/flow) – bố cục theo cột giai đoạn, mũi tên SVG phủ lên lưới khối. */
.flow-page, .flow-panel { --flow-blue: #1f6fd6; --flow-blue-2: #3d8bf0; --flow-lane: #eef5ff; --flow-line: #6d9de0; --flow-alt: #e07a1f; display: grid; gap: 14px; min-width: 0; }
.flow-page.is-loading .flow-board { opacity: .6; transition: opacity .15s; }
.flow-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.flow-head h1 { margin: 2px 0 4px; }
.flow-tools { display: flex; align-items: center; gap: 10px; }

.flow-board { --flow-cols: 6; --flow-gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; box-shadow: var(--shadow); }
.flow-board > * { min-width: 940px; }
.flow-stages { display: grid; grid-template-columns: repeat(var(--flow-cols), minmax(0, 1fr)); gap: var(--flow-gap); padding: 10px 12px; background: linear-gradient(120deg, #1757b8, #2f80ed); }
.flow-stage { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border-radius: 10px; color: #fff; font-weight: 700; font-size: var(--text-small); text-align: center; background: rgba(255,255,255,.12); }
.flow-stage:nth-child(even) { background: rgba(255,255,255,.22); }
.flow-stage { border: 0; font: inherit; font-weight: 700; cursor: pointer; transition: background .15s, box-shadow .15s; }
.flow-stage:hover, .flow-stage:focus-visible { background: rgba(255,255,255,.34); outline: none; }
.flow-stage.is-open { background: #fff; color: #1757b8; box-shadow: 0 2px 8px #0f1d3333; }
.flow-stage.is-open .flow-icon { stroke: #1757b8; }
.flow-stage-card { display: grid; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.flow-stage-card p { margin: 0; }
.flow-stage .flow-icon { width: 26px; height: 26px; stroke: #fff; }

.flow-grid { position: relative; display: grid; grid-template-columns: repeat(var(--flow-cols), minmax(0, 1fr)); grid-template-rows: repeat(var(--flow-rows, 3), 176px); column-gap: var(--flow-gap);
  padding: 26px 12px 44px; }
.flow-lane { position: relative; z-index: 0; margin: -26px calc(var(--flow-gap) / -2) -44px; border-radius: 0; }
.flow-lane.alt { background: rgba(47,128,237,.05); }
.flow-lines { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; stroke-width: 1.6; }
.flow-edge { fill: none; stroke: var(--flow-line); stroke-width: 1.6; stroke-dasharray: 5 4; }
.flow-edge.alt { stroke: var(--flow-alt); }
.flow-tip { stroke: none; } .flow-tip.main { fill: var(--flow-line); } .flow-tip.alt { fill: var(--flow-alt); }
.flow-edge-label { font-size: var(--text-caption); font-weight: 600; fill: #3b5b8c; paint-order: stroke; stroke: #fff; stroke-width: 4px; stroke-linejoin: round; }
.flow-edge-label.alt { fill: #b85c0a; }

.flow-node { position: relative; z-index: 2; justify-self: center; align-self: start; display: flex; flex-direction: column; align-items: center; gap: 8px; width: 150px; height: 150px; overflow: hidden;
  padding: 8px 6px 10px; border: 0; border-radius: 14px; background: transparent; color: var(--ink); font: inherit; cursor: pointer; text-align: center; }
.flow-dot { transition: box-shadow .15s, transform .15s; }
.flow-node:focus-visible { outline: none; }
/* Rê chuột / đang mở: chỉ đổi vòng tròn và màu chữ, không phủ nền lên mũi tên và nhãn bên cạnh. */
.flow-node:hover .flow-dot, .flow-node:focus-visible .flow-dot { box-shadow: 0 0 0 6px #b9d4fa, 0 8px 18px #1f6fd659; transform: translateY(-1px); }
.flow-node.is-open .flow-dot { box-shadow: 0 0 0 6px var(--flow-blue), 0 8px 18px #1f6fd659; }
.flow-node:hover .flow-node-title, .flow-node.is-open .flow-node-title { color: var(--flow-blue); }
.flow-dot { position: relative; display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--flow-blue-2), var(--flow-blue)); box-shadow: 0 0 0 6px #dbe9fc, 0 6px 14px #1f6fd640; flex: none; }
.flow-dot .flow-icon { width: 28px; height: 28px; stroke: #fff; }
.flow-dot.small { width: 42px; height: 42px; box-shadow: 0 0 0 4px #dbe9fc; } .flow-dot.small .flow-icon { width: 22px; height: 22px; }
.flow-count { position: absolute; top: -6px; right: -10px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: #64748b; color: #fff; font-size: var(--text-caption); font-weight: 700; line-height: 24px; box-shadow: 0 0 0 2px #fff; }
.flow-node.tone-danger .flow-count { background: #d92d20; } .flow-node.tone-warn .flow-count { background: #e07a1f; } .flow-node.tone-ok .flow-count { background: #12805c; }
.flow-node-body { display: grid; gap: 2px; }
.flow-node-title { font-weight: 700; font-size: var(--text-label); color: var(--brand-navy); line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.flow-node-sub { font-size: var(--text-caption); color: var(--muted); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.flow-node-shortcut { text-decoration: none; }
.flow-node-pair { display: contents; }
@media screen and (min-width:851px) {
 .flow-node-pair { display:flex; gap:4px; width:100%; max-width:300px; min-width:0; justify-self:center; align-self:start; }
 .flow-node-pair .flow-node { flex:1; width:0; min-width:0; }
 .flow-node-pair .flow-dot { width:48px; height:48px; }
 .flow-node-pair .flow-node-title { font-size:var(--text-caption); }
 .flow-node-pair .flow-node-sub { -webkit-line-clamp:3; }
}
.flow-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.flow-legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0; }
.flow-key { display: inline-block; width: 28px; border-top: 2px dashed var(--flow-line); vertical-align: middle; }
.flow-key.alt { border-color: var(--flow-alt); }

/* Bảng chi tiết */
.flow-shade { position: fixed; inset: 0; z-index: 70; background: #0f1d3338; }
.flow-panel { position: fixed; z-index: 71; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); display: flex; flex-direction: column; gap: 12px; padding: 18px 18px 16px;
  background: var(--surface); box-shadow: var(--shadow-lg); overflow-y: auto; animation: flow-in .18s ease-out; }
@keyframes flow-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.flow-panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.flow-panel-title { display: flex; align-items: center; gap: 14px; }
.flow-panel-title h2 { margin: 2px 0 0; font-size: var(--text-heading); }
.flow-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.flow-stat { display: grid; gap: 2px; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font: inherit; color: var(--ink); cursor: pointer; }
.flow-stat:hover { border-color: var(--line-strong); }
.flow-stat strong { font-size: var(--text-heading); line-height: 1.2; }
.flow-stat small { color: var(--muted); font-size: var(--text-caption); }
.flow-stat.tone-danger strong { color: #c02218; } .flow-stat.tone-warn strong { color: var(--amber); } .flow-stat.tone-ok strong { color: var(--green); }
.flow-list-head { margin: 4px 0 0; font-size: var(--text-label); }
.flow-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.flow-item { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.flow-item-main { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; width: 100%; padding: 10px 12px; border: 0; background: none; font: inherit; color: var(--ink); text-align: left; cursor: pointer; }
.flow-item-main:hover { background: var(--surface-2); }
.flow-item-main b { grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-item-main small { grid-column: 1; color: var(--muted); font-size: var(--text-caption); }
.flow-badge { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: var(--text-caption); font-weight: 700; padding: 3px 8px; border-radius: 99px; background: #eef2f7; color: var(--muted); white-space: nowrap; }
.flow-badge.tone-danger { background: #fdecea; color: #b42318; } .flow-badge.tone-warn { background: var(--amber-50); color: var(--amber); } .flow-badge.tone-ok { background: var(--green-50); color: var(--green); }
.flow-item-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px; }
.flow-item-actions .btn { padding: 5px 12px; font-size: var(--text-caption); }
.flow-panel-foot { position: sticky; bottom: -16px; margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 0 2px; background: var(--surface); border-top: 1px solid var(--line); }

/* Mobile: stage shortcuts and readable cards; no desktop-width canvas or crossed arrows. */
.flow-mobile-hint { display:none; }
@media screen and (max-width:850px) {
 .flow-head { align-items:stretch; }
 .flow-head h1 { font-size:22px; }
 .flow-head p { display:none; }
 .flow-head > div,.flow-tools { min-width:0; }
 .flow-head .flow-tools { width:100%;justify-content:space-between;flex-wrap:wrap; }
 .flow-mobile-hint { display:block;margin:0; }
 .flow-legend { display:none; }
 .flow-board { overflow:visible; }
 .flow-board > * { min-width:0; }
 .flow-stages { grid-template-columns:repeat(3,minmax(0,1fr));padding:10px;gap:8px;border-radius:13px 13px 0 0; }
 .flow-stage { min-width:0;min-height:72px;font-size:12px;overflow-wrap:anywhere; }
 .flow-stage .flow-icon { width:22px;height:22px; }
 .flow-stage:hover,.flow-stage:focus-visible { background:#fff;color:#1757b8; }
 .flow-stage:hover .flow-icon,.flow-stage:focus-visible .flow-icon { stroke:#1757b8; }
 .flow-grid { grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:none;gap:10px;padding:14px 10px; }
 .flow-lane,.flow-lines { display:none; }
 .flow-node { grid-column:auto!important;grid-row:auto!important;width:100%;height:auto;min-height:168px;justify-self:stretch;gap:10px;padding:12px 8px;border:1px solid var(--line);background:var(--surface);overflow:visible; }
 .flow-node::before { content:attr(data-stage-title);font-size:11px;line-height:1.3;color:var(--muted); }
 .flow-dot { width:48px;height:48px; }
 .flow-dot .flow-icon { width:24px;height:24px; }
 .flow-node-body { min-width:0;gap:5px; }
 .flow-node-title,.flow-node-sub { display:block;overflow:visible;overflow-wrap:anywhere;-webkit-line-clamp:unset; }
 .flow-node-title { font-size:14px; }
 .flow-node-sub { font-size:12px; }
 .flow-panel { width:100%;max-width:100vw;height:100dvh;box-sizing:border-box;padding:16px 16px calc(16px + env(safe-area-inset-bottom));overscroll-behavior:contain; }
 .flow-panel-head { flex-shrink:0; }
 .flow-panel-title { min-width:0; }
 .flow-panel-title > div { min-width:0; }
 .flow-panel-title h2 { overflow-wrap:anywhere; }
 .flow-panel-close { flex:none;min-width:44px;min-height:44px; }
 .flow-item-main { grid-template-columns:minmax(0,1fr) auto; }
 .flow-item-main small { min-width:0;overflow-wrap:anywhere; }
 .flow-panel-foot { bottom:calc(-16px - env(safe-area-inset-bottom));padding-bottom:calc(12px + env(safe-area-inset-bottom)); }
}
