/* ---------- 4. Flow (ผังของผู้ใช้ จัดใหม่) ---------- */
.legend{display:flex;gap:12px;align-items:center;flex-wrap:wrap;justify-content:flex-end;font-size:12.5px;color:var(--slate);flex:1;max-width:1150px}
#s4 .sh>div:first-child{flex:none}
#s4 .sh h1{font-size:32px}
#s4 .sh p{font-size:16px}
#s4 .sh{margin-bottom:14px}
.legend span{display:inline-flex;align-items:center;gap:5px}
.legend .sw{width:22px;height:14px;border-radius:4px;display:inline-block;border:1.5px solid transparent}
.legend .sw.main{background:var(--white);border-color:var(--navy)}
.legend .sw.mps{background:var(--navy)}
.legend .sw.sap{background:var(--sky)}
.legend .sw.ai{background:#EDE6FF;border-color:#D6C8FF}
.legend .sw.sub{background:#EEF1F5;border-color:var(--line)}
.legend .dot{width:11px;height:11px;border-radius:50%;display:inline-block;border:1.5px solid var(--white);box-shadow:0 0 0 1px var(--line)}
.legend .dot.proc{background:#7CC4FF}.legend .dot.it{background:#FFD166}.legend .dot.ext{background:#B7C2D0}
.legend .ln{width:24px;height:0;display:inline-block;border-top:2.5px solid var(--ink)}
.legend .ln.sys{border-color:var(--blue-2);border-top-width:2px}
.legend .ln.data{border-top:2px dashed #D98C20}
.legend .ln.planned{border-top:2px dashed #DA2F2F}
.legend .ln.auto{border-color:#0EB70B}
.legend .ai-ico{color:var(--violet);width:15px;height:15px}
.flowwrap{position:relative}
#flowsvg{width:100%;height:100%;display:block}
#flowsvg .n{transform-box:fill-box;transform-origin:center;transition:transform .15s}
#flowsvg .n.clickable{cursor:pointer}
#flowsvg .n.clickable:hover{transform:scale(1.07)}
#flowsvg .n rect{stroke-width:1.5}
#flowsvg .k-main rect{fill:var(--white);stroke:var(--navy);stroke-width:2.5}
#flowsvg .k-main.k-core rect{stroke-width:3;filter:drop-shadow(0 3px 6px rgba(23,54,93,.28))}
#flowsvg .k-main.k-core{filter:none}
#flowsvg .k-main.k-core .nb{border-top:5px solid var(--blue-2);background:var(--white)}
#flowsvg .n .nb{border-radius:inherit}
#flowsvg .step-toggle{cursor:pointer}
#flowsvg .step-toggle circle{fill:var(--navy);stroke:#fff;stroke-width:1.5}
#flowsvg .step-toggle text{fill:#fff;font-family:var(--font);font-size:12px;font-weight:700;text-anchor:middle;dominant-baseline:central;pointer-events:none}
#flowsvg .step-info circle{fill:var(--sky-2);stroke:var(--navy);stroke-width:1.2}
#flowsvg .step-info text{fill:var(--navy);font-family:var(--font);font-size:11px;font-weight:700;text-anchor:middle;dominant-baseline:central;pointer-events:none;font-style:italic}
#flowsvg .lane-bg{pointer-events:none}
#flowsvg .lane-label{font-family:var(--font);font-weight:700;fill:var(--navy);opacity:.55;pointer-events:none}
#flowsvg .lane-label tspan{font-weight:400;opacity:.8}
body.editing #flowsvg .ephandle{fill:#fff;stroke:var(--amber);stroke-width:2;cursor:crosshair}
body.editing #flowsvg .viahandle{fill:var(--amber);stroke:#fff;stroke-width:1.5;cursor:move}
body.editing #flowsvg .addhandle{fill:#fff;stroke:var(--slate);stroke-width:1.3;stroke-dasharray:2 2;cursor:copy;opacity:.65}
body.editing #flowsvg .addhandle:hover{opacity:1;stroke:var(--amber)}
body.editing #flowsvg .n.drop-target rect{stroke:var(--green)!important;stroke-width:3.5!important}
#flowsvg .n.k-collapsed rect{stroke-dasharray:5 4}
#flowsvg .step-toggle circle{opacity:.9}
#flowsvg .k-mps rect{fill:var(--navy);stroke:#345B8A}
#flowsvg .k-sap rect{fill:#DCE8FA;stroke:#9DBAE8}
#flowsvg .k-ai rect{fill:#EDE6FF;stroke:#C9B8FF}
#flowsvg .k-sub rect{fill:#EEF1F5;stroke:#C9D3E0}
#flowsvg .k-fw rect{fill:#E4EAF5;stroke:#9DBAE8}
#flowsvg .k-planned rect{stroke-dasharray:6 4;stroke:#DA2F2F}
#flowsvg .e-proc{stroke:var(--ink);stroke-width:2.6}
#flowsvg .e-sys{stroke:var(--blue-2);stroke-width:2}
#flowsvg .e-data{stroke:#D98C20;stroke-width:2.2;stroke-dasharray:8 6}
#flowsvg .e-planned{stroke:#DA2F2F;stroke-width:2;stroke-dasharray:6 5}
#flowsvg .e-auto{stroke:#0EB70B;stroke-width:2.6}
#flowsvg .e{fill:none;stroke-linejoin:round;stroke-linecap:round}
#flowsvg .lbl-bg{fill:var(--white);stroke:var(--line);rx:7}
#flowsvg .lbl{font-family:var(--font);font-size:13px;font-weight:600}
#flowsvg .lbl.data{fill:#9A4804}#flowsvg .lbl.auto{fill:#0B6B2A}#flowsvg .lbl.sys{fill:var(--navy)}
.nb{width:100%;height:100%;display:flex;align-items:center;justify-content:center;gap:6px;flex-wrap:wrap;padding:3px 8px;text-align:center;box-sizing:border-box;font-family:var(--font);line-height:1.15;overflow:hidden}
.nb .nt{font-weight:600;font-size:15px;color:var(--white)}
.nb .ntag{font-size:10.5px;font-weight:600;letter-spacing:.03em;padding:1px 6px;border-radius:5px;background:rgba(255,255,255,.18);color:var(--white)}
.k-main .nb .nt{font-size:17px;color:var(--navy)}
.k-sap .nb .nt,.k-fw .nb .nt{color:var(--navy);font-size:14.5px}
.k-sap .nb .ntag,.k-fw .nb .ntag{background:rgba(23,54,93,.1);color:var(--navy)}
.k-ai .nb .nt{color:#4C2CB3;font-size:14.5px}
.k-ai .nb .ntag{background:rgba(76,44,179,.12);color:#4C2CB3}
.k-sub .nb .nt{color:var(--ink);font-weight:500;font-size:14px}

/* ---------- Flow: โหมดแก้ไข / ซูม / ลาก (interaction ของผังเท่านั้น) ---------- */
body.editing #flowsvg .n{cursor:move}
body.editing #flowsvg .n.clickable:hover{transform:none}
body.editing #flowsvg .n rect{stroke-dasharray:4 3}
body.editing #flowsvg .lblg{cursor:move}
#flowsvg .bgcatch{cursor:grab}
#flowsvg.dragging .bgcatch{cursor:grabbing}
.zoomctl{position:absolute;right:56px;bottom:74px;z-index:6;display:none;align-items:center;gap:6px;background:var(--white);border:1.5px solid var(--line);border-radius:999px;padding:5px 8px 5px 12px;box-shadow:0 6px 16px rgba(23,54,93,.1);font-size:12.5px;color:var(--slate)}
#s4.on ~ .zoomctl{display:flex}
.zoomctl button{width:30px;height:30px;border-radius:50%;background:var(--sky-2);color:var(--navy);display:grid;place-items:center;font-size:18px;font-weight:600;line-height:1}
.zoomctl button:hover{background:var(--sky)}
.zoomctl .zl{min-width:44px;text-align:center;font-weight:600;color:var(--navy)}
