/* User Flow (public/flow.js). Node colours follow the A044 FigJam board: screens dark, overlays green. */
:root {
  --flow-scr: #1f2128;
  --flow-scr-line: #1f2128;
  --flow-on-scr: #ffffff;
  --flow-on-scr-2: #b9bdc9;
  --flow-ovl: #e9f7ef;
  --flow-ovl-line: #2f9e5b;
  --flow-on-ovl: #14532d;
  --flow-edge: #9aa0b0;
  --flow-back: #d9741c;
  --flow-ovl-edge: #3fae6a;
  --flow-hot: #5465f0;
  --flow-drop: #d93f3f;
  --flow-drop-hi: #b4232b;
  --flow-ad: #c8378f;
  --flow-gone: #6a45c9;
  --flow-time: #2a7f8f;
  --flow-on-badge: #ffffff;
  --flow-grid: #dde0e7;
  --flow-canvas: #fafbfc;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --flow-scr: #2c2f3a; --flow-scr-line: #444959; --flow-on-scr: #f1f2f5; --flow-on-scr-2: #a9aebb;
    --flow-ovl: #10291b; --flow-ovl-line: #3fc27a; --flow-on-ovl: #c4f5d6;
    --flow-edge: #6c7285; --flow-back: #f0a050; --flow-ovl-edge: #3fc27a; --flow-hot: #8b98ff;
    --flow-drop: #e5585b; --flow-drop-hi: #f07074; --flow-ad: #e05aa9; --flow-gone: #a48cff; --flow-time: #5cc3d1; --flow-on-badge: #16171b;
    --flow-grid: #2b2d35; --flow-canvas: #18191d;
  }
}
:root[data-theme="dark"] {
  --flow-scr: #2c2f3a; --flow-scr-line: #444959; --flow-on-scr: #f1f2f5; --flow-on-scr-2: #a9aebb;
  --flow-ovl: #10291b; --flow-ovl-line: #3fc27a; --flow-on-ovl: #c4f5d6;
  --flow-edge: #6c7285; --flow-back: #f0a050; --flow-ovl-edge: #3fc27a; --flow-hot: #8b98ff;
  --flow-drop: #e5585b; --flow-drop-hi: #f07074; --flow-ad: #e05aa9; --flow-gone: #a48cff; --flow-time: #5cc3d1; --flow-on-badge: #16171b;
  --flow-grid: #2b2d35; --flow-canvas: #18191d;
}

/* The flow page fills the window: a narrow column (app, filters, totals) next to the menu, then the canvas */
.main.wide { padding: 12px 14px; height: 100vh; display: flex; flex-direction: column; }
.main.wide > .banner { flex: none; }
.flow-page { flex: 1; min-height: 0; display: flex; gap: 12px; }
/* ---------- left column (filters): one control style, sections spaced instead of ruled ---------- */
.flow-side {
  width: 244px; flex: none; min-height: 0; overflow: auto; display: grid; gap: 18px; align-content: start;
  padding: 14px 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--surface);
  scrollbar-width: thin;
}
.fs-back { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); text-decoration: none; justify-self: start; margin-bottom: -8px; }
.fs-back:hover { color: var(--text); text-decoration: none; }
.fs-back .icon { width: 15px; height: 15px; }
.fs-app { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; align-items: center; }
.flow-app-icon.side { width: 44px; height: 44px; border-radius: 12px; font-size: 13px; box-shadow: 0 0 0 1px var(--line); }
.fs-app-text { display: grid; gap: 4px; min-width: 0; }
.fs-app-name { font-weight: 650; font-size: 14.5px; line-height: 1.25; letter-spacing: -.01em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fs-app-meta { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 11.5px; color: var(--muted); }
.fs-code { flex: none; font-weight: 600; font-size: 10.5px; letter-spacing: .04em; padding: 1px 6px; border-radius: 5px; background: var(--brand-soft); color: var(--brand); }
.fs-pkg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fs-sec { display: grid; gap: 9px; }
.fs-head { display: flex; align-items: center; justify-content: space-between; min-height: 24px; }
.fs-head h3 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.fs-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer; }
.fs-icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.fs-icon-btn .icon { width: 16px; height: 16px; }
.fs-icon-btn .spinner { width: 14px; height: 14px; }
.fs-field { display: grid; gap: 5px; min-width: 0; }
.fs-label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.fs-label-row { display: flex; justify-content: space-between; align-items: baseline; }
.fs-value { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text); padding: 0 6px; border-radius: 5px; background: var(--surface-2); }
.fs-note { margin: 0; font-size: 11.5px; color: var(--muted); }
.fs-note.fs-warn { color: var(--warn); }

/* one look for every control: soft fill, no hard border, ring on focus */
.fs-control {
  width: 100%; min-height: 34px; border: 1px solid transparent; border-radius: 10px; background-color: var(--surface-2);
  color: var(--text); font: inherit; font-size: 13px; padding: 7px 11px; transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.fs-control:hover { border-color: var(--line-strong); }
.fs-control:focus-visible, .fs-control[aria-expanded=true] { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background-color: var(--surface); }
.fs-select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8f9c' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.fs-dates { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; align-items: center; text-align: left; cursor: pointer; padding: 8px 11px; }
.fs-dates .icon { width: 18px; height: 18px; color: var(--brand); }
.fs-dates-text { display: grid; gap: 1px; min-width: 0; }
.fs-dates-text b { font-size: 13px; font-weight: 600; }
.fs-dates-text span { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* segmented control (units) */
.fs-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border-radius: 10px; background: var(--surface-2); }
.fs-seg button { border: 0; background: none; border-radius: 8px; padding: 6px 4px; font: inherit; font-size: 12.5px; color: var(--text-2); cursor: pointer; transition: background .15s, color .15s; }
.fs-seg button:hover { color: var(--text); }
.fs-seg button[aria-pressed=true] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 0 0 1px var(--line); }

/* switch (checkbox underneath, so keyboard and screen readers keep working) */
.fs-switch { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--text); cursor: pointer; min-height: 26px; }
.fs-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.fs-track { flex: none; position: relative; width: 32px; height: 19px; border-radius: 999px; background: var(--line-strong); transition: background .18s; }
.fs-track::after { content: ""; position: absolute; top: 2.5px; left: 2.5px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .18s; }
.fs-switch input:checked + .fs-track { background: var(--brand); }
.fs-switch input:checked + .fs-track::after { transform: translateX(13px); }
.fs-switch input:focus-visible + .fs-track { box-shadow: 0 0 0 3px var(--brand-soft); }

/* slider */
.fs-range { width: 100%; margin: 4px 0 0; accent-color: var(--brand); cursor: pointer; }

/* totals */
.fs-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fs-kpi { display: grid; gap: 2px; padding: 9px 11px; border-radius: 10px; background: var(--surface-2); min-width: 0; }
.fs-kpi span { font-size: 11px; color: var(--muted); }
.fs-kpi b { font-size: 16px; font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.fs-kpi.rev b { color: var(--flow-ad); }
.fs-kpi.gone b { color: var(--flow-gone); }
.fs-list { display: grid; gap: 1px; margin: 0 -8px; }
.fs-list .flow-row { grid-template-columns: minmax(0, 1fr) auto 3.4em; font-size: 12.5px; }
.fs-list .flow-row.on { background: var(--surface-2); }

/* date range popover like AdMob (presets + two months) */
.flow-dp { position: fixed; z-index: 60; width: min(600px, calc(100vw - 16px)); max-height: calc(100vh - 16px); overflow: auto; display: grid; grid-template-columns: 172px minmax(0, 1fr); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 12px 32px rgba(16, 24, 40, .18); }
.flow-dp-presets { display: grid; align-content: start; gap: 2px; padding: 8px; border-right: 1px solid var(--line); }
.flow-dp-presets button { display: grid; gap: 1px; text-align: left; border: 0; background: none; color: var(--text); font: inherit; font-size: 13px; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.flow-dp-presets button:hover { background: var(--surface-2); }
.flow-dp-presets button[aria-pressed=true] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.flow-dp-cal { display: grid; gap: 10px; padding: 12px 14px; align-content: start; }
.flow-dp-months { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.flow-dp-mhead { display: grid; grid-template-columns: 28px 1fr 28px; align-items: center; text-align: center; font-size: 13px; margin-bottom: 4px; }
.flow-dp-mhead .icon-btn { font-size: 18px; line-height: 1; }
.flow-dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; }
.flow-dp-grid .dow { font-size: 10.5px; color: var(--muted); text-align: center; padding: 2px 0 4px; }
.flow-dp-day { position: relative; height: 30px; border: 0; background: none; color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; font-variant-numeric: tabular-nums; }
.flow-dp-day:hover:not(:disabled) { outline: 1px solid var(--brand); outline-offset: -1px; border-radius: 8px; }
.flow-dp-day.in { background: var(--brand-soft); }
.flow-dp-day.start, .flow-dp-day.end { background: var(--brand); color: var(--on-brand); font-weight: 600; }
.flow-dp-day.start { border-radius: 8px 0 0 8px; }
.flow-dp-day.end { border-radius: 0 8px 8px 0; }
.flow-dp-day.start.end { border-radius: 8px; }
.flow-dp-day.today { font-weight: 700; }
.flow-dp-day.partial::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--warn); }
.flow-dp-day:disabled { color: var(--muted); opacity: .4; cursor: default; }
.flow-dp-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding-top: 10px; border-top: 1px solid var(--line); }
.flow-dp-foot .bad { color: var(--bad); }
.flow-dp-foot .warn { color: var(--warn); }
.flow-dp-foot .actions { display: flex; gap: 6px; margin-left: auto; }
@media (max-width: 640px) {
  .flow-dp { grid-template-columns: 1fr; }
  .flow-dp-presets { display: flex; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .flow-dp-months { grid-template-columns: 1fr; }
}


.flow-body { flex: 1; min-height: 0; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.flow-body.with-panel { grid-template-columns: minmax(0, 1fr) 370px; }
.flow-stage { position: relative; min-height: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--surface); overflow: hidden; }
.flow-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); flex: none; font-size: 13px; }
.flow-toolbar .grow { flex: 1; }
.flow-thr, .flow-depth { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); }
.flow-thr input[type=range] { width: 110px; accent-color: var(--brand); }
.flow-thr b { font-variant-numeric: tabular-nums; min-width: 38px; }
.flow-zoom { display: inline-flex; gap: 4px; }
.flow-error { margin: 10px 12px 0; flex: none; }

.flow-canvas {
  position: relative; flex: 1; min-height: 360px; outline: none; cursor: grab; touch-action: none; overscroll-behavior: none; user-select: none;
  background-color: var(--flow-canvas);
  background-image: radial-gradient(var(--flow-grid) 1.1px, transparent 1.2px);
  background-size: 22px 22px;
}
.flow-canvas.panning { cursor: grabbing; }
.flow-canvas.dragging-node { cursor: move; }
.flow-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--brand); }
.flow-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.flow-loading { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: inline-flex; gap: 8px; align-items: center; padding: 7px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: 0 4px 14px rgba(0, 0, 0, .08); font-size: 13px; z-index: 2; white-space: nowrap; }
.flow-empty { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); color: var(--muted); text-align: center; max-width: 420px; }

/* nodes */
.node { cursor: pointer; }
.node rect { stroke-width: 1.5; }
.node text { pointer-events: none; }
.node .nm { font-size: 13px; font-weight: 600; }
.node .sub { font-size: 11.5px; font-variant-numeric: tabular-nums; }
.node.screen rect { fill: var(--flow-scr); stroke: var(--flow-scr-line); }
.node.screen .nm { fill: var(--flow-on-scr); }
.node.screen .sub { fill: var(--flow-on-scr-2); }
.node.overlay rect { fill: var(--flow-ovl); stroke: var(--flow-ovl-line); }
.node.overlay .nm, .node.overlay .sub { fill: var(--flow-on-ovl); font-size: 12px; }
.node.overlay .nm { font-weight: 500; }
.node.start rect { fill: var(--brand); stroke: var(--brand); }
.node.start text { fill: var(--on-brand); }
.node.sel rect { stroke: var(--flow-hot); stroke-width: 3.5; }
.node .badge text { font-size: 10.5px; font-weight: 600; fill: var(--flow-on-badge); }
.node .badge.drop rect { fill: var(--flow-drop); }
.node .badge.drop.hi rect { fill: var(--flow-drop-hi); }
.node .badge.ad rect { fill: var(--flow-ad); }
.node .badge.gone rect { fill: var(--flow-gone); }
.node .badge.time rect { fill: var(--flow-time); }
.node .badge { pointer-events: all; }

/* edges */
.edge { fill: none; stroke: var(--flow-edge); stroke-linecap: round; opacity: .75; transition: opacity .12s; }
.edge.back { stroke: var(--flow-back); stroke-dasharray: 7 6; opacity: .8; }
.edge.ovl { stroke: var(--flow-ovl-edge); stroke-dasharray: 2 4; opacity: .8; }
.edge.move.side { opacity: .32; }
.edge.resume:not(.on), .lbl.resume:not(.on), .edge.off:not(.on) { display: none; }
.edge.on, .edge.hot { stroke: var(--flow-hot); opacity: 1; }
.edge.back.on, .edge.back.hot { stroke: var(--flow-back); }
.arrow path { fill: var(--flow-edge); }
.arrow.back path { fill: var(--flow-back); }
.arrow.ovl path { fill: var(--flow-ovl-edge); }
.arrow.hot path { fill: var(--flow-hot); }
.lbl { font-size: 11px; font-weight: 600; fill: var(--text-2); text-anchor: middle; paint-order: stroke; stroke: var(--flow-canvas); stroke-width: 4px; stroke-linejoin: round; pointer-events: none; font-variant-numeric: tabular-nums; }
.lbl.back { fill: var(--flow-back); }
.lbl.minor, .lbl.side { display: none; }
.lbl.on, .lbl.hot { display: inline; fill: var(--flow-hot); }
.lbl.back.on, .lbl.back.hot { fill: var(--flow-back); }
/* With a selection, what is not next to it fades */
.flow-svg.has-sel .node:not(.near-on) { opacity: .28; }
.flow-svg.has-sel .edge:not(.on) { opacity: .1; }
.flow-svg.has-sel .lbl:not(.on) { display: none; }

.flow-legend { position: absolute; left: 12px; bottom: 10px; display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 6px 10px; border-radius: 10px; background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--line); color: var(--text-2); max-width: calc(100% - 24px); pointer-events: none; }
.flow-legend span { display: inline-flex; align-items: center; gap: 6px; }
.flow-legend .sw { width: 16px; height: 11px; border-radius: 3px; display: inline-block; }
.flow-legend .sw.scr { background: var(--flow-scr); }
.flow-legend .sw.ovl { background: var(--flow-ovl); border: 1.5px solid var(--flow-ovl-line); border-radius: 6px; }
.flow-legend .ln { width: 22px; height: 0; border-top: 3px solid var(--flow-edge); display: inline-block; }
.flow-legend .ln.back { border-top: 2px dashed var(--flow-back); }
.flow-legend .bd { width: 18px; height: 10px; border-radius: 5px; display: inline-block; }
.flow-legend .bd.drop { background: var(--flow-drop); }
.flow-legend .bd.ad { background: var(--flow-ad); }
.flow-legend .bd.gone { background: var(--flow-gone); }
.flow-legend .bd.time { background: var(--flow-time); }
.fs-sub { margin-top: 4px; }
.fs-badge-label { display: inline-flex; align-items: center; gap: 8px; }
.fs-badge-label .bd { width: 18px; height: 10px; border-radius: 5px; display: inline-block; }
.fs-badge-label .bd.drop { background: var(--flow-drop); }
.fs-badge-label .bd.gone { background: var(--flow-gone); }
.fs-badge-label .bd.ad { background: var(--flow-ad); }
.fs-badge-label .bd.time { background: var(--flow-time); }

/* side panel */
.flow-panel { min-height: 0; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--surface); padding: 14px 16px 18px; display: grid; gap: 14px; align-content: start; }
.flow-panel-head { display: flex; align-items: center; gap: 8px; }
.flow-panel-head h2 { margin: 0; font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-panel-head .icon-btn { font-size: 20px; line-height: 1; }
.flow-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.flow-stat { display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.flow-stat b { font-size: 15px; font-variant-numeric: tabular-nums; }
.flow-sec { display: grid; gap: 4px; }
.flow-sec h3 { margin: 0 0 2px; font-size: 13px; display: flex; gap: 8px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.flow-sec p { margin: 2px 0 0; }
.flow-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 5px 8px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.flow-row:hover:not(:disabled):not(.static) { background: var(--surface-2); }
.flow-row:disabled { cursor: default; }
.flow-row.static { cursor: default; }
.flow-row.exit .nm { color: var(--flow-drop); }
.flow-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-row .val { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12.5px; }
.flow-ads { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.flow-ads th, .flow-ads td { text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.flow-ads th:first-child, .flow-ads td:first-child { text-align: left; }
.flow-ads th { color: var(--muted); font-weight: 500; }

/* app picker */
.flow-search { max-width: 260px; }
.flow-apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.flow-app { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); color: var(--text); text-decoration: none; min-width: 0; }
.flow-app:hover { border-color: var(--brand); text-decoration: none; }
.flow-app.stale { opacity: .6; }
.flow-app-text { display: grid; gap: 2px; min-width: 0; }
.flow-app-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.flow-app-code { font-size: 12px; letter-spacing: .02em; color: var(--text-2); }
.flow-app-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-app-pkg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-app-icon { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; background: var(--surface-2); flex: none; }
.flow-app-icon.letter { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; color: var(--muted); }
.flow-app-icon.small { width: 30px; height: 30px; border-radius: 8px; font-size: 11px; align-self: center; }

/* admin: features × teams */
.feature-matrix { border-collapse: collapse; width: 100%; max-width: 640px; }
.feature-matrix th, .feature-matrix td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: center; }
.feature-matrix th:first-child, .feature-matrix td:first-child { text-align: left; }
.feature-matrix th { font-size: 12.5px; color: var(--muted); font-weight: 500; }

@media (max-width: 960px) {
  .main.wide { height: auto; }
  .flow-page { flex-direction: column; }
  .flow-side { width: auto; }
  .flow-body, .flow-body.with-panel { grid-template-columns: minmax(0, 1fr); }
  .flow-canvas { min-height: 70vh; }
  .flow-panel { max-height: none; }
}

/* Path view (flowPathsView): columns of steps over the map */
.flow-path-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fp { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; background: var(--surface); }
.fp-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.fp-title { font-size: 14px; }
.fp-dir { flex: none; }
.fp-chain { padding: 9px 14px 0; font-size: 13px; overflow-wrap: anywhere; }
.fp-chain b { font-weight: 650; }
.fp-note { margin: 4px 14px 8px; }
.fp-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 20px; text-align: center; }
.fp-cols { flex: 1; min-height: 0; display: flex; overflow: auto; border-top: 1px solid var(--line); }
.fp-col { flex: 0 0 232px; min-height: 0; overflow-y: auto; padding: 8px 6px; display: grid; align-content: start; gap: 2px; border-right: 1px solid var(--line); }
.fp-colhead { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 2px 8px 6px; }
.fp-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; width: 100%; padding: 7px 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; font-size: 12.5px; text-align: left; cursor: pointer; overflow: hidden; }
.fp-row:hover:not(:disabled):not(.static):not(.root) { background: var(--surface-2); }
.fp-row.on { background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.fp-row:disabled, .fp-row.static, .fp-row.root { cursor: default; }
.fp-row.term .nm { color: var(--flow-drop); }
.fp-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-row .val { font-variant-numeric: tabular-nums; white-space: nowrap; }
.fp-bar { position: absolute; left: 8px; bottom: 4px; height: 3px; width: var(--w, 0%); max-width: calc(100% - 16px); border-radius: 2px; background: var(--brand); opacity: .55; }
.fp-row.term .fp-bar { background: var(--flow-drop); }

/* Gợi ý cải thiện (flowInsightsPanel) and Claude on this tab */
.flow-count { margin-left: 6px; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--brand); color: #fff; font-size: 11px; line-height: 18px; display: inline-block; text-align: center; }
.btn.primary .flow-count { background: #fff; color: var(--brand); }
.flow-claude { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 600; cursor: pointer; }
.flow-claude .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); animation: flow-pulse 1.6s ease-in-out infinite; }
.flow-claude input { accent-color: var(--brand); margin: 0; }
.flow-claude .muted { font-weight: 500; }
@keyframes flow-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .flow-claude .dot { animation: none; } }
.fi { display: grid; gap: 6px; padding: 11px 12px; border: 1px solid var(--line); border-left: 3px solid var(--muted); border-radius: 10px; background: var(--surface); }
.fi.high { border-left-color: var(--flow-drop); }
.fi.medium { border-left-color: var(--warn); }
.fi.info { border-left-color: var(--brand); }
.fi.on { box-shadow: 0 0 0 1px var(--brand); }
.fi h3 { margin: 0; font-size: 13.5px; line-height: 1.35; }
.fi p { margin: 0; font-size: 12.5px; line-height: 1.45; }
.fi.small { padding: 8px 10px; gap: 3px; }
.fi.small b { font-size: 12.5px; }
.fi-head { display: flex; gap: 6px; }
.fi-sev, .fi-kind { font-size: 10.5px; font-weight: 650; letter-spacing: .03em; text-transform: uppercase; padding: 1px 6px; border-radius: 5px; background: var(--surface-2); color: var(--text-2); }
.fi-sev.high { color: var(--flow-drop); }
.fi-sev.medium { color: var(--warn); }
.fi-sev.info { color: var(--brand); }
.fi-kind.guess { background: var(--brand-soft); color: var(--brand); }
.fi-facts { margin: 0; padding-left: 16px; font-size: 12.5px; line-height: 1.45; display: grid; gap: 2px; font-variant-numeric: tabular-nums; }
.fi-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.fi-wait, .fi-foot { display: flex; gap: 6px; align-items: flex-start; }
.flow-split { margin: 0; }

/* Full-screen ads between screens */
.lbl tspan.ad { fill: var(--flow-ad); }
.lg-ad { color: var(--flow-ad); font-weight: 650; font-size: 11px; margin-right: 4px; }
.ad-tag { color: var(--flow-ad); font-weight: 600; }
.flow-row .val.ad-tag { font-size: 11.5px; }
.flow-panel .flow-row { grid-template-columns: minmax(0, 1fr) auto auto auto auto; }
.fa-row.on { background: var(--surface-2); }
.fp-ad { color: var(--flow-ad); font-size: 11.5px; font-weight: 600; }

/* Time on screen (panel) */
.fs-kpi.time b { color: var(--flow-time); }
.flow-dwell { display: grid; gap: 4px; }
.flow-dwell-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) 42px; gap: 8px; align-items: center; font-size: 12px; font-variant-numeric: tabular-nums; }
.flow-dwell-row b { text-align: right; font-weight: 600; }
.flow-dwell-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.flow-dwell-bar i { display: block; height: 100%; width: var(--w, 0%); background: var(--flow-time); border-radius: 4px; }

/* Card panel: folding sections, "?" help, compact stats */
.flow-panel { gap: 10px; }
.flow-panel details.flow-sec { border-top: 1px solid var(--line); padding-top: 8px; }
.flow-panel details.flow-sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; justify-content: space-between; font-size: 13px; font-weight: 650; padding: 2px 0 4px; user-select: none; }
.flow-panel details.flow-sec > summary::-webkit-details-marker { display: none; }
.flow-panel details.flow-sec > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; flex: none; margin-right: 2px; }
.flow-panel details.flow-sec[open] > summary::before { transform: rotate(45deg); }
.flow-sec-title { display: inline-flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.flow-sec-count { font-size: 11.5px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.flow-help { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--line); color: var(--muted); font-size: 10px; font-weight: 700; cursor: help; flex: none; }
.flow-help:hover { color: var(--brand); border-color: var(--brand); }
.flow-stats.compact { grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 6px; }
.flow-stats.compact .flow-stat { padding: 6px 9px; }
.flow-stats.compact .flow-stat b { font-size: 14px; }
.flow-split { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; margin-top: 4px; }
.flow-more { border: 0; background: none; color: var(--brand); font: inherit; font-size: 12px; padding: 4px 8px; cursor: pointer; text-align: left; }
.flow-more:hover { text-decoration: underline; }
.fi-line { display: flex; gap: 8px; align-items: flex-start; width: 100%; border: 0; background: none; color: var(--text); font: inherit; font-size: 12.5px; line-height: 1.4; text-align: left; padding: 5px 6px; border-radius: 8px; cursor: pointer; }
.fi-line:hover { background: var(--surface-2); }
.fi-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 5px; background: var(--brand); }
.fi-dot.high { background: var(--flow-drop); }
.fi-dot.medium { background: var(--warn); }

/* Đi tiếp / Vào từ: the same columns on every row (name, count, %, ↩, ad) */
.flow-panel details[data-k="out"] .flow-row, .flow-panel details[data-k="in"] .flow-row { grid-template-columns: minmax(0, 1fr) 46px 44px 14px 82px; gap: 6px; }
.flow-panel details[data-k="in"] .flow-row { grid-template-columns: minmax(0, 1fr) 46px 44px 14px; }
.flow-panel details[data-k="out"] .flow-row .val, .flow-panel details[data-k="in"] .flow-row .val { text-align: right; }
.back-tag { color: var(--flow-back); font-weight: 700; }

/* Sidebar blocks fold like the panel sections */
.flow-side details.fs-sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 24px; user-select: none; }
.flow-side details.fs-sec > summary::-webkit-details-marker { display: none; }
.flow-side details.fs-sec > summary::before { content: ""; width: 5px; height: 5px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; flex: none; }
.flow-side details.fs-sec[open] > summary::before { transform: rotate(45deg); }
.flow-side details.fs-sec > summary .flow-sec-title { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.flow-side details.fs-sec > summary .flow-sec-count { font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: none; }
.flow-side details.fs-sec[open] > summary .flow-sec-count { display: none; }
.flow-side details.fs-sec { display: grid; gap: 9px; }
.flow-side details.fs-sec:not([open]) { gap: 0; }
/* Chips (layers, numbers on cards) */
.fs-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fs-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.fs-chip:hover { border-color: var(--line-strong); color: var(--text); }
.fs-chip[aria-pressed=true] { background: var(--brand-soft); border-color: transparent; color: var(--text); font-weight: 550; }
.fs-chip .bd { width: 10px; height: 10px; border-radius: 50%; display: inline-block; opacity: .45; }
.fs-chip[aria-pressed=true] .bd { opacity: 1; }
.fs-chip .bd.drop { background: var(--flow-drop); }
.fs-chip .bd.gone { background: var(--flow-gone); }
.fs-chip .bd.ad, .fs-chip .bd.admove { background: var(--flow-ad); }
.fs-chip .bd.time { background: var(--flow-time); }
.fs-chip .bd.ovl { background: var(--flow-ovl-line); }
.fs-chip .bd.back { background: var(--flow-back); }
/* Overview: three small columns */
.fs-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.fs-kpi { padding: 7px 8px; border-radius: 9px; }
.fs-kpi span { font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-kpi b { font-size: 14px; }
/* Hints: one line each, details on click */
.fi-list { display: grid; gap: 6px; }
details.fi { padding: 0; gap: 0; }
details.fi > summary { list-style: none; cursor: pointer; display: flex; gap: 8px; align-items: flex-start; padding: 9px 10px; font-size: 13px; line-height: 1.4; font-weight: 600; }
details.fi > summary::-webkit-details-marker { display: none; }
details.fi > summary .fi-t { flex: 1; min-width: 0; }
details.fi > summary .fi-kind { flex: none; margin-top: 1px; }
details.fi[open] > summary { padding-bottom: 4px; }
details.fi > :not(summary) { margin-left: 26px; margin-right: 10px; }
details.fi > :last-child { margin-bottom: 10px; }
details.fi .fi-facts { margin-bottom: 4px; }
details.fi p { margin-bottom: 4px; }
.flow-panel-head .flow-help { margin-right: auto; margin-left: -2px; }
.fp-head .flow-help { margin-left: -6px; }
.flow-side details.fs-sec > summary .fs-icon-btn { margin-left: auto; }
.flow-panel-head:has(.flow-help) h2 { flex: 0 1 auto; }

details.fi > summary { color: var(--text); }
.fs-kpi span { white-space: normal; overflow: visible; line-height: 1.2; }
.flow-side details.fs-sec { gap: 11px; }
.flow-howto { display: inline-flex; align-items: center; gap: 6px; }
.flow-ads-panel .fa-row { grid-template-columns: minmax(0, 1fr) 76px 40px 40px; gap: 6px; }
.flow-ads-panel .fa-row .val { text-align: right; }

/* Revenue per 1,000 sessions in the path view */
.fp-row { grid-template-columns: minmax(0, 1fr) auto auto 52px; }
.fp-rev { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); text-align: right; }
.fp-rev.up { color: #1a9a5a; font-weight: 650; }
.fp-rev.down { color: var(--flow-drop); font-weight: 650; }
.fp-col { flex-basis: 260px; }

.fp-colhead { display: flex; justify-content: space-between; gap: 8px; }
.fp-unit { font-weight: 600; letter-spacing: 0; text-transform: none; }
.fp-head .fs-chip { flex: none; }

/* ---- Calmer look (2026-11-17): light cards, soft tinted badges, quiet lines, help only on hover ---- */
:root {
  --flow-scr: #ffffff; --flow-scr-line: #dde1e8; --flow-on-scr: #1d2029; --flow-on-scr-2: #737a8a;
  --flow-ovl: #f4fbf6; --flow-ovl-line: #a9dcbc; --flow-on-ovl: #2c6e46;
  --flow-edge: #b9bfcc; --flow-back: #e3a06a; --flow-ovl-edge: #8ccfa5; --flow-hot: #5465f0;
  --flow-drop: #d24b4b; --flow-gone: #7656d6; --flow-ad: #c2418f; --flow-time: #2b8a99;
  --flow-canvas: #f7f8fa; --flow-grid: #e4e7ed;
  --flow-badge-a: .12;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --flow-scr: #22252d; --flow-scr-line: #353a47; --flow-on-scr: #eceef3; --flow-on-scr-2: #949aa8;
    --flow-ovl: #18261e; --flow-ovl-line: #2f6a47; --flow-on-ovl: #a6dfbd;
    --flow-edge: #4f5566; --flow-back: #b98252; --flow-ovl-edge: #3c8a5e; --flow-hot: #8b98ff;
    --flow-drop: #f08080; --flow-gone: #ab97ff; --flow-ad: #ec7cbe; --flow-time: #6ccbd8;
    --flow-canvas: #16171b; --flow-grid: #262830; --flow-badge-a: .2;
  }
}
:root[data-theme="dark"] {
  --flow-scr: #22252d; --flow-scr-line: #353a47; --flow-on-scr: #eceef3; --flow-on-scr-2: #949aa8;
  --flow-ovl: #18261e; --flow-ovl-line: #2f6a47; --flow-on-ovl: #a6dfbd;
  --flow-edge: #4f5566; --flow-back: #b98252; --flow-ovl-edge: #3c8a5e; --flow-hot: #8b98ff;
  --flow-drop: #f08080; --flow-gone: #ab97ff; --flow-ad: #ec7cbe; --flow-time: #6ccbd8;
  --flow-canvas: #16171b; --flow-grid: #262830; --flow-badge-a: .2;
}
.node rect { stroke-width: 1; }
.node.screen > rect { filter: drop-shadow(0 1px 1.5px rgba(16, 24, 40, .06)); }
.node.screen .nm { font-weight: 600; }
.node.start rect { fill: var(--brand-soft); stroke: color-mix(in srgb, var(--brand) 35%, transparent); }
.node.start text { fill: var(--brand); }
.node.sel rect { stroke: var(--flow-hot); stroke-width: 2; }
.node.screen:hover > rect { stroke: color-mix(in srgb, var(--flow-hot) 55%, var(--flow-scr-line)); }
/* Badges: a soft tint of their colour, the number in that colour */
.node .badge rect { fill-opacity: var(--flow-badge-a); }
.node .badge text { font-weight: 650; }
.node .badge.drop text, .node .badge.drop.hi text { fill: var(--flow-drop); }
.node .badge.drop.hi rect { fill: var(--flow-drop); fill-opacity: calc(var(--flow-badge-a) * 1.8); }
.node .badge.gone text { fill: var(--flow-gone); }
.node .badge.ad text { fill: var(--flow-ad); }
.node .badge.time text { fill: var(--flow-time); }
/* Lines: quiet until a card is picked */
.edge { opacity: .7; }
.edge.move.side { opacity: .22; }
.edge.back { stroke-dasharray: 5 6; opacity: .38; }
.edge.ovl { opacity: .55; }
.edge.on, .edge.hot, .edge.back.on, .edge.back.hot { opacity: 1; }
.lbl { font-size: 10.5px; font-weight: 550; }
.lbl.back:not(.on):not(.hot) { display: none; }
/* Legend: one short line, smaller */
.flow-legend { gap: 2px 12px; padding: 4px 10px; font-size: 11px; border-radius: 8px; color: var(--muted); }
.flow-legend .sw { width: 12px; height: 9px; }
.flow-legend .sw.scr { background: var(--flow-scr); border: 1px solid var(--flow-scr-line); }
.flow-legend .ln { width: 16px; border-top-width: 2px; }
.flow-legend .lg { font-size: 11px; font-weight: 700; }
.flow-legend .lg.drop { color: var(--flow-drop); } .flow-legend .lg.gone { color: var(--flow-gone); }
.flow-legend .lg.ad { color: var(--flow-ad); } .flow-legend .lg.time { color: var(--flow-time); }
.flow-legend .lg-ad { font-size: 11px; margin-right: 0; }
/* "?" only shows when the title is hovered or focused */
summary .flow-help, .flow-panel-head .flow-help, .fp-head .flow-help { opacity: 0; transition: opacity .12s; }
summary:hover .flow-help, summary:focus-within .flow-help, .flow-panel-head:hover .flow-help, .fp-head:hover .flow-help, .flow-help:focus { opacity: 1; }
.flow-howto .flow-help { opacity: .7; }
.btn.icon-only { padding-left: 7px; padding-right: 7px; display: inline-flex; align-items: center; }
.btn.icon-only .icon { width: 15px; height: 15px; }
/* Badges never take the card's outline (selected / hovered) */
.node .badge rect, .node.sel .badge rect, .node.screen:hover .badge rect { stroke: none; filter: none; }
.node.sel > rect { stroke: var(--flow-hot); stroke-width: 2; }
/* Moves back stay thin and light even next to the picked card: they are the side story */
.edge.back { stroke-width: 1.4px; }
.edge.back.on, .edge.back.hot { opacity: .7; }

/* Hover card in the path view */
#fp-tip { position: fixed; z-index: 50; width: 300px; display: none; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: 0 8px 24px rgba(16, 24, 40, .14); font-size: 12px; line-height: 1.45; color: var(--text); pointer-events: none; }
#fp-tip.show { display: grid; gap: 6px; }
.fpt-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; }
.fpt-line { font-variant-numeric: tabular-nums; }
.fpt-sec { display: grid; gap: 2px; padding-top: 6px; border-top: 1px solid var(--line); }
.fpt-sec > .muted { font-size: 11px; }
.fpt-money.up { color: #1a9a5a; } .fpt-money.down { color: var(--flow-drop); }
.fpt-warn { color: var(--warn); }
.fpt-foot { font-size: 11px; }
