// splits.jsx — insured-vs-selfpay yield split + maturation curve at 1mo/4mo/present
// Both sections are NEW additions to the report (not in the legacy template).

// ─────────────────────────── Insured vs Self-Pay ───────────────────────────
const InsuredVsSelfpay = () => {
  const D = window.ROI_DATA.insured_vs_selfpay;
  const ref = React.useRef(null);
  const seen = useInView(ref, 0.2);
  const p = useProgress(1200, seen);

  const totalResp = D.insured.responsibility + D.selfpay.responsibility;
  const insWidth = (D.insured.responsibility / totalResp) * 100;
  const spWidth  = (D.selfpay.responsibility / totalResp) * 100;

  const insRate = useCounter(D.insured.rate_pct, 1400, seen, 1);
  const spRate  = useCounter(D.selfpay.rate_pct, 1400, seen, 1);

  return (
    <div ref={ref}>
      {/* Stacked-bar visualization */}
      <div style={{
        display: "flex", height: 56, border: "1px solid #000",
        background: "#F1F1F1", overflow: "hidden",
      }}>
        <div style={{
          width: `${insWidth * p}%`, background: THEME.neutral,
          display: "flex", alignItems: "center", padding: "0 14px",
          color: "#fff", transition: "width 1200ms cubic-bezier(0.2,0.7,0.2,1)",
        }}>
          <Mono color="rgba(255,255,255,0.9)" size={10}>INSURED · {D.insured.share_of_total.toFixed(1)}%</Mono>
        </div>
        <div style={{
          width: `${spWidth * p}%`, background: THEME.accent,
          display: "flex", alignItems: "center", padding: "0 14px",
          color: "#fff", transition: "width 1200ms cubic-bezier(0.2,0.7,0.2,1) 100ms",
        }}>
          <Mono color="rgba(255,255,255,0.9)" size={10}>SELF-PAY · {D.selfpay.share_of_total.toFixed(1)}%</Mono>
        </div>
      </div>

      {/* Two-column stat grid */}
      <div style={{
        marginTop: 16, display: "grid", gridTemplateColumns: "1fr 1fr",
        border: "1px solid #000",
      }}>
        <SplitCard
          title="INSURED"
          subtitle="patient liability after insurance"
          accent={THEME.primary}
          rate={insRate}
          responsibility={D.insured.responsibility}
          payments={D.insured.payments}
          borderRight
        />
        <SplitCard
          title="SELF-PAY"
          subtitle="patient owes the full charge"
          accent={THEME.accent}
          rate={spRate}
          responsibility={D.selfpay.responsibility}
          payments={D.selfpay.payments}
        />
      </div>

      {/* Delta callout */}
      <div style={{ marginTop: 16, padding: "12px 16px", border: "1px solid #000", background: "#fff" }}>
        <Mono color={THEME.primary} size={10} style={{ display: "block", marginBottom: 6 }}>OBSERVATION</Mono>
        <span style={{ fontSize: 14, lineHeight: 1.45, letterSpacing: "-0.005em" }}>
          {D.selfpay.rate_pct > D.insured.rate_pct ? (
            <>Self-pay outperforms insured by <strong>{(D.selfpay.rate_pct - D.insured.rate_pct).toFixed(1)}pts</strong>. Patients tend to pay better when there's no insurance ambiguity to wait through.</>
          ) : (
            <>Insured outperforms self-pay by <strong>{(D.insured.rate_pct - D.selfpay.rate_pct).toFixed(1)}pts</strong>. After-insurance balances are easier to collect at this practice than direct self-pay.</>
          )}
        </span>
      </div>
    </div>
  );
};

const SplitCard = ({ title, subtitle, accent, rate, responsibility, payments, borderRight = false }) => (
  <div style={{
    padding: "20px 22px 22px",
    borderRight: borderRight ? "1px solid #000" : "none",
    minHeight: 140,
    display: "flex", flexDirection: "column", justifyContent: "space-between",
  }}>
    <div>
      <Mono color={accent} size={10}>{title}</Mono>
      <Mono color="#999" size={9} style={{ display: "block", marginTop: 4 }}>{subtitle}</Mono>
    </div>
    <div>
      <div style={{
        fontFamily: "Suisse Intl", fontWeight: 400,
        fontSize: 38, lineHeight: 1, letterSpacing: "-0.025em",
        color: "#000", marginBottom: 8,
      }}>{rate.toFixed(1)}%</div>
      <Mono color="#666" size={11}>
        {fmt.usdAbbr(payments)} of {fmt.usdAbbr(responsibility)} owed
      </Mono>
    </div>
  </div>
);

window.InsuredVsSelfpay = InsuredVsSelfpay;

// ─────────────────────────── Upfront Capture ───────────────────────────
const UpfrontCapture = () => {
  const D = window.ROI_DATA.upfront_capture;
  const ref = React.useRef(null);
  const seen = useInView(ref, 0.2);
  const p = useProgress(1400, seen);

  const totalResp = D.upfront.dollars + D.after_service.dollars + D.uncollected.dollars;
  const upPct  = (D.upfront.dollars       / totalResp) * 100;
  const asPct  = (D.after_service.dollars / totalResp) * 100;
  const unPct  = (D.uncollected.dollars   / totalResp) * 100;

  const upRate = useCounter(D.upfront.share_pct,       1400, seen, 1);
  const asRate = useCounter(D.after_service.share_pct, 1400, seen, 1);
  const unRate = useCounter(D.uncollected.share_pct,   1400, seen, 1);

  return (
    <div ref={ref}>
      {/* Stacked-bar visualization */}
      <div style={{
        display: "flex", height: 56, border: "1px solid #000",
        background: "#F1F1F1", overflow: "hidden",
      }}>
        <div style={{
          width: `${upPct * p}%`, background: THEME.neutral,
          display: "flex", alignItems: "center", padding: "0 14px",
          color: "#fff", transition: "width 1200ms cubic-bezier(0.2,0.7,0.2,1)",
        }}>
          <Mono color="rgba(255,255,255,0.95)" size={10}>UPFRONT · {D.upfront.share_pct.toFixed(1)}%</Mono>
        </div>
        <div style={{
          width: `${asPct * p}%`, background: "#B8B8B8",
          display: "flex", alignItems: "center", padding: "0 14px",
          color: "#fff", transition: "width 1200ms cubic-bezier(0.2,0.7,0.2,1) 100ms",
        }}>
          <Mono color="rgba(255,255,255,0.95)" size={10}>AFTER SERVICE · {D.after_service.share_pct.toFixed(1)}%</Mono>
        </div>
        <div style={{
          width: `${unPct * p}%`, background: "#E1E1E1",
          display: "flex", alignItems: "center", padding: "0 14px",
          color: "#666", transition: "width 1200ms cubic-bezier(0.2,0.7,0.2,1) 200ms",
        }}>
          <Mono color="#666" size={10}>UNCOLLECTED AFTER FIRST 30 DAYS · {D.uncollected.share_pct.toFixed(1)}%</Mono>
        </div>
      </div>

      {/* Three-column tile grid */}
      <div style={{
        marginTop: 16, display: "grid", gridTemplateColumns: "repeat(3, 1fr)",
        border: "1px solid #000",
      }}>
        <UpfrontTile
          title="UPFRONT"
          subtitle="paid at or before the encounter"
          accent={THEME.primary}
          rate={upRate}
          dollars={D.upfront.dollars}
          highlight
          borderRight
        />
        <UpfrontTile
          title="AFTER SERVICE"
          subtitle="collected post-encounter"
          accent="#666"
          rate={asRate}
          dollars={D.after_service.dollars}
          borderRight
        />
        <UpfrontTile
          title="UNCOLLECTED AFTER FIRST 30 DAYS"
          subtitle="still owed by patients beyond the 30-day window"
          accent="#FF426F"
          rate={unRate}
          dollars={D.uncollected.dollars}
          warn
        />
      </div>

      {/* Insured vs self-pay upfront split */}
      {D.by_mode && (
        <div style={{ marginTop: 16, padding: "14px 18px", border: "1px solid #000", background: "#fff" }}>
          <Mono color={THEME.primary} size={10} style={{ display: "block", marginBottom: 8 }}>UPFRONT CAPTURE BY MODE</Mono>
          <div style={{ display: "flex", gap: 32, alignItems: "baseline" }}>
            <div>
              <Mono color="#999" size={9} style={{ display: "block", marginBottom: 4 }}>INSURED</Mono>
              <span style={{ fontSize: 22, fontWeight: 400, letterSpacing: "-0.02em" }}>{D.by_mode.insured.share_pct.toFixed(1)}%</span>
              <Mono color="#666" size={10} style={{ marginLeft: 8 }}>
                {fmt.usdAbbr(D.by_mode.insured.dollars)} of {fmt.usdAbbr(D.by_mode.insured.responsibility)}
              </Mono>
            </div>
            <div>
              <Mono color={THEME.accent} size={9} style={{ display: "block", marginBottom: 4 }}>SELF-PAY</Mono>
              <span style={{ fontSize: 22, fontWeight: 400, letterSpacing: "-0.02em" }}>{D.by_mode.selfpay.share_pct.toFixed(1)}%</span>
              <Mono color="#666" size={10} style={{ marginLeft: 8 }}>
                {fmt.usdAbbr(D.by_mode.selfpay.dollars)} of {fmt.usdAbbr(D.by_mode.selfpay.responsibility)}
              </Mono>
            </div>
          </div>
        </div>
      )}

      {/* Reconciliation strip */}
      {D.breakdown && (
        <div style={{ marginTop: 12, padding: "10px 16px", background: "#F9F9F9", border: "1px solid #E1E1E1" }}>
          <Mono size={9} color="#666">
            UPFRONT RECONCILIATION · TRUE {fmt.usd(D.breakdown.true_upfront)} ({((D.breakdown.true_upfront / (D.upfront.dollars + D.uncollected.dollars + D.after_service.dollars)) * 100).toFixed(2)}%)
            {" · "}STILL-UNAPPLIED {fmt.usd(D.breakdown.still_unapplied)} ({((D.breakdown.still_unapplied / (D.upfront.dollars + D.uncollected.dollars + D.after_service.dollars)) * 100).toFixed(2)}%)
            {" · "}UNINTENTIONAL {fmt.usd(D.breakdown.unintentional)}
            {" · "}OVER-COLLECTED {fmt.usd(D.breakdown.over_collected)}
          </Mono>
        </div>
      )}

      {/* Department-level scatter + table */}
      {D.by_dept && D.by_dept.length > 0 && (
        <div style={{ marginTop: 24 }}>
          <IndexKicker n="03.b.ii" label="UPFRONT BY DEPARTMENT" />
          <h3 style={{
            fontFamily: "Suisse Intl", fontWeight: 300, fontSize: 26, lineHeight: 1.05,
            letterSpacing: "-0.025em", margin: "12px 0 16px", maxWidth: 720,
          }}>
            {D.claims_with_upfront} of {D.total_claims} claims ({D.pct_claims_with_upfront.toFixed(1)}%) had an upfront payment, averaging {fmt.usd(D.avg_upfront_per_paying_claim)}.
          </h3>

          {/* Scatter: x=upfront %, y=collection rate %, area=responsibility */}
          <DeptScatter depts={D.by_dept} />

          {/* Sortable table below */}
          <div style={{ marginTop: 24, border: "1px solid #000" }}>
            <div style={{
              display: "grid",
              gridTemplateColumns: "1.6fr 0.6fr 0.7fr 0.9fr 0.7fr 0.9fr 0.7fr",
              padding: "10px 14px", borderBottom: "1px solid #000",
              background: "#F1F1F1",
              fontFamily: "Suisse Intl Mono, JetBrains Mono, monospace",
              fontWeight: 700, fontSize: 10, letterSpacing: "-0.02em", color: "#000",
            }}>
              <span>DEPARTMENT</span>
              <span style={{ textAlign: "right" }}>CLAIMS</span>
              <span style={{ textAlign: "right" }}>RESP</span>
              <span style={{ textAlign: "right" }}>COLLECTED 30D</span>
              <span style={{ textAlign: "right" }}>RATE 30D</span>
              <span style={{ textAlign: "right" }}>UPFRONT $</span>
              <span style={{ textAlign: "right" }}>UPFRONT %</span>
            </div>
            {D.by_dept.map((row, i) => (
              <div key={row.name} style={{
                display: "grid",
                gridTemplateColumns: "1.6fr 0.6fr 0.7fr 0.9fr 0.7fr 0.9fr 0.7fr",
                padding: "10px 14px",
                borderBottom: i < D.by_dept.length - 1 ? "1px solid #E1E1E1" : "none",
                fontSize: 12, color: "#000",
              }}>
                <span style={{ fontWeight: 500 }}>{row.name}</span>
                <span style={{ textAlign: "right", color: "#666" }}>{fmt.num(row.claims)}</span>
                <span style={{ textAlign: "right" }}>{fmt.usd(row.responsibility)}</span>
                <span style={{ textAlign: "right" }}>{fmt.usd(row.collected_30d)}</span>
                <span style={{ textAlign: "right", color: row.collection_rate_30d_pct >= 60 ? THEME.primary : row.collection_rate_30d_pct < 25 ? "#FF426F" : "#000" }}>
                  {row.collection_rate_30d_pct.toFixed(1)}%
                </span>
                <span style={{ textAlign: "right" }}>{fmt.usd(row.upfront_dollars)}</span>
                <span style={{ textAlign: "right", color: row.upfront_pct >= 30 ? THEME.primary : "#000" }}>
                  {row.upfront_pct.toFixed(1)}%
                </span>
              </div>
            ))}
          </div>
        </div>
      )}
    </div>
  );
};

const UpfrontTile = ({ title, subtitle, accent, rate, dollars, highlight = false, warn = false, borderRight = false }) => (
  <div style={{
    padding: "20px 22px 22px",
    borderRight: borderRight ? "1px solid #000" : "none",
    background: highlight ? "rgba(0,163,255,0.06)" : "#fff",
    minHeight: 140,
    display: "flex", flexDirection: "column", justifyContent: "space-between",
  }}>
    <div>
      <Mono color={accent} size={10}>{title}</Mono>
      <Mono color="#999" size={9} style={{ display: "block", marginTop: 4 }}>{subtitle}</Mono>
    </div>
    <div>
      <div style={{
        fontFamily: "Suisse Intl", fontWeight: 400,
        fontSize: 38, lineHeight: 1, letterSpacing: "-0.025em",
        color: warn ? "#FF426F" : (highlight ? THEME.primary : "#000"),
        marginBottom: 8,
      }}>{rate.toFixed(1)}%</div>
      <Mono color="#666" size={11}>{fmt.usd(dollars)}</Mono>
    </div>
  </div>
);

window.UpfrontCapture = UpfrontCapture;

// ─────────────────────────── Department Scatter ───────────────────────────
// X-axis: upfront capture % · Y-axis: overall collection rate % · Bubble area: responsibility $
const DeptScatter = ({ depts }) => {
  const ref = React.useRef(null);
  const seen = useInView(ref, 0.15);
  const p = useProgress(1800, seen);
  const [hover, setHover] = React.useState(null);

  // Chart geometry
  const W = 760, H = 380;
  const M = { top: 24, right: 24, bottom: 48, left: 56 };
  const innerW = W - M.left - M.right;
  const innerH = H - M.top - M.bottom;

  // Scales: both axes pinned to 0-100%
  const xScale = pct => M.left + (pct / 100) * innerW;
  const yScale = pct => M.top + innerH - (pct / 100) * innerH;

  // Bubble radius: sqrt of responsibility, scaled to a 6-44 px range
  const maxResp = Math.max(...depts.map(d => d.responsibility));
  const rScale = resp => 6 + Math.sqrt(resp / maxResp) * 38;

  // Cohort P50 reference line, read from data.js so it tracks the benchmark file
  // rather than a stale literal.
  const COHORT_COLL_P50 = (window.ROI_DATA.benchmark && window.ROI_DATA.benchmark.cohort_p50_pct) || 71.6;

  // Quadrants: x=30 (upfront benchmark), y=cohort P50
  const xThresh = 30, yThresh = COHORT_COLL_P50;

  // Gridlines every 20%
  const grid = [0, 20, 40, 60, 80, 100];

  return (
    <div ref={ref} style={{ border: "1px solid #000", background: "#fff", padding: "20px 24px 16px", position: "relative" }}>
      <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline", marginBottom: 12 }}>
        <Mono color={THEME.primary} size={10}>UPFRONT CAPTURE % × COLLECTION RATE %</Mono>
        <Mono color="#999" size={9}>BUBBLE SIZE = APRIL RESPONSIBILITY ${"  "}·{"  "}REFERENCE LINES = COHORT P50 / 30% UPFRONT</Mono>
      </div>

      <svg viewBox={`0 0 ${W} ${H}`} style={{ width: "100%", height: "auto", display: "block" }}>
        {/* Quadrant fills */}
        <rect x={xScale(xThresh)} y={M.top} width={xScale(100) - xScale(xThresh)} height={yScale(yThresh) - M.top}
              fill="rgba(0,163,255,0.05)" />
        <rect x={M.left} y={yScale(yThresh)} width={xScale(xThresh) - M.left} height={M.top + innerH - yScale(yThresh)}
              fill="rgba(255,66,111,0.04)" />

        {/* Gridlines */}
        {grid.map(g => (
          <React.Fragment key={`g-${g}`}>
            <line x1={xScale(g)} x2={xScale(g)} y1={M.top} y2={M.top + innerH}
                  stroke="#E1E1E1" strokeWidth="1" />
            <line x1={M.left} x2={M.left + innerW} y1={yScale(g)} y2={yScale(g)}
                  stroke="#E1E1E1" strokeWidth="1" />
            <text x={xScale(g)} y={M.top + innerH + 16} fill="#666" fontSize="9"
                  fontFamily="Suisse Intl Mono, JetBrains Mono, monospace" textAnchor="middle">{g}%</text>
            <text x={M.left - 8} y={yScale(g) + 3} fill="#666" fontSize="9"
                  fontFamily="Suisse Intl Mono, JetBrains Mono, monospace" textAnchor="end">{g}%</text>
          </React.Fragment>
        ))}

        {/* Threshold lines */}
        <line x1={xScale(xThresh)} x2={xScale(xThresh)} y1={M.top} y2={M.top + innerH}
              stroke="#000" strokeWidth="1" strokeDasharray="3 3" opacity="0.5" />
        <line x1={M.left} x2={M.left + innerW} y1={yScale(yThresh)} y2={yScale(yThresh)}
              stroke="#000" strokeWidth="1" strokeDasharray="3 3" opacity="0.5" />
        <text x={xScale(xThresh) + 6} y={M.top + 10} fill="#666" fontSize="9"
              fontFamily="Suisse Intl Mono, JetBrains Mono, monospace">UPFRONT 30%</text>
        <text x={M.left + 6} y={yScale(yThresh) - 6} fill="#666" fontSize="9"
              fontFamily="Suisse Intl Mono, JetBrains Mono, monospace">COHORT P50 · {COHORT_COLL_P50.toFixed(1)}%</text>

        {/* Axis labels */}
        <text x={M.left + innerW / 2} y={H - 6} fill="#000" fontSize="11"
              fontFamily="Suisse Intl Mono, JetBrains Mono, monospace" textAnchor="middle"
              fontWeight="700">UPFRONT CAPTURE %</text>
        <text x={14} y={M.top + innerH / 2} fill="#000" fontSize="11"
              fontFamily="Suisse Intl Mono, JetBrains Mono, monospace" textAnchor="middle"
              fontWeight="700" transform={`rotate(-90 14 ${M.top + innerH / 2})`}>COLLECTION RATE %</text>

        {/* Bubbles + labels */}
        {depts.map((d, i) => {
          const x = xScale(d.upfront_pct);
          const y = yScale(d.collection_rate_30d_pct);
          const r = rScale(d.responsibility) * p;
          // Color by quadrant: top-right = primary blue, bottom-left = red, others = mid grey
          const inGood = d.upfront_pct >= xThresh && d.collection_rate_30d_pct >= yThresh;
          const inBad  = d.upfront_pct <  xThresh && d.collection_rate_30d_pct <  yThresh;
          const color = inGood ? THEME.neutral : inBad ? "#FF426F" : "#D4D4D4";
          const isHover = hover === i;
          return (
            <g key={d.name}
               onMouseEnter={() => setHover(i)}
               onMouseLeave={() => setHover(null)}
               style={{ cursor: "pointer" }}>
              {/* Wider invisible hit area so small bubbles are easy to hover */}
              <circle cx={x} cy={y} r={Math.max(r, 14)} fill="transparent" />
              <circle cx={x} cy={y} r={r}
                      fill={color} fillOpacity={isHover ? 0.85 : 0.65}
                      stroke={isHover ? "#000" : color} strokeWidth={isHover ? 2 : 1.5}
                      style={{ transition: "r 800ms cubic-bezier(0.2,0.7,0.2,1), fill-opacity 120ms, stroke 120ms, stroke-width 120ms" }} />
            </g>
          );
        })}
      </svg>

      {/* Hover tooltip — full dept name + key metrics */}
      {hover !== null && (() => {
        const d = depts[hover];
        if (!d) return null;
        // Position tooltip relative to the bubble center; flip horizontally if it would overflow.
        // We use absolute positioning over the svg using viewBox-relative percentages.
        const x = xScale(d.upfront_pct);
        const y = yScale(d.collection_rate_30d_pct);
        const xPct = (x / W) * 100;
        const yPct = (y / H) * 100;
        const flipLeft = xPct > 65;
        const flipUp = yPct > 65;
        return (
          <div style={{
            position: "absolute",
            // SVG fills the padded area; tooltip anchored to bubble using % of container
            left: `calc(${(x / W) * 100}% - 12px)`,
            top: `calc(${(y / H) * 100}% - 12px)`,
            transform: `translate(${flipLeft ? "calc(-100% - 14px)" : "14px"}, ${flipUp ? "calc(-100% - 14px)" : "14px"})`,
            background: "#000", color: "#fff",
            padding: "10px 12px",
            border: `1px solid ${THEME.onDark}`,
            minWidth: 220, maxWidth: 280,
            pointerEvents: "none",
            zIndex: 10,
            fontFamily: "Suisse Intl",
            boxShadow: "0 4px 16px rgba(0,0,0,0.15)",
          }}>
            <div style={{
              fontFamily: "Suisse Intl Mono, JetBrains Mono, monospace",
              fontWeight: 700, fontSize: 10, letterSpacing: "-0.02em",
              color: THEME.onDark, marginBottom: 6,
            }}>DEPARTMENT</div>
            <div style={{ fontSize: 14, fontWeight: 500, marginBottom: 8, letterSpacing: "-0.01em" }}>
              {d.name}
            </div>
            <div style={{
              display: "grid", gridTemplateColumns: "1fr auto", rowGap: 4, columnGap: 12,
              fontFamily: "Suisse Intl Mono, JetBrains Mono, monospace",
              fontSize: 10, letterSpacing: "-0.02em",
            }}>
              <span style={{ color: "rgba(255,255,255,0.6)" }}>CLAIMS</span>
              <span style={{ textAlign: "right" }}>{fmt.num(d.claims)}</span>
              <span style={{ color: "rgba(255,255,255,0.6)" }}>W/ UPFRONT</span>
              <span style={{ textAlign: "right" }}>{d.with_upfront} ({d.pct_with_upfront.toFixed(1)}%)</span>
              <span style={{ color: "rgba(255,255,255,0.6)" }}>RESPONSIBILITY</span>
              <span style={{ textAlign: "right" }}>{fmt.usd(d.responsibility)}</span>
              <span style={{ color: "rgba(255,255,255,0.6)" }}>UPFRONT $</span>
              <span style={{ textAlign: "right", color: THEME.primary }}>{fmt.usd(d.upfront_dollars)}</span>
              <span style={{ color: "rgba(255,255,255,0.6)" }}>UPFRONT %</span>
              <span style={{ textAlign: "right", color: THEME.primary }}>{d.upfront_pct.toFixed(1)}%</span>
              <span style={{ color: "rgba(255,255,255,0.6)" }}>COLLECTED 30D</span>
              <span style={{ textAlign: "right" }}>{fmt.usd(d.collected_30d)}</span>
              <span style={{ color: "rgba(255,255,255,0.6)" }}>RATE 30D</span>
              <span style={{ textAlign: "right" }}>{d.collection_rate_30d_pct.toFixed(1)}%</span>
            </div>
          </div>
        );
      })()}

      {/* Legend strip */}
      <div style={{ display: "flex", justifyContent: "space-between", marginTop: 10, padding: "8px 0", borderTop: "1px solid #E1E1E1" }}>
        <Mono size={9} color="#666">
          <span style={{ display: "inline-block", width: 8, height: 8, background: THEME.primary, opacity: 0.65, borderRadius: 4, marginRight: 6, verticalAlign: "middle" }} />
          TOP-RIGHT: HIGH UPFRONT + HIGH RATE
        </Mono>
        <Mono size={9} color="#666">
          <span style={{ display: "inline-block", width: 8, height: 8, background: "#B8B8B8", borderRadius: 4, marginRight: 6, verticalAlign: "middle" }} />
          MIDDLE: ONE STRONG, ONE WEAK
        </Mono>
        <Mono size={9} color="#666">
          <span style={{ display: "inline-block", width: 8, height: 8, background: "#FF426F", opacity: 0.65, borderRadius: 4, marginRight: 6, verticalAlign: "middle" }} />
          BOTTOM-LEFT: LOW BOTH
        </Mono>
      </div>
    </div>
  );
};

window.DeptScatter = DeptScatter;
