// data.jsx — Données RAYCAST v2 — alignées sur :
//   • Liste de prix Larks v16 INTERNE (forfaits cout/vendant)
//   • Catalogue Raycom v5 (mPower Tesla, Franken Solar, Tarification Solaire)
//   • Listes prix 2026 Q1
// Tous prix CAD hors taxes.

const RAYCOM_DATA = {
  // === LARKS FORFAITS v16 — Source de vérité pour l'install électrique ===
  // Chaque forfait : { code, label, brand, onds, dim, backup, cost, sell }
  // brand "fox_sig" = applicable Fox ESS et Sigenergy
  // brand "tesla" = Tesla Powerwall 3 (whole-home par défaut via Gateway 3)
  larks_forfaits: [
    { code: "FOX-1OND-LITE",         label: "Solo Lite",       brand: "fox_sig", onds: 1, dim: false, backup: false, cost: 1822, sell: 2850 },
    { code: "FOX-1OND-DIM",          label: "Solo HQ",         brand: "fox_sig", onds: 1, dim: true,  backup: false, cost: 2342, sell: 3500 },
    { code: "FOX-1OND-BAT-PB-NODIM", label: "Solo Backup",     brand: "fox_sig", onds: 1, dim: false, backup: true,  cost: 2844, sell: 4600 },
    { code: "FOX-1OND-BAT-PB-DIM",   label: "Solo Sécurité",   brand: "fox_sig", onds: 1, dim: true,  backup: true,  cost: 3364, sell: 5250 },
    { code: "FOX-2OND-LITE",         label: "Duo Lite",        brand: "fox_sig", onds: 2, dim: false, backup: false, cost: 2454, sell: 3850 },
    { code: "FOX-2OND-DIM",          label: "Duo HQ",          brand: "fox_sig", onds: 2, dim: true,  backup: false, cost: 2974, sell: 4500 },
    { code: "FOX-2OND-BAT-PB-NODIM", label: "Duo Backup",      brand: "fox_sig", onds: 2, dim: false, backup: true,  cost: 3476, sell: 5600 },
    { code: "FOX-2OND-BAT-PB-DIM",   label: "Duo Sécurité",    brand: "fox_sig", onds: 2, dim: true,  backup: true,  cost: 3996, sell: 6250 },
    { code: "TES-1PW3",              label: "Tesla Solo",      brand: "tesla",   onds: 1, dim: true,  backup: false, cost: 2402, sell: 3550 },
    { code: "TES-1PW3-PLUS",         label: "Tesla Solo Plus", brand: "tesla",   onds: 1, dim: true,  backup: true,  cost: 3424, sell: 5300 },
    { code: "TES-2PW3",              label: "Tesla Duo",       brand: "tesla",   onds: 2, dim: true,  backup: false, cost: 3034, sell: 4600 },
    { code: "TES-2PW3-PLUS",         label: "Tesla Duo Plus",  brand: "tesla",   onds: 2, dim: true,  backup: true,  cost: 4056, sell: 6350 }
  ],

  // Options Larks v16 (coût/vendant unitaire)
  larks_options: {
    "OPT-AC-METRE":     { label: "Câblage AC TECK 6/3 1KV", unit: "m",  cost: 34.08,  sell: 50 },
    "OPT-PV-1S-METRE":  { label: "Câblage PV 1 string TECK 10/2", unit: "m", cost: 18.93, sell: 30 },
    "OPT-PV-2S-METRE":  { label: "Câblage PV 2 strings TECK 10/4", unit: "m", cost: 23.07, sell: 35 },
    "OPT-PV-34S-METRE": { label: "Câblage PV 3-4 strings", unit: "m", cost: 34.99, sell: 55 },
    "OPT-CONDUIT-METRE":{ label: "Conduit PVC 2 po extérieur", unit: "m", cost: 19.33, sell: 30 },
    "OPT-RESEAU-WIFI":  { label: "Câblage réseau Wi-Fi onduleur", unit: "ens", cost: 105, sell: 150 },
    "OPT-V2X-SIG":      { label: "V2X CCS1 Sigenergy — installation", unit: "ens", cost: 930, sell: 1450 },
    "OPT-3E-OND":       { label: "3e onduleur additionnel (Fox/Sig)", unit: "ens", cost: 849.55, sell: 1300 },
    "OPT-MO-EXTRA":     { label: "Main-d'œuvre équipe 2 — heure additionnelle", unit: "h-équipe", cost: 140, sell: 225 },
    "OPT-MAINTENANCE":  { label: "Forfait maintenance annuelle", unit: "ens", cost: 507.50, sell: 775 },
    "OPT-RETRAIT":      { label: "Retrait/déconnexion ancien système", unit: "ens", cost: 450, sell: 700 },
    "OPT-LEVAGE-PW3":   { label: "Levage Tesla Powerwall 3 (accès difficile)", unit: "ens", cost: 240, sell: 375 }
  },

  // Zones de déplacement (v16)
  zones: [
    { key: "Z1", label: "Z1 — Mascouche/Terrebonne/Repentigny/Laval N (≤30 km)", cost: 0, sell: 0 },
    { key: "Z2", label: "Z2 — Laval/Rive-Sud/Mtl NE/St-Eustache (30-60 km)",    cost: 30, sell: 45 },
    { key: "Z3", label: "Z3 — Joliette/St-Jérôme/Granby/St-Hyacinthe (75-100 km)", cost: 100, sell: 155 },
    { key: "Z4", label: "Z4 — Drummondville/Sherbrooke/T-R/Gatineau (150-200 km)", cost: 230, sell: 350 },
    { key: "Z5", label: "Z5 — Québec/Saguenay/BSL (200-300 km)", cost: 410, sell: 625 },
    { key: "Z6", label: "Z6 — Régions ressources (sur soumission)", cost: 0, sell: 0, quoted: true }
  ],

  // === MATÉRIEL PRIMAIRE (prix réels catalogue v5) ===
  // Panneau de référence : Thornova TS-BB66 (500) All Black Bifacial — datasheet v2023.12.15
  panel_ref: {
    sku: "FRK-5000398",
    name: "Thornova TS-BB66(500) All Black Bifacial 500 W",
    watts: 500,
    cost: 168.97,
    sell: 211.21,
    warranty_product_years: 15,
    warranty_perf_years: 25,
    warranty_perf_min_pct: 84.8,
    degradation_pct_yr: 0.55,
    bifaciality_pct: 70,
    cells: 132,
    efficiency_pct: 21.06
  },

  // Tesla mPower réel
  tesla_skus: {
    pw3:           { sku: "MPW-1707000-11-M", name: "Tesla Powerwall 3",            cost: 9840,  sell: 12300,   kwh: 13.5, kw: 11.5 },
    pw3_dc_exp:    { sku: "MPW-1807000-20-B", name: "Tesla Powerwall 3 DC Expansion", cost: 7800, sell: 9750,    kwh: 13.5, kw: 0 },
    gw3:           { sku: "MPW-1841000-01-E", name: "Tesla Energy Gateway 3",       cost: 1165,  sell: 1456.25 },
    bag:           { sku: "MPW-1857363-00-F", name: "Powerwall 3 Accessory Bag",    cost: 108,   sell: 162 },
    rmm:           { sku: "MPW-2045796-00-A", name: "Tesla Primary Remote Meter Kit + 2× CT 200A", cost: 313, sell: 469.50 },
    stack:         { sku: "MPW-1978070-00-C", name: "PW3 Expansion Stacking Kit",   cost: 186,   sell: 279 }
  },

  // Onduleur hybride générique (Fox ESS Hub G2 réel + AIO estimé)
  // Fox Hub G2 (DIM HQ) : Franken Solar FRK — coût 565.13 / vente 706.41
  fox_hub_g2: { cost: 565.13, sell: 706.41 },
  // Onduleurs limités à 12 kW chacun (Larks)
  generic_hybrid_inverter: { cost: 3500, sell: 5000, kw: 11.4 }, // ~12 kW max single
  generic_lfp_10kwh:       { cost: 5500, sell: 7700, kwh: 10 },

  // Coûts kit racking (par 10 panneaux)
  racking_per_10: { cost: 850, sell: 1360 },
  // Câblage solaire générique par kit (cost / sell)
  solar_wiring_kit: { cost: 320, sell: 450 },
  solar_protections: { cost: 280, sell: 400 },
  combiner_kit: { cost: 220, sell: 320 },
  monitoring_kit: { cost: 350, sell: 500 },
  // Ingénierie OIQ + permis HQ
  oiq_seal: { cost: 600, sell: 900 },
  hq_permit: { cost: 450, sell: 680 },

  // === MARQUES BATTERIE ===
  battery_brands: [
    { key: "tesla",  name: "Tesla Powerwall 3", logo_text: "TESLA",     sub: "PW3 · onduleur intégré 11,5 kW · Gateway 3 (DIM intégré)", dim_required: true,  dim_label: "Gateway 3",  larks_brand: "tesla" },
    { key: "fox",    name: "Fox ESS",           logo_text: "FOX ESS",   sub: "AIO FLEX 11,4 kW · ECS 8/16/20/24/28 kWh · Hub G2 DIM", dim_required: false, dim_label: "Hub G2",     larks_brand: "fox_sig" },
    { key: "sig",    name: "Sigenergy",         logo_text: "SIGENERGY", sub: "SigenStor 11,5 kW · LoadHub DIM · V2X CCS1/NACS 25 kW (prix mars 2026)",  dim_required: false, dim_label: "LoadHub",    larks_brand: "fox_sig" },
    { key: "solark", name: "Sol-Ark",           logo_text: "SOL-ARK",   sub: "12K/15K hybride · stockage HomeGrid/Pytes · DIM externe", dim_required: false, dim_label: "DIM externe", larks_brand: "fox_sig" },
    { key: "other",  name: "Autre / non décidé",logo_text: "—",         sub: "Solis/Growatt/Enphase/Hoymiles — devis sur soumission",   dim_required: false, dim_label: "—",          larks_brand: "fox_sig" },
    { key: "none",   name: "Sans batterie",     logo_text: "—",         sub: "Mesurage net pur — onduleur string standard",            dim_required: false, dim_label: "—",          larks_brand: "fox_sig" }
  ],

  // Presets batterie — cost_inv et cost_batt sont les COÛTANTS MATÉRIEL primaires
  // Le cout d'install Larks vient du forfait, séparé
  battery_packs: {
    tesla: [
      { id: "tesla-1pw3",       label: "1 × PW3",                  kwh: 13.5, kw_inv: 11.5, onds: 1, cost_inv: 1165,        cost_batt: 9840,   ls: 1, v2x: false }, // GW3 + 1 PW3
      { id: "tesla-1pw3-1exp",  label: "1 × PW3 + 1 expansion",    kwh: 27,   kw_inv: 11.5, onds: 1, cost_inv: 1165,        cost_batt: 17640,  ls: 2, v2x: false }, // GW3 + PW3 + Exp
      { id: "tesla-2pw3",       label: "2 × PW3",                  kwh: 27,   kw_inv: 23,   onds: 2, cost_inv: 1165,        cost_batt: 19680,  ls: 2, v2x: false }, // GW3 + 2 PW3
      { id: "tesla-2pw3-2exp",  label: "2 × PW3 + 2 expansions",   kwh: 54,   kw_inv: 23,   onds: 2, cost_inv: 1165,        cost_batt: 35280,  ls: 4, v2x: false },
      { id: "tesla-3pw3",       label: "3 × PW3 (Triple)",         kwh: 40.5, kw_inv: 34.5, onds: 3, cost_inv: 1165,        cost_batt: 29520,  ls: 3, v2x: false }
    ],
    fox: [
      // === KITS bundlés (onduleur + batterie) ===
      { id: "fox-8",  label: "FLEX 11,4 kW + 8 kWh",  kwh: 8.06,  kw_inv: 11.4, onds: 1, cost_inv: 3500, cost_batt: 3600,  ls: 1, v2x: false, kind: "kit" },
      { id: "fox-16", label: "FLEX 11,4 kW + 16 kWh", kwh: 16.12, kw_inv: 11.4, onds: 1, cost_inv: 3500, cost_batt: 6900,  ls: 2, v2x: false, kind: "kit" },
      { id: "fox-20", label: "FLEX 11,4 kW + 20 kWh", kwh: 20.15, kw_inv: 11.4, onds: 1, cost_inv: 3500, cost_batt: 8500,  ls: 2, v2x: false, kind: "kit" },
      { id: "fox-24", label: "FLEX 11,4 kW + 24 kWh", kwh: 24.18, kw_inv: 11.4, onds: 1, cost_inv: 3500, cost_batt: 10100, ls: 3, v2x: false, kind: "kit" },
      { id: "fox-28", label: "FLEX 11,4 kW + 28 kWh", kwh: 28.21, kw_inv: 11.4, onds: 1, cost_inv: 3500, cost_batt: 11700, ls: 3, v2x: false, kind: "kit" },
      { id: "fox-duo-32", label: "DUO 22,8 kW + 32 kWh", kwh: 32.24, kw_inv: 22.8, onds: 2, cost_inv: 7000, cost_batt: 13400, ls: 3, v2x: false, kind: "kit" },
      // === ONDULEURS SEULS (sans batterie) — pour solaire pur ou ajout futur ===
      { id: "fox-inv-1",  label: "AIO FLEX 11,4 kW — onduleur seul",      kwh: 0, kw_inv: 11.4, onds: 1, cost_inv: 3500,  cost_batt: 0, ls: 0, v2x: false, kind: "inv" },
      { id: "fox-inv-2",  label: "DUO 22,8 kW — 2 onduleurs seuls",       kwh: 0, kw_inv: 22.8, onds: 2, cost_inv: 7000,  cost_batt: 0, ls: 0, v2x: false, kind: "inv" },
      { id: "fox-inv-3",  label: "TRIO 34,2 kW — 3 onduleurs seuls",      kwh: 0, kw_inv: 34.2, onds: 3, cost_inv: 10500, cost_batt: 0, ls: 0, v2x: false, kind: "inv" },
      // === BATTERIES SEULES (ECS) — ajout/extension à un onduleur existant ===
      { id: "fox-batt-8",  label: "ECS 8 kWh — batterie seule",   kwh: 8.06,  kw_inv: 0, onds: 0, cost_inv: 0, cost_batt: 3600,  ls: 1, v2x: false, kind: "batt" },
      { id: "fox-batt-16", label: "ECS 16 kWh — batterie seule",  kwh: 16.12, kw_inv: 0, onds: 0, cost_inv: 0, cost_batt: 6900,  ls: 2, v2x: false, kind: "batt" },
      { id: "fox-batt-20", label: "ECS 20 kWh — batterie seule",  kwh: 20.15, kw_inv: 0, onds: 0, cost_inv: 0, cost_batt: 8500,  ls: 2, v2x: false, kind: "batt" },
      { id: "fox-batt-24", label: "ECS 24 kWh — batterie seule",  kwh: 24.18, kw_inv: 0, onds: 0, cost_inv: 0, cost_batt: 10100, ls: 3, v2x: false, kind: "batt" },
      { id: "fox-batt-28", label: "ECS 28 kWh — batterie seule",  kwh: 28.21, kw_inv: 0, onds: 0, cost_inv: 0, cost_batt: 11700, ls: 3, v2x: false, kind: "batt" }
    ],
    sig: [
      // Sigenergy KITS (LoadHub + Contrôleur 11,5 kW inclus) — source : Prix partenaires SigEnergy mars 2026
      // Composants : Contrôleur 11,5 kW coût 2368 $, LoadHub 200 A coût 1509 $ (= 3877 $ installé), Batt 6 kWh 2896 $, Batt 9 kWh 3799 $, V2X 3517 $
      { id: "sig-6",      label: "KIT 1 BAT 6 kWh (SigenStor)",          kwh: 6,  kw_inv: 11.5, onds: 1, cost_inv: 3877, cost_batt: 2896,  sell_total: 9143.55,  ls: 1, v2x: false, kind: "kit" },
      { id: "sig-9",      label: "KIT 1 BAT 9 kWh",                     kwh: 9,  kw_inv: 11.5, onds: 1, cost_inv: 3877, cost_batt: 3799,  sell_total: 10362.60, ls: 2, v2x: false, kind: "kit" },
      { id: "sig-15",     label: "KIT 1 BAT 9 + 1 BAT 6 (15 kWh)",      kwh: 15, kw_inv: 11.5, onds: 1, cost_inv: 3877, cost_batt: 6695,  sell_total: 14272.20, ls: 2, v2x: false, kind: "kit" },
      { id: "sig-18",     label: "KIT 2 BAT 9 (18 kWh)",                kwh: 18, kw_inv: 11.5, onds: 1, cost_inv: 3877, cost_batt: 7598,  sell_total: 15491.25, ls: 2, v2x: false, kind: "kit" },
      { id: "sig-24",     label: "KIT 2 BAT 9 + 1 BAT 6 (24 kWh)",      kwh: 24, kw_inv: 11.5, onds: 1, cost_inv: 3877, cost_batt: 10494, sell_total: 19400.85, ls: 3, v2x: false, kind: "kit" },
      { id: "sig-27",     label: "KIT 3 BAT 9 (27 kWh)",                kwh: 27, kw_inv: 11.5, onds: 1, cost_inv: 3877, cost_batt: 11397, sell_total: 20619.90, ls: 3, v2x: false, kind: "kit" },
      // V2X variants — ajoute borne V2X NACS/CCS1 3517 $
      { id: "sig-9-v2x",  label: "KIT 1 BAT 9 + V2X (9 kWh)",           kwh: 9,  kw_inv: 11.5, onds: 1, cost_inv: 7394, cost_batt: 3799,  sell_total: 15110.55, ls: 2, v2x: true, kind: "kit" },
      { id: "sig-18-v2x", label: "KIT 2 BAT 9 + V2X (18 kWh)",          kwh: 18, kw_inv: 11.5, onds: 1, cost_inv: 7394, cost_batt: 7598,  sell_total: 20239.20, ls: 2, v2x: true, kind: "kit" },
      { id: "sig-27-v2x", label: "KIT 3 BAT 9 + V2X (27 kWh)",          kwh: 27, kw_inv: 11.5, onds: 1, cost_inv: 7394, cost_batt: 11397, sell_total: 25367.85, ls: 3, v2x: true, kind: "kit" },
      // Configuration Duo Larks (2 contrôleurs en parallèle pour > 12 kW)
      { id: "sig-duo-36-v2x", label: "DUO 23 kW + 36 kWh + V2X",       kwh: 36, kw_inv: 23,   onds: 2, cost_inv: 9762, cost_batt: 15196, sell_total: 33500,    ls: 3, v2x: true, kind: "kit" },
      // === ONDULEURS SEULS (Contrôleur 11,5 kW + LoadHub 200 A) — sans batterie ===
      { id: "sig-inv-1",     label: "Contrôleur 11,5 kW + LoadHub — onduleur seul", kwh: 0, kw_inv: 11.5, onds: 1, cost_inv: 3877, cost_batt: 0, ls: 0, v2x: false, kind: "inv" },
      { id: "sig-inv-2",     label: "DUO 23 kW (2 contrôleurs + LoadHub) seul",    kwh: 0, kw_inv: 23,   onds: 2, cost_inv: 6245, cost_batt: 0, ls: 0, v2x: false, kind: "inv" },
      { id: "sig-inv-1-v2x", label: "Contrôleur 11,5 kW + LoadHub + V2X — seul",   kwh: 0, kw_inv: 11.5, onds: 1, cost_inv: 7394, cost_batt: 0, ls: 0, v2x: true,  kind: "inv" },
      // === BATTERIES SEULES (SigenStor) — ajout à un système existant ===
      { id: "sig-batt-6",  label: "SigenStor 6 kWh — batterie seule",  kwh: 6,  kw_inv: 0, onds: 0, cost_inv: 0, cost_batt: 2896, ls: 1, v2x: false, kind: "batt" },
      { id: "sig-batt-9",  label: "SigenStor 9 kWh — batterie seule",  kwh: 9,  kw_inv: 0, onds: 0, cost_inv: 0, cost_batt: 3799, ls: 2, v2x: false, kind: "batt" },
      { id: "sig-batt-15", label: "SigenStor 9 + 6 (15 kWh) — seules", kwh: 15, kw_inv: 0, onds: 0, cost_inv: 0, cost_batt: 6695, ls: 2, v2x: false, kind: "batt" },
      { id: "sig-batt-18", label: "SigenStor 2× 9 (18 kWh) — seules",  kwh: 18, kw_inv: 0, onds: 0, cost_inv: 0, cost_batt: 7598, ls: 2, v2x: false, kind: "batt" }
    ],
    solark: [
      { id: "solark-12k-15", label: "12K + HomeGrid 15 kWh", kwh: 14.4, kw_inv: 12, onds: 1, cost_inv: 4200, cost_batt: 6800,  ls: 2, v2x: false },
      { id: "solark-15k-20", label: "15K + HomeGrid 20 kWh", kwh: 19.2, kw_inv: 15, onds: 2, cost_inv: 4800, cost_batt: 8900,  ls: 2, v2x: false },
      { id: "solark-15k-30", label: "15K + HomeGrid 30 kWh", kwh: 28.8, kw_inv: 15, onds: 2, cost_inv: 4800, cost_batt: 12600, ls: 3, v2x: false }
    ],
    other: [
      { id: "other-10",     label: "Estimation générique 10 kWh", kwh: 10, kw_inv: 10, onds: 1, cost_inv: 3500, cost_batt: 5500, ls: 1, v2x: false }
    ],
    none: []
  },

  // === TYPES BÂTIMENT ===
  building_types: [
    { key: "residentiel_unifam", label: "Résidentiel unifamilial",        margin: 0.35, kw_max: 20,  segment: "res" },
    { key: "multilog",           label: "Multilogement (4–12 log.)",       margin: 0.35, kw_max: 50,  segment: "res" },
    { key: "com_petit",          label: "Commercial petit (<50 kW)",       margin: 0.33, kw_max: 50,  segment: "com_p" },
    { key: "com_moyen",          label: "Commercial moyen (50–200 kW)",    margin: 0.30, kw_max: 200, segment: "com_m" },
    { key: "com_grand",          label: "Commercial grand (>200 kW)",      margin: 0.25, kw_max: 500, segment: "com_g" }
  ],

  // === TYPES TOITURE ===
  roof_types: [
    { key: "asphalte",    label: "Toit asphalte (bardeaux)",   sub: "Standard, installation rapide",     flat: false, larks_supported: true },
    { key: "metal_joint", label: "Toit métal (joint debout)",  sub: "Fixation sans perçage, plus rapide", flat: false, larks_supported: true },
    { key: "metal_tole",  label: "Toit métal (tôle agricole)", sub: "Perçage requis",                     flat: false, larks_supported: true },
    { key: "tpo",         label: "Toit membrane TPO",          sub: "Lestage ou collage",                 flat: true,  larks_supported: false },
    { key: "epdm",        label: "Toit membrane EPDM",         sub: "Lestage ou collage",                 flat: true,  larks_supported: false },
    { key: "ground",      label: "Sol (ground mount)",         sub: "Excavation + structure",             flat: true,  larks_supported: false }
  ],

  // === MATRICE $/W TARIFICATION SOLAIRE ===
  // Format : [building_key, roof_key] → { no_batt, with_batt_10kwh }
  // Source : feuille « Tarification_Solaire » catalogue v5
  rates_solar: [
    { building: "residentiel_unifam", roof: "asphalte",    no_batt: 3.10, with_batt: 4.20 },
    { building: "residentiel_unifam", roof: "metal_joint", no_batt: 3.30, with_batt: 4.40 },
    { building: "residentiel_unifam", roof: "metal_tole",  no_batt: 3.40, with_batt: 4.50 },
    { building: "residentiel_unifam", roof: "tpo",         no_batt: 3.60, with_batt: 4.70 },
    { building: "residentiel_unifam", roof: "epdm",        no_batt: 3.60, with_batt: 4.70 },
    { building: "residentiel_unifam", roof: "ground",      no_batt: 3.50, with_batt: 4.60 },

    { building: "multilog", roof: "asphalte",    no_batt: 3.10, with_batt: 4.20 },
    { building: "multilog", roof: "metal_joint", no_batt: 3.20, with_batt: 4.30 },
    { building: "multilog", roof: "metal_tole",  no_batt: 3.30, with_batt: 4.40 },
    { building: "multilog", roof: "tpo",         no_batt: 3.20, with_batt: 4.30 },
    { building: "multilog", roof: "epdm",        no_batt: 3.20, with_batt: 4.30 },
    { building: "multilog", roof: "ground",      no_batt: 3.40, with_batt: 4.50 },

    { building: "com_petit",  roof: "tpo", no_batt: 2.90, with_batt: 3.90 },
    { building: "com_petit",  roof: "epdm", no_batt: 2.90, with_batt: 3.90 },
    { building: "com_petit",  roof: "asphalte", no_batt: 3.00, with_batt: 4.00 },
    { building: "com_petit",  roof: "metal_joint", no_batt: 3.10, with_batt: 4.10 },
    { building: "com_petit",  roof: "metal_tole", no_batt: 3.10, with_batt: 4.10 },
    { building: "com_petit",  roof: "ground", no_batt: 3.20, with_batt: 4.20 },

    { building: "com_moyen",  roof: "tpo", no_batt: 2.60, with_batt: 3.50 },
    { building: "com_moyen",  roof: "epdm", no_batt: 2.60, with_batt: 3.50 },
    { building: "com_moyen",  roof: "asphalte", no_batt: 2.70, with_batt: 3.60 },
    { building: "com_moyen",  roof: "metal_joint", no_batt: 2.80, with_batt: 3.70 },
    { building: "com_moyen",  roof: "metal_tole", no_batt: 2.80, with_batt: 3.70 },
    { building: "com_moyen",  roof: "ground", no_batt: 2.90, with_batt: 3.80 },

    { building: "com_grand",  roof: "tpo", no_batt: 2.30, with_batt: 3.10 },
    { building: "com_grand",  roof: "epdm", no_batt: 2.30, with_batt: 3.10 },
    { building: "com_grand",  roof: "asphalte", no_batt: 2.40, with_batt: 3.20 },
    { building: "com_grand",  roof: "metal_joint", no_batt: 2.50, with_batt: 3.30 },
    { building: "com_grand",  roof: "metal_tole", no_batt: 2.50, with_batt: 3.30 },
    { building: "com_grand",  roof: "ground", no_batt: 2.60, with_batt: 3.40 }
  ],

  // === CATALOGUE BORNES VÉ (prix réels) ===
  bornes: [
    { key: "tesla_wc3",       brand: "Tesla", model: "Wall Connector Gen 3",         connector: "NACS",        kw: 11.5, cost: 600,  sell: 850,  rve: true },
    { key: "tesla_universal", brand: "Tesla", model: "Universal Wall Connector",     connector: "NACS+J1772",  kw: 11.5, cost: 720,  sell: 1020, rve: true },
    { key: "flo_x3",          brand: "FLO",   model: "Maison X3",                    connector: "J1772",       kw: 7.7,  cost: 549,  sell: 779,  rve: true },
    { key: "flo_x5",          brand: "FLO",   model: "Maison X5",                    connector: "J1772",       kw: 9.6,  cost: 690,  sell: 979,  rve: true },
    { key: "flo_x6",          brand: "FLO",   model: "Maison X6",                    connector: "J1772",       kw: 9.6,  cost: 850,  sell: 1210, rve: true },
    { key: "flo_x8",          brand: "FLO",   model: "Maison X8",                    connector: "J1772",       kw: 11.5, cost: 950,  sell: 1350, rve: true },
    { key: "chargepoint",     brand: "ChargePoint", model: "Home Flex",              connector: "J1772",       kw: 12,   cost: 715,  sell: 1015, rve: true },
    { key: "wallbox_pulsar",  brand: "Wallbox", model: "Pulsar Plus 48A 11,2 kW",    connector: "J1772",       kw: 11.5, cost: 739,  sell: 1049, rve: true },
    { key: "grizzle",         brand: "Grizzl-E", model: "Classic",                   connector: "J1772",       kw: 9.6,  cost: 489,  sell: 695,  rve: true },
    { key: "evduty",          brand: "EVduty",   model: "EVC30",                     connector: "J1772",       kw: 7.2,  cost: 599,  sell: 850,  rve: true },
    { key: "siemens_versi",   brand: "Siemens",  model: "VersiCharge Gen 3",         connector: "J1772",       kw: 11.5, cost: 690,  sell: 980,  rve: true },
    { key: "sig_v2x",         brand: "Sigenergy", model: "Roulez Électrique V2X",    connector: "CCS1",        kw: 25,   cost: 3800, sell: 5400, rve: true, v2x: true },
    { key: "client",          brand: "Client",   model: "Borne fournie par client",  connector: "—",           kw: 0,    cost: 0,    sell: 0,    rve: false }
  ],

  // Coûts install borne (en plus de la borne elle-même)
  borne_install: {
    fil_neuf:    { cost: 745, sell: 1066,  desc: "Câblage neuf RW90 #6 (15m), boîte+sectionneur, MO ~4h" },
    prefilage:   { cost: 220, sell: 330,   desc: "Réutilisation préfilage 2018+, disjoncteur dédié, MO ~2h" },
    cable_extra: { cost: 4.26, sell: 6.40, desc: "$/m additionnel au-delà de 50 pi" }, // RW90 #6 LMN
    dcc12:       { cost: 580, sell: 870,   desc: "DCC-12 RVE homologué HQ" },
    dsdc:        { cost: 320, sell: 480,   desc: "Tesla DSDC Remote Meter" }
  },

  // === RÉGIONS QC ===
  regions: [
    { key: "mascouche",  label: "Mascouche / Lanaudière", kwh_per_kw: 1170, zone: "Z1" },
    { key: "laval",      label: "Laval / Rive-Nord",      kwh_per_kw: 1175, zone: "Z2" },
    { key: "montreal",   label: "Montréal",               kwh_per_kw: 1180, zone: "Z2" },
    { key: "longueuil",  label: "Longueuil / Rive-Sud",   kwh_per_kw: 1175, zone: "Z2" },
    { key: "joliette",   label: "Joliette / St-Jérôme",   kwh_per_kw: 1170, zone: "Z3" },
    { key: "granby",     label: "Granby / St-Hyacinthe",  kwh_per_kw: 1195, zone: "Z3" },
    { key: "sherbrooke", label: "Sherbrooke / Estrie",    kwh_per_kw: 1195, zone: "Z4" },
    { key: "gatineau",   label: "Gatineau / Outaouais",   kwh_per_kw: 1210, zone: "Z4" },
    { key: "trois_riv",  label: "Trois-Rivières / Mauricie", kwh_per_kw: 1160, zone: "Z4" },
    { key: "quebec",     label: "Québec",                 kwh_per_kw: 1150, zone: "Z5" },
    { key: "saguenay",   label: "Saguenay-Lac-St-Jean",   kwh_per_kw: 1100, zone: "Z5" }
  ],

  // === PLANS FINANCEIT === (source : feuilles taux Financeit Québec, eff. 30 oct 2025)
  financeit_plans: [
    // Standard — crédit à 12,99 % (taux préf. 4,45 % + 8,54 %), aucun frais marchand
    { id: "comptant", label: "Comptant",                       apr: 0,     months: 0,   fee_pct: 0,    popular: true,  category: "Comptant" },
    { id: "60m",      label: "60 mois à 12,99 %",                apr: 12.99, months: 60,  fee_pct: 0,    popular: false, category: "Standard" },
    { id: "120m",     label: "120 mois à 12,99 %",               apr: 12.99, months: 120, fee_pct: 0,    popular: false, category: "Standard" },
    { id: "180m",     label: "180 mois à 12,99 %",               apr: 12.99, months: 180, fee_pct: 0,    popular: false, category: "Standard" },
    { id: "240m",     label: "240 mois à 12,99 % (sans frais marchand)", apr: 12.99, months: 240, fee_pct: 0, popular: true, category: "Standard" },
    // Promos spéciale (expirent 2026-07-01) — frais marchand prélevés sur le marchand
    { id: "3m0",      label: "3 mois à 0 % — sans paiement (promo)",   apr: 0,    months: 3,   fee_pct: 3.99, popular: true,  category: "Promo sans paiement" },
    { id: "6m0",      label: "6 mois à 0 % — sans paiement (promo)",   apr: 0,    months: 6,   fee_pct: 9.49, popular: true,  category: "Promo sans paiement" },
    { id: "12m0",     label: "12 mois à 0 % — sans paiement (promo)",  apr: 0,    months: 12,  fee_pct: 14.49, popular: false, category: "Promo sans paiement" },
    // Rachat de taux promos
    { id: "24m_799",  label: "24 mois à 7,99 % (rachat taux)",          apr: 7.99, months: 24,  fee_pct: 10.99, popular: false, category: "Rachat de taux" },
    { id: "36m_699",  label: "36 mois à 6,99 % (rachat taux)",          apr: 6.99, months: 36,  fee_pct: 15.99, popular: false, category: "Rachat de taux" },
    { id: "48m_799",  label: "48 mois à 7,99 % (rachat taux)",          apr: 7.99, months: 48,  fee_pct: 16.99, popular: false, category: "Rachat de taux" }
  ],

  // === TARIFS HQ ===
  hq_tariffs: [
    { id: "D",     label: "D — Résidentiel régulier",        rate: 7.78 },
    { id: "FlexD", label: "Flex D — Tarif dynamique",        rate: 8.10 },
    { id: "DP",    label: "DP — Pointe critique",            rate: 8.40 },
    { id: "DT",    label: "DT — Bi-énergie",                 rate: 6.95 },
    { id: "M",     label: "M — Moyenne puissance commerciale", rate: 6.20 },
    { id: "G",     label: "G — Petite puissance commerciale", rate: 9.15 },
    { id: "G9",    label: "G9 — Éclairage public",           rate: 5.40 }
  ],

  lead_sources: ["Référence client", "Site web", "Facebook / Instagram", "Visite spontanée", "Partenaire", "Autre"],

  // === MAPPING CODE POSTAL / VILLE → région + zone ===
  // Détecté automatiquement quand le vendeur entre l'adresse. Source : règle Hydro-Québec/Postes Canada.
  // Préfixe : 1er caractère = G (Québec/régions), H (Montréal), J (couronne) ; chiffres suivants raffinent.
  address_lookup: [
    // Lanaudière / Couronne nord (Mascouche, Terrebonne, Repentigny) — Z1
    { prefix: "J7K", city: "Mascouche",   region_id: "mascouche", zone: "Z1" },
    { prefix: "J6V", city: "Terrebonne",  region_id: "mascouche", zone: "Z1" },
    { prefix: "J6W", city: "Terrebonne",  region_id: "mascouche", zone: "Z1" },
    { prefix: "J6X", city: "Terrebonne",  region_id: "mascouche", zone: "Z1" },
    { prefix: "J5Y", city: "Repentigny",  region_id: "mascouche", zone: "Z1" },
    { prefix: "J5Z", city: "Repentigny",  region_id: "mascouche", zone: "Z1" },
    { prefix: "J6A", city: "Repentigny",  region_id: "mascouche", zone: "Z1" },
    // Laval — Z2
    { prefix: "H7",  city: "Laval",       region_id: "laval",     zone: "Z2" },
    // Montréal — Z2
    { prefix: "H1",  city: "Montréal",    region_id: "montreal",  zone: "Z2" },
    { prefix: "H2",  city: "Montréal",    region_id: "montreal",  zone: "Z2" },
    { prefix: "H3",  city: "Montréal",    region_id: "montreal",  zone: "Z2" },
    { prefix: "H4",  city: "Montréal",    region_id: "montreal",  zone: "Z2" },
    // Rive-Sud (Longueuil) — Z2
    { prefix: "J3",  city: "Longueuil",   region_id: "longueuil", zone: "Z2" },
    { prefix: "J4",  city: "Longueuil",   region_id: "longueuil", zone: "Z2" },
    // Joliette / Saint-Jérôme — Z3
    { prefix: "J6E", city: "Joliette",    region_id: "joliette",  zone: "Z3" },
    { prefix: "J7Y", city: "Saint-Jérôme",region_id: "joliette",  zone: "Z3" },
    { prefix: "J7Z", city: "Saint-Jérôme",region_id: "joliette",  zone: "Z3" },
    // Granby / Saint-Hyacinthe — Z3
    { prefix: "J2G", city: "Granby",      region_id: "granby",    zone: "Z3" },
    { prefix: "J2H", city: "Granby",      region_id: "granby",    zone: "Z3" },
    { prefix: "J2S", city: "Saint-Hyacinthe", region_id: "granby", zone: "Z3" },
    // Sherbrooke — Z4
    { prefix: "J1",  city: "Sherbrooke",  region_id: "sherbrooke",zone: "Z4" },
    // Trois-Rivières — Z4
    { prefix: "G8",  city: "Trois-Rivières", region_id: "trois_riv", zone: "Z4" },
    { prefix: "G9",  city: "Trois-Rivières", region_id: "trois_riv", zone: "Z4" },
    // Gatineau — Z4
    { prefix: "J8",  city: "Gatineau",    region_id: "gatineau",  zone: "Z4" },
    { prefix: "J9",  city: "Gatineau",    region_id: "gatineau",  zone: "Z4" },
    // Québec — Z5
    { prefix: "G1",  city: "Québec",      region_id: "quebec",    zone: "Z5" },
    { prefix: "G2",  city: "Québec",      region_id: "quebec",    zone: "Z5" },
    { prefix: "G3",  city: "Québec",      region_id: "quebec",    zone: "Z5" },
    // Saguenay — Z5
    { prefix: "G7",  city: "Saguenay",    region_id: "saguenay",  zone: "Z5" }
  ],

  // === OPTIONS SOLAIRES === (selon vendeur Raycom — extras hors forfait courants)
  options_solaire: [
    { id: "OPT-PNL-200A",    label: "Upgrade panneau électrique 200 A — 40 circuits (Siemens) · démarches HQ", cost: 2318.81, sell: 3130.39 },
    { id: "OPT-BORNE-SUS",   label: "Raccordement borne VÉ niveau 2 en sus du système (48 A · 11,5 kW)",     cost: 1547.90, sell: 2012.27 },
    { id: "OPT-MAINTENANCE", label: "Forfait maintenance annuelle (par système)",                            cost: 507.50,  sell: 775 },
    { id: "OPT-LEVAGE-PW3",  label: "Levage Tesla Powerwall 3 — accès difficile",                            cost: 240,     sell: 375 },
    { id: "OPT-RESEAU-WIFI", label: "Câblage réseau Wi-Fi (onduleur ↔ routeur, Cat6 jusqu'à 10 m)",          cost: 105,     sell: 150 },
    { id: "OPT-3E-OND",      label: "3e onduleur additionnel (Fox/Sig grand format)",                        cost: 849.55,  sell: 1300 },
    { id: "OPT-MO-EXTRA-4H", label: "Main-d'œuvre additionnelle équipe 2 (4 h forfait)",                     cost: 560,     sell: 900 }
  ],

  // Service amperage
  service_options: [100, 200, 300, 400],

  // Backup modes — affecté par le forfait Larks (Backup/Sécurité vs Lite/HQ)
  // Règle métier : tout système AVEC batterie alimente automatiquement des charges critiques
  // ou la maison au complet — le mode « mesurage net seul » est réservé au solaire sans batterie
  backup_modes: [
    { key: "partial",    label: "Charges critiques",   sub: "Sub-panel 100 A — backup sélectif (frigo, chauffage, prises)",  delta: 0, requires_battery: true },
    { key: "whole_home", label: "Backup complet",      sub: "Maison entière via Gateway 3 / LoadHub (≤ 200 A)",            delta: 0, requires_battery: true },
    { key: "none",       label: "Mesurage net seul",   sub: "Pas de backup en panne — solaire pur",                         delta: 0, requires_battery: false }
  ],

  // V16 paramètres
  v16_params: {
    marge_cible: 0.35,
    marge_plancher: 0.30,
    mo_compagnon: 90,
    mo_apprenti: 50,
    mo_equipe_2: 140,
    mo_jf: 175,
    mo_kim: 60,
    permis_mun_refact: 0.15
  }
};

window.RAYCOM_DATA = RAYCOM_DATA;
