// custom.jsx — maturation curve tiles, cardiology cut, collection drag,
// pull quotes, and projection section. Built for reports where no reusable
// component already existed for the shape.

// ─────────────────────────── Pull Quote ───────────────────────────
// Matches the blue-left-border italic callout pattern used in other
// Superscript reports (e.g. Patient Collections Report chart annotations).
const PullQuote = ({ children }) => (
  <div style={{
    borderLeft: `3px solid ${THEME.primary}`,
    background: "#F9F9F9",
    padding: "20px 24px",
    margin: "24px 0",
  }}>
    <span style={{
      fontFamily: "Suisse Intl", fontStyle: "italic", fontWeight: 400,
      fontSize: 20, lineHeight: 1.4, letterSpacing: "-0.01em", color: "#000",
    }}>{children}</span>
  </div>
);
window.PullQuote = PullQuote;

// Wraps a number/phrase in the blue highlight color — use sparingly, on the
// one or two figures a PullQuote is actually making a point about.
const PQHighlight = ({ children }) => (
  <strong style={{ color: THEME.primary, fontStyle: "italic", fontWeight: 700 }}>{children}</strong>
);
window.PQHighlight = PQHighlight;

// ─────────────────────────── AR Acceleration ───────────────────────────
// Practice's real D0-D120 curve vs a composite "with Superscript" overlay
// derived from live case studies (North Shore Gastro 62% D0 upfront,
// Knownwell +10.2pp yield, Hudson Medical) — same composite curve used in
// other ROI reports, not MSPB-specific.
// WARNING — hardcoded composite of North Shore Gastro (D0 upfront), Knownwell (yield
// lift) and Hudson Medical. NOT cohort data and NOT specific to the practice in
// data.js. ARAcceleration below draws this as a "WITH SUPERSCRIPT" line, which asserts
// a projected curve the report has not measured. For a cohort-benchmarked curve use
// CollectionCurve + BenchmarkChart in charts.jsx, which read the real quartiles from
// data.js (collection_curve.cohort_p25/p50/p75). Only use ARAcceleration if you intend
// the composite overlay and have said so in the copy.
const SS_CURVE = [62, 78, 87, 91, 93, 95]; // D0, D7, D30, D60, D90, D120

const ARAcceleration = () => {
  const D = window.ROI_DATA.collection_curve;
  const ref = React.useRef(null);
  const seen = useInView(ref, 0);
  const p = useProgress(1400, seen);
  const [hover, setHover] = React.useState(null);

  const W = 880, H = 360;
  const PAD = { l: 56, r: 150, t: 24, b: 48 };
  const innerW = W - PAD.l - PAD.r;
  const innerH = H - PAD.t - PAD.b;
  const xMax = 120;
  const xS = (d) => PAD.l + (d / xMax) * innerW;
  const yS = (v) => PAD.t + (1 - v / 100) * innerH;

  const buildPath = (vals) => D.days.map((d, i) => `${i === 0 ? "M" : "L"} ${xS(d)} ${yS(vals[i])}`).join(" ");
  const practicePath = buildPath(D.practice);
  const practiceRef = React.useRef(null);
  const [practiceLen, setPracticeLen] = React.useState(2000);
  React.useEffect(() => { if (practiceRef.current) setPracticeLen(practiceRef.current.getTotalLength()); }, []);

  const yTicks = [0, 25, 50, 75, 100];
  const practiceName = window.ROI_DATA.practice.split(" ")[0].toUpperCase();

  return (
    <div ref={ref}>
      <svg viewBox={`0 0 ${W} ${H}`} width="100%" overflow="visible" style={{ display: "block", border: "1px solid #000", background: "#fff" }}>
        {yTicks.map(t => (
          <g key={t}>
            <line x1={PAD.l} x2={W - PAD.r} y1={yS(t)} y2={yS(t)} stroke="#E1E1E1" strokeWidth="0.5" strokeDasharray={t === 0 ? "" : "2,3"} />
            <text x={PAD.l - 8} y={yS(t) + 3} fontSize="9" fontFamily="Suisse Intl Mono, JetBrains Mono, monospace" fontWeight="700" textAnchor="end" fill="#666">{t}%</text>
          </g>
        ))}
        {D.days.map(d => (
          <g key={d}>
            <line x1={xS(d)} x2={xS(d)} y1={PAD.t} y2={H - PAD.b} stroke="#F1F1F1" strokeWidth="0.5" />
            <text x={xS(d)} y={H - PAD.b + 18} fontSize="9" fontFamily="Suisse Intl Mono, JetBrains Mono, monospace" fontWeight="700" textAnchor="middle" fill="#666">D{d}</text>
          </g>
        ))}

        <path ref={practiceRef} d={practicePath} fill="none" stroke="#000" strokeWidth="2"
              strokeDasharray={practiceLen} strokeDashoffset={practiceLen * (1 - p)} />

        <path d={buildPath(SS_CURVE)} fill="none" stroke={THEME.proj} strokeWidth="1.5" strokeDasharray="5,3" opacity={p > 0.4 ? p : 0} />
        {D.days.map((d, i) => (
          <rect key={`ss-${d}`} x={xS(d) - 3} y={yS(SS_CURVE[i]) - 3} width={p > 0.7 ? 6 : 0} height={p > 0.7 ? 6 : 0} fill={THEME.proj} />
        ))}

        {/* D0 upfront capture annotation */}
        <g opacity={p > 0.5 ? 1 : 0} style={{ transition: "opacity 0.4s" }}>
          <line x1={xS(0)} x2={xS(0)} y1={yS(SS_CURVE[0]) + 5} y2={yS(D.practice[0]) - 5} stroke={THEME.proj} strokeWidth="1" strokeDasharray="2,2" />
          <text x={xS(0) + 10} y={yS(SS_CURVE[0]) + 16} fontSize="7.5" fontFamily="Suisse Intl Mono, JetBrains Mono, monospace" fontWeight="700" fill={THEME.proj}>
            <tspan x={xS(0) + 10} dy="0">WITH SUPERSCRIPT</tspan>
            <tspan x={xS(0) + 10} dy="10">{SS_CURVE[0]}% COLLECTED DAY-OF</tspan>
            <tspan x={xS(0) + 10} dy="10">vs {D.practice[0]}% today</tspan>
          </text>
        </g>

        {D.days.map((d, i) => (
          <g key={d}>
            <rect x={xS(d) - 3} y={yS(D.practice[i]) - 3} width={p > 0.7 ? 6 : 0} height={p > 0.7 ? 6 : 0} fill="#000" stroke="#000" strokeWidth="1" />
            <rect x={xS(d) - 24} y={PAD.t} width={48} height={innerH} fill="transparent"
                  onMouseEnter={() => setHover(i)} onMouseLeave={() => setHover(null)} style={{ cursor: "crosshair" }} />
          </g>
        ))}

        <g opacity={p > 0.8 ? 1 : 0}>
          <line x1={xS(120) + 6} x2={xS(120) + 16} y1={yS(SS_CURVE[5])} y2={yS(SS_CURVE[5])} stroke={THEME.proj} strokeWidth="1" />
          <text x={xS(120) + 20} y={yS(SS_CURVE[5]) + 4} fontSize="10" fontFamily="Suisse Intl Mono, JetBrains Mono, monospace" fontWeight="700" fill={THEME.proj}>SUPERSCRIPT · {SS_CURVE[5]}%</text>
          <line x1={xS(120) + 6} x2={xS(120) + 16} y1={yS(D.practice[5])} y2={yS(D.practice[5])} stroke="#000" strokeWidth="1" />
          <text x={xS(120) + 20} y={yS(D.practice[5]) + 4} fontSize="10" fontFamily="Suisse Intl Mono, JetBrains Mono, monospace" fontWeight="700" fill="#000">{practiceName} · {D.practice[5]}%</text>
        </g>
      </svg>

      {/* Row-per-day layout: compact on any width, no card-grid dead space on mobile */}
      <div style={{ marginTop: 16, border: "1px solid #E1E1E1", background: "#fff" }}>
        <div style={{
          display: "flex", padding: "8px 14px", borderBottom: "1px solid #E1E1E1",
          background: "#F9F9F9", justifyContent: "space-between",
        }}>
          <Mono size={9} color="#999">DAY</Mono>
          <div style={{ display: "flex", gap: 24 }}>
            <Mono size={9} color="#999">BASELINE</Mono>
            <Mono size={9} color={THEME.proj}>WITH SUPERSCRIPT</Mono>
          </div>
        </div>
        {D.days.map((d, i) => (
          <div key={d} style={{
            display: "flex", alignItems: "baseline", justifyContent: "space-between",
            padding: "10px 14px",
            borderBottom: i < D.days.length - 1 ? "1px solid #E1E1E1" : "none",
          }}>
            <Mono color={THEME.primary} size={11}>DAY {d}</Mono>
            <div style={{ display: "flex", alignItems: "baseline", gap: 10 }}>
              <span style={{ fontFamily: "Suisse Intl", fontWeight: 400, fontSize: 18, letterSpacing: "-0.02em", color: "#000", minWidth: 52, textAlign: "right" }}>{D.practice[i]}%</span>
              <Mono size={10} color="#999">→</Mono>
              <span style={{ fontFamily: "Suisse Intl", fontWeight: 500, fontSize: 18, letterSpacing: "-0.02em", color: THEME.proj, minWidth: 42, textAlign: "right" }}>{SS_CURVE[i]}%</span>
            </div>
          </div>
        ))}
      </div>

      <Mono size={9} color="#999" style={{ display: "block", marginTop: 10 }}>
        SUPERSCRIPT OVERLAY: COMPOSITE OF NORTH SHORE GASTRO (D0 UPFRONT), KNOWNWELL (YIELD LIFT), HUDSON MEDICAL — NOT MSPB-SPECIFIC
      </Mono>
    </div>
  );
};
window.ARAcceleration = ARAcceleration;

// ─────────────────────────── Collection Curve Table (real cohort P75) ───────────────────────────
// Day-by-day practice actual vs. real cohort P75 — grounded companion to the
// composite "with Superscript" overlay above.
const CollectionCurveTable = () => {
  const D = window.ROI_DATA.collection_curve;
  return (
    <div style={{ marginTop: 16, display: "grid", gridTemplateColumns: `repeat(${D.days.length}, 1fr)`, border: "1px solid #E1E1E1", background: "#fff" }}>
      {D.days.map((d, i) => (
        <div key={d} style={{ padding: "10px 14px", borderRight: i < D.days.length - 1 ? "1px solid #E1E1E1" : "none" }}>
          <Mono color={THEME.primary} size={9}>DAY {d}</Mono>
          <div style={{ fontFamily: "Suisse Intl", fontWeight: 400, fontSize: 20, marginTop: 6, letterSpacing: "-0.02em", color: "#000" }}>{D.practice[i]}%</div>
          <Mono size={9} color="#999" style={{ marginTop: 3, display: "block" }}>P75: {D.cohort_p75[i]}%</Mono>
        </div>
      ))}
    </div>
  );
};
window.CollectionCurveTable = CollectionCurveTable;

// ─────────────────────────── Maturation Curve ───────────────────────────
const MaturationCurve = () => {
  const D = window.ROI_DATA.maturation_curve;
  const ref = React.useRef(null);
  const seen = useInView(ref, 0.2);
  const p = useProgress(1400, seen);

  const stages = [
    { key: "at_1mo", label: "1 MONTH", sub: "responsibility posted within 30 days of DOS" },
    { key: "at_4mo", label: "4 MONTHS", sub: "responsibility posted within 120 days of DOS" },
    { key: "at_present", label: "PRESENT", sub: "all responsibility through data cutoff" },
  ];

  return (
    <div ref={ref} style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", border: "1px solid #000", background: "#fff" }}>
      {stages.map((s, i) => {
        const row = D[s.key];
        const warn = row.rate_pct < 60;
        return (
          <div key={s.key} style={{
            padding: "20px 22px 22px",
            borderRight: i < stages.length - 1 ? "1px solid #000" : "none",
            minHeight: 180,
            display: "flex", flexDirection: "column", justifyContent: "space-between", gap: 12,
          }}>
            <div>
              <Mono color={THEME.primary} size={10}>{s.label}</Mono>
              <Mono color="#999" size={9} style={{ display: "block", marginTop: 4 }}>{s.sub}</Mono>
            </div>
            <div>
              <div style={{
                fontFamily: "Suisse Intl", fontWeight: 400, fontSize: 38, lineHeight: 1,
                letterSpacing: "-0.025em", marginBottom: 8,
                color: warn ? "#FF426F" : "#000",
              }}>{row.rate_pct.toFixed(2)}%</div>
              <div style={{ position: "relative", height: 8, background: "#F1F1F1", marginBottom: 8 }}>
                <div style={{
                  position: "absolute", left: 0, top: 0, bottom: 0,
                  width: `${row.rate_pct * p}%`,
                  background: warn ? THEME.accent : THEME.primary,
                  transition: "width 200ms linear",
                }} />
              </div>
              <Mono color="#666" size={11}>{fmt.usdAbbr(row.payments)} of {fmt.usdAbbr(row.responsibility)}</Mono>
            </div>
          </div>
        );
      })}
    </div>
  );
};
window.MaturationCurve = MaturationCurve;

// ─────────────────────────── Cardiology Cut ───────────────────────────
// Defined by rendering provider specialty, split into office-based vs
// hospital professional-fee work — see the comment on cardiology in data.js
// for why this replaced an earlier department-name-only cut.
const CardiologyCut = () => {
  const D = window.ROI_DATA.cardiology;
  const ref = React.useRef(null);
  const seen = useInView(ref, 0.15);
  const p = useProgress(1400, seen);
  const totalRate = useCounter(D.total.rate_pct, 1400, seen, 2);
  const officeRate = useCounter(D.office.rate_pct, 1400, seen, 2);
  const hospitalRate = useCounter(D.hospital.rate_pct, 1400, seen, 2);

  const DeptTable = (sub, warnThreshold) => {
    const maxResp = Math.max(...sub.departments.map(d => d.responsibility));
    return (
      <div style={{ border: "1px solid #000", background: "#fff" }}>
        <div style={{
          display: "grid", gridTemplateColumns: "1.6fr 1fr 1fr 0.8fr 1fr", columnGap: 14,
          padding: "10px 16px", background: "#000", borderBottom: "1px solid #000",
        }}>
          <Mono color={THEME.onDark} size={10}>DEPARTMENT</Mono>
          <Mono color={THEME.onDark} size={10} style={{ textAlign: "right" }}>RESPONSIBILITY</Mono>
          <Mono color={THEME.onDark} size={10} style={{ textAlign: "right" }}>COLLECTED</Mono>
          <Mono color={THEME.onDark} size={10} style={{ textAlign: "right" }}>RATE</Mono>
          <Mono color={THEME.onDark} size={10} style={{ textAlign: "right" }}>LEAKED REVENUE</Mono>
        </div>
        {sub.departments.map((row, i) => {
          const warn = row.rate_pct < warnThreshold;
          const barW = (row.responsibility / maxResp) * 100 * p;
          return (
            <div key={row.name} style={{
              display: "grid", gridTemplateColumns: "1.6fr 1fr 1fr 0.8fr 1fr", columnGap: 14,
              padding: "12px 16px", alignItems: "center",
              borderBottom: i < sub.departments.length - 1 ? "1px solid #E1E1E1" : "none",
              background: warn ? "rgba(255,66,111,0.03)" : "#fff",
            }}>
              <div style={{ fontSize: 13, fontWeight: 500, letterSpacing: "-0.005em" }}>{row.name}</div>
              <div style={{ textAlign: "right", position: "relative" }}>
                <Mono size={12} color="#000">{fmt.usd(row.responsibility)}</Mono>
                <div style={{ height: 3, marginTop: 4, width: `${barW}%`, background: warn ? "#FFD7DF" : "#EDEDED", marginLeft: "auto" }} />
              </div>
              <Mono size={12} color="#000" style={{ textAlign: "right" }}>{fmt.usd(row.payments)}</Mono>
              <span style={{
                fontFamily: "Suisse Intl", fontWeight: 500, fontSize: 14, letterSpacing: "-0.01em",
                color: warn ? "#FF426F" : "#000", textAlign: "right", display: "block",
              }}>{row.rate_pct.toFixed(1)}%</span>
              <Mono size={11} color="#666" style={{ textAlign: "right" }}>{fmt.usd(row.written_off)}</Mono>
            </div>
          );
        })}
      </div>
    );
  };

  return (
    <div ref={ref}>
      {/* Total stat row */}
      <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", border: "1px solid #000", background: "#fff", marginBottom: 24 }}>
        <StatTile label="TRUE CARDIOLOGY BOOK" valueSize={26} value={<span style={{ whiteSpace: "nowrap" }}>{fmt.usd(D.total.uncollected)} <span style={{ fontSize: "0.5em", fontWeight: 400, color: "#999" }}>uncollected</span></span>} note={`of ${fmt.usd(D.total.responsibility)} collectable · ${D.total.share_of_practice_pct.toFixed(1)}% of the practice`} borderRight />
        <StatTile label="BLENDED COLLECTION RATE" value={`${totalRate.toFixed(2)}%`} note="vs 76.54% practice-wide — below average, not above" accent borderRight />
        <StatTile label="OFFICE / HOSPITAL SPLIT" value={`${D.office.share_of_cardiology_pct.toFixed(0)}% / ${D.hospital.share_of_cardiology_pct.toFixed(0)}%`} note={`${D.office.share_of_cardiology_pct.toFixed(0)}% of cardiology's book billed through offices, ${D.hospital.share_of_cardiology_pct.toFixed(0)}% through hospitals`} />
      </div>

      <PullQuote>
        Cardiology's office-based book collects excellently. Hospital professional fees — inpatient rounds, cath lab, consults, billed through facility departments like JFK Medical Center — collect at a fraction of that rate. Same doctors, two very different outcomes depending on where the claim is billed.
      </PullQuote>

      {/* Office vs Hospital comparison bars */}
      <div style={{ display: "flex", flexDirection: "column", gap: 16, margin: "24px 0" }}>
        {[
          { key: "office", data: D.office, color: THEME.primary },
          { key: "hospital", data: D.hospital, color: "#FF426F" },
        ].map(({ key, data, color }) => {
          const rate = key === "office" ? officeRate : hospitalRate;
          const w = data.rate_pct * p;
          return (
            <div key={key}>
              <div style={{ display: "flex", justifyContent: "space-between", marginBottom: 6 }}>
                <Mono size={10} color={THEME.primary}>{data.label.toUpperCase()}</Mono>
                <Mono size={10} color="#666">{rate.toFixed(2)}% COLLECTION RATE</Mono>
              </div>
              <div style={{ position: "relative", height: 44, background: "#F1F1F1", border: "1px solid #000" }}>
                <div style={{
                  position: "absolute", left: 0, top: 0, bottom: 0,
                  width: `${w}%`, background: color,
                  transition: "width 200ms linear",
                  display: "flex", alignItems: "center", padding: "0 14px",
                }}>
                  <span style={{
                    fontFamily: "Suisse Intl", fontWeight: 500, fontSize: 18, letterSpacing: "-0.02em", color: "#fff",
                  }}>{fmt.usd(data.responsibility)}</span>
                </div>
              </div>
            </div>
          );
        })}
      </div>

      {/* Department tables */}
      <div style={{ marginBottom: 24 }}>
        <IndexKicker n="05.a" label="OFFICE-BASED · 93.37% COLLECTION RATE" />
        <div style={{ marginTop: 12 }}>{DeptTable(D.office, 60)}</div>
      </div>
      <div>
        <IndexKicker n="05.b" label="HOSPITAL PROFESSIONAL FEES · 26.22% COLLECTION RATE" />
        <div style={{ marginTop: 12 }}>{DeptTable(D.hospital, 60)}</div>
      </div>
    </div>
  );
};

const StatTile = ({ label, value, valueSize, note, secondary, accent = false, borderRight = false }) => (
  <div style={{
    padding: "18px 20px 20px",
    borderRight: borderRight ? "1px solid #000" : "none",
    background: accent ? "rgba(0,163,255,0.06)" : "#fff",
    minHeight: 120,
    display: "flex", flexDirection: "column", justifyContent: "space-between",
  }}>
    <Mono color={THEME.primary} size={10}>{label}</Mono>
    <div>
      {secondary && (
        <div style={{ display: "flex", gap: 24, marginBottom: 6 }}>
          {(Array.isArray(secondary) ? secondary : [secondary]).map((s, i) => (
            <div key={i}>
              <Mono size={9} color="#999">{s.label}</Mono>
              <div style={{ fontFamily: "Suisse Intl", fontWeight: 500, fontSize: 15, letterSpacing: "-0.01em", color: "#444" }}>{s.value}</div>
            </div>
          ))}
        </div>
      )}
      <div style={{
        fontFamily: "Suisse Intl", fontWeight: 400, fontSize: valueSize || 30, lineHeight: 1,
        letterSpacing: "-0.02em", marginBottom: 6, color: accent ? THEME.primary : "#000",
      }}>{value}</div>
      <Mono color="#666" size={10}>{note}</Mono>
    </div>
  </div>
);
window.CardiologyCut = CardiologyCut;

// ─────────────────────────── Projection ───────────────────────────
const Projection = () => {
  const D = window.ROI_DATA.projection;
  const H = window.ROI_DATA.headline;
  const ref = React.useRef(null);
  const seen = useInView(ref, 0.2);
  const p = useProgress(1600, seen);
  const uplift = useCounter(D.gross_annual_uplift, 1800, seen);

  return (
    <div ref={ref}>
      <div style={{ display: "flex", flexDirection: "column", gap: 20, maxWidth: 760, margin: "0 auto 32px" }}>
        {[
          { label: "TODAY", value: H.total_collected, rate: H.collection_rate_pct, color: THEME.neutral, projected: false },
          { label: "WITH SUPERSCRIPT", value: D.projected_collections, rate: D.projected_rate_pct, color: THEME.proj, projected: true },
        ].map(row => {
          const w = row.rate * p;
          return (
            <div key={row.label}>
              <div style={{ display: "flex", justifyContent: "space-between", marginBottom: 6 }}>
                <Mono size={10} color={row.projected ? THEME.proj : THEME.primary}>{row.label}</Mono>
                <Mono size={10} color="#666">{row.rate.toFixed(2)}% COLLECTION RATE</Mono>
              </div>
              <div style={{ position: "relative", height: 44, background: "#F1F1F1", border: "1px solid #000" }}>
                <div style={{
                  position: "absolute", left: 0, top: 0, bottom: 0,
                  width: `${w}%`, background: row.color,
                  transition: "width 200ms linear",
                  display: "flex", alignItems: "center", padding: "0 14px",
                }}>
                  <span style={{
                    fontFamily: "Suisse Intl", fontWeight: 500, fontSize: 18, letterSpacing: "-0.02em",
                    color: "#fff",
                  }}>{fmt.usd(row.value)}</span>
                </div>
              </div>
            </div>
          );
        })}
      </div>

      {/* Centered uplift callout */}
      <div style={{
        textAlign: "center", padding: "32px 24px", border: "1px solid #000", background: "#000",
      }}>
        <Mono color={THEME.proj} size={11} style={{ display: "block", marginBottom: 12 }}>ADDITIONAL ANNUAL COLLECTIONS AT +{D.uplift_pts}PP</Mono>
        <div style={{
          fontFamily: "Suisse Intl", fontWeight: 300, fontSize: 64, lineHeight: 1,
          letterSpacing: "-0.03em", color: "#fff",
        }}>+{fmt.usdAbbr(uplift)}</div>
        <Mono color="rgba(255,255,255,0.6)" size={10} style={{ display: "block", marginTop: 12 }}>
          PURE COLLECTIONS LIFT · NO OPERATIONAL OR LABOR SAVINGS INCLUDED
        </Mono>
      </div>

      {/* Supporting breakdown — kept separate from the headline figure above */}
      {D.fee && (
        <>
          <div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", border: "1px solid #000", borderTop: "none" }}>
            <ProjectionStat label="PROJECTED FEES" value={fmt.usd(D.fee.fee_total)} note={`${D.fee.fee_pct}% of projected collections · excl. card processing`} borderRight />
            <ProjectionStat label="NET UPLIFT AFTER FEES" value={fmt.usd(D.fee.net_uplift_after_fees)} note="gross uplift minus fees" borderRight />
            <ProjectionStat label="GROSS ROI" value={`${D.fee.gross_roi_multiple.toFixed(2)}x`} note="gross uplift / fees" borderRight />
            <ProjectionStat label="NET ROI" value={`${D.fee.net_roi_multiple.toFixed(2)}x`} note="net uplift / fees" />
          </div>
          <div style={{ display: "grid", gridTemplateColumns: "repeat(2, 1fr)", border: "1px solid #000", borderTop: "none" }}>
            <ProjectionStat label="CASH MOVED FORWARD" value={fmt.usd(D.cash_moved_forward)} note="same dollars, ~32 days sooner" borderRight />
            <ProjectionStat label="EST. LABOR SPEND ADDRESSABLE" value={fmt.usd(D.labor_cost_estimate)} note={`~${D.labor_cost_pct}% of what's collected, industry benchmark`} />
          </div>
        </>
      )}
    </div>
  );
};

const ProjectionStat = ({ label, value, note, borderRight = false }) => (
  <div style={{ padding: "18px 20px 20px", borderRight: borderRight ? "1px solid #000" : "none", background: "#fff" }}>
    <Mono color={THEME.primary} size={10}>{label}</Mono>
    <div style={{ fontFamily: "Suisse Intl", fontWeight: 400, fontSize: 26, lineHeight: 1, letterSpacing: "-0.02em", margin: "8px 0 6px", color: "#000" }}>{value}</div>
    <Mono color="#666" size={10}>{note}</Mono>
  </div>
);
window.Projection = Projection;
