// Mock data for Digital Contractors internal dashboard
// Realistic Tuesday-morning state with 1-2 red clients, 2 at-risk accounts.

const TODAY = new Date('2026-04-29T09:00:00Z');

const CLIENTS = [
  { slug: 'patio-pros',      name: 'Patio Pros',           initials: 'PP', tone: 'forest' },
  { slug: 'stoneworks',      name: 'Stoneworks Co.',       initials: 'SW', tone: 'gold' },
  { slug: 'evergreen',       name: 'Evergreen Outdoor',    initials: 'EG', tone: 'forest' },
  { slug: 'brad-hardscapes', name: 'Brad Hardscapes',      initials: 'BH', tone: 'gold' },
  { slug: 'midland-stone',   name: 'Midland Stone',        initials: 'MS', tone: 'forest' },
  { slug: 'paver-and-co',    name: 'Paver & Co.',          initials: 'P&', tone: 'gold' },
  { slug: 'oak-ridge',       name: 'Oak Ridge Outdoor',    initials: 'OR', tone: 'forest' },
  { slug: 'cornerstone',     name: 'Cornerstone Living',   initials: 'CS', tone: 'gold' },
  { slug: 'high-country',    name: 'High Country Hardscape', initials: 'HC', tone: 'forest' },
  { slug: 'lakeside',        name: 'Lakeside Outdoor',     initials: 'LO', tone: 'gold' },
  { slug: 'redrock',         name: 'Redrock Patios',       initials: 'RR', tone: 'forest' },
  { slug: 'meridian',        name: 'Meridian Stone',       initials: 'MD', tone: 'gold' },
  { slug: 'foundry',         name: 'Foundry Hardscapes',   initials: 'FH', tone: 'forest' },
  { slug: 'wildwood',        name: 'Wildwood Patios',      initials: 'WW', tone: 'gold' },
  { slug: 'apex-outdoor',    name: 'Apex Outdoor',         initials: 'AO', tone: 'forest' },
  { slug: 'northstar',       name: 'Northstar Stone',      initials: 'NS', tone: 'gold' },
  { slug: 'summit',          name: 'Summit Hardscape',     initials: 'SH', tone: 'forest' },
  { slug: 'blackstone',      name: 'Blackstone Patios',    initials: 'BS', tone: 'gold' },
  { slug: 'ironwood',        name: 'Ironwood Outdoor',     initials: 'IW', tone: 'forest' },
  { slug: 'craftsman',       name: 'Craftsman Stone',      initials: 'CM', tone: 'gold' },
];

const findClient = (slug) => CLIENTS.find(c => c.slug === slug);

// ── HENRY (owner — strategic) ────────────────────────────────────────────────

const HENRY_BUSY = {
  user: { email: 'henry@digitalcontractors.io', name: 'Henry', role: 'owner' },
  config: { widgets: ['agents','blockers','priorities','goals','transcript-recs','churn-risk'] },
  data: {
    agents: [
      { id: 'sal',   name: 'Sal Rivera',  role: 'Marketing',  initials: 'SR',
        scope: 'agency-only',
        lastRun: '2026-04-29T08:00:00Z', flaggedCount: 3,
        priorities: [
          'DC demo cost up 60% WoW — review agency Meta ads',
          'Agency landing page LP-V4 hook test ready to ship',
          'Q2 positioning memo — competitor pricing audit complete',
        ] },
      { id: 'cole',  name: 'Cole Mercer', role: 'Fulfillment', initials: 'CM',
        scope: 'client-work',
        lastRun: '2026-04-29T07:42:00Z', flaggedCount: 4,
        priorities: [
          'Patio Pros booking flow change request — needs your call',
          'Brad Hardscapes — new hook variants drafted, awaiting brief',
          'Cornerstone GHL form audit — 14 starts, 0 completes',
          'Wildwood Patios kickoff stalled at calendar embed',
        ] },
      { id: 'david', name: 'David Holt',  role: 'Sales',       initials: 'DH',
        scope: 'sales',
        lastRun: '2026-04-29T08:15:00Z', flaggedCount: 2,
        priorities: [
          'New inbound from Foundry Hardscapes — fits ICP, score 92',
          'D100 follow-up batch ready (12 prospects)',
        ] },
    ],
    blockers: [
      { id: 'b1', title: 'Approve new offer doc for Patio Pros',         owner: 'me',       ownerName: 'Henry',  client: 'Patio Pros',         ageDays: 6, clickupUrl: '#' },
      { id: 'b2', title: 'Sign off on creative brief — Brad Spring',     owner: 'me',       ownerName: 'Henry',  client: 'Brad Hardscapes',    ageDays: 2, clickupUrl: '#' },
      { id: 'b3', title: 'Decide on dedicated number policy',            owner: 'me',       ownerName: 'Henry',  client: null,                 ageDays: 4, clickupUrl: '#' },
      { id: 'b4', title: 'Rewrite booking confirmation copy',            owner: 'team',     ownerName: 'Cole',   client: null,                 ageDays: 1, clickupUrl: '#' },
      { id: 'b5', title: 'Build new hook variants — Cornerstone',        owner: 'team',     ownerName: 'Vukasi', client: 'Cornerstone Living', ageDays: 3, clickupUrl: '#' },
      { id: 'b6', title: 'Pull EOM report data for Stoneworks',          owner: 'team',     ownerName: 'Cole',   client: 'Stoneworks Co.',     ageDays: 7, clickupUrl: '#' },
      { id: 'b7', title: 'Awaiting GHL tag mapping from client',         owner: 'client',   ownerName: 'Brad',   client: 'Brad Hardscapes',    ageDays: 9, clickupUrl: '#' },
      { id: 'b8', title: 'Budget approval for May — Lakeside',           owner: 'client',   ownerName: 'Janet',  client: 'Lakeside Outdoor',   ageDays: 2, clickupUrl: '#' },
      { id: 'b9', title: 'Photos pending — Wildwood project shoot',      owner: 'client',   ownerName: 'Mike',   client: 'Wildwood Patios',    ageDays: 11, clickupUrl: '#' },
      { id: 'b10', title: 'Meta business mgr access — pending review',   owner: 'external', ownerName: 'Meta',   client: 'Foundry Hardscapes', ageDays: 5, clickupUrl: '#' },
      { id: 'b11', title: 'Domain DNS propagation — Northstar',          owner: 'external', ownerName: 'Cloudflare', client: 'Northstar Stone', ageDays: 1, clickupUrl: '#' },
    ],
    priorities: [
      { id: 'p1', title: 'Call w/ Patio Pros — discuss Q2 pivot',                 status: 'in_progress', clickupUrl: '#' },
      { id: 'p2', title: 'Review Vukasi\'s creative refresh plan',                status: 'not_started', clickupUrl: '#' },
      { id: 'p3', title: 'Approve Cornerstone offer rewrite',                      status: 'not_started', clickupUrl: '#' },
      { id: 'p4', title: 'Sign Brad Hardscapes Q2 SOW',                            status: 'done',        clickupUrl: '#' },
      { id: 'p5', title: 'Ship May playbook — cost per booked job',                status: 'not_started', clickupUrl: '#' },
    ],
    // Single source of truth: status drives drivingMetric. Counts derived from .status field downstream.
    clientHealth: CLIENTS.map((c, i) => {
      const RULES = {
        0: { status: 'red',    drivingMetric: 'CPL up 4.3x WoW',                  daysSinceLastBooking: 9  },
        7: { status: 'red',    drivingMetric: 'No bookings in 11 days',           daysSinceLastBooking: 11 },
        3: { status: 'yellow', drivingMetric: 'Hook rate down 60%',               daysSinceLastBooking: 4  },
        5: { status: 'yellow', drivingMetric: 'Pacing 38% behind monthly target', daysSinceLastBooking: 3  },
        9: { status: 'yellow', drivingMetric: 'Booked-job rate dipped to 18%',    daysSinceLastBooking: 5  },
        13:{ status: 'yellow', drivingMetric: 'Creative refresh overdue (18d)',   daysSinceLastBooking: 6  },
      };
      if (RULES[i]) return { ...c, ...RULES[i] };
      const greens = ['CPL holding under target', 'Booked rate 32%', 'Spend pacing on plan', 'New hook outperforming'];
      return { ...c, status: 'green', drivingMetric: greens[i % greens.length], daysSinceLastBooking: (i % 4) + 1 };
    }),
    kpis: {
      revenueMTD:    { label: 'Revenue MTD',          value: '$47,200', target: '$60,000 target', delta: '79% of plan', trend: 'warn',    sentiment: 'down', series: [3200,5100,6800,9400,12100,15500,18200,22400,26800,31200,36000,40500,44100,47200], prefix: '$' },
      demosBooked:   { label: 'Demos booked (week)',  value: '6',       target: '8 target',        delta: '-2 vs last wk',  trend: 'warn',    sentiment: 'down', series: [9,11,8,10,7,8,6], prefix: '' },
      activeClients: { label: 'Active clients',       value: '18',      target: '25 target',       delta: '+1 vs Mar',      trend: 'neutral', sentiment: 'flat', series: [16,16,17,17,17,17,18,18,18,18,18,18,18,18], prefix: '' },
    },
    focus: {
      tone: 'amber',
      headline: 'DC demo cost is $480 — up 60% WoW.',
      cta: 'Review agency Meta ads',
      source: 'Sal flagged 12m ago',
    },
    goals: {
      newClientsMTD:  { current: 2,    target: 4,    label: 'New clients (MTD)' },
      pipelineNext30: { current: 78000, target: 120000, label: 'Qualified pipeline (next 30d)', prefix: '$' },
      retention90d:   { current: 94,   target: 95,   label: '90-day retention', suffix: '%' },
    },
    transcriptRecs: [
      { id: 'tr1', callTitle: 'Cole call w/ Patio Pros',        callDate: '2026-04-28',
        recommendation: 'Move discovery question about budget range BEFORE scope. Client said "I get the budget question feels intrusive when it comes after I\'ve described my dream patio."' },
      { id: 'tr2', callTitle: 'David call w/ Foundry Hardscapes', callDate: '2026-04-28',
        recommendation: 'Add a "non-negotiables" section to the proposal — Foundry called out that 3 of our last 5 deals stalled here. Test for two weeks.' },
      { id: 'tr3', callTitle: 'Sal review w/ Brad Hardscapes',    callDate: '2026-04-27',
        recommendation: 'Replace the "Spring Refresh" hook with the "Estimator time" angle. Brad himself used this language unprompted three times in the call.' },
      { id: 'tr4', callTitle: 'Cole call w/ Wildwood Patios',     callDate: '2026-04-26',
        recommendation: 'Introduce a 48-hour "post-booking confirmation" SMS. Wildwood said 2 of last 8 booked appointments no-showed because nothing followed up.' },
    ],
  }
};

// ── VUKASI (media buyer — operational) ───────────────────────────────────────

const VUKASI_BUSY = {
  user: { email: 'vukasi@digitalcontractors.io', name: 'Vukasi', role: 'media-buyer' },
  config: { widgets: ['at-risk','neglected','my-tasks','creative-gaps','wins'] },
  data: {
    atRiskAccounts: [
      { slug: 'patio-pros', name: 'Patio Pros',
        issue: 'CPL is $187 vs $43 account average — 4.3x spike since Friday',
        metricName: 'CPL ($)', metricSeries: [41, 43, 44, 47, 49, 52, 58, 71, 89, 112, 134, 156, 172, 187],
        lastUpdated: '2026-04-29T07:55:00Z',
        nextSteps: [
          { id: 'a1', text: 'Pause ad set "Brad — Spring Refresh" — driving 78% of bad CPL', priority: 1 },
          { id: 'a2', text: 'Test new hook variant on the Brad avatar (3 drafts ready)',     priority: 2 },
          { id: 'a3', text: 'Add 2 new creatives — last refresh was 18 days ago',            priority: 3 },
        ],
        evidence: {
          metrics: [
            { k: 'CPL (last 14d)',   v: '$187', delta: '+334% vs avg' },
            { k: 'Spend (week)',     v: '$3,210', delta: 'on pace' },
            { k: 'Bookings (week)',  v: '1', delta: '-83%' },
            { k: 'Hook rate',        v: '4.1%', delta: '-60%' },
          ],
          recentCreatives: [
            { name: 'Brad — Spring Refresh', type: 'video', age: 18 },
            { name: 'Estimator Time v2',     type: 'image', age: 24 },
            { name: 'Tire-kicker Hook',      type: 'video', age: 31 },
          ],
          recentClickup: [
            { date: '04-28', text: 'Vukasi: Flagged ad set, awaiting Henry approval' },
            { date: '04-26', text: 'Sal note: Hook fatigue confirmed in transcript' },
            { date: '04-22', text: 'Last creative refresh shipped' },
          ],
        }
      },
      { slug: 'cornerstone', name: 'Cornerstone Living',
        issue: 'No bookings in 9 days. Spend pacing 38% behind monthly target.',
        metricName: 'Bookings (daily)', metricSeries: [3, 2, 4, 2, 3, 2, 1, 0, 0, 1, 0, 0, 0, 0],
        lastUpdated: '2026-04-29T07:48:00Z',
        nextSteps: [
          { id: 'c1', text: 'Audit GHL booking flow — 14 form starts, 0 completes since 04-23', priority: 1 },
          { id: 'c2', text: 'Reactivate paused "Outdoor Kitchen" ad set — last week\'s top performer', priority: 2 },
          { id: 'c3', text: 'Push budget +$200/day to recover pacing', priority: 3 },
        ],
        evidence: {
          metrics: [
            { k: 'Bookings (week)', v: '0', delta: '-100%' },
            { k: 'Form starts',     v: '14', delta: '0 completes' },
            { k: 'Spend pacing',    v: '62%', delta: '38% behind' },
            { k: 'CPL trend',       v: '—', delta: 'no conversions' },
          ],
          recentCreatives: [
            { name: 'Outdoor Kitchen', type: 'image', age: 6 },
            { name: 'Pergola at Dusk', type: 'video', age: 9 },
          ],
          recentClickup: [
            { date: '04-28', text: 'Vukasi: Flagged booking flow as suspect' },
            { date: '04-25', text: 'Cole: Confirmed GHL form is live, no errors logged' },
          ],
        }
      },
    ],
    neglectedAccounts: [
      { slug: 'high-country',  name: 'High Country Hardscape', daysNeglected: 21, lastActivity: 'Creative refresh',  lastActivityDate: '2026-04-08' },
      { slug: 'redrock',       name: 'Redrock Patios',         daysNeglected: 18, lastActivity: 'Budget change',     lastActivityDate: '2026-04-11' },
      { slug: 'wildwood',      name: 'Wildwood Patios',        daysNeglected: 17, lastActivity: 'Creative refresh',  lastActivityDate: '2026-04-12' },
      { slug: 'apex-outdoor',  name: 'Apex Outdoor',           daysNeglected: 16, lastActivity: 'Vukasi note',       lastActivityDate: '2026-04-13' },
      { slug: 'meridian',      name: 'Meridian Stone',         daysNeglected: 15, lastActivity: 'Creative refresh',  lastActivityDate: '2026-04-14' },
      { slug: 'foundry',       name: 'Foundry Hardscapes',     daysNeglected: 14, lastActivity: 'Budget change',     lastActivityDate: '2026-04-15' },
    ],
    myTasks: [
      { id: 't1', title: 'Pause "Brad Spring Refresh" ad set',         client: 'Patio Pros',         dueDate: '2026-04-28', status: 'overdue',   clickupUrl: '#' },
      { id: 't2', title: 'Build 3 new hook variants — Cornerstone',    client: 'Cornerstone Living', dueDate: '2026-04-29', status: 'today',     clickupUrl: '#' },
      { id: 't3', title: 'Audit GHL form on Cornerstone',              client: 'Cornerstone Living', dueDate: '2026-04-29', status: 'today',     clickupUrl: '#' },
      { id: 't4', title: 'Refresh creative pool — Brad Hardscapes',    client: 'Brad Hardscapes',    dueDate: '2026-04-30', status: 'this_week', clickupUrl: '#' },
      { id: 't5', title: 'Pull weekly hook-rate report',                client: null,                 dueDate: '2026-05-01', status: 'this_week', clickupUrl: '#' },
      { id: 't6', title: 'Test new avatar — Stoneworks',               client: 'Stoneworks Co.',     dueDate: '2026-05-02', status: 'this_week', clickupUrl: '#' },
    ],
    creativeLogGaps: [
      { slug: 'high-country',  name: 'High Country Hardscape', daysSinceLastCreative: 22, lastCreativeType: 'video' },
      { slug: 'redrock',       name: 'Redrock Patios',         daysSinceLastCreative: 19, lastCreativeType: 'image' },
      { slug: 'patio-pros',    name: 'Patio Pros',             daysSinceLastCreative: 18, lastCreativeType: 'video' },
      { slug: 'apex-outdoor',  name: 'Apex Outdoor',           daysSinceLastCreative: 16, lastCreativeType: 'image' },
      { slug: 'meridian',      name: 'Meridian Stone',         daysSinceLastCreative: 15, lastCreativeType: 'video' },
      { slug: 'oak-ridge',     name: 'Oak Ridge Outdoor',      daysSinceLastCreative: 12, lastCreativeType: 'image' },
      { slug: 'evergreen',     name: 'Evergreen Outdoor',      daysSinceLastCreative: 9,  lastCreativeType: 'video' },
      { slug: 'lakeside',      name: 'Lakeside Outdoor',       daysSinceLastCreative: 6,  lastCreativeType: 'image' },
    ],
    accountWins: [
      { slug: 'evergreen',  name: 'Evergreen Outdoor', metric: 'CPL',          value: '$28', vsTarget: '-35%' },
      { slug: 'oak-ridge',  name: 'Oak Ridge Outdoor', metric: 'Booked rate',  value: '38%', vsTarget: '+11pp' },
      { slug: 'midland-stone', name: 'Midland Stone',  metric: 'CPL',          value: '$31', vsTarget: '-28%' },
      { slug: 'ironwood',   name: 'Ironwood Outdoor',  metric: 'Hook rate',    value: '12%', vsTarget: '+3pp'  },
    ],
    kpis: {
      avgCPL:      { label: 'Avg CPL (portfolio)',         value: '$58',  target: '$50 target',  delta: '+12% WoW', trend: 'warn',    sentiment: 'down', series: [44,46,48,49,51,52,53,55,57,58,59,58,57,58], prefix: '$', goodIs: 'down' },
      cpBooked:    { label: 'Cost / booked appt',          value: '$142', target: '$120 target', delta: '+8% WoW',  trend: 'warn',    sentiment: 'down', series: [128,130,131,134,136,138,140,141,143,144,145,143,142,142], prefix: '$', goodIs: 'down' },
      hookRate:    { label: 'Avg hook rate (portfolio)',   value: '7.2%', target: '8% target',   delta: '-0.4pp WoW', trend: 'warn',  sentiment: 'down', series: [8.1,8.0,7.9,7.8,7.7,7.6,7.5,7.4,7.4,7.3,7.2,7.1,7.2,7.2], prefix: '', suffix: '%', goodIs: 'up' },
    },
  }
};

// ── Scenario variants: calm / busy / crisis ─────────────────────────────────

const SCENARIOS = {
  busy:   { henry: HENRY_BUSY, vukasi: VUKASI_BUSY },
  // calm = trim red items, lighter list
  calm: {
    henry: { ...HENRY_BUSY,
      data: { ...HENRY_BUSY.data,
        blockers: HENRY_BUSY.data.blockers.slice(0, 4),
        clientHealth: HENRY_BUSY.data.clientHealth.map(c => ({ ...c,
          status: c.status === 'red' ? 'yellow' : (c.status === 'yellow' ? 'green' : 'green'),
          drivingMetric: c.status === 'green' ? c.drivingMetric : 'CPL holding under target',
        })),
        priorities: HENRY_BUSY.data.priorities.slice(0,3).map(p => ({ ...p, status: 'done' })),
        transcriptRecs: HENRY_BUSY.data.transcriptRecs.slice(0,1),
        agents: HENRY_BUSY.data.agents.map(a => ({ ...a, flaggedCount: 0, priorities: a.priorities.slice(0,1) })),
      }
    },
    vukasi: { ...VUKASI_BUSY,
      data: { ...VUKASI_BUSY.data,
        atRiskAccounts: [],
        neglectedAccounts: VUKASI_BUSY.data.neglectedAccounts.slice(0,2),
        myTasks: VUKASI_BUSY.data.myTasks.filter(t => t.status === 'this_week').slice(0,2),
        creativeLogGaps: VUKASI_BUSY.data.creativeLogGaps.slice(4),
        accountWins: VUKASI_BUSY.data.accountWins,
      }
    }
  },
  // crisis = amplify red, more blockers, more at-risk
  crisis: {
    henry: { ...HENRY_BUSY,
      data: { ...HENRY_BUSY.data,
        blockers: [
          ...HENRY_BUSY.data.blockers,
          { id: 'b12', title: 'Emergency: Patio Pros considering pause',  owner: 'me', ownerName: 'Henry', client: 'Patio Pros', ageDays: 1, clickupUrl: '#' },
          { id: 'b13', title: 'Stoneworks SLA breach — 48h overdue',      owner: 'me', ownerName: 'Henry', client: 'Stoneworks Co.', ageDays: 2, clickupUrl: '#' },
        ],
        clientHealth: HENRY_BUSY.data.clientHealth.map((c, i) => i < 5
          ? { ...c, status: 'red',    drivingMetric: 'Multiple metrics flagged' }
          : i < 10 ? { ...c, status: 'yellow', drivingMetric: c.drivingMetric || 'Trending down' }
          : c),
        agents: HENRY_BUSY.data.agents.map(a => ({ ...a, flaggedCount: a.flaggedCount + 3 })),
      }
    },
    vukasi: { ...VUKASI_BUSY,
      data: { ...VUKASI_BUSY.data,
        atRiskAccounts: [
          ...VUKASI_BUSY.data.atRiskAccounts,
          { slug: 'stoneworks', name: 'Stoneworks Co.',
            issue: 'Hook rate dropped 60% this week. Spend up, conversions flat.',
            metricName: 'Hook rate (%)', metricSeries: [11.2, 10.8, 10.5, 9.8, 8.4, 7.9, 6.2, 5.1, 4.6, 4.4, 4.2, 4.1, 4.0, 4.4],
            lastUpdated: '2026-04-29T07:50:00Z',
            nextSteps: [
              { id: 's1', text: 'Pull top 3 historical hooks for re-test',     priority: 1 },
              { id: 's2', text: 'Pause underperforming "Patio Reveal" cluster', priority: 2 },
              { id: 's3', text: 'Brief new creative with operator-memo angle',  priority: 3 },
            ],
            evidence: { metrics: [
              { k: 'Hook rate', v: '4.4%', delta: '-60% week' },
              { k: 'Spend',     v: '$2,850', delta: '+12%' },
              { k: 'Bookings',  v: '4', delta: '-50%' },
            ], recentCreatives: [], recentClickup: [] }
          }
        ],
        myTasks: [
          { id: 'tx1', title: 'URGENT: pause Patio Pros ad set',  client: 'Patio Pros',     dueDate: '2026-04-29', status: 'overdue', clickupUrl: '#' },
          { id: 'tx2', title: 'URGENT: brief Stoneworks creative', client: 'Stoneworks Co.', dueDate: '2026-04-29', status: 'overdue', clickupUrl: '#' },
          ...VUKASI_BUSY.data.myTasks,
        ],
      }
    }
  }
};

// Drawer detail data — used by both Henry's client tile and Vukasi's neglected-row click
function getClientDrawerData(slug) {
  const c = findClient(slug) || { slug, name: slug, initials: slug.slice(0,2).toUpperCase(), tone: 'forest' };
  const seed = slug.charCodeAt(0) + slug.length;
  const cplSeries = Array.from({length: 14}, (_,i) => 38 + ((seed * (i+1)) % 30));
  const isRed = ['patio-pros','cornerstone'].includes(slug);
  const isYellow = ['brad-hardscapes','paver-and-co','lakeside','wildwood'].includes(slug);
  const cpbCur = 42 + (seed % 60);
  const cpbTgt = 50;
  const bookedRate = 18 + (seed % 18);
  const appts = 10 + (seed % 18);
  const spend = seed * 187;
  const hookRate = (4 + (seed % 9));
  const formStarts = 20 + (seed % 50);

  const statusReason = isRed
    ? bookedRate < 22 ? `Booked rate ${bookedRate}%` : `CPB $${cpbCur} vs $${cpbTgt} target`
    : isYellow ? `Hook rate trending down`
    : `Booked rate ${bookedRate}%`;

  return {
    client: c,
    status: isRed ? 'red' : isYellow ? 'yellow' : 'green',
    statusReason,
    summary: isRed
      ? 'Multiple metrics off pace. Account needs a Henry call this week.'
      : isYellow
      ? 'Drifting. Vukasi is on it — watch through Friday.'
      : 'Holding the line. Booked-job rate above target.',
    lastUpdated: { meta: '2026-04-29T07:50:00Z', clickup: '2026-04-29T08:42:00Z' },
    // Order: cost/booked first, spend last
    metaMetrics: [
      { k: 'Cost / booked',  v: `$${cpbCur}`,    cmp: cpbCur <= cpbTgt ? `▼ vs $${cpbTgt} target` : `▲ vs $${cpbTgt} target`, good: cpbCur <= cpbTgt },
      { k: 'Booked rate',    v: `${bookedRate}%`, cmp: bookedRate >= 25 ? '▲ +3pp WoW' : '▼ -2pp WoW', good: bookedRate >= 25 },
      { k: 'Appointments',   v: `${appts}`,       cmp: '▲ +12% WoW', good: true },
      { k: 'Spend (MTD)',    v: `$${spend.toLocaleString()}`, cmp: 'on pace', good: true },
      { k: 'Hook rate',      v: `${hookRate.toFixed(1)}%`,    cmp: hookRate >= 6 ? '▲ above avg' : '▼ below avg', good: hookRate >= 6 },
      { k: 'Form starts',    v: `${formStarts}`,  cmp: '▲ +8% WoW', good: true },
    ],
    cplSeries,
    bookingSeries: Array.from({length: 14}, (_,i) => Math.max(0, 4 - ((seed + i) % 5))),
    clickupActivity: [
      { date: '04-28', who: 'Vukasi', text: 'Flagged ad set "Brad Spring Refresh" — CPL spike',  url: '#' },
      { date: '04-26', who: 'Sal',    text: 'Hook fatigue noted in transcript review',           url: '#' },
      { date: '04-24', who: 'Cole',   text: 'Booking flow re-tested — calendar embed OK',        url: '#' },
      { date: '04-22', who: 'Vukasi', text: 'Creative refresh shipped — 3 new variants',         url: '#' },
      { date: '04-19', who: 'David',  text: 'Quarterly check-in scheduled',                      url: '#' },
      { date: '04-17', who: 'Cole',   text: 'EOM report delivered to client',                    url: '#' },
      { date: '04-15', who: 'Sal',    text: 'New avatar tested in transcript pull',              url: '#' },
      { date: '04-12', who: 'Vukasi', text: 'Budget shifted from Set A to Set C',                url: '#' },
    ],
    recentCalls: {
      count30d: 3,
      latest: {
        date: '2026-04-28',
        title: `Cole call w/ ${c.name}`,
        bullets: [
          'Client confirmed estimator availability through end of May.',
          isRed
            ? 'Strong pushback on current creative — wants more "operator memo" feel.'
            : 'Generally happy, asked about expanding to a second metro.',
          'Asked us to push out the next monthly review by one week.',
          'Mentioned competitor running a $2k giveaway — ignore for now.',
        ]
      },
      others: [
        { date: '2026-04-15', title: `Henry call w/ ${c.name}`, snippet: 'Quarterly business review. Pricing held.' },
        { date: '2026-04-02', title: `Cole call w/ ${c.name}`,  snippet: 'Booking flow tweaks signed off.' },
      ]
    }
  };
}

// ── Route data: Henry /ai-agents ────────────────────────────────────────────
const AGENT_DETAIL = {
  sal: {
    id: 'sal', name: 'Sal Rivera', role: 'Marketing', initials: 'SR', scope: 'agency-only',
    cadence: 'Daily 7:00 AM CT · plus on-demand',
    description: 'Audits the agency\'s own marketing. Reviews DC\'s ads, landing pages, positioning. Does NOT touch client work.',
    triggers: [
      { id: 'sal-batch', label: 'Generate weekly content batch', desc: 'Drafts 5 LinkedIn posts + 2 reel scripts from the last 7 days of agency wins.', kind: 'fire' },
      { id: 'sal-reel',  label: 'Refresh reel script bibliography', desc: 'Pulls hook patterns from top 50 reels in our niche this month.', kind: 'fire' },
      { id: 'sal-dc-ad', label: 'Draft DC ad variant', desc: 'Generates 3 ad variants for the agency\'s own Meta campaign. Specify angle.', kind: 'input' },
    ],
    outputs: [
      { id: 'sal-o1', when: '2026-04-29T08:00:00Z', title: 'DC demo cost spike memo',                 status: 'shipped',   url: '#' },
      { id: 'sal-o2', when: '2026-04-28T14:22:00Z', title: 'LP-V4 hook variants (3)',                  status: 'review',    url: '#' },
      { id: 'sal-o3', when: '2026-04-28T07:55:00Z', title: 'Q2 positioning competitor scan',           status: 'shipped',   url: '#' },
      { id: 'sal-o4', when: '2026-04-27T16:08:00Z', title: 'Weekly LinkedIn batch (5 posts)',          status: 'shipped',   url: '#' },
      { id: 'sal-o5', when: '2026-04-26T07:42:00Z', title: 'Reel script — "operator memo"',            status: 'dropped',   url: '#' },
      { id: 'sal-o6', when: '2026-04-25T08:00:00Z', title: 'Pricing audit summary',                    status: 'shipped',   url: '#' },
      { id: 'sal-o7', when: '2026-04-24T19:11:00Z', title: 'Agency case study draft — Evergreen',      status: 'review',    url: '#' },
      { id: 'sal-o8', when: '2026-04-23T08:02:00Z', title: 'Hook A/B test plan',                        status: 'shipped',   url: '#' },
      { id: 'sal-o9', when: '2026-04-22T07:58:00Z', title: 'Email sequence — agency newsletter',       status: 'shipped',   url: '#' },
      { id: 'sal-o10',when: '2026-04-21T08:14:00Z', title: 'Competitor pricing scan',                   status: 'shipped',   url: '#' },
    ],
    runHistory: [
      { when: '2026-04-29T08:00:00Z', durationS: 184, outputs: 3, status: 'ok' },
      { when: '2026-04-28T08:00:00Z', durationS: 167, outputs: 2, status: 'ok' },
      { when: '2026-04-27T08:00:00Z', durationS: 201, outputs: 4, status: 'ok' },
      { when: '2026-04-26T08:00:00Z', durationS: 158, outputs: 2, status: 'ok' },
      { when: '2026-04-25T08:00:00Z', durationS: 0,   outputs: 0, status: 'fail', err: 'Meta API rate limit' },
      { when: '2026-04-24T08:00:00Z', durationS: 173, outputs: 3, status: 'ok' },
      { when: '2026-04-23T08:00:00Z', durationS: 191, outputs: 2, status: 'ok' },
    ],
  },
  cole: {
    id: 'cole', name: 'Cole Mercer', role: 'Fulfillment', initials: 'CM', scope: 'client-work',
    cadence: 'Hourly during business hours · transcript-driven',
    description: 'Audits client accounts. Listens to call transcripts, watches GHL/Meta data, surfaces drift, drafts briefs.',
    triggers: [
      { id: 'cole-drift', label: 'Run client drift scan',           desc: 'Scans all 18 active clients for metric drift past threshold. Returns ranked list.', kind: 'fire' },
      { id: 'cole-brief', label: 'Generate creative brief',          desc: 'Produces a refresh brief for one client based on their last 30d transcripts + ad data.', kind: 'input' },
      { id: 'cole-eom',   label: 'Draft EOM report',                  desc: 'Pulls month\'s metrics + transcript wins for one client into a shareable doc.', kind: 'input' },
    ],
    outputs: [
      { id: 'cole-o1',  when: '2026-04-29T07:42:00Z', title: 'Patio Pros booking-flow change request',  status: 'review',  url: '#' },
      { id: 'cole-o2',  when: '2026-04-29T07:10:00Z', title: 'Brad Hardscapes hook variants (3)',        status: 'review',  url: '#' },
      { id: 'cole-o3',  when: '2026-04-29T06:55:00Z', title: 'Cornerstone GHL form audit',                status: 'shipped', url: '#' },
      { id: 'cole-o4',  when: '2026-04-29T06:30:00Z', title: 'Wildwood kickoff blocker memo',             status: 'review',  url: '#' },
      { id: 'cole-o5',  when: '2026-04-28T17:42:00Z', title: 'Stoneworks EOM report',                     status: 'shipped', url: '#' },
      { id: 'cole-o6',  when: '2026-04-28T15:11:00Z', title: 'Evergreen creative brief',                   status: 'shipped', url: '#' },
      { id: 'cole-o7',  when: '2026-04-28T11:08:00Z', title: 'Patio Pros transcript drift detect',        status: 'shipped', url: '#' },
      { id: 'cole-o8',  when: '2026-04-28T08:45:00Z', title: 'Lakeside booking confirm copy',              status: 'shipped', url: '#' },
      { id: 'cole-o9',  when: '2026-04-27T16:22:00Z', title: 'Brad Hardscapes EOM report',                status: 'shipped', url: '#' },
      { id: 'cole-o10', when: '2026-04-27T14:01:00Z', title: 'Drift scan (18 accounts)',                   status: 'shipped', url: '#' },
    ],
    runHistory: [
      { when: '2026-04-29T08:00:00Z', durationS: 612, outputs: 4, status: 'ok' },
      { when: '2026-04-29T07:00:00Z', durationS: 587, outputs: 3, status: 'ok' },
      { when: '2026-04-28T17:00:00Z', durationS: 644, outputs: 5, status: 'ok' },
      { when: '2026-04-28T15:00:00Z', durationS: 598, outputs: 2, status: 'ok' },
      { when: '2026-04-28T13:00:00Z', durationS: 0,   outputs: 0, status: 'fail', err: 'GHL token expired' },
      { when: '2026-04-28T11:00:00Z', durationS: 612, outputs: 3, status: 'ok' },
    ],
  },
  david: {
    id: 'david', name: 'David Holt', role: 'Sales', initials: 'DH', scope: 'sales',
    cadence: 'Triggered by new inbound · plus 9:00 AM daily review',
    description: 'Triages inbound leads, scores ICP fit, drafts follow-ups, preps Henry for sales calls.',
    triggers: [
      { id: 'david-followup', label: 'Draft follow-up sequence', desc: '5-touch sequence for one prospect, tuned to their last call signals.', kind: 'input' },
      { id: 'david-precall',  label: 'Generate pre-call brief',   desc: 'One-pager: prospect background, ICP score, talking points for an upcoming meeting.', kind: 'input' },
      { id: 'david-d100',     label: 'Refresh D100 batch',         desc: 'Re-scores the dream-100 list and surfaces this week\'s top 12 prospects.', kind: 'fire' },
    ],
    outputs: [
      { id: 'david-o1', when: '2026-04-29T08:15:00Z', title: 'Foundry Hardscapes — ICP score 92',         status: 'review',  url: '#' },
      { id: 'david-o2', when: '2026-04-29T08:00:00Z', title: 'D100 batch (12 prospects)',                  status: 'shipped', url: '#' },
      { id: 'david-o3', when: '2026-04-28T18:32:00Z', title: 'Pre-call brief: Cornerstone QBR',            status: 'shipped', url: '#' },
      { id: 'david-o4', when: '2026-04-28T11:14:00Z', title: 'Follow-up seq — Granite & Co',                status: 'shipped', url: '#' },
      { id: 'david-o5', when: '2026-04-27T17:08:00Z', title: 'Foundry pre-call brief',                      status: 'shipped', url: '#' },
      { id: 'david-o6', when: '2026-04-26T09:21:00Z', title: 'D100 weekly refresh',                          status: 'shipped', url: '#' },
      { id: 'david-o7', when: '2026-04-25T15:11:00Z', title: 'Inbound triage — 4 leads scored',              status: 'shipped', url: '#' },
    ],
    runHistory: [
      { when: '2026-04-29T09:00:00Z', durationS: 78,  outputs: 1, status: 'ok' },
      { when: '2026-04-29T08:00:00Z', durationS: 142, outputs: 2, status: 'ok' },
      { when: '2026-04-28T09:00:00Z', durationS: 119, outputs: 2, status: 'ok' },
      { when: '2026-04-28T11:00:00Z', durationS: 88,  outputs: 1, status: 'ok' },
      { when: '2026-04-27T09:00:00Z', durationS: 134, outputs: 1, status: 'ok' },
    ],
  },
};

// ── Route data: Vukasi /at-risk-accounts (extended risk register) ───────────
const RISK_REGISTER = [
  // already-flagged accounts come from atRiskAccounts; this adds the watchlist
  { slug: 'patio-pros',    name: 'Patio Pros',           score: 13, status: 'flagged',  trigger: 'CPL spike (4.3x)',           sinceDays: 4,  cpl: 187, daysQuiet: 0,  spendPace: 102 },
  { slug: 'cornerstone',   name: 'Cornerstone Living',   score: 19, status: 'flagged',  trigger: 'No bookings 9d',             sinceDays: 9,  cpl: null, daysQuiet: 9,  spendPace: 62  },
  { slug: 'stoneworks',    name: 'Stoneworks Co.',       score: 36, status: 'watching', trigger: 'Hook rate -42% WoW',          sinceDays: 2,  cpl: 71,  daysQuiet: 1,  spendPace: 112 },
  { slug: 'brad-hardscapes', name: 'Brad Hardscapes',    score: 42, status: 'watching', trigger: 'Booked rate dipped to 18%',  sinceDays: 6,  cpl: 49,  daysQuiet: 2,  spendPace: 96  },
  { slug: 'lakeside',      name: 'Lakeside Outdoor',     score: 53, status: 'watching', trigger: 'Spend pacing 38% behind',     sinceDays: 5,  cpl: 52,  daysQuiet: 2,  spendPace: 62  },
  { slug: 'paver-and-co',  name: 'Paver & Co.',          score: 59, status: 'watching', trigger: 'Hook rate trending down',     sinceDays: 8,  cpl: 47,  daysQuiet: 3,  spendPace: 88  },
  { slug: 'wildwood',      name: 'Wildwood Patios',      score: 62, status: 'watching', trigger: 'Creative refresh overdue 17d',sinceDays: 17, cpl: 44,  daysQuiet: 17, spendPace: 91  },
  { slug: 'oak-ridge',     name: 'Oak Ridge Outdoor',    score: 78, status: 'healthy',  trigger: '—',                            sinceDays: 0,  cpl: 38,  daysQuiet: 1,  spendPace: 104 },
  { slug: 'evergreen',     name: 'Evergreen Outdoor',    score: 82, status: 'healthy',  trigger: '—',                            sinceDays: 0,  cpl: 28,  daysQuiet: 0,  spendPace: 99  },
  { slug: 'midland-stone', name: 'Midland Stone',        score: 84, status: 'healthy',  trigger: '—',                            sinceDays: 0,  cpl: 31,  daysQuiet: 1,  spendPace: 101 },
];

const RISK_RESOLVED = [
  { slug: 'apex-outdoor',  name: 'Apex Outdoor',     resolvedDate: '2026-04-22', daysAtRisk: 6, action: 'Paused 3 ad sets, refreshed creative pool' },
  { slug: 'foundry',       name: 'Foundry Hardscapes', resolvedDate: '2026-04-18', daysAtRisk: 4, action: 'New hook variant restored CPL' },
  { slug: 'northstar',     name: 'Northstar Stone',  resolvedDate: '2026-04-11', daysAtRisk: 9, action: 'GHL form fix unlocked bookings' },
];

const RISK_THRESHOLDS = {
  cplSpike:    { label: 'CPL spike multiplier',     value: 2.5, unit: 'x avg', desc: 'Trigger flag when CPL exceeds account 14d average by this factor.' },
  daysNoBook:  { label: 'Days without booking',      value: 7,   unit: 'days',  desc: 'Trigger flag after this many consecutive days with zero bookings.' },
  spendDip:    { label: 'Spend pacing dip',          value: 25,  unit: '%',     desc: 'Trigger flag when MTD spend pace falls below target by this %.' },
  hookDrop:    { label: 'Hook rate drop (WoW)',     value: 35,  unit: '%',     desc: 'Trigger flag when hook rate drops more than this % week-over-week.' },
};

// ── Route data: Vukasi /creative-log (per-account archive) ──────────────────
const CREATIVE_ARCHIVE = {
  'patio-pros': [
    { id: 'pp-c1', name: 'Brad — Spring Refresh',   format: 'video',    shipped: '2026-04-11', age: 18, hookRate: 4.1, cpl: 187, ctr: 1.2, status: 'paused' },
    { id: 'pp-c2', name: 'Estimator Time v2',        format: 'image',    shipped: '2026-04-05', age: 24, hookRate: 6.8, cpl: 51,  ctr: 2.1, status: 'archived' },
    { id: 'pp-c3', name: 'Tire-kicker Hook',         format: 'video',    shipped: '2026-03-29', age: 31, hookRate: 9.2, cpl: 38,  ctr: 2.8, status: 'archived' },
    { id: 'pp-c4', name: 'Operator Memo Reel',       format: 'video',    shipped: '2026-03-22', age: 38, hookRate: 11.4, cpl: 34, ctr: 3.0, status: 'archived' },
    { id: 'pp-c5', name: 'Backyard Reveal',          format: 'carousel', shipped: '2026-03-15', age: 45, hookRate: 7.7, cpl: 42,  ctr: 2.4, status: 'archived' },
  ],
  'cornerstone': [
    { id: 'cs-c1', name: 'Outdoor Kitchen',          format: 'image',    shipped: '2026-04-23', age: 6,  hookRate: 5.4, cpl: null, ctr: 1.6, status: 'paused' },
    { id: 'cs-c2', name: 'Pergola at Dusk',          format: 'video',    shipped: '2026-04-20', age: 9,  hookRate: 8.2, cpl: 44,   ctr: 2.5, status: 'live' },
    { id: 'cs-c3', name: 'Owner POV Walkthrough',    format: 'video',    shipped: '2026-04-12', age: 17, hookRate: 9.8, cpl: 38,   ctr: 2.9, status: 'archived' },
  ],
  'high-country': [
    { id: 'hc-c1', name: 'Patio Reveal Slow-mo',     format: 'video',    shipped: '2026-04-08', age: 21, hookRate: 6.4, cpl: 52,  ctr: 1.9, status: 'live' },
    { id: 'hc-c2', name: 'Estimator Quote Card',     format: 'image',    shipped: '2026-03-25', age: 35, hookRate: 4.8, cpl: 67,  ctr: 1.4, status: 'archived' },
  ],
  'redrock': [
    { id: 'rr-c1', name: 'Sunset Patio Build',       format: 'video',    shipped: '2026-04-11', age: 18, hookRate: 7.1, cpl: 41,  ctr: 2.2, status: 'live' },
    { id: 'rr-c2', name: 'Stamped Concrete Reel',    format: 'video',    shipped: '2026-04-02', age: 27, hookRate: 5.9, cpl: 49,  ctr: 1.8, status: 'archived' },
  ],
  'evergreen': [
    { id: 'eg-c1', name: 'Backyard Transformation',  format: 'video',    shipped: '2026-04-21', age: 8,  hookRate: 11.2, cpl: 28, ctr: 3.4, status: 'live' },
    { id: 'eg-c2', name: 'Family at the Firepit',    format: 'image',    shipped: '2026-04-14', age: 15, hookRate: 9.1,  cpl: 32, ctr: 2.7, status: 'archived' },
  ],
  'oak-ridge': [
    { id: 'or-c1', name: 'Texture Carousel',         format: 'carousel', shipped: '2026-04-18', age: 11, hookRate: 8.4, cpl: 38,  ctr: 2.3, status: 'live' },
    { id: 'or-c2', name: 'Stone Mason at Work',      format: 'video',    shipped: '2026-04-09', age: 20, hookRate: 7.6, cpl: 41,  ctr: 2.0, status: 'archived' },
  ],
  'stoneworks': [
    { id: 'sw-c1', name: 'Patio Reveal',             format: 'video',    shipped: '2026-04-19', age: 10, hookRate: 4.4, cpl: 71,  ctr: 1.3, status: 'live' },
    { id: 'sw-c2', name: 'Outdoor Living Series',    format: 'image',    shipped: '2026-04-09', age: 20, hookRate: 6.7, cpl: 52,  ctr: 1.8, status: 'archived' },
  ],
};

const CREATIVE_REFRESH_PLAN = [
  { slug: 'patio-pros',    name: 'Patio Pros',           dueIn: -4, urgency: 'overdue' },
  { slug: 'high-country',  name: 'High Country Hardscape', dueIn: -7, urgency: 'overdue' },
  { slug: 'redrock',       name: 'Redrock Patios',       dueIn: -4, urgency: 'overdue' },
  { slug: 'apex-outdoor',  name: 'Apex Outdoor',         dueIn: -2, urgency: 'overdue' },
  { slug: 'meridian',      name: 'Meridian Stone',       dueIn: -1, urgency: 'overdue' },
  { slug: 'oak-ridge',     name: 'Oak Ridge Outdoor',    dueIn: 2,  urgency: 'soon'    },
  { slug: 'evergreen',     name: 'Evergreen Outdoor',    dueIn: 5,  urgency: 'soon'    },
  { slug: 'lakeside',      name: 'Lakeside Outdoor',     dueIn: 8,  urgency: 'ok'      },
];

window.DC_DATA = {
  CLIENTS, SCENARIOS, getClientDrawerData,
  AGENT_DETAIL, RISK_REGISTER, RISK_RESOLVED, RISK_THRESHOLDS,
  CREATIVE_ARCHIVE, CREATIVE_REFRESH_PLAN,
  // ── Blockers route extras
  BLOCKER_HISTORY: [
    { id: 'h1', title: 'Stripe → ClickUp webhook',     resolvedDate: '2026-04-25', daysOpen: 3, owner: 'team',     ownerName: 'Vukasi' },
    { id: 'h2', title: 'Cornerstone GHL form fix',      resolvedDate: '2026-04-23', daysOpen: 2, owner: 'team',     ownerName: 'Vukasi' },
    { id: 'h3', title: 'Foundry contract signature',    resolvedDate: '2026-04-21', daysOpen: 5, owner: 'client',   ownerName: 'Foundry' },
    { id: 'h4', title: 'Domain DNS — Apex',             resolvedDate: '2026-04-19', daysOpen: 1, owner: 'external', ownerName: 'Cloudflare' },
    { id: 'h5', title: 'Q1 invoice batch',              resolvedDate: '2026-04-16', daysOpen: 4, owner: 'me',       ownerName: 'Henry' },
    { id: 'h6', title: 'Northstar billing dispute',     resolvedDate: '2026-04-12', daysOpen: 8, owner: 'client',   ownerName: 'Northstar' },
  ],
  // ── Goals route extras
  GOAL_DETAIL: {
    newClientsMTD: {
      contributing: [
        { date: '2026-04-21', text: 'Closed: Foundry Hardscapes — $4.2k MRR',        owner: 'David Holt',  status: 'won' },
        { date: '2026-04-08', text: 'Closed: Granite & Co — $3.6k MRR',               owner: 'David Holt',  status: 'won' },
        { date: '2026-04-29', text: 'In flight: Wildwood Patios — proposal sent',    owner: 'David Holt',  status: 'pending' },
        { date: '2026-04-25', text: 'In flight: Meridian Stone — discovery scheduled', owner: 'Henry',     status: 'pending' },
      ],
      trajectory: [0, 0, 1, 1, 1, 2, 2], // weekly cumulative
    },
    pipelineNext30: {
      contributing: [
        { date: '2026-04-29', text: 'Wildwood Patios — qualified, $4.5k MRR potential', owner: 'David Holt', status: 'pending' },
        { date: '2026-04-26', text: 'Meridian Stone — discovery booked, $3.2k', owner: 'Henry',  status: 'pending' },
        { date: '2026-04-22', text: 'Boulder Outdoor — re-engaged, $5k',         owner: 'David Holt', status: 'pending' },
        { date: '2026-04-19', text: 'D100 batch generated 4 new MQLs',            owner: 'David Holt', status: 'pending' },
      ],
      trajectory: [12000, 28000, 41000, 55000, 64000, 72000, 78000],
    },
    retention90d: {
      contributing: [
        { date: '2026-04-12', text: 'Apex Outdoor renewed (90d)',              owner: 'Vukasi',  status: 'won' },
        { date: '2026-04-04', text: 'Northstar renewed early',                  owner: 'Vukasi',  status: 'won' },
        { date: '2026-04-29', text: 'Patio Pros at risk — pause threat',        owner: 'Henry',   status: 'risk' },
      ],
      trajectory: [88, 89, 91, 92, 93, 94, 94],
    },
  },
  // ── Transcript archive
  TRANSCRIPT_ARCHIVE: [
    { id: 't1', call: 'Patio Pros — discovery debrief',     client: 'Patio Pros', date: '2026-04-28', who: 'Cole', status: 'pending', theme: 'Discovery flow', summary: 'Move budget question before scope. Client felt budget after dream-patio felt intrusive.' },
    { id: 't2', call: 'Cornerstone QBR',                    client: 'Cornerstone Living', date: '2026-04-27', who: 'Cole', status: 'pending', theme: 'Reporting', summary: 'Client wants weekly snapshot, not monthly. Switch to Friday digest cadence.' },
    { id: 't3', call: 'Brad Hardscapes monthly',            client: 'Brad Hardscapes', date: '2026-04-26', who: 'Cole', status: 'approved', theme: 'Creative', summary: 'Drop "patio dream" angle, double-down on operator-memo voice. Hook rate +3pp on memo style.' },
    { id: 't4', call: 'Stoneworks check-in',                client: 'Stoneworks Co.', date: '2026-04-25', who: 'Cole', status: 'approved', theme: 'Creative', summary: 'Add slow-mo reveal to top-of-funnel reel. Shipped 04-26.' },
    { id: 't5', call: 'Lakeside intro',                     client: 'Lakeside Outdoor', date: '2026-04-23', who: 'Cole', status: 'dismissed', theme: 'Pricing', summary: 'Client requested tier discount. Held line — pricing audit shows we are at floor.' },
    { id: 't6', call: 'Foundry kickoff',                    client: 'Foundry Hardscapes', date: '2026-04-22', who: 'David', status: 'approved', theme: 'Onboarding', summary: 'Move kickoff form to GHL native, shave 2 days off onboarding.' },
    { id: 't7', call: 'Apex monthly',                       client: 'Apex Outdoor',  date: '2026-04-21', who: 'Cole', status: 'approved', theme: 'Reporting', summary: 'Add CPL trendline to monthly recap. Shipped in template.' },
    { id: 't8', call: 'Patio Pros pivot call',              client: 'Patio Pros',    date: '2026-04-19', who: 'Henry', status: 'approved', theme: 'Strategy', summary: 'Pivot away from estimator-time hook. Operator memo becomes the lead.' },
    { id: 't9', call: 'Evergreen monthly',                  client: 'Evergreen Outdoor', date: '2026-04-17', who: 'Cole', status: 'approved', theme: 'Creative', summary: 'Family-at-firepit shot is the new winner. Lean in.' },
    { id: 't10', call: 'Oak Ridge planning',                client: 'Oak Ridge Outdoor', date: '2026-04-16', who: 'Cole', status: 'approved', theme: 'Strategy', summary: 'Texture carousel format unlocked, repeat in Q2.' },
    { id: 't11', call: 'Northstar renewal',                 client: 'Northstar Stone',   date: '2026-04-04', who: 'Henry', status: 'approved', theme: 'Renewal', summary: 'Renewed 6 months early. They want lead-routing logic doc next.' },
    { id: 't12', call: 'Cornerstone offer audit',           client: 'Cornerstone Living', date: '2026-04-02', who: 'Cole', status: 'dismissed', theme: 'Pricing', summary: 'Client asked for free month — declined, offered scope add instead.' },
  ],
  // ── Vukasi tasks (extended)
  TASK_ARCHIVE: [
    { id: 'tx1', title: 'Pause "Brad Spring Refresh" ad set',        client: 'Patio Pros', dueDate: '2026-04-28', status: 'overdue',   priority: 'high',   estimateH: 0.5, clickupUrl: '#' },
    { id: 'tx2', title: 'Build 3 new hook variants — Cornerstone',   client: 'Cornerstone Living', dueDate: '2026-04-29', status: 'today', priority: 'high', estimateH: 3, clickupUrl: '#' },
    { id: 'tx3', title: 'Refresh creative pool — Stoneworks',        client: 'Stoneworks Co.', dueDate: '2026-04-29', status: 'today',  priority: 'med',  estimateH: 2,   clickupUrl: '#' },
    { id: 'tx4', title: 'Write EOM report — Apex',                    client: 'Apex Outdoor', dueDate: '2026-04-30', status: 'this_week', priority: 'med', estimateH: 1.5, clickupUrl: '#' },
    { id: 'tx5', title: 'Audit Lakeside spend pacing',                client: 'Lakeside Outdoor', dueDate: '2026-05-01', status: 'this_week', priority: 'med', estimateH: 1, clickupUrl: '#' },
    { id: 'tx6', title: 'Hook test plan — Brad Hardscapes',           client: 'Brad Hardscapes', dueDate: '2026-05-01', status: 'this_week', priority: 'low', estimateH: 2, clickupUrl: '#' },
    { id: 'tx7', title: 'Update GHL form for Cornerstone',            client: 'Cornerstone Living', dueDate: '2026-05-02', status: 'this_week', priority: 'high', estimateH: 1.5, clickupUrl: '#' },
    { id: 'tx8', title: 'Review Patio Pros CPL — root cause memo',    client: 'Patio Pros', dueDate: '2026-04-29', status: 'today',     priority: 'high', estimateH: 1, clickupUrl: '#' },
    { id: 'tx9', title: 'Kickoff Wildwood — gather creative assets',  client: 'Wildwood Patios', dueDate: '2026-05-03', status: 'this_week', priority: 'med', estimateH: 2, clickupUrl: '#' },
    { id: 'tx10', title: 'EOM report — Brad',                          client: 'Brad Hardscapes', dueDate: '2026-04-30', status: 'this_week', priority: 'med', estimateH: 1, clickupUrl: '#' },
    { id: 'tx11', title: 'Renew Meta token (DC agency)',               client: 'DC',          dueDate: '2026-04-27', status: 'overdue',   priority: 'low', estimateH: 0.25, clickupUrl: '#' },
  ],
  // ── Neglected accounts: multi-source activity timeline
  NEGLECTED_DETAIL: {
    'high-country':  { mrr: 4200, owner: 'Vukasi', cadence: 'Weekly', cadenceDaysExpected: 7,
      timeline: [
        { date: '2026-04-08', source: 'meta',    text: 'Creative refresh shipped — 3 new hooks' },
        { date: '2026-04-02', source: 'ghl',     text: 'Inbound lead form submission' },
        { date: '2026-03-28', source: 'clickup', text: 'Monthly recap task closed' },
        { date: '2026-03-21', source: 'call',    text: 'Owner call — discussed Q2 budget' },
      ]},
    'redrock':       { mrr: 3800, owner: 'Vukasi', cadence: 'Weekly', cadenceDaysExpected: 7,
      timeline: [
        { date: '2026-04-11', source: 'meta',    text: 'Budget change — +$500/wk' },
        { date: '2026-04-04', source: 'clickup', text: 'Hook test plan filed' },
        { date: '2026-03-25', source: 'ghl',     text: 'Pipeline review · 18 MQLs' },
      ]},
    'wildwood':      { mrr: 4500, owner: 'David', cadence: 'Bi-weekly', cadenceDaysExpected: 14,
      timeline: [
        { date: '2026-04-12', source: 'meta',    text: 'Creative refresh — texture carousel' },
        { date: '2026-03-30', source: 'call',    text: 'Discovery call w/ David' },
      ]},
    'apex-outdoor':  { mrr: 3500, owner: 'Vukasi', cadence: 'Weekly', cadenceDaysExpected: 7,
      timeline: [
        { date: '2026-04-13', source: 'note',    text: 'Vukasi flagged spend pacing high' },
        { date: '2026-04-06', source: 'meta',    text: 'Hook variant test concluded' },
        { date: '2026-03-30', source: 'clickup', text: 'EOM report sent' },
      ]},
    'meridian':      { mrr: 3200, owner: 'David', cadence: 'Weekly', cadenceDaysExpected: 7,
      timeline: [
        { date: '2026-04-14', source: 'meta',    text: 'Creative refresh — operator memo' },
        { date: '2026-04-07', source: 'ghl',     text: 'Form completion rate review' },
      ]},
    'foundry':       { mrr: 4200, owner: 'David', cadence: 'Weekly', cadenceDaysExpected: 7,
      timeline: [
        { date: '2026-04-15', source: 'meta',    text: 'Budget change — onboarding push' },
        { date: '2026-04-09', source: 'call',    text: 'Kickoff call' },
      ]},
  },
  NEGLECT_RULES: [
    { k: 'cadence_warn',  l: 'Cadence warning',  current: '7d past expected', desc: 'Triggers amber row when no activity for 1 cadence period past expected.' },
    { k: 'cadence_red',   l: 'Cadence breach',   current: '14d past expected', desc: 'Red row + auto-flag when 2 cadence periods missed.' },
    { k: 'auto_outreach', l: 'Auto outreach',    current: 'Off',              desc: 'When on, drafts a Sal check-in DM at red threshold.' },
  ],
  // ── Wins archive
  WIN_ARCHIVE: [
    { id: 'w1', client: 'Evergreen Outdoor',  metric: 'CPL',         value: '$28', vsTarget: '-35%', date: '2026-04-21', playbook: 'Backyard transformation hook + family-at-firepit visual', shareable: true,  testimonialDrafted: true },
    { id: 'w2', client: 'Oak Ridge Outdoor',  metric: 'Booked rate', value: '38%', vsTarget: '+11pp', date: '2026-04-18', playbook: 'Texture carousel format — 7 swipes, 1 CTA at end', shareable: true, testimonialDrafted: false },
    { id: 'w3', client: 'Midland Stone',      metric: 'CPL',         value: '$31', vsTarget: '-28%', date: '2026-04-15', playbook: 'Operator-memo voice + before/after split', shareable: true, testimonialDrafted: false },
    { id: 'w4', client: 'Ironwood Outdoor',   metric: 'Hook rate',   value: '12%', vsTarget: '+3pp', date: '2026-04-11', playbook: 'Slow-mo reveal in first 1.5s, no text overlay', shareable: true, testimonialDrafted: true },
    { id: 'w5', client: 'Northstar Stone',    metric: 'Renewed early', value: '6mo',  vsTarget: 'early', date: '2026-04-04', playbook: 'Lead-routing logic doc + monthly trendline added', shareable: false, testimonialDrafted: true },
    { id: 'w6', client: 'Apex Outdoor',       metric: 'CPL',         value: '$34', vsTarget: '-22%', date: '2026-03-28', playbook: 'Owner POV walkthrough + estimator quote card', shareable: true, testimonialDrafted: false },
  ],
  WIN_PATTERNS: [
    { pattern: 'Operator-memo voice in copy',              winsCount: 4, lift: 'Avg CPL -28% across 4 clients' },
    { pattern: 'Slow-mo reveal in first 1.5s',             winsCount: 3, lift: 'Avg hook rate +3.2pp' },
    { pattern: 'Texture/carousel format (5-7 swipes)',     winsCount: 2, lift: 'Avg booked-rate +9pp' },
    { pattern: 'Family-at-firepit warm visuals',            winsCount: 2, lift: 'Avg CPL -31%' },
  ],
};
