// Veridian Markets — mock dataset.
// Fictional/illustrative numbers; not market data.
//
// ARCHITECTURE:
//   VM_INDEX      — global market strip (not per-company)
//   VM_COMPANIES  — company list used by Screener, FrontPage, etc.
//   VM_COMPANY_DATA — all per-company detail, keyed by ticker
//   resolveCompany(ticker) — THE DATA SEAM.
//     Today: returns mock from VM_COMPANY_DATA.
//     Later: replace the body with fetch('/api/company/${ticker}').
//     All tabs call this; none read VM_COMPANY_DATA directly.

const VM_INDEX = [
  { sym:'S&P 500', val:'5,247.10', chg:'+0.42%', dir:'up'   },
  { sym:'NASDAQ',  val:'16,542',   chg:'+0.71%', dir:'up'   },
  { sym:'DOW',     val:'38,991',   chg:'-0.18%', dir:'down' },
  { sym:'GOLD',    val:'2,341',    chg:'+0.88%', dir:'up'   },
  { sym:'OIL',     val:'$78.14',   chg:'+1.40%', dir:'up'   },
  { sym:'BTC',     val:'69,420',   chg:'-2.31%', dir:'down' },
  { sym:'EUR/USD', val:'1.0842',   chg:'-0.09%', dir:'down' },
  { sym:'10Y UST', val:'4.21%',    chg:'-0.03',  dir:'down' },
];

const VM_COMPANIES = [
  { ticker:'AAPL', name:'Apple Inc.',         sector:'Tech · Consumer',       cap:'$4.54T', price:'308.82', chg:'+1.26%', dir:'up',
    sub:'Consumer electronics', analogue:'MSFT', analogueYear:'2014', match:87,
    inputs:[{t:'TSM',d:'chips'},{t:'2317.TW',d:'assembly'},{t:'LPL',d:'OLED'},{t:'SONY',d:'sensors'},{t:'QCOM',d:'modems'}],
    external:[{t:'MAERSK.B',d:'shipping'},{t:'XOM',d:'energy'},{t:'MP',d:'rare-earth'},{t:'ALB',d:'battery'}],
    customers:[{t:'TMUS',d:'carrier'},{t:'VZ',d:'carrier'},{t:'BBY',d:'retail'},{t:'COST',d:'retail'},{t:'AMZN',d:'retail+cloud'}],
    competitors:[{t:'005930.KS',d:'Samsung'},{t:'1810.HK',d:'Xiaomi'},{t:'GOOGL',d:'Alphabet'},{t:'MSFT',d:'Microsoft'}] },
  { ticker:'NVDA', name:'NVIDIA Corp.',       sector:'Tech · Semiconductors', cap:'$2.32T', price:'945.10', chg:'+3.40%', dir:'up',   sub:'Accelerated computing', analogue:'CSCO', analogueYear:'1999', match:70 },
  { ticker:'MSFT', name:'Microsoft Corp.',    sector:'Tech · Software',       cap:'$3.17T', price:'427.15', chg:'+0.84%', dir:'up',   sub:'Cloud + software',      analogue:'IBM',  analogueYear:'2004', match:71 },
  { ticker:'GOOGL',name:'Alphabet Inc.',      sector:'Tech · Advertising',    cap:'$2.13T', price:'172.04', chg:'-0.42%', dir:'down', sub:'Search + ads',           analogue:'AAPL', analogueYear:'2013', match:59 },
  { ticker:'AMZN', name:'Amazon.com Inc.',    sector:'Retail · Cloud',        cap:'$1.93T', price:'185.30', chg:'+0.91%', dir:'up',   sub:'Marketplace + AWS',      analogue:'WMT',  analogueYear:'2001', match:55 },
  { ticker:'META', name:'Meta Platforms',     sector:'Tech · Social',         cap:'$1.27T', price:'498.22', chg:'+1.87%', dir:'up',   sub:'Social + ads',           analogue:'GOOGL',analogueYear:'2015', match:62 },
  { ticker:'TSLA', name:'Tesla, Inc.',        sector:'Auto · EVs',            cap:'$580B',  price:'182.04', chg:'-2.14%', dir:'down', sub:'EVs + energy',           analogue:'AMZN', analogueYear:'2014', match:48 },
  { ticker:'BRK.B',name:'Berkshire Hathaway', sector:'Conglomerate',          cap:'$903B',  price:'418.92', chg:'+0.31%', dir:'up',   sub:'Insurance + holdings',   analogue:'GE',   analogueYear:'1998', match:51 },
  { ticker:'AVGO', name:'Broadcom Inc.',      sector:'Tech · Semiconductors', cap:'$623B',  price:'1342.0', chg:'+2.10%', dir:'up',   sub:'Semis + software',       analogue:'TXN',  analogueYear:'2010', match:57 },
  { ticker:'JPM',  name:'JPMorgan Chase',     sector:'Finance · Banking',     cap:'$615B',  price:'215.40', chg:'+0.18%', dir:'up',   sub:'Universal bank',         analogue:'WFC',  analogueYear:'2006', match:44 },
  { ticker:'V',    name:'Visa Inc.',          sector:'Finance · Payments',    cap:'$560B',  price:'275.18', chg:'+0.55%', dir:'up',   sub:'Payment rails',          analogue:'MA',   analogueYear:'2012', match:66 },

  // Indices / commodities / forex — added for testing the search list (not equities).
  { ticker:'SPX',    name:'S&P 500 Index',     sector:'Index · US large-cap',  cap:'—', price:'5,247.10', chg:'+0.42%', dir:'up',   sub:'US 500 large-caps',   analogue:'1995', analogueYear:'1995', match:61 },
  { ticker:'GOLD',   name:'Gold · spot',       sector:'Commodity · Metals',    cap:'—', price:'2,341',    chg:'+0.88%', dir:'up',   sub:'Safe-haven metal',    analogue:'1979', analogueYear:'1979', match:58 },
  { ticker:'WTI',    name:'Crude Oil · WTI',   sector:'Commodity · Energy',    cap:'—', price:'78.14',    chg:'+1.40%', dir:'up',   sub:'US benchmark crude',  analogue:'1973', analogueYear:'1973', match:53 },
  { ticker:'EURUSD', name:'Euro / US Dollar',  sector:'Forex · Majors',        cap:'—', price:'1.0842',   chg:'-0.09%', dir:'down', sub:'EUR/USD spot',        analogue:'2002', analogueYear:'2002', match:47 },
  { ticker:'GBPUSD', name:'Pound / US Dollar', sector:'Forex · Majors',        cap:'—', price:'1.2710',   chg:'-0.12%', dir:'down', sub:'GBP/USD spot',        analogue:'1992', analogueYear:'1992', match:45 },
  { ticker:'USDJPY', name:'US Dollar / Yen',   sector:'Forex · Majors',        cap:'—', price:'156.30',   chg:'+0.21%', dir:'up',   sub:'USD/JPY spot',        analogue:'1998', analogueYear:'1998', match:49 },
];

// ─────────────────────────────────────────────────────────────────────────────
// Per-company detail. Add a new key when a new company is wired up.
// Shape must stay consistent across tickers — tabs depend on it.
// ─────────────────────────────────────────────────────────────────────────────
const VM_COMPANY_DATA = {
  AAPL: {
    overview: {
      description: 'Apple Inc. designs, manufactures, and markets smartphones, personal computers, tablets, wearables, and accessories. It also operates one of the world\'s largest software-services businesses — App Store, iCloud, Apple Music, advertising — now ~22% of revenue and growing roughly twice as fast as hardware.',
      sector:      'Technology · Consumer electronics',
      subIndustry: 'Mobile hardware + Services',
      index:       'S&P 500 · NDX 100 · DJIA',
      country:     'United States',
    },
    quick: [
      ['Founded',       '1 April 1976'],
      ['HQ',            'Cupertino, CA'],
      ['Employees',     '161,000'],
      ['Fiscal year',   'Ends Sep · FY = Oct–Sep'],
      ['Exchange',      'NASDAQ · since Dec 1980'],
      ['Auditor',       'Ernst & Young'],
      ['Lead bank',     'Goldman Sachs · JPM'],
      ['Next earnings', 'Jan 28 · FY26 Q1'],
    ],
    revenueMix: [
      { k:'iPhone',    v:52, c:'#1D4E3A' },
      { k:'Services',  v:22, c:'#C46A3B' },
      { k:'Wearables', v:10, c:'#8A857D' },
      { k:'Mac',       v:9,  c:'#2D5E5A' },
      { k:'iPad',      v:7,  c:'#B6AFA2' },
    ],
    revenueMixMeta: 'FY2025 · $397B',
    leaders: [
      { role:'CEO',      name:'Tim Cook',      since:'Aug 2011', note:'Replaced Jobs. Operations specialist; ran supply chain since 1998.' },
      { role:'CFO',      name:'Kevan Parekh',  since:'Jan 2025', note:'Internal promote; ran corporate finance previously.' },
      { role:'COO',      name:'Jeff Williams', since:'Dec 2015', note:'Apple Watch lead. Often-floated CEO successor.' },
      { role:'CHIEF HW', name:'John Ternus',   since:'Jan 2021', note:'iPhone, iPad, Mac engineering. Rising profile.' },
    ],
    financials: {
      periods: ['TTM', 'FY2025', 'FY2024', 'FY2023', 'FY2022'],
      income: [
        { k:'Total revenue',         v:[397000,391000,383285,394328,365817], b:false       },
        { k:'Cost of revenue',       v:[211000,207000,201471,212981,201471], b:false, in:1 },
        { k:'Gross profit',          v:[186000,184000,181814,181347,164346], b:true        },
        { k:'Operating expense',     v:[58000, 57000, 56054, 54847, 51345],  b:false, in:1 },
        { k:'Operating income',      v:[128000,127000,125760,126500,112901], b:true        },
        { k:'Interest expense, net', v:[-4800, -4600, -3765, -2931, -2692],  b:false, in:1 },
        { k:'Pre-tax income',        v:[124000,123000,121862,116918,111884], b:false       },
        { k:'Tax provision',         v:[29000, 28900, 29584, 29749, 25371],  b:false, in:1 },
        { k:'Net income',            v:[95000, 94000, 93736, 96995, 90000],  b:true        },
        { k:'EPS diluted',           v:[6.51,  6.42,  6.08,  6.11,  5.61],  b:false, fmt:'eps' },
        { k:'EBITDA',                v:[139000,138000,134661,130071,123000], b:false       },
      ],
      balance: [
        { k:'Cash & equivalents',    v:[67000, 65000, 29965, 29965, 23646],  b:false       },
        { k:'Short-term investments',v:[21000, 19000, 35228, 31590, 24658],  b:false, in:1 },
        { k:'Total current assets',  v:[152000,149000,152987,143566,135405], b:true        },
        { k:'Total assets',          v:[353000,352000,364980,352583,352755], b:true        },
        { k:'Long-term debt',        v:[98000, 97000, 85750, 98959,109106],  b:false, in:1 },
        { k:'Total liabilities',     v:[290000,288000,308030,290437,302083], b:true        },
        { k:'Shareholders equity',   v:[62000, 63000, 56950, 62146, 50672],  b:true        },
      ],
      cashflow: [
        { k:'Operating cash flow',   v:[118000,116000,118254,114301, 99803], b:true        },
        { k:'Capital expenditure',   v:[-11000,-11000,-9447,-10959,-10708],  b:false, in:1 },
        { k:'Free cash flow',        v:[107000,105000,108807,103342, 89095], b:true        },
        { k:'Investing activities',  v:[-18000,-17000,-3236,-19891,-22354],  b:false, in:1 },
        { k:'Financing activities',  v:[-99000,-98000,-112,-95984,-77560],   b:false, in:1 },
        { k:'Net change in cash',    v:[1000,  1000,  1000, -1571,-10952],   b:false       },
      ],
    },
    patents: {
      stats: [
        ['Active patents', '2,334'],
        ['Filed FY2025',   '820 ∂'],
        ['Granted FY2025', '512'],
        ['In litigation',  '14'],
      ],
      cats: [
        { k:'Semiconductor design', pct:22, n:515, c:'#1D4E3A' },
        { k:'Display · optical',    pct:16, n:374, c:'#C46A3B' },
        { k:'Wireless · RF',        pct:13, n:305, c:'#1F1D1A' },
        { k:'AI · on-device ML',    pct:12, n:281, c:'#2D5E5A' },
        { k:'Battery · power',      pct:10, n:234, c:'#B35A3A' },
        { k:'Health · sensors',     pct:9,  n:211, c:'#8A857D' },
        { k:'Camera · imaging',     pct:10, n:234, c:'#185FA5' },
        { k:'Audio · spatial',      pct:8,  n:187, c:'#B6AFA2' },
      ],
      filings: [
        { y:'FY20', n:2380 }, { y:'FY21', n:2614 }, { y:'FY22', n:2190 },
        { y:'FY23', n:2340 }, { y:'FY24', n:2512 }, { y:'FY25', n:820, partial:true },
      ],
      notable: [
        { id:'US11,956,321', filed:'Nov 2023', granted:'Mar 2025', title:'On-device neural processing with dynamic power allocation',                          area:'AI · on-device ML'  },
        { id:'US11,874,019', filed:'Aug 2023', granted:'Jan 2025', title:'Variable refresh rate OLED with ambient-adaptive tone mapping',                     area:'Display · optical'  },
        { id:'US11,801,247', filed:'Feb 2023', granted:'Oct 2024', title:'Millimetre-wave phased-array antenna integration in thin-form chassis',             area:'Wireless · RF'      },
        { id:'US11,734,502', filed:'Dec 2022', granted:'Aug 2024', title:'Electrochemical cell health monitoring via impedance spectroscopy',                  area:'Battery · power'    },
        { id:'US11,692,188', filed:'Sep 2022', granted:'May 2024', title:'Photoplethysmography waveform decomposition for atrial fibrillation detection',     area:'Health · sensors'   },
      ],
    },
    history: {
      timeline: [
        { y:'1976', e:'Founded in Cupertino. Wozniak builds the Apple I circuit board.' },
        { y:'1984', e:'Macintosh launch. First mass-market GUI computer. Ridley Scott Super Bowl ad.' },
        { y:'1997', e:'Jobs returns after NeXT acquisition. Company weeks from bankruptcy.' },
        { y:'2001', e:'iPod + iTunes. First hardware + services model prototype.' },
        { y:'2007', e:'iPhone launch. Redefined the phone; created a platform. Everything after follows from this.' },
        { y:'2011', e:'Jobs dies. Cook becomes CEO. Services strategy accelerates; margin discipline tightens.' },
        { y:'2015', e:'Apple Watch. Health + wearables platform. Now ~$40B annual revenue segment.' },
        { y:'2020', e:'Apple Silicon (M1). Broke Intel dependency. Gross margins begin structural move higher.' },
        { y:'2022', e:'Services crosses $80B/yr. App Store + subscriptions becoming the earnings engine.' },
        { y:'2024', e:'Apple Intelligence. On-device AI. Privacy as product differentiation.' },
      ],
      closestAnalogue: { ticker:'MSFT', year:'2014', match:87, what:'Services pivot · margin expansion · capital-light shift' },
      patternMatch: [
        { k:'Services revenue mix',    v:94, note:"22% AAPL vs 23% MSFT '14" },
        { k:'Gross margin trajectory', v:91, note:'+340bp / 5Y'               },
        { k:'Cash return policy',      v:88, note:'buybacks + div'            },
        { k:'P/E vs growth gap',       v:82, note:'priced for low single-digit'},
        { k:'Capex / revenue',         v:79, note:'~2% · capital-light'       },
      ],
      patternDiff: [
        { k:'Supplier concentration', note:"AAPL: 1 country, TSMC. MSFT '14: diversified."  },
        { k:'Regulatory backdrop',    note:'AAPL: EU DMA + DOJ. MSFT had cleared its decree.'},
        { k:'AI capex cycle',         note:'AAPL is a buyer, not a seller, of compute.'       },
        { k:'China exposure',         note:'AAPL ~17% rev, ~95% assembly. MSFT was ~3%.'     },
      ],
      analogues: [
        { ticker:'MSFT', year:'2014', match:87, what:'Services pivot · capital-light shift · margin expansion', ret:'+612%', dir:'up',   outcome:'CLOSEST' },
        { ticker:'JNJ',  year:'2010', match:72, what:'Capital return · brand moat · slow growth · premium P/E', ret:'+92%',  dir:'up',   outcome:'ECHO'    },
        { ticker:'IBM',  year:'1992', match:69, what:'Services + hardware mix · ~20% margin · cyclical clients', ret:'+158%', dir:'up',   outcome:'ECHO'    },
        { ticker:'INTC', year:'2002', match:61, what:'Dominant platform · supplier concentration · new entrants',ret:'+12%',  dir:'up',   outcome:'MIXED'   },
        { ticker:'XOM',  year:'2008', match:58, what:'Cash cow · capex moderation · commodity exposure',         ret:'+22%',  dir:'up',   outcome:'MIXED'   },
        { ticker:'GE',   year:'2000', match:47, what:'Conglomerate premium · regulatory headwinds',              ret:'-28%',  dir:'down', outcome:'WARNING' },
        { ticker:'CSCO', year:'2000', match:42, what:'Platform crowding · forward multiples · single product',   ret:'-35%',  dir:'down', outcome:'WARNING' },
        { ticker:'NOK',  year:'2007', match:38, what:'Hardware concentration · platform shift risk',             ret:'-78%',  dir:'down', outcome:'WARNING' },
      ],
    },
  },

  // ── NVIDIA ────────────────────────────────────────────────────────────────
  NVDA: {
    overview: {
      description: "NVIDIA designs graphics processing units (GPUs) and system-on-chip units for gaming, professional visualisation, and — increasingly — AI training and inference. Its CUDA software platform has become the de-facto standard for accelerated computing: most AI code targets it. The H100 and Blackwell GPU generations are the backbone of the current AI infrastructure build-out, from hyperscalers to national labs.",
      sector:      'Technology · Semiconductors',
      subIndustry: 'AI accelerators + GPUs',
      index:       'S&P 500 · NDX 100',
      country:     'United States',
    },
    quick: [
      ['Founded',       '5 April 1993'],
      ['HQ',            'Santa Clara, CA'],
      ['Employees',     '32,000'],
      ['Fiscal year',   'Ends Jan · FY = Feb–Jan'],
      ['Exchange',      'NASDAQ · since Jan 1999'],
      ['Auditor',       'PricewaterhouseCoopers'],
      ['Lead bank',     'Morgan Stanley · Goldman'],
      ['Next earnings', 'Aug 2025 · FY26 Q2'],
    ],
    revenueMix: [
      { k:'Data Center', v:87, c:'#1D4E3A' },
      { k:'Gaming',      v: 9, c:'#C46A3B' },
      { k:'Professional',v: 2, c:'#2D5E5A' },
      { k:'Auto/Other',  v: 2, c:'#B6AFA2' },
    ],
    revenueMixMeta: 'FY2025 · $130B',
    leaders: [
      { role:'CEO',         name:'Jensen Huang',   since:'Feb 1993', note:'Co-founder. Runs product, engineering, and strategy. Only Fortune 500 CEO who personally demos at developer conferences.' },
      { role:'CFO',         name:'Colette Kress',  since:'Sep 2013', note:'Financial architect of the AI-era scale-up. Led the capex and capital-return framework.' },
      { role:'EVP Research',name:'Bill Dally',     since:'Jan 2009', note:'Chief Scientist. Stanford professor on leave. Drives GPU architecture and AI chip research.' },
      { role:'EVP Compute', name:'Ian Buck',       since:'Mar 2006', note:'Invented CUDA. That one decision may be the most durable competitive moat in semiconductors.' },
    ],
    financials: {
      periods: ['TTM', 'FY2025', 'FY2024', 'FY2023', 'FY2022'],
      income: [
        { k:'Total revenue',         v:[133000,130000, 60922, 26974, 26914], b:false       },
        { k:'Cost of revenue',       v:[ 36000, 34000, 16621, 11618, 11633], b:false, in:1 },
        { k:'Gross profit',          v:[ 97000, 96000, 44301, 15356, 15281], b:true        },
        { k:'Operating expense',     v:[ 12000, 11000,  9050,  7575,  4749], b:false, in:1 },
        { k:'Operating income',      v:[ 85000, 85000, 35251,  7781, 10532], b:true        },
        { k:'Interest income, net',  v:[  2000,  2000,  1398,   496,   212], b:false, in:1 },
        { k:'Pre-tax income',        v:[ 87000, 87000, 36649,  8277, 10744], b:false       },
        { k:'Tax provision',         v:[  4000,  4000,  2486,   189,   174], b:false, in:1 },
        { k:'Net income',            v:[ 83000, 83000, 34163,  8088, 10570], b:true        },
        { k:'EPS diluted',           v:[  33.6,  33.5,  13.89,  3.30,  4.19], b:false, fmt:'eps' },
        { k:'EBITDA',                v:[ 90000, 90000, 38200, 10000, 12000], b:false       },
      ],
      balance: [
        { k:'Cash & equivalents',    v:[ 10000,  8000,  7280, 3389, 1990], b:false       },
        { k:'Short-term investments',v:[ 28000, 26000, 18700, 9907, 7142], b:false, in:1 },
        { k:'Total current assets',  v:[ 67000, 65000, 44345,23073,28829], b:true        },
        { k:'Total assets',          v:[111000,108000, 65728,41193,44187], b:true        },
        { k:'Long-term debt',        v:[  8000,  8000,  8460, 9700,10903], b:false, in:1 },
        { k:'Total liabilities',     v:[ 27000, 26000, 21966,17575,17575], b:true        },
        { k:'Shareholders equity',   v:[ 84000, 82000, 42978,22101,26612], b:true        },
      ],
      cashflow: [
        { k:'Operating cash flow',   v:[ 70000, 67000, 28608, 5640, 9108], b:true        },
        { k:'Capital expenditure',   v:[ -2000, -2000, -1069, -976, -976], b:false, in:1 },
        { k:'Free cash flow',        v:[ 68000, 65000, 27539, 4664, 8132], b:true        },
        { k:'Investing activities',  v:[-20000,-18000, -9539,-5495,-9567], b:false, in:1 },
        { k:'Financing activities',  v:[-37000,-38000,-18499,-4247,-3000], b:false, in:1 },
        { k:'Net change in cash',    v:[  2000,  2000,   570, -102, -459], b:false       },
      ],
    },
    patents: {
      stats: [
        ['Active patents', '4,214'],
        ['Filed FY2025',   '960 ∂'],
        ['Granted FY2025', '588'],
        ['In litigation',  '8'],
      ],
      cats: [
        { k:'GPU architecture',    pct:28, n: 591, c:'#1D4E3A' },
        { k:'AI · ML accelerators',pct:24, n: 507, c:'#C46A3B' },
        { k:'Networking · NVLink', pct:12, n: 254, c:'#1F1D1A' },
        { k:'Automotive · AV',     pct:10, n: 210, c:'#2D5E5A' },
        { k:'Ray tracing',         pct: 8, n: 169, c:'#B35A3A' },
        { k:'Memory systems',      pct: 8, n: 169, c:'#8A857D' },
        { k:'Power efficiency',    pct: 6, n: 127, c:'#185FA5' },
        { k:'Display · video',     pct: 4, n:  84, c:'#B6AFA2' },
      ],
      filings: [
        { y:'FY20', n:2100 }, { y:'FY21', n:2400 }, { y:'FY22', n:2650 },
        { y:'FY23', n:3100 }, { y:'FY24', n:3800 }, { y:'FY25', n:960, partial:true },
      ],
      notable: [
        { id:'US12,082,441', filed:'Sep 2023', granted:'Apr 2025', title:'Transformer Engine with per-tensor floating-point scaling for large language models',   area:'AI · ML accelerators'  },
        { id:'US12,014,729', filed:'Jun 2023', granted:'Dec 2024', title:'Multi-chip NVLink fabric with adaptive routing for congestion avoidance',               area:'Networking · NVLink'   },
        { id:'US11,972,638', filed:'Mar 2023', granted:'Sep 2024', title:'Confidence-scored ray traversal with hardware bounding-volume hierarchy acceleration',  area:'Ray tracing'           },
        { id:'US11,908,114', filed:'Jan 2023', granted:'Jun 2024', title:'Occupancy-aware SM partitioning for concurrent neural-network inference workloads',      area:'GPU architecture'      },
        { id:'US11,854,271', filed:'Nov 2022', granted:'Feb 2024', title:'LIDAR point-cloud to BEV projection pipeline for real-time autonomous driving',         area:'Automotive · AV'       },
      ],
    },
    history: {
      timeline: [
        { y:'1993', e:"Founded by Jensen Huang, Chris Malachowsky, and Curtis Priem. Early focus on multimedia PC chips." },
        { y:'1999', e:"GeForce 256 ships. NVIDIA coins the term 'GPU'. The gaming market becomes the revenue engine." },
        { y:'2006', e:"CUDA launched — general-purpose GPU computing. Most AI code written today still runs on this." },
        { y:'2012', e:"AlexNet wins ImageNet using two NVIDIA GPUs. Deep learning finds its accelerator." },
        { y:'2016', e:"DGX-1 shipped to OpenAI — the first AI supercomputer in a box. Jensen delivers it personally." },
        { y:'2020', e:"Arm acquisition attempted ($40B). Abandoned 2022 due to regulator opposition." },
        { y:'2022', e:"ChatGPT launches on A100 clusters. Enterprise demand for H100s begins building." },
        { y:'2023', e:"H100 allocations stretch 12 months. Revenue doubles. NVIDIA becomes the defining AI infrastructure company." },
        { y:'2024', e:"Blackwell (B100/B200) ships. Market cap crosses $3T. Jensen at every major tech conference." },
        { y:'2025', e:"Rubin architecture announced. $130B revenue run-rate. 87% of revenue from data centre." },
      ],
      closestAnalogue: { ticker:'CSCO', year:'1999', match:70, what:'Infrastructure bottleneck · dominant standard · pricing power during build-out' },
      patternMatch: [
        { k:'Infrastructure monopoly',  v:91, note:"GPU compute = Cisco's routers in '99" },
        { k:'Ecosystem lock-in',        v:88, note:'CUDA: 18Y moat'                       },
        { k:'Backlog / scarcity',       v:85, note:'12-month H100 wait vs Y2K routers'    },
        { k:'Margin expansion speed',   v:82, note:'74.6% gross → 78%+ trajectory'        },
        { k:'Rev concentration risk',   v:78, note:'Hyperscalers = 40%+ of NVDA rev'      },
      ],
      patternDiff: [
        { k:'Software moat depth',   note:'CUDA has no equivalent in Cisco routing — switching costs are higher.'         },
        { k:'Customer concentration',note:'Microsoft, Google, Meta = 40%+ of NVDA revenue. Cisco was more diversified.'  },
        { k:'Capex dependency',       note:'NVDA is fabless (TSMC). Cisco owned its fabs — a different risk profile.'    },
        { k:'Competitive response',   note:'AMD, Google TPUs, Amazon Trainium provide alternatives. Cisco had fewer.'     },
      ],
      analogues: [
        { ticker:'CSCO', year:'1999', match:70, what:'Infrastructure bottleneck · dominant standard · build-out peak',     ret:'+312%', dir:'up',   outcome:'CLOSEST' },
        { ticker:'INTC', year:'1995', match:65, what:"Wintel monopoly · 60%+ market share · Grove's paranoia culture",    ret:'+428%', dir:'up',   outcome:'ECHO'    },
        { ticker:'QCOM', year:'2014', match:58, what:'IP licensing + chip monopoly · mobile handset royalties',            ret:'+88%',  dir:'up',   outcome:'ECHO'    },
        { ticker:'CSCO', year:'2000', match:52, what:'Platform crowding · multiples stretched · capacity overbuild begins',ret:'-89%',  dir:'down', outcome:'WARNING' },
        { ticker:'INTC', year:'2003', match:48, what:'AMD/ARM disruption begins · complacency in platform refresh',        ret:'+12%',  dir:'up',   outcome:'MIXED'   },
        { ticker:'XLNX', year:'2017', match:41, what:'FPGA specialty chip · acquired by AMD after peak cycle',             ret:'+62%',  dir:'up',   outcome:'MIXED'   },
        { ticker:'NOK',  year:'2007', match:35, what:'Platform dominance then rapid disruption by vertical integrator',    ret:'-78%',  dir:'down', outcome:'WARNING' },
        { ticker:'SGI',  year:'1997', match:31, what:'Workstation GPU leader · commoditisation by general-purpose compute',ret:'-96%',  dir:'down', outcome:'WARNING' },
      ],
    },
  },

  // ── Microsoft ─────────────────────────────────────────────────────────────
  MSFT: {
    overview: {
      description: "Microsoft builds productivity software, cloud infrastructure, and gaming platforms. Azure is the second-largest cloud provider. Microsoft 365 generates recurring subscription revenue across 1.4 billion commercial seats. A deep investment in OpenAI powers Copilot, which is being woven through every product in the stack — Windows, Office, GitHub, Dynamics, Azure. The 2023 Activision Blizzard acquisition added the world's largest game publisher.",
      sector:      'Technology · Software',
      subIndustry: 'Cloud infrastructure + productivity',
      index:       'S&P 500 · NDX 100 · DJIA',
      country:     'United States',
    },
    quick: [
      ['Founded',       '4 April 1975'],
      ['HQ',            'Redmond, WA'],
      ['Employees',     '228,000'],
      ['Fiscal year',   'Ends Jun · FY = Jul–Jun'],
      ['Exchange',      'NASDAQ · since Mar 1986'],
      ['Auditor',       'Deloitte & Touche'],
      ['Lead bank',     'Goldman Sachs · JPMorgan'],
      ['Next earnings', 'Oct 2025 · FY26 Q1'],
    ],
    revenueMix: [
      { k:'Intelligent Cloud', v:43, c:'#1D4E3A' },
      { k:'Productivity+Biz',  v:32, c:'#C46A3B' },
      { k:'Personal Computing',v:25, c:'#8A857D' },
    ],
    revenueMixMeta: 'FY2025 · $278B',
    leaders: [
      { role:'CEO',      name:'Satya Nadella',  since:'Feb 2014', note:'Architect of the cloud pivot. Transformed a Windows-era company into an AI-era cloud company.' },
      { role:'CFO',      name:'Amy Hood',       since:'May 2013', note:'Longest-serving CFO in MSFT history. Core to the disciplined capital allocation strategy.' },
      { role:'CTO',      name:'Kevin Scott',    since:'Mar 2017', note:'Chief Technology Officer. Leads OpenAI integration and Azure AI infrastructure.' },
      { role:'EVP Cloud',name:'Scott Guthrie',  since:'Oct 1997', note:'Azure founding leader. Technical credibility across the enterprise developer base.' },
    ],
    financials: {
      periods: ['TTM', 'FY2025', 'FY2024', 'FY2023', 'FY2022'],
      income: [
        { k:'Total revenue',         v:[280000,278000,245122,211915,198270], b:false       },
        { k:'Cost of revenue',       v:[ 84000, 83000, 74398, 65863, 62650], b:false, in:1 },
        { k:'Gross profit',          v:[196000,195000,170724,146052,135620], b:true        },
        { k:'Operating expense',     v:[ 52000, 51000, 47000, 43678, 41951], b:false, in:1 },
        { k:'Operating income',      v:[144000,144000,123724,102374, 93669], b:true        },
        { k:'Interest income, net',  v:[  3000,  3000,  3271,  2994,  2094], b:false, in:1 },
        { k:'Pre-tax income',        v:[147000,147000,126995,105368, 95763], b:false       },
        { k:'Tax provision',         v:[ 18000, 18000, 15576, 13280, 11260], b:false, in:1 },
        { k:'Net income',            v:[129000,129000,111419, 92088, 84503], b:true        },
        { k:'EPS diluted',           v:[  17.41, 17.38, 14.93, 12.26, 11.20], b:false, fmt:'eps' },
        { k:'EBITDA',                v:[171000,171000,149800,125000,113000], b:false       },
      ],
      balance: [
        { k:'Cash & equivalents',    v:[ 18000, 17000, 18315, 34704, 13931], b:false       },
        { k:'Short-term investments',v:[ 65000, 63000, 76558, 76558, 90826], b:false, in:1 },
        { k:'Total current assets',  v:[177000,175000,171612,184257,184406], b:true        },
        { k:'Total assets',          v:[526000,519000,512163,411976,364840], b:true        },
        { k:'Long-term debt',        v:[ 45000, 44000, 41989, 47187, 48238], b:false, in:1 },
        { k:'Total liabilities',     v:[253000,249000,243686,205753,198298], b:true        },
        { k:'Shareholders equity',   v:[273000,270000,268477,206223,166542], b:true        },
      ],
      cashflow: [
        { k:'Operating cash flow',   v:[133000,132000,118548, 87582, 89035], b:true        },
        { k:'Capital expenditure',   v:[-55000,-52000,-44482,-28107,-23886], b:false, in:1 },
        { k:'Free cash flow',        v:[ 78000, 80000, 74066, 59475, 65149], b:true        },
        { k:'Investing activities',  v:[-58000,-55000,-62460,-36468,-30311], b:false, in:1 },
        { k:'Financing activities',  v:[-61000,-60000,-56048,-46803,-49186], b:false, in:1 },
        { k:'Net change in cash',    v:[  1000,  2000,   256,  4311,  9538], b:false       },
      ],
    },
    patents: {
      stats: [
        ['Active patents', '63,000+'],
        ['Filed FY2025',   '4,200 ∂'],
        ['Granted FY2025', '2,800'],
        ['In litigation',  '32'],
      ],
      cats: [
        { k:'Cloud infrastructure', pct:21, n:13230, c:'#1D4E3A' },
        { k:'AI · ML systems',      pct:18, n:11340, c:'#C46A3B' },
        { k:'Productivity software',pct:15, n: 9450, c:'#1F1D1A' },
        { k:'Security · identity',  pct:12, n: 7560, c:'#2D5E5A' },
        { k:'Gaming · Xbox',        pct:10, n: 6300, c:'#B35A3A' },
        { k:'Natural language',     pct: 9, n: 5670, c:'#8A857D' },
        { k:'Networking · edge',    pct: 8, n: 5040, c:'#185FA5' },
        { k:'Hardware devices',     pct: 7, n: 4410, c:'#B6AFA2' },
      ],
      filings: [
        { y:'FY20', n:3600 }, { y:'FY21', n:3900 }, { y:'FY22', n:4000 },
        { y:'FY23', n:4100 }, { y:'FY24', n:4200 }, { y:'FY25', n:4200, partial:true },
      ],
      notable: [
        { id:'US12,091,344', filed:'Oct 2023', granted:'May 2025', title:'Retrieval-augmented code generation with test-suite grounding in large language models', area:'AI · ML systems'      },
        { id:'US12,041,627', filed:'Jul 2023', granted:'Jan 2025', title:'Zero-trust continuous access evaluation with adaptive token revocation',               area:'Security · identity'  },
        { id:'US11,998,201', filed:'Apr 2023', granted:'Oct 2024', title:'Serverless function cold-start elimination via speculative pre-warming on Azure',       area:'Cloud infrastructure' },
        { id:'US11,951,774', filed:'Jan 2023', granted:'Jun 2024', title:'Cross-tenant semantic search with differential-privacy embedding aggregation',         area:'Natural language'     },
        { id:'US11,892,441', filed:'Sep 2022', granted:'Mar 2024', title:'Adaptive game-streaming resolution scaling with neural upsampling on Xbox Cloud',      area:'Gaming · Xbox'        },
      ],
    },
    history: {
      timeline: [
        { y:'1975', e:'Gates and Allen found Microsoft. First product: BASIC interpreter for the Altair 8800.' },
        { y:'1980', e:'IBM DOS deal. Microsoft licenses an OS it did not yet own. The catalytic event.' },
        { y:'1990', e:'Windows 3.0. The GUI-PC market takes off. Microsoft begins its decade of dominance.' },
        { y:'1995', e:'Windows 95 + Internet Explorer. Browser wars begin. The internet moment.' },
        { y:'2001', e:'Xbox launch. A new platform bet alongside the core OS + Office business.' },
        { y:'2008', e:'Azure cloud announced at PDC. Ballmer-era investment that took eight years to pay off.' },
        { y:'2014', e:'Satya Nadella becomes CEO. "Mobile first, cloud first." The pivot begins.' },
        { y:'2016', e:'LinkedIn acquired for $26B. Largest acquisition to date. Professional network + data.' },
        { y:'2018', e:'GitHub acquired for $7.5B. Developer ecosystem lock-in deepens.' },
        { y:'2020', e:'Teams reaches 75M DAU during COVID. Remote-work tailwind accelerates adoption.' },
        { y:'2023', e:'OpenAI investment deepened. Copilot integrated across Office, GitHub, Azure, Windows.' },
        { y:'2024', e:"AI PC + Copilot+ category launched. Market cap crosses $3T." },
      ],
      closestAnalogue: { ticker:'IBM', year:'2004', match:71, what:'Services transformation · hardware drag declining · multiple re-ratings ahead' },
      patternMatch: [
        { k:'Cloud transition maturity', v:88, note:"Azure ~30% of rev — IBM services was ~35% in '04" },
        { k:'Recurring revenue base',    v:85, note:'M365 subs + Azure = 75%+ of gross profit'         },
        { k:'Capital return consistency',v:81, note:'14Y consecutive dividend growth'                   },
        { k:'Enterprise moat depth',     v:79, note:'Active Directory + Azure AD lock-in'               },
        { k:'AI-revenue timing',         v:74, note:'Copilot monetisation just starting — IBM had SOA'  },
      ],
      patternDiff: [
        { k:'AI monetisation scale',  note:"MSFT's OpenAI edge is deeper than IBM's SOA consulting was in 2004."         },
        { k:'Gaming wildcard',        note:"Activision Blizzard has no IBM equivalent — adds consumer cyclicality."      },
        { k:'Regulatory backdrop',    note:'EU Digital Markets Act + DOJ antitrust active. IBM had cleared its decree.'  },
        { k:'Capex trajectory',       note:"Azure AI build-out requires $50B+/yr capex. IBM was capex-light in '04."    },
      ],
      analogues: [
        { ticker:'IBM',  year:'2004', match:71, what:'Services-led transformation · hardware drag fading · re-rating cycle', ret:'+68%',  dir:'up',   outcome:'CLOSEST' },
        { ticker:'AAPL', year:'2016', match:65, what:'Services pivot · recurring revenue · ecosystem premium re-rate',      ret:'+387%', dir:'up',   outcome:'ECHO'    },
        { ticker:'ORCL', year:'2012', match:58, what:'Cloud transition drag · license-to-subscription multiple compression', ret:'+142%', dir:'up',   outcome:'ECHO'    },
        { ticker:'CRM',  year:'2015', match:54, what:'Enterprise SaaS at scale · land-and-expand · bundling pressure',      ret:'+312%', dir:'up',   outcome:'ECHO'    },
        { ticker:'INTC', year:'2018', match:47, what:'Platform maturity · fab investment cycle · AMD resurgence',           ret:'-22%',  dir:'down', outcome:'MIXED'   },
        { ticker:'HPQ',  year:'2011', match:42, what:'PC + enterprise hardware drag · services pivot too slow',             ret:'-14%',  dir:'down', outcome:'MIXED'   },
        { ticker:'CSCO', year:'2015', match:38, what:'Network platform maturity · cloud disrupts capex spend',             ret:'+44%',  dir:'up',   outcome:'MIXED'   },
        { ticker:'IBM',  year:'2015', match:31, what:'Services shrinkage · cloud too late · earnings-per-share engineering',ret:'-35%',  dir:'down', outcome:'WARNING' },
      ],
    },
  },

  // ── Alphabet ──────────────────────────────────────────────────────────────
  GOOGL: {
    overview: {
      description: "Alphabet is the parent of Google, which operates the world's dominant search engine, the largest digital advertising platform, and the second-fastest-growing cloud provider. Search and advertising constitute ~75% of revenue; Google Cloud is ~12% and growing at 28%+ annually. YouTube is the largest video platform. Waymo is the most advanced autonomous-vehicle deployment. The company faces structural risk from AI-native search disruption and antitrust pressure in multiple jurisdictions.",
      sector:      'Technology · Advertising',
      subIndustry: 'Search + cloud + AI',
      index:       'S&P 500 · NDX 100',
      country:     'United States',
    },
    quick: [
      ['Founded',       '4 September 1998'],
      ['HQ',            'Mountain View, CA'],
      ['Employees',     '181,000'],
      ['Fiscal year',   'Ends Dec · FY = Jan–Dec'],
      ['Exchange',      'NASDAQ · since Aug 2004'],
      ['Auditor',       'Ernst & Young'],
      ['Lead bank',     'Goldman Sachs · Credit Suisse'],
      ['Next earnings', 'Jul 2025 · Q2 FY2025'],
    ],
    revenueMix: [
      { k:'Google Search', v:57, c:'#1D4E3A' },
      { k:'YouTube Ads',   v:10, c:'#C46A3B' },
      { k:'Google Cloud',  v:12, c:'#2D5E5A' },
      { k:'Network Ads',   v: 8, c:'#8A857D' },
      { k:'Other Bets',    v: 2, c:'#B6AFA2' },
      { k:'Other Google',  v:11, c:'#185FA5' },
    ],
    revenueMixMeta: 'FY2024 · $350B',
    leaders: [
      { role:'CEO',        name:'Sundar Pichai',  since:'Oct 2015', note:'CEO of both Google and Alphabet. Led Chrome and Android before the top job. Navigating the AI moment carefully.' },
      { role:'CFO',        name:'Anat Ashkenazi', since:'Jul 2024', note:'Former Eli Lilly CFO. Replacing Ruth Porat who moved to President/CIO of Alphabet.' },
      { role:'CEO Cloud',  name:'Thomas Kurian',  since:'Jan 2019', note:'Former Oracle President. Transformed Google Cloud from a distant third to a credible enterprise contender.' },
      { role:'DeepMind',   name:'Demis Hassabis', since:'Apr 2023', note:'CEO of Google DeepMind (merged). Nobel laureate. AlphaFold, Gemini lead.' },
    ],
    financials: {
      periods: ['TTM', 'FY2025', 'FY2024', 'FY2023', 'FY2022'],
      income: [
        { k:'Total revenue',         v:[365000,362000,350018,307394,282836], b:false       },
        { k:'Cost of revenue',       v:[155000,153000,148912,133332,126203], b:false, in:1 },
        { k:'Gross profit',          v:[210000,209000,201106,174062,156633], b:true        },
        { k:'Operating expense',     v:[ 85000, 84000, 85302, 80994, 69875], b:false, in:1 },
        { k:'Operating income',      v:[125000,125000,115804, 93068, 86758], b:true        },
        { k:'Interest income, net',  v:[  8000,  8000,  7200,  5700,  2800], b:false, in:1 },
        { k:'Pre-tax income',        v:[133000,133000,123004, 98768, 89558], b:false       },
        { k:'Tax provision',         v:[ 17000, 17000, 16000, 11922, 12430], b:false, in:1 },
        { k:'Net income',            v:[116000,116000,107004, 86846, 77128], b:true        },
        { k:'EPS diluted',           v:[   9.12,  9.10,  8.05,  6.44,  5.62], b:false, fmt:'eps' },
        { k:'EBITDA',                v:[143000,142000,130000,109000, 96000], b:false       },
      ],
      balance: [
        { k:'Cash & equivalents',    v:[ 21000, 20000, 21027, 24048, 21879], b:false       },
        { k:'Short-term investments',v:[ 90000, 88000, 86868, 91956, 99652], b:false, in:1 },
        { k:'Total current assets',  v:[181000,178000,171539,164795,153523], b:true        },
        { k:'Total assets',          v:[460000,455000,450502,402392,359268], b:true        },
        { k:'Long-term debt',        v:[ 12000, 12000, 13253, 13253, 14701], b:false, in:1 },
        { k:'Total liabilities',     v:[126000,124000,128240,115440,107633], b:true        },
        { k:'Shareholders equity',   v:[334000,331000,322262,286952,251635], b:true        },
      ],
      cashflow: [
        { k:'Operating cash flow',   v:[104000,102000, 99000, 91495, 91651], b:true        },
        { k:'Capital expenditure',   v:[-52000,-50000,-52241,-32251,-31485], b:false, in:1 },
        { k:'Free cash flow',        v:[ 52000, 52000, 46759, 59244, 60166], b:true        },
        { k:'Investing activities',  v:[-55000,-53000,-54067,-30378,-25467], b:false, in:1 },
        { k:'Financing activities',  v:[-55000,-53000,-62488,-57765,-59401], b:false, in:1 },
        { k:'Net change in cash',    v:[  1000,  1000,  -756,  3352,  6783], b:false       },
      ],
    },
    patents: {
      stats: [
        ['Active patents', '51,000+'],
        ['Filed FY2024',   '3,800 ∂'],
        ['Granted FY2024', '2,400'],
        ['In litigation',  '27'],
      ],
      cats: [
        { k:'Search algorithms',    pct:18, n: 9180, c:'#1D4E3A' },
        { k:'AI · ML systems',      pct:22, n:11220, c:'#C46A3B' },
        { k:'Cloud infrastructure', pct:14, n: 7140, c:'#1F1D1A' },
        { k:'Autonomous vehicles',  pct:12, n: 6120, c:'#2D5E5A' },
        { k:'Video · streaming',    pct:10, n: 5100, c:'#B35A3A' },
        { k:'Mobile · Android',     pct: 9, n: 4590, c:'#8A857D' },
        { k:'Quantum computing',    pct: 8, n: 4080, c:'#185FA5' },
        { k:'Hardware (TPU/pixel)', pct: 7, n: 3570, c:'#B6AFA2' },
      ],
      filings: [
        { y:'FY19', n:2900 }, { y:'FY20', n:3100 }, { y:'FY21', n:3300 },
        { y:'FY22', n:3500 }, { y:'FY23', n:3650 }, { y:'FY24', n:3800, partial:true },
      ],
      notable: [
        { id:'US12,088,752', filed:'Nov 2023', granted:'Apr 2025', title:'Multi-modal grounding with retrieval-augmented generation for conversational AI agents',  area:'AI · ML systems'     },
        { id:'US12,032,614', filed:'Aug 2023', granted:'Jan 2025', title:'Quantum error correction via surface codes with real-time syndrome extraction',           area:'Quantum computing'   },
        { id:'US11,991,281', filed:'May 2023', granted:'Oct 2024', title:'Neural radiance field reconstruction from street-level LiDAR for Waymo scene understanding',area:'Autonomous vehicles'},
        { id:'US11,941,874', filed:'Feb 2023', granted:'Jun 2024', title:'TPU v5 tensor tiling with compiler-directed memory-bandwidth optimisation',               area:'Hardware (TPU/pixel)'},
        { id:'US11,884,422', filed:'Nov 2022', granted:'Feb 2024', title:'Privacy-preserving federated learning with differential privacy and secure aggregation',   area:'AI · ML systems'    },
      ],
    },
    history: {
      timeline: [
        { y:'1998', e:"Brin and Page found Google in a Menlo Park garage. PageRank reorders the web." },
        { y:'2000', e:"AdWords launched. The business model: match advertiser intent to user query at scale." },
        { y:'2004', e:"IPO at $85/share. Brin and Page write the 'Do no evil' founder letter." },
        { y:'2006', e:"YouTube acquired for $1.65B. Analysts called it overpriced. It generates $31B/yr today." },
        { y:'2008', e:"Chrome browser launched. Android ships on first device. Two platform bets at once." },
        { y:'2015', e:"Alphabet restructuring. Google becomes a subsidiary. Sundar Pichai becomes Google CEO." },
        { y:'2017', e:"TPU v2 deployed at scale in data centres. Google starts designing its own AI silicon." },
        { y:'2022', e:"ChatGPT launches. Google declares 'code red'. Bard fast-tracked from LaMDA." },
        { y:'2023', e:"Gemini (Bard successor) launched. Google Cloud passes $33B run-rate. AI Overviews in search." },
        { y:'2024', e:"US antitrust ruling finds Google illegally monopolised search. Waymo at 150K+ weekly paid trips." },
      ],
      closestAnalogue: { ticker:'AAPL', year:'2013', match:59, what:"Services monetisation inflection · hardware as a moat · regulatory overhang" },
      patternMatch: [
        { k:'Advertising moat depth',  v:88, note:"Search intent still the most valuable ad signal" },
        { k:'Cloud second-mover gap',  v:72, note:'Closing on AWS but still 10+ pts behind'          },
        { k:'AI-first product refresh',v:81, note:'Gemini integration across Search, Cloud, Android'  },
        { k:'Free cash flow quality',  v:85, note:'$52B FCF · net cash $99B+, no debt concerns'       },
        { k:'Regulatory discount',     v:68, note:'EU DMA + DOJ ruling pending remedy phase'          },
      ],
      patternDiff: [
        { k:'Search disruption risk',  note:"LLM-native search (Perplexity, ChatGPT) is a direct threat AAPL 2013 did not face." },
        { k:'Capital intensity',       note:"GCP capex $52B+ in 2024. Apple's capex was <3% of revenue in 2013."                 },
        { k:'Ad regulation',           note:"EU DSA + US antitrust ruling create structural remedies risk beyond what Apple faced."},
        { k:'Moonshot drag',           note:"Other Bets (Waymo, DeepMind, etc.) consume $2-3B/yr with uncertain timelines."       },
      ],
      analogues: [
        { ticker:'AAPL', year:'2013', match:59, what:'Services inflection · hardware moat · regulatory overhang',        ret:'+472%', dir:'up',   outcome:'CLOSEST' },
        { ticker:'META', year:'2018', match:55, what:'Advertising monopoly at scale · privacy/regulatory pressure',       ret:'+244%', dir:'up',   outcome:'ECHO'    },
        { ticker:'MSFT', year:'2003', match:51, what:"Antitrust consent decree · platform dominance · re-rating ahead",  ret:'+112%', dir:'up',   outcome:'ECHO'    },
        { ticker:'IBM',  year:'2012', match:46, what:'Legacy revenue defence while new unit grows · valuation discount',  ret:'-18%',  dir:'down', outcome:'MIXED'   },
        { ticker:'YHOO', year:'2008', match:41, what:'Search dominance challenged · strategic drift · activist pressure', ret:'-62%',  dir:'down', outcome:'WARNING' },
        { ticker:'AOL',  year:'2001', match:36, what:'Captive-audience model disrupted by open-web shift',                ret:'-88%',  dir:'down', outcome:'WARNING' },
        { ticker:'META', year:'2022', match:49, what:'Advertiser revolt · macro headwinds · pivot to unproven platform',  ret:'+194%', dir:'up',   outcome:'MIXED'   },
        { ticker:'NFLX', year:'2022', match:38, what:'Growth plateau · pricing pressure · competitive entry',             ret:'+168%', dir:'up',   outcome:'MIXED'   },
      ],
    },
  },

  // ── Amazon ────────────────────────────────────────────────────────────────
  AMZN: {
    overview: {
      description: "Amazon operates the world's largest e-commerce marketplace, the leading cloud provider (AWS), and a rapidly growing digital advertising business. AWS contributes ~13% of revenue but generates the majority of operating income, subsidising the retail flywheel. The advertising segment (~9% of revenue) has grown to rival traditional media companies. Prime membership underpins both the marketplace and streaming businesses across 200M+ subscribers.",
      sector:      'Retail · Cloud',
      subIndustry: 'Marketplace + AWS + advertising',
      index:       'S&P 500 · NDX 100',
      country:     'United States',
    },
    quick: [
      ['Founded',       '5 July 1994'],
      ['HQ',            'Seattle, WA'],
      ['Employees',     '1,532,000'],
      ['Fiscal year',   'Ends Dec · FY = Jan–Dec'],
      ['Exchange',      'NASDAQ · since May 1997'],
      ['Auditor',       'Ernst & Young'],
      ['Lead bank',     'JPMorgan · Goldman Sachs'],
      ['Next earnings', 'Aug 2025 · Q2 FY2025'],
    ],
    revenueMix: [
      { k:'Online stores',   v:38, c:'#1D4E3A' },
      { k:'AWS',             v:18, c:'#C46A3B' },
      { k:'3rd-party seller',v:24, c:'#2D5E5A' },
      { k:'Advertising',     v: 9, c:'#8A857D' },
      { k:'Subscriptions',   v: 7, c:'#185FA5' },
      { k:'Physical stores', v: 4, c:'#B6AFA2' },
    ],
    revenueMixMeta: 'FY2024 · $591B',
    leaders: [
      { role:'CEO',     name:'Andy Jassy',    since:'Jul 2021', note:'Founded AWS in 2006. Replaced Bezos as CEO. Cost discipline and AWS AI expansion define his tenure.' },
      { role:'CFO',     name:'Brian Olsavsky',since:'Jun 2015', note:'Decade-long CFO. Managed the 2022 cost-cutting cycle and the AWS AI capex ramp.' },
      { role:'CEO AWS', name:'Matt Garman',   since:'Jun 2024', note:'Former AWS sales + marketing head. Replacing Adam Selipsky to accelerate enterprise AI.' },
      { role:'Founder', name:'Jeff Bezos',    since:'May 2021', note:'Executive Chairman. Stepped back as CEO to focus on Blue Origin and long-term bets.' },
    ],
    financials: {
      periods: ['TTM', 'FY2025', 'FY2024', 'FY2023', 'FY2022'],
      income: [
        { k:'Total revenue',         v:[650000,638000,590740,513983,469822], b:false       },
        { k:'Cost of revenue',       v:[368000,360000,319358,304492,288831], b:false, in:1 },
        { k:'Gross profit',          v:[282000,278000,271382,209491,180991], b:true        },
        { k:'Operating expense',     v:[172000,168000,185765,197946,183005], b:false, in:1 },
        { k:'Operating income',      v:[110000,110000, 85617, 11545, -2014], b:true        },
        { k:'Interest expense, net', v:[ -2000, -2000, -1787, -2669, -2175], b:false, in:1 },
        { k:'Pre-tax income',        v:[108000,108000, 83830,  8876, -4189], b:false       },
        { k:'Tax provision',         v:[  8000,  8000,  5968,  3541,  3217], b:false, in:1 },
        { k:'Net income',            v:[100000,100000, 77862,  5335, -7406], b:true        },
        { k:'EPS diluted',           v:[   9.60,  9.55,  7.50,  0.51, -0.70], b:false, fmt:'eps' },
        { k:'EBITDA',                v:[138000,135000,115900, 47300, 16500], b:false       },
      ],
      balance: [
        { k:'Cash & equivalents',    v:[ 73000, 70000, 53888, 34970, 35178], b:false       },
        { k:'Short-term investments',v:[  3000,  3000,  4254,     0, 59829], b:false, in:1 },
        { k:'Total current assets',  v:[188000,185000,155891,146791,146791], b:true        },
        { k:'Total assets',          v:[656000,641000,527854,462675,411171], b:true        },
        { k:'Long-term debt',        v:[ 53000, 51000, 58314, 67150, 67650], b:false, in:1 },
        { k:'Total liabilities',     v:[400000,391000,374115,358116,316248], b:true        },
        { k:'Shareholders equity',   v:[256000,250000,153739,104559, 94923], b:true        },
      ],
      cashflow: [
        { k:'Operating cash flow',   v:[118000,115000, 84946, 46752, -3278], b:true        },
        { k:'Capital expenditure',   v:[-67000,-63000,-52729,-48133,-58321], b:false, in:1 },
        { k:'Free cash flow',        v:[ 51000, 52000, 32217, -1381,-61599], b:true        },
        { k:'Investing activities',  v:[-10000, -9000, -5678,-45379,-67651], b:false, in:1 },
        { k:'Financing activities',  v:[-19000,-18000,-18192,-11553,-42018], b:false, in:1 },
        { k:'Net change in cash',    v:[  3000,  2000,  9834,-10180, -7000], b:false       },
      ],
    },
    patents: {
      stats: [
        ['Active patents', '11,800+'],
        ['Filed FY2024',   '2,100 ∂'],
        ['Granted FY2024', '1,400'],
        ['In litigation',  '19'],
      ],
      cats: [
        { k:'Cloud · distributed systems',pct:22, n:2596, c:'#1D4E3A' },
        { k:'Logistics · robotics',       pct:20, n:2360, c:'#C46A3B' },
        { k:'AI · recommendation',        pct:16, n:1888, c:'#1F1D1A' },
        { k:'Payment systems',            pct:12, n:1416, c:'#2D5E5A' },
        { k:'Voice · Alexa NLU',          pct:10, n:1180, c:'#B35A3A' },
        { k:'Drone · delivery',           pct: 9, n:1062, c:'#8A857D' },
        { k:'Display advertising',        pct: 6, n: 708, c:'#185FA5' },
        { k:'Streaming · video',          pct: 5, n: 590, c:'#B6AFA2' },
      ],
      filings: [
        { y:'FY19', n:1500 }, { y:'FY20', n:1700 }, { y:'FY21', n:1900 },
        { y:'FY22', n:2000 }, { y:'FY23', n:2050 }, { y:'FY24', n:2100, partial:true },
      ],
      notable: [
        { id:'US12,071,823', filed:'Oct 2023', granted:'Mar 2025', title:'Autonomous drone corridor management with dynamic geofencing and cooperative sense-and-avoid', area:'Drone · delivery'          },
        { id:'US12,019,447', filed:'Jul 2023', granted:'Dec 2024', title:'Demand-aware warehouse robot task allocation using multi-agent reinforcement learning',        area:'Logistics · robotics'      },
        { id:'US11,981,204', filed:'Apr 2023', granted:'Sep 2024', title:'Sparse retrieval-augmented recommendation with personalised long-tail coverage',              area:'AI · recommendation'       },
        { id:'US11,934,817', filed:'Jan 2023', granted:'May 2024', title:'Nitro hypervisor memory isolation for multi-tenant confidential computing on AWS',            area:'Cloud · distributed systems'},
        { id:'US11,878,391', filed:'Oct 2022', granted:'Jan 2024', title:'Intent-aware contextual question decomposition for Alexa multi-turn dialogue management',     area:'Voice · Alexa NLU'         },
      ],
    },
    history: {
      timeline: [
        { y:'1994', e:"Bezos founds Amazon in a Seattle garage as an online bookstore. The company name was chosen for its position early in the alphabet." },
        { y:'1997', e:"IPO at $18/share. Bezos writes the first shareholder letter — long-termism as strategy." },
        { y:'1999', e:"Bezos named Time Person of the Year. Amazon markets itself as the 'earth's biggest bookstore' then everything store." },
        { y:'2005', e:"Amazon Prime launched. Two-day free shipping as a subscription model. The flywheel accelerator." },
        { y:'2006', e:"AWS launched with S3 and EC2. Cloud computing as a product — most dismissed it. The most consequential business launch since the iPhone." },
        { y:'2013', e:"Same-day delivery pilots. 60-minute Prime Now. The logistics network becomes a moat." },
        { y:'2014', e:"Echo + Alexa. Voice computing as a new platform. First-mover in the smart speaker market." },
        { y:'2021', e:"Bezos steps down. Andy Jassy (AWS founder) becomes CEO. Blue Origin and philanthropy occupy Bezos." },
        { y:'2022', e:"First loss in nearly a decade ($7.4B). Rivian writedown. 18,000 layoffs. Cost discipline forced." },
        { y:'2024', e:"AWS AI services re-accelerate. Advertising $47B run-rate. Operating margin recovers to 10%+." },
      ],
      closestAnalogue: { ticker:'WMT', year:'2001', match:55, what:'Distribution moat · logistics scale · supplier leverage · low-margin volume' },
      patternMatch: [
        { k:'Logistics network depth',  v:88, note:"200+ fulfilment centres; WMT had 3,000+ stores in '01" },
        { k:'Private label push',       v:82, note:'Amazon Basics = WMT store brands at scale'             },
        { k:'AWS = retail subsidy',     v:79, note:'High-margin unit funds low-margin flywheel'             },
        { k:'Supplier leverage',        v:76, note:'1P vs 3P mix management echoes WMT buyer power'        },
        { k:'International expansion',  v:68, note:'EU + India markets; WMT went global same era'          },
      ],
      patternDiff: [
        { k:'Cloud upside',        note:"WMT had no AWS equivalent. Amazon's margin ceiling is far higher." },
        { k:'Media + advertising', note:"Amazon's $47B ad business has no Walmart 2001 analogue."          },
        { k:'Technology moat',     note:"AWS switching costs exceed anything Walmart could build in distribution."},
        { k:'Labour dynamics',     note:"Amazon's 1.5M workforce faces unionisation pressure WMT managed differently."},
      ],
      analogues: [
        { ticker:'WMT',  year:'2001', match:55, what:'Distribution moat · supplier leverage · low-margin volume engine',ret:'+312%', dir:'up',   outcome:'CLOSEST' },
        { ticker:'MSFT', year:'2022', match:52, what:'Cloud leader re-rates on AI monetisation · cost discipline',      ret:'+142%', dir:'up',   outcome:'ECHO'    },
        { ticker:'FDX',  year:'2004', match:48, what:'Logistics network build-out · capex intensity · pricing power',   ret:'+188%', dir:'up',   outcome:'ECHO'    },
        { ticker:'AMZN', year:'2016', match:44, what:'AWS inflection · margin expansion begins · retail stabilises',    ret:'+294%', dir:'up',   outcome:'ECHO'    },
        { ticker:'EBAY', year:'2004', match:41, what:'Marketplace dominance · take-rate pressure · new entrants',       ret:'+12%',  dir:'up',   outcome:'MIXED'   },
        { ticker:'SEARS',year:'2005', match:37, what:'Dominant retailer loses relevance · digital late · real estate trap',ret:'-94%', dir:'down', outcome:'WARNING' },
        { ticker:'JCP',  year:'2012', match:33, what:'Legacy distribution · brand dilution · failed pivot',             ret:'-81%',  dir:'down', outcome:'WARNING' },
        { ticker:'K',    year:'2001', match:29, what:'CPG supplier squeezed by channel power · margin compression',     ret:'-8%',   dir:'down', outcome:'MIXED'   },
      ],
    },
  },
};

// ─────────────────────────────────────────────────────────────────────────────
// Returns mock data; replace with a real fetch when the backend is ready.
function resolveCompany(ticker) {
  return VM_COMPANY_DATA[ticker] || VM_COMPANY_DATA['AAPL'];
}

Object.assign(window, { VM_INDEX, VM_COMPANIES, VM_COMPANY_DATA, resolveCompany });
