/* Variations — 6 lower-fidelity exploratory artboards.
   These reuse data from data.jsx and the Icon/Badge primitives from ui.jsx
   but draw their own layouts to explore aesthetic + density tradeoffs. */

const { useState: useStateV } = React;

// ─────────────────────────────────────────────────────────────
// Shared mini primitives (variant-only, so they don't conflict)
// ─────────────────────────────────────────────────────────────
const VBox = ({ children, title, sub, right, padded = true, className = "" }) => (
  <div className={"vcard " + className}>
    {(title || right) && (
      <div className="vcard-head">
        <div>
          {title && <div className="vcard-title">{title}</div>}
          {sub && <div className="vcard-sub">{sub}</div>}
        </div>
        {right && <div style={{ marginLeft: "auto" }}>{right}</div>}
      </div>
    )}
    <div style={{ padding: padded ? "0 16px 16px" : 0 }}>{children}</div>
  </div>
);

const Spark = ({ data, color = "var(--accent)", h = 28, w = 90, fill = true }) => {
  const lo = Math.min(...data), hi = Math.max(...data);
  const pts = data.map((v, i) => {
    const x = (i / (data.length - 1)) * w;
    const y = h - ((v - lo) / (hi - lo || 1)) * h;
    return `${x.toFixed(1)},${y.toFixed(1)}`;
  });
  return (
    <svg width={w} height={h} style={{ display: "block" }}>
      {fill && <polygon points={`0,${h} ${pts.join(" ")} ${w},${h}`} fill={color} opacity="0.16" />}
      <polyline points={pts.join(" ")} fill="none" stroke={color} strokeWidth="1.4" />
    </svg>
  );
};

const VKpi = ({ label, value, delta, color = "var(--accent)" }) => (
  <div style={{ borderBottom: "1px solid var(--border-subtle)", padding: "12px 14px" }}>
    <div style={{ fontSize: 9.5, letterSpacing: ".09em", textTransform: "uppercase", color: "var(--text-faint)" }}>{label}</div>
    <div className="num" style={{ fontSize: 22, fontWeight: 600, marginTop: 4, color: "var(--text)" }}>{value}</div>
    {delta != null && (
      <div className="mono" style={{ fontSize: 10.5, marginTop: 2, color: delta >= 0 ? "var(--green)" : "var(--red)" }}>
        {delta >= 0 ? "▲" : "▼"} {Math.abs(delta).toFixed(1)}%
      </div>
    )}
  </div>
);

// ═════════════════════════════════════════════════════════════════
// DASHBOARD VARIANT A — Bloomberg terminal density
// ═════════════════════════════════════════════════════════════════
const DashA = () => {
  const sparkRev = REVENUE_MONTHLY.map(m => m.rev);
  const sparkP   = REVENUE_MONTHLY.map(m => m.profit);
  const topMargs = [...PRODUCTS].sort((a,b)=>b.margin-a.margin).slice(0, 6);

  return (
    <div style={{ padding: 14, fontSize: 12, height: "100%", overflow: "hidden", background: "var(--bg-1)" }}>
      {/* Ticker row */}
      <div style={{
        display: "grid", gridTemplateColumns: "repeat(6, 1fr)", gap: 1,
        background: "var(--border-subtle)", border: "1px solid var(--border-subtle)", marginBottom: 10
      }}>
        {[
          ["REV 30J",  "$142.7K", 6.4],
          ["MARGE",    "$36.9K",  4.1],
          ["NETTE",    "25.8%",   0.4],
          ["UNITÉS",   "1 248",   -2.1],
          ["ACOS",     "18.2%",   -0.8],
          ["BUFFER",   "$58.4K",  12.0],
        ].map(([l, v, d]) => (
          <div key={l} style={{ padding: "8px 10px", background: "var(--bg-2)" }}>
            <div style={{ fontSize: 9, letterSpacing: ".1em", color: "var(--text-faint)" }}>{l}</div>
            <div className="num" style={{ fontSize: 15, fontWeight: 600, marginTop: 2 }}>{v}</div>
            <div className="mono" style={{ fontSize: 9.5, color: d >= 0 ? "var(--green)" : "var(--red)" }}>
              {d >= 0 ? "+" : ""}{d.toFixed(1)}%
            </div>
          </div>
        ))}
      </div>

      {/* Body — 3 cols */}
      <div style={{ display: "grid", gridTemplateColumns: "1.4fr 1.6fr 1fr", gap: 10 }}>
        {/* Col 1 — perf */}
        <div style={{ border: "1px solid var(--border-subtle)" }}>
          <div style={{ padding: "7px 10px", borderBottom: "1px solid var(--border-subtle)", background: "var(--bg-2)" }}>
            <div className="mono" style={{ fontSize: 10, color: "var(--text-faint)" }}>PERFORMANCE · 13M</div>
          </div>
          <div style={{ padding: 10 }}>
            <div className="num" style={{ fontSize: 24, fontWeight: 600 }}>$1.62M <span style={{ fontSize: 11, color: "var(--green)" }}>+18.4% YoY</span></div>
            <Spark data={sparkRev} color="var(--accent)" w={260} h={56} />
            <div className="mono" style={{ fontSize: 10, color: "var(--text-dim)", marginTop: 6 }}>
              moy mens · <span style={{ color: "var(--text)" }}>$124.6K</span> &nbsp; max · <span className="num">$162.4K</span>
            </div>
          </div>
        </div>

        {/* Col 2 — top margins table */}
        <div style={{ border: "1px solid var(--border-subtle)" }}>
          <div style={{ padding: "7px 10px", borderBottom: "1px solid var(--border-subtle)", background: "var(--bg-2)" }}>
            <div className="mono" style={{ fontSize: 10, color: "var(--text-faint)" }}>TOP MARGES · 30J</div>
          </div>
          <table style={{ width: "100%", fontSize: 11, borderCollapse: "collapse" }}>
            <thead>
              <tr style={{ color: "var(--text-faint)", textAlign: "left" }}>
                <th style={{ padding: "5px 10px", fontWeight: 500 }}>ASIN</th>
                <th style={{ padding: "5px 10px", fontWeight: 500 }}>PRODUIT</th>
                <th style={{ padding: "5px 10px", fontWeight: 500, textAlign: "right" }}>BSR</th>
                <th style={{ padding: "5px 10px", fontWeight: 500, textAlign: "right" }}>MARGE</th>
              </tr>
            </thead>
            <tbody>
              {topMargs.map((p) => (
                <tr key={p.id} style={{ borderTop: "1px solid var(--border-subtle)" }}>
                  <td style={{ padding: "5px 10px" }}><Asin value={p.asin} /></td>
                  <td style={{ padding: "5px 10px", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", maxWidth: 200 }}>{p.name.split(" ").slice(0, 4).join(" ")}</td>
                  <td className="num" style={{ padding: "5px 10px", textAlign: "right" }}>{p.bsr.toLocaleString()}</td>
                  <td className="num" style={{ padding: "5px 10px", textAlign: "right", color: "var(--green)", fontWeight: 600 }}>{p.margin.toFixed(1)}%</td>
                </tr>
              ))}
            </tbody>
          </table>
        </div>

        {/* Col 3 — alerts feed */}
        <div style={{ border: "1px solid var(--border-subtle)" }}>
          <div style={{ padding: "7px 10px", borderBottom: "1px solid var(--border-subtle)", background: "var(--bg-2)" }}>
            <div className="mono" style={{ fontSize: 10, color: "var(--text-faint)" }}>FLUX · ALERTES</div>
          </div>
          <div>
            {ALERTS.slice(0, 5).map((a) => (
              <div key={a.id} style={{ padding: "7px 10px", borderTop: "1px solid var(--border-subtle)", fontSize: 11 }}>
                <div style={{ display: "flex", gap: 6, alignItems: "baseline" }}>
                  <span className="mono" style={{ fontSize: 9, color: `var(--${a.tone})` }}>●</span>
                  <span className="mono" style={{ fontSize: 9.5, color: "var(--text-faint)" }}>{a.time}</span>
                </div>
                <div style={{ marginTop: 2, fontSize: 10.5, lineHeight: 1.35 }}>{a.title.replace(/—.*/, "")}</div>
              </div>
            ))}
          </div>
        </div>
      </div>
    </div>
  );
};

// ═════════════════════════════════════════════════════════════════
// DASHBOARD VARIANT B — Editorial / executive briefing
// ═════════════════════════════════════════════════════════════════
const DashB = () => {
  const sparkRev = REVENUE_MONTHLY.map(m => m.rev);

  return (
    <div style={{ padding: "28px 36px", height: "100%", overflow: "hidden", background: "var(--bg-1)" }}>
      <div style={{ fontFamily: "'Instrument Serif', serif", fontSize: 40, letterSpacing: "-.01em", lineHeight: 1.05 }}>
        Bonjour Clarens.
      </div>
      <div style={{ fontSize: 12, color: "var(--text-dim)", marginTop: 6 }}>
        Vendredi 10 mai 2026 — <span style={{ color: "var(--text)" }}>Mois en avance</span> sur les objectifs Q2 de <span className="num">+6.4%</span>.
      </div>

      <div style={{ marginTop: 28, display: "grid", gridTemplateColumns: "1.4fr 1fr", gap: 36 }}>
        {/* Hero number + chart */}
        <div>
          <div style={{ fontSize: 10.5, letterSpacing: ".12em", textTransform: "uppercase", color: "var(--text-faint)" }}>Revenu — 30 derniers jours</div>
          <div style={{ display: "flex", alignItems: "baseline", gap: 14, marginTop: 8 }}>
            <div className="num" style={{ fontSize: 56, fontWeight: 500, letterSpacing: "-.02em", lineHeight: 1 }}>$142,700</div>
            <div style={{ fontSize: 14, color: "var(--green)" }}>↑ 6.4%</div>
          </div>
          <div style={{ marginTop: 14, borderTop: "1px solid var(--border-subtle)", paddingTop: 14 }}>
            <Spark data={sparkRev} color="var(--accent)" w={420} h={70} />
          </div>
          <div style={{ display: "flex", gap: 28, marginTop: 14 }}>
            {[
              ["Marge nette",   "$36.9K", "var(--green)"],
              ["Unités",        "1 248",  "var(--text)"],
              ["Buffer trésor.","$58.4K", "var(--text)"],
            ].map(([l, v, c]) => (
              <div key={l}>
                <div style={{ fontSize: 10, letterSpacing: ".1em", textTransform: "uppercase", color: "var(--text-faint)" }}>{l}</div>
                <div className="num" style={{ fontSize: 20, fontWeight: 500, marginTop: 4, color: c }}>{v}</div>
              </div>
            ))}
          </div>
        </div>

        {/* Right column — narrative alerts */}
        <div>
          <div style={{ fontSize: 10.5, letterSpacing: ".12em", textTransform: "uppercase", color: "var(--text-faint)" }}>Ce que vous devez savoir</div>
          <div style={{ marginTop: 12 }}>
            {ALERTS.slice(0, 4).map((a, i) => (
              <div key={a.id} style={{ padding: "12px 0", borderTop: i ? "1px solid var(--border-subtle)" : "none", display: "flex", gap: 10 }}>
                <div className="num" style={{ fontFamily: "'Instrument Serif', serif", fontSize: 20, color: "var(--text-dim)", width: 28, lineHeight: 1, marginTop: 2 }}>0{i+1}</div>
                <div style={{ flex: 1 }}>
                  <div style={{ fontSize: 13, fontWeight: 500, lineHeight: 1.35 }}>{a.title}</div>
                  <div style={{ fontSize: 11, color: "var(--text-dim)", marginTop: 3 }}>{a.sub}</div>
                </div>
              </div>
            ))}
          </div>
        </div>
      </div>
    </div>
  );
};

// ═════════════════════════════════════════════════════════════════
// DASHBOARD VARIANT C — Bento / glanceable
// ═════════════════════════════════════════════════════════════════
const DashC = () => {
  const sparkRev = REVENUE_MONTHLY.map(m => m.rev);
  const sparkP = REVENUE_MONTHLY.map(m => m.profit);
  const topMargs = [...PRODUCTS].sort((a,b)=>b.margin-a.margin).slice(0, 3);

  const bento = (style) => ({
    background: "var(--bg-2)", border: "1px solid var(--border-subtle)",
    borderRadius: 14, padding: 16, ...style,
  });

  return (
    <div style={{ padding: 20, height: "100%", background: "var(--bg-1)", display: "grid",
      gridTemplateColumns: "repeat(4, 1fr)", gridTemplateRows: "auto auto auto", gap: 12 }}>
      {/* Hero KPI — spans 2 */}
      <div style={{ ...bento({ gridColumn: "span 2", gridRow: "span 2", padding: 18, background: "linear-gradient(135deg, color-mix(in oklch, var(--accent) 14%, var(--bg-2)), var(--bg-2))" }) }}>
        <div style={{ fontSize: 10.5, letterSpacing: ".1em", textTransform: "uppercase", color: "var(--text-faint)" }}>Revenu 30 jours</div>
        <div className="num" style={{ fontSize: 44, fontWeight: 600, letterSpacing: "-.02em", marginTop: 8 }}>$142.7K</div>
        <div style={{ fontSize: 12, color: "var(--green)", marginTop: 2 }}>↑ 6.4% vs période préc.</div>
        <div style={{ marginTop: 12 }}>
          <Spark data={sparkRev} color="var(--accent)" w={300} h={64} />
        </div>
      </div>

      {/* Margin */}
      <div style={bento()}>
        <div style={{ fontSize: 10.5, letterSpacing: ".1em", textTransform: "uppercase", color: "var(--text-faint)" }}>Marge nette</div>
        <div className="num" style={{ fontSize: 26, fontWeight: 600, marginTop: 6 }}>$36.9K</div>
        <div style={{ fontSize: 11, color: "var(--green)", marginTop: 2 }}>↑ 4.1%</div>
        <Spark data={sparkP} color="var(--green)" w={140} h={32} />
      </div>

      {/* Alertes badge */}
      <div style={{ ...bento({ background: "color-mix(in oklch, var(--red) 18%, var(--bg-2))" }) }}>
        <div style={{ fontSize: 10.5, letterSpacing: ".1em", textTransform: "uppercase", color: "var(--text-faint)" }}>Alertes critiques</div>
        <div className="num" style={{ fontSize: 44, fontWeight: 600, marginTop: 8, color: "var(--red)" }}>2</div>
        <div style={{ fontSize: 11, color: "var(--text-dim)", marginTop: 2 }}>↓ 33% vs hier</div>
      </div>

      {/* Top margins — wide */}
      <div style={{ ...bento({ gridColumn: "span 2" }) }}>
        <div style={{ fontSize: 11, fontWeight: 600, marginBottom: 10 }}>Top marges</div>
        {topMargs.map((p, i) => (
          <div key={p.id} style={{ display: "flex", alignItems: "center", gap: 10, padding: "7px 0", borderTop: i ? "1px solid var(--border-subtle)" : "none" }}>
            <div className="mono" style={{ fontSize: 10, color: "var(--text-faint)", width: 16 }}>{i+1}</div>
            <div style={{ flex: 1, fontSize: 11.5, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>
              {p.name.split(" ").slice(0, 4).join(" ")}
            </div>
            <div className="num" style={{ fontSize: 13, fontWeight: 600, color: "var(--green)" }}>{p.margin.toFixed(1)}%</div>
          </div>
        ))}
      </div>

      {/* Velocity ring */}
      <div style={bento()}>
        <div style={{ fontSize: 10.5, letterSpacing: ".1em", textTransform: "uppercase", color: "var(--text-faint)" }}>Velocité 7j</div>
        <div className="num" style={{ fontSize: 26, fontWeight: 600, marginTop: 6 }}>9.2 <span style={{ fontSize: 11, color: "var(--text-faint)" }}>u/j</span></div>
        <Spark data={[7,9,8,10,11,9,12,9]} color="var(--accent)" w={140} h={32} />
      </div>

      {/* Trésorerie */}
      <div style={bento()}>
        <div style={{ fontSize: 10.5, letterSpacing: ".1em", textTransform: "uppercase", color: "var(--text-faint)" }}>Trésorerie</div>
        <div className="num" style={{ fontSize: 26, fontWeight: 600, marginTop: 6 }}>$58.4K</div>
        <div style={{ fontSize: 11, color: "var(--text-dim)", marginTop: 2 }}>↑ 12% buffer</div>
      </div>
    </div>
  );
};

// ═════════════════════════════════════════════════════════════════
// RESEARCH VARIANT A — Spreadsheet density
// ═════════════════════════════════════════════════════════════════
const ResA = () => {
  const rows = PRODUCTS.slice(0, 11);
  return (
    <div style={{ padding: 14, fontSize: 11.5, height: "100%", background: "var(--bg-1)", overflow: "hidden" }}>
      <div style={{ display: "flex", alignItems: "center", gap: 8, marginBottom: 10 }}>
        <div style={{ fontSize: 14, fontWeight: 600 }}>Recherche produits</div>
        <div className="mono" style={{ fontSize: 10.5, color: "var(--text-faint)" }}>18 résultats · tri: marge ↓</div>
        <div style={{ marginLeft: "auto", display: "flex", gap: 6 }}>
          {["status","cat","BSR<5k","marge>25%"].map(c => (
            <span key={c} className="mono" style={{ fontSize: 10, padding: "3px 7px", border: "1px solid var(--border-subtle)", borderRadius: 4, color: "var(--text-dim)" }}>{c}</span>
          ))}
        </div>
      </div>
      <div style={{ border: "1px solid var(--border-subtle)", borderRadius: 4, overflow: "hidden" }}>
        <table style={{ width: "100%", borderCollapse: "collapse", fontSize: 11 }}>
          <thead style={{ background: "var(--bg-2)", color: "var(--text-faint)" }}>
            <tr>
              {["ASIN", "Produit", "Cat.", "Prix", "Coût", "FBA", "BSR", "Stock", "Vel.", "Marge", "Status"].map((h, i) => (
                <th key={h} style={{ padding: "6px 8px", textAlign: i >= 3 ? "right" : "left", fontWeight: 500, letterSpacing: ".04em", textTransform: "uppercase", fontSize: 9.5, borderBottom: "1px solid var(--border-subtle)" }}>
                  {h} {i === 9 && "↓"}
                </th>
              ))}
            </tr>
          </thead>
          <tbody>
            {rows.map((p, i) => (
              <tr key={p.id} style={{ borderTop: i ? "1px solid var(--border-subtle)" : "none", background: i % 2 ? "var(--bg-1)" : "transparent" }}>
                <td style={{ padding: "5px 8px" }}><Asin value={p.asin} /></td>
                <td style={{ padding: "5px 8px", maxWidth: 240, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>{p.name}</td>
                <td style={{ padding: "5px 8px", color: "var(--text-dim)", fontSize: 10.5 }}>{p.cat.split(" ")[0]}</td>
                <td className="num" style={{ padding: "5px 8px", textAlign: "right" }}>${p.price.toFixed(2)}</td>
                <td className="num" style={{ padding: "5px 8px", textAlign: "right", color: "var(--text-dim)" }}>${p.cost.toFixed(2)}</td>
                <td className="num" style={{ padding: "5px 8px", textAlign: "right", color: "var(--text-dim)" }}>${p.fees.toFixed(2)}</td>
                <td className="num" style={{ padding: "5px 8px", textAlign: "right" }}>{p.bsr.toLocaleString()}</td>
                <td className="num" style={{ padding: "5px 8px", textAlign: "right", color: p.stock === 0 ? "var(--red)" : p.stock < 50 ? "var(--amber)" : "var(--text)" }}>{p.stock}</td>
                <td className="num" style={{ padding: "5px 8px", textAlign: "right" }}>{p.vel}/j</td>
                <td className="num" style={{ padding: "5px 8px", textAlign: "right", fontWeight: 600, color: "var(--green)" }}>{p.margin.toFixed(1)}%</td>
                <td style={{ padding: "5px 8px" }}>
                  <span className="mono" style={{ fontSize: 9.5, color: "var(--text-faint)" }}>{p.status}</span>
                </td>
              </tr>
            ))}
          </tbody>
        </table>
      </div>
    </div>
  );
};

// ═════════════════════════════════════════════════════════════════
// RESEARCH VARIANT B — Visual card grid (poster mode)
// ═════════════════════════════════════════════════════════════════
const ResB = () => {
  const rows = PRODUCTS.slice(0, 6);
  // Pastel placeholder palette by category
  const palette = {
    "Maison & Cuisine": ["#d4c3a8", "#8a7355"],
    "Électronique":     ["#a8c3d4", "#557a8a"],
    "Auto":             ["#c2c2c2", "#555555"],
    "Animalerie":       ["#d4b8a8", "#8a6855"],
    "Sport & Plein Air":["#a8d4b8", "#558a68"],
    "Bureau":           ["#d4a8c3", "#8a5575"],
    "Voyage":           ["#c3a8d4", "#75558a"],
  };
  return (
    <div style={{ padding: 18, height: "100%", background: "var(--bg-1)", overflow: "hidden" }}>
      <div style={{ display: "flex", alignItems: "center", marginBottom: 14 }}>
        <div style={{ fontSize: 16, fontWeight: 600 }}>Catalogue</div>
        <div style={{ marginLeft: "auto", display: "flex", gap: 6 }}>
          <span className="mono" style={{ fontSize: 10.5, padding: "4px 8px", background: "var(--bg-3)", borderRadius: 4 }}>Cartes</span>
          <span className="mono" style={{ fontSize: 10.5, padding: "4px 8px", color: "var(--text-faint)" }}>Tableau</span>
          <span className="mono" style={{ fontSize: 10.5, padding: "4px 8px", color: "var(--text-faint)" }}>Kanban</span>
        </div>
      </div>
      <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 14 }}>
        {rows.map((p) => {
          const [c1, c2] = palette[p.cat] || palette["Maison & Cuisine"];
          return (
            <div key={p.id} style={{ background: "var(--bg-2)", border: "1px solid var(--border-subtle)", borderRadius: 8, overflow: "hidden" }}>
              <div style={{ height: 90, background: `linear-gradient(135deg, ${c1}, ${c2})`, position: "relative" }}>
                <div className="mono" style={{ position: "absolute", top: 8, left: 10, fontSize: 9, color: "rgba(255,255,255,.85)", letterSpacing: ".08em" }}>{p.asin}</div>
                <div style={{ position: "absolute", top: 8, right: 10, background: "rgba(0,0,0,.4)", color: "#fff", fontSize: 10, padding: "2px 7px", borderRadius: 4, backdropFilter: "blur(4px)" }} className="mono">
                  BSR {p.bsr > 9999 ? (p.bsr/1000).toFixed(1) + "k" : p.bsr}
                </div>
              </div>
              <div style={{ padding: 12 }}>
                <div style={{ fontSize: 11.5, fontWeight: 500, lineHeight: 1.3, marginBottom: 4, height: 30, overflow: "hidden" }}>{p.name.split(" ").slice(0, 6).join(" ")}</div>
                <div className="mono" style={{ fontSize: 9.5, color: "var(--text-faint)", marginBottom: 8 }}>{p.cat}</div>
                <div style={{ display: "flex", gap: 10, fontSize: 10.5, color: "var(--text-dim)" }}>
                  <div><span className="num" style={{ color: "var(--text)" }}>${p.price.toFixed(0)}</span> prix</div>
                  <div><span className="num" style={{ color: "var(--green)" }}>{p.margin.toFixed(0)}%</span> marge</div>
                  <div><span className="num" style={{ color: p.stock === 0 ? "var(--red)" : "var(--text)" }}>{p.stock}</span> stock</div>
                </div>
              </div>
            </div>
          );
        })}
      </div>
    </div>
  );
};

// ═════════════════════════════════════════════════════════════════
// RESEARCH VARIANT C — Pipeline scoring
// ═════════════════════════════════════════════════════════════════
const ResC = () => {
  const lanes = [
    { id: "evaluer",   label: "À évaluer",   tone: "var(--text-faint)" },
    { id: "recherche", label: "En recherche",tone: "var(--accent)" },
    { id: "valide",    label: "Validé",      tone: "var(--green)" },
    { id: "commande",  label: "En commande", tone: "var(--amber)" },
  ];
  const buckets = lanes.map((l) => ({
    ...l,
    items: PRODUCTS.filter((p) => p.status === l.id).slice(0, 3),
  }));

  const score = (p) => Math.min(99, Math.round(p.margin * 1.6 + (10000 - p.bsr) / 200));

  return (
    <div style={{ padding: 14, height: "100%", background: "var(--bg-1)", overflow: "hidden" }}>
      <div style={{ display: "flex", alignItems: "baseline", marginBottom: 12 }}>
        <div style={{ fontSize: 14, fontWeight: 600 }}>Pipeline sourcing</div>
        <div style={{ marginLeft: 10, fontSize: 11, color: "var(--text-dim)" }}>Score = marge × BSR · drag pour avancer</div>
      </div>
      <div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 10, height: "calc(100% - 36px)" }}>
        {buckets.map((b) => (
          <div key={b.id} style={{ background: "var(--bg-2)", border: "1px solid var(--border-subtle)", borderRadius: 8, overflow: "hidden", display: "flex", flexDirection: "column" }}>
            <div style={{ display: "flex", alignItems: "center", padding: "8px 10px", borderBottom: "1px solid var(--border-subtle)" }}>
              <span style={{ width: 6, height: 6, borderRadius: 999, background: b.tone, marginRight: 8 }}/>
              <span style={{ fontSize: 11, fontWeight: 600 }}>{b.label}</span>
              <span className="mono" style={{ marginLeft: "auto", fontSize: 10, color: "var(--text-faint)" }}>{b.items.length}</span>
            </div>
            <div style={{ padding: 8, display: "flex", flexDirection: "column", gap: 8, overflow: "hidden" }}>
              {b.items.length === 0 && (
                <div style={{ fontSize: 10.5, color: "var(--text-faint)", textAlign: "center", padding: 14 }}>—</div>
              )}
              {b.items.map((p) => {
                const s = score(p);
                return (
                  <div key={p.id} style={{ background: "var(--bg-1)", border: "1px solid var(--border-subtle)", borderRadius: 6, padding: 9 }}>
                    <div style={{ display: "flex", alignItems: "baseline", gap: 8 }}>
                      <div className="num" style={{ fontSize: 18, fontWeight: 600, color: s > 70 ? "var(--green)" : s > 50 ? "var(--amber)" : "var(--text-dim)" }}>{s}</div>
                      <div className="mono" style={{ fontSize: 9, color: "var(--text-faint)", letterSpacing: ".05em" }}>SCORE</div>
                    </div>
                    <div style={{ fontSize: 10.5, lineHeight: 1.3, marginTop: 4, height: 26, overflow: "hidden" }}>{p.name.split(" ").slice(0, 5).join(" ")}</div>
                    <div className="mono" style={{ fontSize: 9, color: "var(--text-faint)", marginTop: 4 }}>BSR {p.bsr.toLocaleString()} · {p.margin.toFixed(0)}% marge</div>
                    <div style={{ marginTop: 6, height: 3, background: "var(--bg-3)", borderRadius: 999, overflow: "hidden" }}>
                      <div style={{ width: s + "%", height: "100%", background: s > 70 ? "var(--green)" : s > 50 ? "var(--amber)" : "var(--text-dim)" }}/>
                    </div>
                  </div>
                );
              })}
            </div>
          </div>
        ))}
      </div>
    </div>
  );
};

window.DashA = DashA;
window.DashB = DashB;
window.DashC = DashC;
window.ResA = ResA;
window.ResB = ResB;
window.ResC = ResC;
