:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #1c2230; --muted: #667085; --line: #e4e7ec;
  --accent: #2554c7; --accent-soft: #eaf0ff; --ok: #12805c; --ok-soft: #e6f6ef;
  --warn: #b54708; --warn-soft: #fef3e6; --bad: #c0362c; --bad-soft: #fdecea; --side: #111827; --side-ink: #d0d5dd;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1117; --panel: #161b22; --ink: #e6e8eb; --muted: #98a2b3; --line: #2a313c;
    --accent: #7ea2ff; --accent-soft: #1d2740; --ok: #4ccf9b; --ok-soft: #12261f; --warn: #f0a35e; --warn-soft: #2b1f12;
    --bad: #ff8076; --bad-soft: #2d1614; --side: #0a0d12; --side-ink: #b8c0cc; --shadow: none; }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", "Rubik", "Assistant", Arial, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); padding: 28px; border-radius: 14px; box-shadow: var(--shadow); width: min(360px, 100%); display: grid; gap: 14px; border: 1px solid var(--line); }
.brand-big { font-size: 22px; font-weight: 700; }
label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
input { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); }
.btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.error { color: var(--bad); font-size: 14px; }

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: #fff; padding: 4px 8px 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #4ccf9b; }
.side nav { display: grid; gap: 2px; flex: 1; }
.side nav a { color: var(--side-ink); padding: 7px 10px; border-radius: 7px; }
.side nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.side nav a.active { background: rgba(126,162,255,.18); color: #fff; }
.nav-h { font-size: 12px; opacity: .6; padding: 12px 10px 4px; }
.side-foot { font-size: 13px; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.side-foot a { color: var(--side-ink); }

main { min-width: 0; }
.top { display: flex; gap: 12px; align-items: center; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.menu-btn { display: none; font-size: 20px; background: none; border: 0; color: var(--ink); cursor: pointer; }
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; }
.search-results { position: absolute; top: 44px; inset-inline: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto; }
.search-results a { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; color: var(--ink); border-bottom: 1px solid var(--line); }
.search-results a:hover { background: var(--accent-soft); text-decoration: none; }
.badge { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.readonly { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.gray { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

.view { padding: 24px; max-width: 1200px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.grid { display: grid; gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); color: var(--ink); }
.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile .n { font-size: 26px; font-weight: 700; }
.tile .l { color: var(--muted); font-size: 13px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: start; color: var(--muted); font-weight: 600; font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--accent-soft); }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters .btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.list-links { display: grid; gap: 6px; }
.list-links .row { display: flex; gap: 8px; align-items: baseline; }
.empty { color: var(--muted); font-size: 14px; }
.warn-list { font-size: 13px; color: var(--warn); margin: 0; padding-inline-start: 18px; }

.state { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.state::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.state.open { color: var(--ok); } .state.blocked { color: var(--bad); } .state.off { color: var(--muted); }

.tree { list-style: none; margin: 0; padding-inline-start: 18px; border-inline-start: 2px solid var(--line); }
.tree > li { margin: 6px 0; position: relative; }
.node { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.node .key { background: var(--accent); color: #fff; border-radius: 6px; padding: 1px 7px; font-weight: 700; font-size: 13px; }
.node .kind { font-size: 12px; color: var(--muted); }
.node.broken { border-color: var(--bad); }
.toggle { cursor: pointer; user-select: none; color: var(--muted); font-size: 12px; }
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details > summary .toggle::before { content: '◂ '; }
details[open] > summary .toggle::before { content: '▾ '; }
.did-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 8px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 250px; z-index: 20; transform: translateX(100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu-btn { display: block; }
  .view { padding: 16px; }
  .top { padding: 10px 16px; }
  .kv { grid-template-columns: 110px 1fr; }
  .scroll { overflow-x: auto; }
}

.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 16px; align-items: end; }
.form label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); }
select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); max-width: 100%; }
.picker { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.picker select:first-child { min-width: 110px; }
.picker select:last-child { min-width: 200px; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.play { padding: 2px 9px; font-size: 13px; }
.btn.del { padding: 4px 10px; }
.toast { position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(50%); background: var(--ink); color: var(--panel);
  padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow); z-index: 50; font-size: 14px; }
.toast.bad { background: var(--bad); color: #fff; }
a.btn { display: inline-block; }
a.btn:hover { text-decoration: none; }

.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; padding: 20px; width: min(520px, 100%); box-shadow: var(--shadow); border: 1px solid var(--line); }
.modal .form { grid-template-columns: 1fr; }
input[type=time] { width: 110px; }
.cfg { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 12px; overflow: auto; max-height: 260px; text-align: left; }
.modal { max-height: 90vh; overflow: auto; }
.settings-form { width: 100%; border-collapse: collapse; }
.settings-form th { text-align: right; font-weight: 500; padding: 8px 6px; vertical-align: top; width: 55%; }
.settings-form td { padding: 6px; }
.settings-form select, .settings-form input { width: 100%; box-sizing: border-box; }
.small { font-size: 12px; font-weight: 400; }
.modal.wide { width: min(760px, 100%); }
.card.wide { grid-column: 1 / -1; }
.num.wrap { word-break: break-all; }
#sd-rows .sd-label { min-width: 140px; }
#sd-rows .sd-slot { width: 70px; }
.pname { font-size: 12px; color: var(--muted); }
.add-c { font-weight: 700; padding: 0 4px; text-decoration: none; }
.flag-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.flag audio { width: 100%; margin: 6px 0; }
.transcript { white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: 10px; margin: 6px 0; line-height: 1.6; }
.btn.bad { color: var(--bad, #c0392b); }
/* live status */
.bad-text { color: var(--bad); }
#live details { margin-top: 12px; }
#live details > summary { color: var(--accent); font-weight: 600; }
#live details > summary::before { content: '◂ '; }
#live details[open] > summary::before { content: '▾ '; }
#live .tiles { margin: 10px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 13px; text-decoration: none; color: var(--ink); }
.chip:hover { border-color: var(--accent); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.sm { white-space: nowrap; }
.alert { border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; font-weight: 600; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- navigation: collapsible groups ---------- */
.side nav { display: block; }
.nav-group { margin-bottom: 2px; }
.nav-head { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: 0; color: var(--side-ink);
  font: inherit; font-weight: 600; padding: 9px 10px; border-radius: 8px; cursor: pointer; text-align: start; }
.nav-head:hover { background: rgba(255,255,255,.06); }
.nav-head .ico { width: 22px; text-align: center; font-size: 16px; flex: none; }
.nav-head .lbl { flex: 1; }
.nav-head .chev { font-size: 11px; opacity: .7; transition: transform .15s; }
.nav-group.open .nav-head .chev { transform: rotate(-90deg); }
.nav-group.has-active > .nav-head { color: #fff; }
.nav-sub { display: none; padding: 2px 0 6px; margin-inline-start: 20px; border-inline-start: 1px solid rgba(255,255,255,.12); }
.nav-group.open .nav-sub { display: grid; gap: 1px; }
.side .nav-sub a { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 12px; font-size: 14px; }
.nav-new { font-size: 10px; font-weight: 700; background: #4ccf9b; color: #0a2a1d; border-radius: 999px; padding: 1px 7px; }
.nav-count { font-size: 11px; background: rgba(255,255,255,.12); border-radius: 999px; padding: 0 7px; }
.nav-head .nav-new { margin-inline-start: 4px; }

/* ---------- top bar ---------- */
.crumbs { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.crumbs b { color: var(--ink); font-weight: 600; }
.live-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 10px; color: var(--ink); white-space: nowrap; }
.live-pill:hover { text-decoration: none; border-color: var(--accent); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live-pill.on .live-dot { background: #e5484d; box-shadow: 0 0 0 3px rgba(229,72,77,.2); }

/* ---------- where it runs (per page) ---------- */
.where { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: -10px 0 18px; font-size: 13px; }
.where .w { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px; border: 1px solid var(--line); }
.where .w::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.w.live { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.w.old { color: var(--muted); }
.w.after { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.w.plan { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.w.new { color: #0a2a1d; background: #4ccf9b; border-color: transparent; font-weight: 700; }
.w.new::before { display: none; }

/* ---------- capability map ---------- */
.cap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.cap-item { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.cap-item:last-child { border-bottom: 0; }
.cap-item .d { color: var(--muted); font-size: 12px; margin-top: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }

/* ---------- members picker ---------- */
.mp { border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: grid; gap: 8px; background: var(--panel); }
.mp-list { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; }
.mp-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 13px; }
.mp-chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 4px; }
.mp-chip .ord { font-weight: 700; opacity: .7; }
.mp-add { display: flex; gap: 6px; }
.mp-add input { flex: 1; min-width: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks label { display: inline-flex; flex-direction: row; gap: 6px; align-items: center; color: var(--ink); }
.form .full { grid-column: 1 / -1; }
.modal .form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- progress + misc ---------- */
.progress { height: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; display: flex; }
.progress span { display: block; height: 100%; }
.progress .p-ok { background: var(--ok); } .progress .p-bad { background: var(--bad); } .progress .p-run { background: var(--accent); }
.acts { display: flex; flex-wrap: wrap; gap: 6px; }
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.diff pre { margin: 0; }
.pill-state { font-size: 12px; border-radius: 6px; padding: 2px 8px; background: var(--bg); border: 1px solid var(--line); }
.help { background: var(--accent-soft); color: var(--ink); border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 16px; line-height: 1.6; }
.help b { color: var(--accent); }
.dial-link { text-decoration: none; margin-inline-start: 4px; font-size: 13px; }
h3 { font-size: 14px; margin: 14px 0 8px; }
@media (max-width: 860px) {
  .crumbs { display: none; }
  .live-pill { padding: 4px 8px; }
  #dial-btn { padding: 4px 8px; }
  .modal .form .row2 { grid-template-columns: 1fr; }
  .diff { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; }
  .search { order: 5; flex-basis: 100%; max-width: none; }
}
.vm.vm-new { border-inline-start: 4px solid var(--accent); }
.vm audio { width: 100%; margin: 6px 0; }
.tile.on { border-color: var(--accent); background: var(--accent-soft); }
.chart { margin: 0 0 8px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-size: 11px; fill: var(--muted); }
.chart .ytick { font-size: 10px; }
.chart .grid { stroke: var(--line); stroke-dasharray: 3 3; }
.chart .axis { stroke: var(--line); }
.chart .bar:hover rect:first-child { opacity: .75; }

/* outbound routes editor + tester */
.pat-row, .tr-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.pat-row input { flex: 1 1 90px; min-width: 70px; }
.pat-row .p-pat { flex: 3 1 160px; }
.tr-row select { flex: 1; }
.ord { display: inline-flex; gap: 2px; }
.ord .btn.sm { padding: 1px 6px; font-size: 11px; }
ul.steps { list-style: none; padding: 0; margin: 6px 0 0; }
ul.steps li { padding: 3px 0; display: flex; gap: 8px; }
ul.steps li span { width: 1.2em; text-align: center; flex: none; }
ul.steps li.st-ok span { color: var(--ok); }
ul.steps li.st-bad { color: var(--bad); }
ul.steps li.st-warn { color: var(--warn); }
.chip .small { font-size: 11px; }
td audio { height: 32px; max-width: 240px; vertical-align: middle; }

/* caller-ID picker (list + "new number") */
.cidpick { display: grid; gap: 6px; }
.cidpick .cid-new { display: grid; grid-template-columns: 1fr 1.4fr; gap: 6px; }
.cidpick .cid-new[hidden] { display: none; }
@media (max-width: 640px) { .cidpick .cid-new { grid-template-columns: 1fr; } }
.settings-form .cidpick .cid-new { grid-template-columns: 1fr; }
.cidpick select, .cidpick input { min-width: 0; }

/* ================= call-flow canvas (#/flow, static/flow.js) ================= */
.view.fl-view { max-width: none; padding: 0; height: calc(100vh - 59px); height: calc(100dvh - 59px); }
.fl-app { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.fl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.fl-title { display: grid; min-width: 0; }
.fl-title b { font-size: 17px; }
.fl-title span { font-size: 12.5px; }
.fl-search { position: relative; flex: 1 1 220px; max-width: 360px; }
.fl-search input { width: 100%; padding: 7px 11px; }
.fl-res { position: absolute; top: 40px; inset-inline: 0; z-index: 40; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.18); max-height: 55vh; overflow: auto; padding: 4px; }
.fl-res button { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; width: 100%; text-align: right; background: none; border: 0; padding: 7px 9px; border-radius: 7px; color: var(--ink); font: inherit; cursor: pointer; }
.fl-res button small { grid-column: 2; color: var(--muted); font-size: 12px; }
.fl-res button:hover { background: var(--accent-soft); }
.fl-grp { display: flex; flex-wrap: wrap; gap: 6px; margin-inline-start: auto; }
.fl-b { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13.5px; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 6px 11px; border-radius: 8px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.fl-b:hover { border-color: var(--accent); text-decoration: none; }
.fl-b svg { width: 16px; height: 16px; flex: none; }
.fl-b.ico { padding: 6px; min-width: 32px; justify-content: center; }
.fl-b.sm { padding: 3px 8px; font-size: 12.5px; }
.fl-b.ico.sm { padding: 4px; min-width: 26px; }
.fl-b.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.fl-b.danger { color: var(--bad); }
.fl-pill { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 12px; display: inline-grid; place-items: center; }
.fl-pill.warn { background: var(--warn-soft); color: var(--warn); }
.fl-pill.ok { background: var(--ok-soft); color: var(--ok); }
.fl-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 250px 1fr 330px; }
.fl-main.nopal { grid-template-columns: 1fr 330px; }
.fl-main.nopal .fl-pal { display: none; }
.fl-canvas { position: relative; overflow: hidden; direction: ltr; touch-action: none; outline: none;
  background-color: var(--bg); background-image: radial-gradient(color-mix(in srgb, var(--muted) 38%, transparent) 1px, transparent 1.2px); background-size: 22px 22px; }
.fl-canvas.panning { cursor: grabbing; }
.fl-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.fl-wires { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.fl-w { fill: none; stroke: color-mix(in srgb, var(--muted) 70%, transparent); stroke-width: 2; }
.fl-w.dash { stroke-dasharray: 6 5; }
.fl-w.temp { stroke: var(--accent); stroke-dasharray: 5 5; stroke-width: 2.5; }
.fl-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.fl-wg:hover .fl-w, .fl-wg.hot .fl-w { stroke: var(--accent); }
.fl-wg.sel .fl-w { stroke: var(--accent); stroke-width: 3.2; }
.fl-wg.sim .fl-w { stroke: var(--ok); stroke-width: 3.6; }
.fl-wg.dim { opacity: .12; }
.fl-del { cursor: pointer; pointer-events: all; }
.fl-del circle { fill: var(--bad); }
.fl-del path { stroke: #fff; stroke-width: 2; stroke-linecap: round; }
.fl-node { position: absolute; width: 248px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; direction: rtl; cursor: grab; user-select: none;
  box-shadow: 0 1px 2px rgba(16,24,40,.07), 0 6px 16px rgba(16,24,40,.07); font-size: 13.5px; }
.fl-node.dragging { cursor: grabbing; z-index: 3; }
.fl-node.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 8px 22px rgba(16,24,40,.14); z-index: 2; }
.fl-node.sim { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok), 0 0 28px color-mix(in srgb, var(--ok) 45%, transparent); z-index: 2; }
.fl-node.dim { opacity: .18; }
.fl-node.drop { box-shadow: 0 0 0 2.5px var(--accent); }
.fl-node.nodrop { box-shadow: 0 0 0 2.5px var(--bad); }
.fl-nh { display: flex; align-items: center; gap: 9px; padding: 9px 11px 7px; }
.fl-ic { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; flex: none; color: #fff; }
.fl-ic svg { width: 16px; height: 16px; }
.fl-ic.lg { width: 38px; height: 38px; border-radius: 9px; }
.fl-ic.lg svg { width: 20px; height: 20px; }
.fl-nt { min-width: 0; flex: 1; }
.fl-nt small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fl-nt b { display: block; font-size: 14px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fl-warn { flex: none; min-width: 20px; height: 20px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.fl-state { flex: none; font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.fl-state.open { background: var(--ok-soft); color: var(--ok); }
.fl-state.blocked { background: var(--bad-soft); color: var(--bad); }
.fl-sub { padding: 0 11px 8px; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fl-sub .bad, .fl-stub.bad { color: var(--bad); }
.fl-chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 11px 8px; }
.fl-chips span { font-size: 11.5px; padding: 1px 6px; border-radius: 5px; background: var(--bg); border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.fl-pre { margin: 0 11px 8px; padding: 5px 8px; border-radius: 7px; background: var(--warn-soft); color: var(--warn); font-size: 12px; }
.fl-outs { border-top: 1px solid var(--line); padding: 3px 0; }
.fl-out { position: relative; display: flex; align-items: center; gap: 7px; height: 27px; padding: 0 11px 0 16px; }
.fl-out.sys { color: var(--muted); font-size: 12.5px; }
.fl-key { flex: none; min-width: 21px; height: 20px; padding: 0 5px; border-radius: 5px; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.fl-key.edit { cursor: pointer; }
.fl-key.edit:hover { outline: 1.5px solid var(--accent); }
.fl-pl { flex: none; }
.fl-to { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fl-out.sys .fl-to { text-align: left; }
.fl-stub { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-style: italic; font-size: 12.5px; }
.fl-port { position: absolute; width: 13px; height: 13px; border-radius: 50%; background: var(--panel); border: 2.5px solid color-mix(in srgb, var(--muted) 75%, transparent); z-index: 2; }
.fl-port.in { left: -8px; top: 18px; }
.fl-port.o { right: -8px; top: 7px; cursor: crosshair; }
.fl-port.o.on { background: color-mix(in srgb, var(--muted) 75%, transparent); }
.fl-port.o.ro { cursor: default; border-style: dotted; }
.fl-port.o:not(.ro):hover { border-color: var(--accent); background: var(--accent); transform: scale(1.25); }
.fl-scope { position: absolute; top: 10px; inset-inline: 10px; direction: rtl; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px;
  background: color-mix(in srgb, var(--panel) 94%, transparent); border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; box-shadow: 0 4px 14px rgba(16,24,40,.08); font-size: 13.5px; }
.fl-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; }
.fl-crumbs b { font-weight: 700; }
.fl-crumb { background: none; border: 0; padding: 2px 4px; border-radius: 6px; font: inherit; color: var(--accent); cursor: pointer; }
.fl-crumb:hover { background: var(--accent-soft); }
.fl-sep { color: var(--muted); }
.fl-scope-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.fl-scope-acts select { font: inherit; font-size: 12.5px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); max-width: 170px; }
.fl-depth { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); }
.fl-b.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.fl-to.link { color: var(--accent); cursor: pointer; display: inline-flex; align-items: center; gap: 2px; justify-content: flex-start; }
.fl-to.link svg { width: 13px; height: 13px; flex: none; transform: scaleX(-1); }
.fl-to.link:hover { text-decoration: underline; }
.fl-to.link.sample { display: inline-flex; }
.fl-node.root { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.fl-inbadge { position: absolute; left: -12px; top: -10px; font-size: 10.5px; font-weight: 700; padding: 1px 5px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); }
.fl-tag { font-size: 11px; padding: 0 6px; border-radius: 6px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); margin-inline-start: auto; }
/* palette: sections + tools */
.fl-pal { border-inline-end: 1px solid var(--line); background: var(--panel); overflow: auto; min-height: 0; display: flex; flex-direction: column; }
.fl-tabs { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 10px 10px 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.fl-tab { font: inherit; font-weight: 700; font-size: 13.5px; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--muted); cursor: pointer; }
.fl-tab.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.fl-pb { padding: 8px 10px 20px; display: flex; flex-direction: column; gap: 3px; }
.fl-pb input[type=search] { width: 100%; padding: 6px 10px; margin: 2px 0 6px; font-size: 13.5px; }
.fl-ph { font-size: 11.5px; font-weight: 800; letter-spacing: .03em; color: var(--muted); margin: 10px 2px 4px; }
.fl-part { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; width: 100%; text-align: right; background: none; border: 1px solid transparent; border-radius: 8px; padding: 5px 8px; font: inherit; color: var(--ink); cursor: pointer; }
.fl-part b { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fl-part small { grid-column: 2; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fl-part:hover { background: var(--bg); }
.fl-part.on { background: var(--accent-soft); border-color: var(--accent); }
.fl-tool { display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: center; padding: 6px 7px; border-radius: 9px; border: 1px solid transparent; cursor: grab; user-select: none; }
.fl-tool:hover { background: var(--bg); border-color: var(--line); }
.fl-tool[draggable=false] { cursor: default; opacity: .6; }
.fl-tool b { display: block; font-size: 13.5px; font-weight: 700; }
.fl-tool small { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.fl-tool.sm { grid-template-columns: auto 1fr; padding: 4px 7px; }
.fl-tool.sm b { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fl-grip { color: var(--muted); display: grid; }
.fl-grip svg { width: 14px; height: 14px; }
.fl-world { padding-top: 0; }
.fl-zoom { position: absolute; left: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 5px; z-index: 10; }
.fl-zv { font-size: 11.5px; min-width: 44px; font-variant-numeric: tabular-nums; }
.fl-mini { position: absolute; right: 12px; bottom: 12px; width: 180px; height: 120px; border-radius: 10px; border: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 90%, transparent); overflow: hidden; cursor: pointer; z-index: 10; }
.fl-mini canvas { width: 100%; height: 100%; display: block; }
.fl-qa { position: absolute; z-index: 30; width: 290px; max-height: 370px; display: flex; flex-direction: column; direction: rtl; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 40px rgba(0,0,0,.25); }
.fl-qh { padding: 10px 12px 0; font-size: 12.5px; color: var(--muted); }
.fl-qa input { margin: 8px 10px; padding: 7px 10px; }
.fl-ql { overflow: auto; padding: 0 6px 8px; }
.fl-ql button, .fl-pop button, .fl-pop a { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; width: 100%; text-align: right; background: none; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; font: inherit; color: var(--ink); cursor: pointer; }
.fl-ql button small { grid-column: 2; color: var(--muted); font-size: 12px; }
.fl-ql button b { font-weight: 600; }
.fl-ql button:not(:has(.fl-dot)) b { grid-column: 1 / span 2; }
.fl-ql button:not(:has(.fl-dot)) small { grid-column: 1 / span 2; }
.fl-ql button.act, .fl-ql button:hover, .fl-pop button:hover, .fl-pop a:hover { background: var(--accent-soft); text-decoration: none; }
.fl-pop { position: fixed; z-index: 60; min-width: 220px; direction: rtl; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 40px rgba(0,0,0,.25); padding: 6px; }
.fl-pop svg { width: 16px; height: 16px; color: var(--muted); }
.fl-poph { font-size: 12px; color: var(--muted); padding: 6px 8px; max-width: 240px; }
.fl-chk { display: flex; align-items: center; gap: 8px; padding: 5px 8px; color: var(--ink); font-size: 14px; cursor: pointer; }
.fl-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.fl-toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; gap: 12px; align-items: center; background: var(--ink); color: var(--bg); padding: 8px 10px 8px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.3); direction: rtl; }
.fl-toast .fl-b { background: transparent; color: inherit; border-color: color-mix(in srgb, var(--bg) 40%, transparent); }
/* inspector */
.fl-insp { border-inline-start: 1px solid var(--line); background: var(--panel); overflow: auto; min-height: 0; }
.fl-ih { position: sticky; top: 0; z-index: 2; background: var(--panel); display: flex; gap: 10px; align-items: center; padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.fl-ih > div { flex: 1; min-width: 0; }
.fl-ih h3 { margin: 0; font-size: 16px; }
.fl-ih p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.fl-ib { padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 10px; }
.fl-sect { font-size: 11.5px; font-weight: 800; letter-spacing: .04em; color: var(--muted); padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.fl-kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 13.5px; }
.fl-kv dt { color: var(--muted); }
.fl-kv dd { margin: 0; }
.fl-form { display: flex; flex-direction: column; gap: 9px; }
.fl-form label { font-size: 12.5px; }
.fl-form input, .fl-form select, .fl-tsel, .fl-row select { font: inherit; font-size: 13.5px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); min-width: 0; width: 100%; }
.fl-row { display: flex; gap: 8px; align-items: center; }
.fl-row.wrap { flex-wrap: wrap; }
.fl-row.wrap select { width: auto; }
.fl-row audio { height: 32px; max-width: 150px; }
.fl-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fl-sw input { width: auto !important; }
.fl-sw { display: flex !important; align-items: center; gap: 8px; color: var(--ink) !important; font-size: 13.5px !important; }
.fl-prow { display: grid; grid-template-columns: minmax(62px, auto) 1fr 30px; gap: 7px; align-items: center; }
.fl-plab { font-size: 13px; display: grid; }
.fl-plab small { color: var(--muted); font-size: 11px; }
.fl-inc { display: flex; flex-direction: column; gap: 4px; }
.fl-link { display: flex; align-items: center; gap: 7px; text-align: right; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font: inherit; font-size: 13px; color: var(--ink); cursor: pointer; }
.fl-link:hover { border-color: var(--accent); text-decoration: none; }
.fl-issue { display: block; width: 100%; text-align: right; font: inherit; font-size: 13px; border: 0; border-radius: 8px; padding: 7px 10px; background: var(--warn-soft); color: var(--ink); cursor: pointer; }
.fl-issue.bad { background: var(--bad-soft); }
.fl-issue.info { background: var(--bg); color: var(--muted); }
.fl-issue.ok { background: var(--ok-soft); cursor: default; }
.fl-note { margin: 0; font-size: 12.5px; color: var(--warn); background: var(--warn-soft); padding: 7px 10px; border-radius: 8px; }
.fl-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.fl-acts.col { flex-direction: column; }
.fl-acts.col button { text-align: right; font: inherit; font-weight: 600; font-size: 13.5px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 9px; padding: 7px 11px; cursor: pointer; }
.fl-acts.col button:hover { border-color: var(--accent); }
.fl-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.fl-stats div { background: var(--bg); border-radius: 9px; padding: 8px 10px; }
.fl-stats b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; }
.fl-stats span { font-size: 11.5px; color: var(--muted); }
.fl-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12.5px; }
.fl-legend > span { display: inline-flex; align-items: center; gap: 5px; }
/* test call */
.fl-sim { position: absolute; left: 12px; top: 12px; width: 290px; max-height: calc(100% - 24px); z-index: 25; direction: rtl; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 14px 40px rgba(0,0,0,.25); }
.fl-simh { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.fl-simh b { flex: 1; }
.fl-live { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 25%, transparent); }
.fl-simb { padding: 10px 12px; overflow: auto; display: flex; flex-direction: column; gap: 9px; }
.fl-now { background: var(--bg); border-radius: 9px; padding: 9px 11px; line-height: 1.55; font-size: 13.5px; }
.fl-now small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 700; }
.fl-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; direction: ltr; }
.fl-pad button { height: 38px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; }
.fl-pad button.has { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.fl-log { font-size: 12px; color: var(--muted); line-height: 1.6; border-top: 1px solid var(--line); padding-top: 7px; max-height: 130px; overflow: auto; }
.fl-log div::before { content: "• "; color: var(--ok); }
.muted.small, p.small { font-size: 12px; margin: 0; }
.canvas-link { display: inline-flex; align-items: center; gap: 5px; }
.canvas-link svg { width: 14px; height: 14px; }
td .canvas-link.mini { padding: 2px 6px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); }
td .canvas-link.mini:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
h1 .canvas-link { font-size: 13px; font-weight: 600; vertical-align: middle; margin-inline-start: 10px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; }
@media (max-width: 900px) {
  .view.fl-view { height: calc(100dvh - 59px); }
  .fl-main, .fl-main.nopal { grid-template-columns: 1fr; }
  .fl-pal { position: fixed; top: 0; bottom: 0; right: 0; width: min(300px, 86vw); z-index: 55; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .fl-pal:not(.open) { display: none; }
  .fl-hide-sm { display: none; }
  .fl-insp { position: fixed; inset: auto 0 0 0; max-height: 62vh; z-index: 50; border-top: 1px solid var(--line); border-inline-start: 0; box-shadow: 0 -12px 30px rgba(0,0,0,.25); border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .fl-insp:not(.open) { display: none; }
  .fl-mini { display: none; }
  .fl-title span { display: none; }
  .fl-b span:not(.fl-pill) { display: none; }
  .fl-sim { width: calc(100% - 24px); max-height: 55%; }
}
@media (prefers-reduced-motion: no-preference) { .fl-live { animation: flpulse 1.4s infinite; } }
@keyframes flpulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--ok) 5%, transparent); } }
/* canvas layout modes (horizontal / vertical / cluster) */
.fl-port.o.left { right: auto; left: -8px; }
.fl-port.in.top { left: calc(50% - 7px); top: -8px; }
.fl-wl circle { fill: var(--panel); stroke: var(--accent); stroke-width: 1.5; }
.fl-wl text { fill: var(--accent); font-size: 11.5px; font-weight: 700; text-anchor: middle; font-family: inherit; }
.fl-wg.dim .fl-wl { opacity: .2; }
.fl-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.fl-seg button { font: inherit; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.fl-seg button + button { border-inline-start: 1px solid var(--line); }
.fl-seg button.on { background: var(--accent-soft); color: var(--accent); }

/* extension call handling card (extcall.js) */
.xc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 22px; }
.xc-grid h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.xc-grid .mp-list { margin: 6px 0 10px; }
table.compact td { padding: 5px 8px; }

/* travel page */
.tile.active { outline: 2px solid var(--accent); }
iframe.tv-prev { width: 100%; height: 60vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* canvas: add a key right on the menu node */
.fl-addk { display: block; width: calc(100% - 16px); margin: 4px 8px 8px; border: 1px dashed var(--line); background: transparent; color: var(--accent); border-radius: 8px; padding: 4px; font: inherit; font-size: 12px; cursor: pointer; }
.fl-addk:hover { background: var(--accent-soft); }
