/* Consultgenix cfo-strategy-portal v1: styles written during parse, page script after DOM ready */
document.write("\n");
(function(){function run(){
(function(){
var FORM_ID = "0FWhemBh07LrbrMm5F0I";
var FORM_URL = "https://api.leadconnectorhq.com/widget/form/" + FORM_ID;
function $(id){ return document.getElementById(id); }
function esc(s){ return String(s).replace(/[&<>"]/g, function(c){ return {"&":"&","<":"<",">":">",'"':"""}[c]; }); }
function usd(v){ var a = Math.abs(v); var s = a >= 1e6 ? "$" + (a/1e6).toFixed(2) + "M" : a >= 1e3 ? "$" + Math.round(a/1e3).toLocaleString("en-US") + "K" : "$" + Math.round(a); return (v < 0 ? "-" : "") + s; }
function full(v){ return (v < 0 ? "-$" : "$") + Math.round(Math.abs(v)).toLocaleString("en-US"); }
function m1(v){ var a = Math.abs(v); var s = a >= 1e6 ? "$" + (a/1e6).toFixed(1) + "M" : "$" + Math.round(a/1e3) + "K"; return (v < 0 ? "-" : "") + s; }
function pct(v, d){ return (v * 100).toFixed(d === undefined ? 1 : d) + "%"; }
/* Sample Co. data. Identical to the Strategy Portal tab of the AI CFO Dashboard Kit. */
var CH = [["Direct sales",9800000,10650000,11000000],["Distributors",7400000,7250000,7900000],["E-commerce",2900000,3640000,3500000],["Service contracts",2100000,2460000,2600000]];
var REG = ["Florida","Texas","Georgia","Carolinas"];
var REV = [9100000,6700000,4600000,3600000], GP = [3550000,2480000,1790000,1290000], OPX = [1920000,1610000,1150000,1020000];
var OPX_PY = [1870000,1560000,1120000,1000000];
var CAT = [["Personnel",3180000,3250000],["Technology",560000,620000],["Facilities",530000,540000],["Sales and marketing",650000,690000],["Professional services",360000,330000],["Other",270000,270000]];
var PY = {rev:22200000, gp:8280000, opx:5550000};
var DEF = {price:2, dist:100, tx:1, car:5, ecom:5, target:3700000};
function sum(a){ return a.reduce(function(x,y){ return x + y; }, 0); }
var T = {rev:sum(REV), gp:sum(GP), opx:sum(OPX)}; T.ebitda = T.gp - T.opx; T.gm = T.gp / T.rev;
PY.ebitda = PY.gp - PY.opx;
function inputs(){
return {price:+$("a-price").value, dist:+$("a-dist").value, tx:+$("a-tx").value, car:+$("a-car").value, ecom:+$("a-ecom").value, target:+$("a-target").value || 0};
}
function levers(a){
var L = [
["Price increase on Direct sales", CH[0][2] * a.price / 100],
["Recover Distributor volume", Math.max(0, CH[1][1] - CH[1][2]) * a.dist / 100 * T.gm],
["Gross margin points, Texas", REV[1] * a.tx / 100],
["Opex cut, Carolinas", OPX[3] * a.car / 100],
["Further E-commerce growth", CH[2][2] * a.ecom / 100 * T.gm]
];
var gap = T.ebitda - a.target, cum = 0, closedAt = -1;
L = L.map(function(l, i){ cum += l[1]; if (closedAt < 0 && gap < 0 && gap + cum >= 0) closedAt = i; return {name:l[0], impact:l[1], cum:cum, left:Math.min(0, gap + cum)}; });
return {list:L, gap:gap, total:cum, closedAt:closedAt};
}
/* ---------- tiny SVG charts ---------- */
var W = 520, H = 280, PAD = {l:58, r:12, t:14, b:46};
function niceMax(v){ var p = Math.pow(10, Math.floor(Math.log10(v))); var m = Math.ceil(v / p * 2) / 2 * p; return m; }
function axisY(max, fmt){
var s = "", n = 4;
for (var i = 0; i <= n; i++) {
var v = max * i / n, y = PAD.t + (H - PAD.t - PAD.b) * (1 - i / n);
s += ' ';
s += '' + esc(fmt(v)) + ' ';
}
return s;
}
function grouped(el, cats, series, colors, names){
var max = niceMax(Math.max.apply(null, series.map(function(s){ return Math.max.apply(null, s); })));
var iw = W - PAD.l - PAD.r, ih = H - PAD.t - PAD.b, gw = iw / cats.length, bw = Math.min(26, (gw - 14) / series.length);
var s = '' + axisY(max, usd);
cats.forEach(function(c, i){
var x0 = PAD.l + gw * i + (gw - bw * series.length) / 2;
series.forEach(function(ser, j){
var h = ser[i] / max * ih;
s += '' + esc(c + ", " + names[j] + ": " + full(ser[i])) + ' ';
});
s += '' + esc(c) + ' ';
});
s += " ";
s += '
' + names.map(function(n, j){ return ' ' + esc(n) + " "; }).join("") + "
";
el.innerHTML = s;
}
function hbars(el, rows, opts){
/* rows: [label, value, color]; opts: {min,max,fmt,ref} */
var rh = 34, h = rows.length * rh + 30, lw = 140, iw = W - lw - 70;
var min = opts.min, max = opts.max, sc = function(v){ return lw + (v - min) / (max - min) * iw; };
var s = '';
if (opts.ref !== undefined) s += '' + esc(opts.refLabel || opts.fmt(opts.ref)) + ' ';
rows.forEach(function(r, i){
var y = 8 + i * rh, x0 = sc(Math.max(min, Math.min(0, r[1]) )), x1 = sc(Math.max(0, r[1]));
if (opts.fromMin) { x0 = sc(min); x1 = sc(Math.min(max, r[1])); }
s += '' + esc(r[0]) + ' ';
s += '' + esc(r[0] + ": " + opts.fmt(r[1])) + ' ';
s += '' + esc(opts.fmt(r[1])) + ' ';
});
el.innerHTML = s + " ";
}
function waterfall(el, steps){
/* steps: [label, value, kind] kind: "start" | "delta" | "total" */
var max = niceMax(Math.max.apply(null, steps.map(function(s){ return Math.abs(s[1]); })));
var iw = W - PAD.l - PAD.r, ih = H - PAD.t - PAD.b, gw = iw / steps.length, bw = gw * 0.56, run = 0;
var y = function(v){ return PAD.t + ih - v / max * ih; };
var s = '' + axisY(max, usd);
steps.forEach(function(st, i){
var a, b, col;
if (st[2] === "delta") { a = run; b = run + st[1]; run = b; col = st[1] < 0 ? "#c23b3b" : "#1e8e5a"; }
else { a = 0; b = st[1]; run = st[1]; col = st[2] === "start" ? "#0f2338" : "#c9a24a"; }
var top = y(Math.max(a, b)), hh = Math.abs(y(a) - y(b)), x = PAD.l + gw * i + (gw - bw) / 2;
s += '' + esc(st[0] + ": " + full(st[1])) + ' ';
s += '' + esc(usd(st[1])) + ' ';
s += '' + esc(st[0]) + ' ';
});
el.innerHTML = s + " ";
}
/* ---------- views ---------- */
var tab = "rev";
function kpi(l, v, d, cls){ return '' + esc(l) + '
' + esc(v) + '
' + esc(d) + "
"; }
function render(){
var a = inputs(), lv = levers(a);
$("v-price").textContent = a.price + "%"; $("v-dist").textContent = a.dist + "%"; $("v-tx").textContent = a.tx + " pts";
$("v-car").textContent = a.car + "%"; $("v-ecom").textContent = a.ecom + "%";
var cy = sum(CH.map(function(c){ return c[2]; })), tg = sum(CH.map(function(c){ return c[3]; })), py = sum(CH.map(function(c){ return c[1]; }));
var after = T.ebitda + lv.total, gapAfter = after - a.target, k = $("sp-kpis");
if (tab === "rev") {
var worst = CH.slice().sort(function(x, y){ return (x[2] - x[3]) - (y[2] - y[3]); })[0];
k.innerHTML = kpi("Revenue", usd(cy), "+" + pct(cy / py - 1) + " vs prior year", "up")
+ kpi("Target", usd(tg), pct(cy / tg) + " reached", cy >= tg ? "up" : "dn")
+ kpi("Gap to target", usd(cy - tg), cy >= tg ? "Ahead of plan" : "Behind plan", cy >= tg ? "up" : "dn")
+ kpi("Weakest channel", worst[0], usd(worst[2] - worst[3]) + " vs target", "dn");
grouped($("c-rev"), CH.map(function(c){ return c[0]; }), [CH.map(function(c){ return c[1]; }), CH.map(function(c){ return c[2]; }), CH.map(function(c){ return c[3]; })], ["#9aa3ab", "#0f2338", "#c9a24a"], ["Prior year", "Current year", "Target"]);
hbars($("c-prog"), CH.map(function(c){ var r = c[2] / c[3]; return [c[0], r, r >= 1 ? "#1e8e5a" : "#c23b3b"]; }), {min:0.8, max:1.1, fmt:function(v){ return pct(v); }, ref:1, refLabel:"Target", fromMin:true, label:"Share of target reached by channel"});
} else if (tab === "cost") {
var opy = sum(OPX_PY), big = CAT.slice().sort(function(x, y){ return (y[2] - y[1]) - (x[2] - x[1]); })[0];
k.innerHTML = kpi("Operating expenses", usd(T.opx), "+" + pct(T.opx / opy - 1) + " vs prior year", "dn")
+ kpi("Opex as % of revenue", pct(T.opx / T.rev), "Prior year " + pct(PY.opx / PY.rev), T.opx / T.rev <= PY.opx / PY.rev ? "up" : "dn")
+ kpi("Largest region", REG[0], usd(OPX[0]) + " of opex", "")
+ kpi("Biggest increase", big[0], "+" + usd(big[2] - big[1]) + " vs prior year", "dn");
grouped($("c-oreg"), REG, [OPX_PY, OPX], ["#9aa3ab", "#0f2338"], ["Prior year", "Current year"]);
var deltas = CAT.map(function(c){ var d = c[2] - c[1]; return [c[0], d, d > 0 ? "#c23b3b" : "#1e8e5a"]; });
var m = Math.max.apply(null, deltas.map(function(d){ return Math.abs(d[1]); })) * 1.15;
hbars($("c-ocat"), deltas, {min:-m, max:m, fmt:function(v){ return (v > 0 ? "+" : "") + usd(v); }, ref:0, refLabel:"No change", label:"Change in operating expenses by category"});
} else {
k.innerHTML = kpi("EBITDA", usd(T.ebitda), pct(T.ebitda / T.rev) + " margin, prior year " + usd(PY.ebitda), "up")
+ kpi("Target", usd(a.target), lv.gap >= 0 ? "Already met" : usd(lv.gap) + " gap", lv.gap >= 0 ? "up" : "dn")
+ kpi("Levers add", usd(lv.total), "From the assumptions", "up")
+ kpi("After levers", usd(after), gapAfter >= 0 ? "Gap closed" : usd(gapAfter) + " still open", gapAfter >= 0 ? "up" : "dn");
waterfall($("c-wf"), [["Revenue", T.rev, "start"], ["COGS", -(T.rev - T.gp), "delta"], ["Gross profit", T.gp, "total"], ["Opex", -T.opx, "delta"], ["EBITDA", T.ebitda, "total"]]);
var rows = [["Revenue", REV, T.rev, PY.rev], ["Gross profit", GP, T.gp, PY.gp], ["Gross margin", null], ["Operating expenses", OPX, T.opx, PY.opx], ["EBITDA", null], ["EBITDA margin", null]];
var h = "Line " + REG.map(function(r){ return "" + esc(r) + " "; }).join("") + "Total PY ";
var eb = REG.map(function(r, i){ return GP[i] - OPX[i]; });
rows.forEach(function(r){
var cells;
if (r[0] === "Gross margin") cells = REG.map(function(x, i){ return pct(GP[i] / REV[i]); }).concat([pct(T.gm), pct(PY.gp / PY.rev)]);
else if (r[0] === "EBITDA") cells = eb.map(m1).concat([m1(T.ebitda), m1(PY.ebitda)]);
else if (r[0] === "EBITDA margin") cells = eb.map(function(e, i){ return pct(e / REV[i]); }).concat([pct(T.ebitda / T.rev), pct(PY.ebitda / PY.rev)]);
else cells = r[1].map(m1).concat([m1(r[2]), m1(r[3])]);
h += '" + esc(r[0]) + " " + cells.map(function(c){ return "" + esc(c) + " "; }).join("") + " ";
});
$("t-reg").innerHTML = h;
var lh = "Lever EBITDA Cumulative Gap left ";
lv.list.forEach(function(l, i){
var closes = (i === lv.closedAt);
lh += "" + esc(l.name) + (closes ? ' closes it ' : "") + " " + esc(usd(l.impact)) + " " + esc(usd(l.cum)) + ' ' + esc(l.left < 0 ? usd(l.left) : "closed") + " ";
});
$("t-lev").innerHTML = lh;
var weakest = CH.slice().sort(function(x, y){ return (x[2] - x[3]) - (y[2] - y[3]); })[0];
var lowReg = REG.map(function(r, i){ return [r, eb[i] / REV[i]]; }).sort(function(x, y){ return x[1] - y[1]; })[0];
var d = [];
d.push("Revenue is " + full(cy) + ", " + full(Math.abs(cy - tg)) + (cy < tg ? " short of" : " ahead of") + " target (" + pct(cy / tg) + " of plan).");
d.push("Weakest channel: " + weakest[0] + ", " + full(Math.abs(weakest[2] - weakest[3])) + " below target and below last year. Fix or replace the volume before pushing price there.");
d.push("Lowest regional margin: " + lowReg[0] + " at " + pct(lowReg[1]) + " EBITDA margin. Its cost base is the first place to look.");
if (lv.gap >= 0) d.push("EBITDA already meets the target. Use the levers to build headroom, not to chase a number.");
else if (lv.closedAt >= 0) d.push("The first " + (lv.closedAt + 1) + " lever" + (lv.closedAt ? "s close" : " closes") + " the " + full(-lv.gap) + " gap. The decision is which of them leadership will actually commit to, with an owner and a date.");
else d.push("All five levers together leave " + full(-gapAfter) + " open. The target needs a bigger move or a reset, and it is better to say so now than in month eleven.");
$("sp-diag").innerHTML = d.map(function(x){ return "" + esc(x) + " "; }).join("");
}
}
Array.prototype.forEach.call(document.querySelectorAll(".sp-tabs button"), function(b){
b.addEventListener("click", function(){
tab = b.getAttribute("data-tab");
Array.prototype.forEach.call(document.querySelectorAll(".sp-tabs button"), function(x){ x.setAttribute("aria-selected", x === b ? "true" : "false"); });
Array.prototype.forEach.call(document.querySelectorAll(".sp-panel"), function(p){ p.hidden = p.getAttribute("data-panel") !== tab; });
render();
});
});
$("sp-toggle").addEventListener("click", function(){
var o = $("sp-ass").hidden; $("sp-ass").hidden = !o; this.setAttribute("aria-expanded", o ? "true" : "false");
if (o && tab !== "pl") { document.querySelector('.sp-tabs button[data-tab="pl"]').click(); }
});
["a-price","a-dist","a-tx","a-car","a-ecom","a-target"].forEach(function(id){ $(id).addEventListener("input", render); });
$("sp-reset").addEventListener("click", function(){
$("a-price").value = DEF.price; $("a-dist").value = DEF.dist; $("a-tx").value = DEF.tx; $("a-car").value = DEF.car; $("a-ecom").value = DEF.ecom; $("a-target").value = DEF.target; render();
});
function mountForm(){
var wrap = $("sp-form");
if (!wrap) return;
if (!FORM_ID || FORM_ID.charAt(0) === "{") {
wrap.innerHTML = 'The workbook is sent by email. While the request form is being set up, ask for it on a 30-minute call and I will send it the same day.
Book a 30-minute call ';
$("sp-form-note").textContent = "";
return;
}
var f = document.createElement("iframe");
f.src = FORM_URL + "?cgx_source_page=" + encodeURIComponent("cfo-strategy-portal") + "&cgx_lead_magnet=" + encodeURIComponent("AI CFO Dashboard Kit workbook");
f.id = "inline-" + FORM_ID; f.title = "Send me the AI CFO Dashboard Kit";
f.style.cssText = "width:100%;min-height:420px;border:0";
f.setAttribute("data-layout", '{"id":"INLINE"}'); f.setAttribute("data-trigger-type", "alwaysShow");
f.setAttribute("data-activation-type", "alwaysActivated"); f.setAttribute("data-deactivation-type", "neverDeactivate");
f.setAttribute("data-form-name", "CGX - AI CFO Dashboard Kit"); f.setAttribute("data-layout-iframe-id", "inline-" + FORM_ID); f.setAttribute("data-form-id", FORM_ID);
wrap.appendChild(f);
if (!document.getElementById("ghl-embed-js")) { var sc = document.createElement("script"); sc.id = "ghl-embed-js"; sc.src = "https://link.msgsndr.com/js/form_embed.js"; document.body.appendChild(sc); }
}
render(); mountForm();
})();
}
if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',run);}else{run();}})();