/* ChatFlow Funnels and Funnel Lab views (#funnels-view, #funnel-lab-view, design A).
   Needs tokens.css, components.css, chrome.css (.cf-page) and analytics.css first: the
   two views share the Analytics frame, so the Period control (.an-period), the status
   line (.an-error), the KPI card (.an-kpis, .an-hero, .an-tile, .an-grid, .an-cell), the
   provenance note (.an-note), the table (.an-scroll, .an-table) and the series keys
   (.k-leads, .k-revenue) come from there. Colours come from tokens only, so night needs
   no rules here.

   Status is a word on a chip in the colour language (COLOUR-TOKENS): Goal Met, Converted and
   Self-Liquidating green, Below Goal and Pending amber, Below Breakeven and Paying to Acquire
   red, Auto and IT Only blue, Not Counted grey. A figure with a threshold takes the same
   colour (.num-ok / .num-warn / .num-bad): every ROAS against the 2x goal and 1x breakeven,
   a funnel's CR % against 3% and 1.5%. Bars are marks in the chart palette: visitors and
   leads in --chart-leads, deposits and paying subscribers in --chart-revenue. The KPI cards,
   the funnel cards and the tables are raised surfaces (--shadow-card). */

/* ---------- Shared: page header controls, section titles ---------- */
.fn-head .page-head-text,
.fl-head .page-head-text { flex: 1 1 320px; }
/* a toggle on the neutral button: pressed = the selected look of the segmented control */
.fn-toggle[aria-pressed="true"] { background: var(--reply-tint); box-shadow: inset 0 0 0 1px var(--reply); }
.fn-block-title {
  margin: 0;
  font: var(--fw-semibold) var(--fs-body)/var(--lh-body) var(--font);
  color: var(--ink);
}
.fn-hint { margin: 4px 0 0; max-width: 88ch; }
.fn-prov { margin: 4px 0 0; max-width: 88ch; }
.fn-kpis > .an-grid:first-child { border-top: 0; }
.fn-scroll { max-height: none; }
.fn-empty { margin: 0; padding: 16px; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink-2); }
.fn-skel { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.fn-skel .an-skel { height: 12px; }
.fn-skel .an-skel:nth-child(2n) { width: 72%; }
.fn-skel .an-skel:nth-child(3n) { width: 48%; }

/* ---------- Funnels list (Sites > Funnels): one row per funnel, a click opens its page ---------- */
.fn-index-row { cursor: pointer; }
.fn-index-row:hover > * { background: var(--hover); }
.fn-index .fn-open { font-weight: var(--fw-semibold); color: var(--ink); text-decoration: none; }
.fn-index .fn-open:hover { text-decoration: underline; }
.fn-index-domain { display: block; margin-top: 2px; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink-2); }
.fn-index-go { width: 32px; color: var(--ink-2); }
/* A funnel's page: a way back to the list, its name and domain as the page title */
.fn-back { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 6px; font: var(--fw-semibold) var(--fs-label)/var(--lh-label) var(--font); color: var(--reply); text-decoration: none; }
.fn-back:hover { text-decoration: underline; }
.fn-back[hidden], .fn-domain[hidden], #fn-it-chip[hidden], .fn-prov[hidden] { display: none; }
.fn-title-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
/* Its tabs, Stats, Backend, Pending Carts: the Tracker's tab look (ui/tracker.css .tr-tabs), as links */
.fn-tabs { margin: 0 0 20px; }
.fn-tabs .tr-tab { display: inline-flex; align-items: center; text-decoration: none; }
.fn-tabs .tr-tab[aria-current="page"] { color: var(--reply); border-bottom-color: var(--reply); }
.fn-panel[hidden] { display: none; }

/* ---------- Funnels: one section per funnel ---------- */
.fn-list { display: flex; flex-direction: column; gap: 32px; }
.fn-funnel-head { margin-bottom: 12px; }
.fn-funnel-head .section-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.fn-domain {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  color: var(--reply);
  font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font);
  text-decoration: none;
}
.fn-domain:hover { text-decoration: underline; }
.fn-domain:focus-visible,
.fn-step-link:focus-visible,
.fn-phone:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.fn-block { margin-top: 24px; }
.fn-block > .section-head { min-height: 0; }
.fn-block .an-scroll,
.fn-block .card,
.fn-block .an-error { margin-top: 12px; }
.fn-block .an-error { margin-bottom: 0; }

/* steps: the Step column carries the number, the page link and the proportional bar */
.fn-steps .fn-step { min-width: 260px; padding-top: 8px; padding-bottom: 8px; }
.fn-step-line { display: flex; align-items: baseline; gap: 10px; }
.fn-n { flex: none; min-width: 16px; color: var(--ink-2); font-size: var(--fs-caption); text-align: right; }
.fn-step-link { display: inline-flex; align-items: center; gap: 4px; min-width: 0; color: var(--ink); font-weight: var(--fw-semibold); text-decoration: none; }
.fn-step-link .ic { flex: none; color: var(--ink-2); }
.fn-step-link:hover { color: var(--reply); }
.fn-step-link:hover .ic { color: var(--reply); }
.fn-track { display: block; height: 4px; margin: 6px 0 0 26px; border-radius: 2px; background: var(--fill); overflow: hidden; }
.fn-bar { display: block; height: 100%; border-radius: 2px; background: currentColor; }
.an-table.fn-steps td.muted { color: var(--ink-2); }

/* backend list */
.fn-bk .fn-note { max-width: 420px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.fn-bk .fn-type { display: inline-flex; align-items: center; gap: 6px; }
.fn-bk tr.is-off > * { color: var(--ink-2); }
.fn-bk tr.is-off .fn-amt { text-decoration: line-through; }
.fn-bk .fn-act { width: 1%; }
.fn-bk .fn-act .btn,
.fn-bk .fn-act .icon-btn { vertical-align: middle; }
.fn-add {
  display: grid;
  grid-template-columns: 160px 160px 150px minmax(200px, 1fr) auto;
  align-items: start;
  gap: 12px;
  margin-top: 12px;
  padding: 16px;
}
.fn-add .btn { margin-top: 24px; }
.fn-add .field-error:empty { display: none; }

/* pending carts */
.fn-pc .fn-name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.fn-pc .fn-name .chip { margin-left: 6px; vertical-align: 1px; }
.fn-pc tr.is-test > * { color: var(--ink-2); }
.fn-pc .fn-group > th { height: 28px; background: var(--fill); color: var(--ink-2); font: var(--fw-semibold) var(--fs-caption)/var(--lh-caption) var(--font); text-align: left; }
.fn-phone { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; color: var(--reply); text-decoration: none; }
.fn-phone:hover { text-decoration: underline; }
.fn-phone .ic { color: currentColor; }

/* ---------- Funnel Lab ---------- */
.fl-geo { gap: 8px; }
.fl-geo-label { font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink-2); }
.fl-geo .seg > button { min-width: 56px; }
.fl-kpis { margin-bottom: 24px; }
.fl-compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 16px; }
.fl-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.fl-card-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.fl-card-title { margin: 0; font: var(--fw-semibold) var(--fs-body)/var(--lh-body) var(--font); color: var(--ink); }
.fl-card-cap { font: var(--fw-regular) var(--fs-caption)/var(--lh-caption) var(--font); color: var(--ink-2); }
.fl-stages { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.fl-stage dt { font: var(--fw-regular) var(--fs-caption)/var(--lh-caption) var(--font); color: var(--ink-2); }
.fl-stage dd { margin: 0; }
.fl-stage .fl-num { margin-top: 2px; font: var(--fw-semibold) var(--fs-section)/var(--lh-section) var(--font); color: var(--ink); font-variant-numeric: tabular-nums; }
.fl-stage .fl-stage-note { font: var(--fw-regular) var(--fs-caption)/var(--lh-caption) var(--font); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.fl-stage .fl-track { display: block; height: 4px; margin-top: 6px; border-radius: 2px; background: var(--fill); overflow: hidden; }
.fl-bar { display: block; max-width: 100%; height: 100%; border-radius: 2px; background: currentColor; }
.fl-foot {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: auto 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.fl-foot dt,
.fl-facts dt { font: var(--fw-regular) var(--fs-caption)/var(--lh-caption) var(--font); color: var(--ink-2); }
.fl-foot dd,
.fl-facts dd { margin: 2px 0 0; font: var(--fw-semibold) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fl-foot dd .chip,
.fl-facts dd .chip,
.fl-verdict .chip { vertical-align: 1px; }
.fl-foot .fl-wide { grid-column: 1 / -1; }
.fl-foot .fl-note { font-weight: var(--fw-regular); color: var(--ink-2); }
/* A ROAS figure in its threshold colour (the ink above outranks the bare .num-* helpers) */
.fl-foot dd.num-ok, .fl-verdict b.num-ok { color: var(--ok); }
.fl-foot dd.num-warn, .fl-verdict b.num-warn { color: var(--warn); }
.fl-foot dd.num-bad, .fl-verdict b.num-bad { color: var(--bad); }

/* the model: one card of fields, sliders two or three to a row */
.fl-model { margin-top: 24px; padding: 16px; }
.fl-model .fn-block-title { margin-bottom: 12px; }
.fl-leads-field { max-width: 200px; margin-bottom: 16px; }
.fl-sliders { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 24px; }
.fl-group { min-width: 0; margin: 0; padding: 0; border: 0; }
.fl-group + .fl-group { margin-top: 20px; }
.fl-group legend { margin-bottom: 8px; padding: 0; font: var(--fw-semibold) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink); }
.fl-group legend span { font-weight: var(--fw-regular); color: var(--ink-2); }
.fl-range { gap: 2px; }
.fl-range-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.fl-range-head .field-label { font-weight: var(--fw-regular); }
.fl-range-head .fl-hint { color: var(--ink-2); }
.fl-out { flex: none; font: var(--fw-semibold) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink); font-variant-numeric: tabular-nums; }
/* the slider rides on the field component (.input keeps the old night layer off it), with
   the field's box removed: the native track, thumb in the one interactive blue */
.input.fl-slider {
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  accent-color: var(--reply);
  cursor: pointer;
}
.input.fl-slider:focus { border: 0; box-shadow: none; }
.input.fl-slider:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* MRS low-ticket */
.fl-mrs { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line); }
.fl-mrs .section-sub { margin: 0 0 8px; }
.fl-mrs-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; }
.fl-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px 16px; margin: 0; }
.fl-facts .fl-wide { grid-column: 1 / -1; }
.fl-facts .fl-note { font-weight: var(--fw-regular); color: var(--ink-2); }
.fl-verdict { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin: 0; padding-top: 12px; border-top: 1px solid var(--line); }
.fl-verdict b { font: var(--fw-semibold) var(--fs-body)/var(--lh-body) var(--font); color: var(--ink); font-variant-numeric: tabular-nums; }
.fl-verdict .chip:empty { display: none; }
.fl-foot-note { margin: 16px 0 0; }

@media (prefers-reduced-motion: reduce) {
  .fn-skel .an-skel { animation: none; }
}

/* ---------- Phones ---------- */
@media (max-width: 767px) {
  .fn-head .page-actions,
  .fl-head .page-actions { flex: 1 1 100%; }
  .fl-geo .seg { flex: 1 1 auto; }
  .fl-geo .seg > button { min-width: 0; }
  .fn-add { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; }
  .fn-add .fn-add-note { grid-column: 1 / -1; }
  .fn-add .btn { grid-column: 1 / -1; margin-top: 0; }
  .fn-steps .fn-step { min-width: 200px; }
  .fl-sliders { grid-template-columns: minmax(0, 1fr); }
  .fl-card { padding: 12px; }
  .fl-model { padding: 12px; }
}
@media (pointer: coarse) {
  .fn-phone,
  .fn-domain { min-height: 44px; }
  .input.fl-slider { height: 44px; }
}

/* ---------- Colour pass: the words beside coloured figures ---------- */
/* the Steps table's To Next Step bands, named beside the title as the Ads sections name theirs */
.fn-steps-note { flex: 1 1 auto; margin: 0; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink-2); }
/* Funnel Lab facts (EPC, CPA, LP to sale) in their threshold colour */
.fl-facts dd.num-ok { color: var(--ok); }
.fl-facts dd.num-warn { color: var(--warn); }
.fl-facts dd.num-bad { color: var(--bad); }
/* a word chip after a Funnel Lab figure; a long word wraps under it, flush left */
.fl-foot dd:has(> .cf-word),
.fl-facts dd:has(> .cf-word) { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
/* the Watch / Low word before a To Next Step share (no text node between them: the gap is here) */
.fn-steps td > .cf-word { margin-right: 6px; }

/* Folders of the Funnels list (2026-10-14): the table sits inside the folder card, so it drops its own
   frame; the More column is as narrow as its button; an archived funnel's steps, name and address. */
.fn-folds .fn-scroll { border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.fn-index-more { width: 44px; padding-top: 2px; padding-bottom: 2px; }
.fn-index-row[draggable="true"] { -webkit-user-drag: element; }
.fn-archive-steps .fn-path { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
#fn-arch-chip[hidden], #fn-actions[hidden], #fn-new-folder[hidden], #fn-sub[hidden] { display: none; }
/* In folders the tables are stacked: one column grid for all of them, so their columns line up */
.fn-folds .fn-index { table-layout: fixed; width: 100%; }
.fn-folds .fn-index th:first-child { width: 34%; }
.fn-folds .fn-index th:nth-last-child(2), .fn-folds .fn-index th:last-child { width: 44px; }
@media (max-width: 767px) { .fn-folds .fn-index { table-layout: auto; min-width: 640px; } }
