// Sample data for Mindworks Projects module
const PROJECTS = [
  {
    id: "P-2401",
    name: "Cedar Heights Solar — Fixed-Tilt",
    customer: "Cedar Heights Holdings",
    customerType: "Construction",
    pm: { name: "Robert Fox", initials: "RF", color: "#76ADFF" },
    status: "At Risk",
    contract: 4_850_000,
    budgetActual: 3_120_000,
    budgetPlan: 2_780_000,
    budgetTone: "danger",
    pct: 64,
    billing: "In Progress",
    nextMilestone: "Install Purlins",
    nextMilestoneDate: "05/14/2026",
    changeOrders: 3,
    coValue: 285_000,
    risk: "high",
    updated: "2h ago",
  },
  {
    id: "P-2402",
    name: "Northstar Solar — Tracker",
    customer: "Northstar Manufacturing",
    customerType: "Manufacturing",
    pm: { name: "Emma Connor", initials: "EC", color: "#22863A" },
    status: "In Progress",
    contract: 2_340_000,
    budgetActual: 1_180_000,
    budgetPlan: 1_220_000,
    budgetTone: "success",
    pct: 51,
    billing: "Ready",
    nextMilestone: "Install Torque Tube",
    nextMilestoneDate: "05/22/2026",
    changeOrders: 1,
    coValue: 42_000,
    risk: "low",
    updated: "Today",
  },
  {
    id: "P-2403",
    name: "Vector Steel Solar — Pull Out Test",
    customer: "Vector Steel Works",
    customerType: "Manufacturing",
    pm: { name: "Nick Merley", initials: "NM", color: "#B279FF" },
    status: "In Progress",
    contract: 1_120_000,
    budgetActual: 540_000,
    budgetPlan: 560_000,
    budgetTone: "success",
    pct: 48,
    billing: "Invoiced",
    nextMilestone: "Perform QA/QC",
    nextMilestoneDate: "05/30/2026",
    changeOrders: 0,
    coValue: 0,
    risk: "low",
    updated: "Yesterday",
  },
  {
    id: "P-2404",
    name: "Halcyon Solar — Warranty",
    customer: "Halcyon Plastics",
    customerType: "Manufacturing",
    pm: { name: "Jordan Lin", initials: "JL", color: "#FF9143" },
    status: "Planned",
    contract: 870_000,
    budgetActual: 0,
    budgetPlan: 0,
    budgetTone: "neutral",
    pct: 4,
    billing: "Not Started",
    nextMilestone: "Screw Installation",
    nextMilestoneDate: "06/03/2026",
    changeOrders: 0,
    coValue: 0,
    risk: "low",
    updated: "3d ago",
  },
  {
    id: "P-2405",
    name: "Crestwood Solar — Fixed-Tilt",
    customer: "Crestwood Robotics",
    customerType: "Construction",
    pm: { name: "Robert Fox", initials: "RF", color: "#76ADFF" },
    status: "At Risk",
    contract: 3_410_000,
    budgetActual: 2_640_000,
    budgetPlan: 2_310_000,
    budgetTone: "danger",
    pct: 78,
    billing: "In Progress",
    nextMilestone: "Install Uprights",
    nextMilestoneDate: "05/09/2026",
    changeOrders: 5,
    coValue: 412_000,
    risk: "high",
    updated: "1h ago",
  },
  {
    id: "P-2406",
    name: "Bridgepoint Solar — Tracker",
    customer: "Bridgepoint Foundries",
    customerType: "Manufacturing",
    pm: { name: "Emma Connor", initials: "EC", color: "#22863A" },
    status: "On Hold",
    contract: 1_675_000,
    budgetActual: 720_000,
    budgetPlan: 740_000,
    budgetTone: "warning",
    pct: 38,
    billing: "In Progress",
    nextMilestone: "Install Purlins",
    nextMilestoneDate: "—",
    changeOrders: 2,
    coValue: 96_500,
    risk: "med",
    updated: "5d ago",
  },
  {
    id: "P-2407",
    name: "Kestrel Solar — Pull Out Test",
    customer: "Kestrel Aerospace",
    customerType: "Manufacturing",
    pm: { name: "Nick Merley", initials: "NM", color: "#B279FF" },
    status: "In Progress",
    contract: 6_240_000,
    budgetActual: 2_810_000,
    budgetPlan: 2_870_000,
    budgetTone: "success",
    pct: 44,
    billing: "Ready",
    nextMilestone: "Install Purlins",
    nextMilestoneDate: "05/18/2026",
    changeOrders: 2,
    coValue: 188_000,
    risk: "low",
    updated: "Today",
  },
  {
    id: "P-2408",
    name: "Infinity Solar — Warranty",
    customer: "Infinity Payroll Services",
    customerType: "Construction",
    pm: { name: "Jordan Lin", initials: "JL", color: "#FF9143" },
    status: "In Progress",
    contract: 920_000,
    budgetActual: 410_000,
    budgetPlan: 460_000,
    budgetTone: "success",
    pct: 56,
    billing: "Ready",
    nextMilestone: "Install Purlins",
    nextMilestoneDate: "05/12/2026",
    changeOrders: 1,
    coValue: 24_000,
    risk: "low",
    updated: "4h ago",
  },
  {
    id: "P-2409",
    name: "Atlas Solar — Fixed-Tilt",
    customer: "Atlas Logistics Co.",
    customerType: "Construction",
    pm: { name: "Robert Fox", initials: "RF", color: "#76ADFF" },
    status: "Completed",
    contract: 2_080_000,
    budgetActual: 2_010_000,
    budgetPlan: 2_080_000,
    budgetTone: "success",
    pct: 100,
    billing: "Invoiced",
    nextMilestone: "Perform QA/QC",
    nextMilestoneDate: "Done",
    changeOrders: 4,
    coValue: 132_000,
    risk: "low",
    updated: "2w ago",
  },
];

const STATUS_TONES = {
  "Planned": "neutral",
  "In Progress": "success",
  "At Risk": "danger",
  "On Hold": "warning",
  "Completed": "info",
};

const BILLING_TONES = {
  "Not Started": "neutral",
  "In Progress": "info",
  "Ready": "warning",
  "Invoiced": "success",
};

const RISK_TONES = { high: "danger", med: "warning", low: "success" };

const fmtMoney = (v) => {
  if (v >= 1_000_000) return `$${(v / 1_000_000).toFixed(2)}M`;
  if (v >= 1_000) return `$${(v / 1_000).toFixed(0)}K`;
  return `$${v}`;
};

const fmtMoneyFull = (v) => "$" + v.toLocaleString("en-US");

window.PROJECTS = PROJECTS;
window.STATUS_TONES = STATUS_TONES;
window.BILLING_TONES = BILLING_TONES;
window.RISK_TONES = RISK_TONES;
window.fmtMoney = fmtMoney;
window.fmtMoneyFull = fmtMoneyFull;
