// ══════════════════════════════════════════════════════════
// Client Service Page - activity, phase, and resource data
// ══════════════════════════════════════════════════════════

// Demo state presets. Each preset sets which activities are completed
// and which have their reminders toggled on.
const DEMO_STATES = {
  pristine: {
    label: "Pristine (new client)",
    completed: [],
    reminders: [],
    accountabilityCommitted: false,
    clientName: "Margaret & Daniel Whitcomb"
  },
  midyear: {
    label: "Mid-year (typical)",
    completed: ["welcome-meeting", "risk-review", "beneficiary-review"],
    reminders: ["contannuity-build"],
    accountabilityCommitted: false,
    clientName: "Margaret & Daniel Whitcomb"
  },
  overdue: {
    label: "Overdue (behind schedule)",
    completed: ["welcome-meeting"],
    reminders: ["mid-year-check", "tax-docs"],
    accountabilityCommitted: false,
    forceOverdue: ["risk-review", "beneficiary-review", "mid-year-check", "tax-docs"],
    overdueDates: {
      "risk-review": "Was due Feb 15 · 30 days late",
      "beneficiary-review": "Was due Mar 20 · 28 days late",
      "mid-year-check": "Now overdue · 5 days late",
      "tax-docs": "Was due Apr 15 · 4 days late"
    },
    clientName: "Margaret & Daniel Whitcomb"
  },
  nearcomplete: {
    label: "Near complete",
    completed: ["welcome-meeting", "risk-review", "beneficiary-review", "contannuity-build", "watch-primer", "mid-year-check", "tax-docs"],
    reminders: ["annual-review"],
    accountabilityCommitted: true,
    clientName: "Margaret & Daniel Whitcomb"
  }
};

// Activity catalog. Each has: id, title, category, status hint, due date label,
// description, points (contribution to score), a checklist of what happens in it,
// and an optional linked resource.
const ACTIVITIES = [
  {
    id: "welcome-meeting",
    title: "Welcome meeting and goals review",
    category: "Onboarding",
    categoryKey: "review",
    due: "Completed Jan 14",
    dueSort: 1,
    points: 10,
    desc: "A 60-minute sit-down to confirm what you want this plan to do for you, what has changed since last year, and what you want us to focus on together.",
    expanded: {
      title: "What we cover in this meeting",
      steps: [
        "A review of last year's outcomes against the goals you set.",
        "Any life changes (family, health, work, property) that affect the plan.",
        "Your priorities for the year ahead, in your own words.",
        "The activity calendar you are looking at on this page, tailored to you."
      ],
      resourceLabel: "Welcome meeting agenda"
    }
  },
  {
    id: "risk-review",
    title: "Annual risk and KYC refresh",
    category: "Review",
    categoryKey: "review",
    due: "Completed Feb 02",
    dueSort: 2,
    points: 10,
    desc: "Regulators ask every registered advisor to confirm your information is current once a year. This is that conversation, kept short.",
    expanded: {
      title: "What we confirm together",
      steps: [
        "Your contact details, employment, and residency.",
        "Your investment objectives and time horizon.",
        "Your risk tolerance and the appropriate portfolio mix.",
        "Any material change in net worth, income, or dependents."
      ],
      resourceLabel: "KYC worksheet"
    }
  },
  {
    id: "beneficiary-review",
    title: "Beneficiary and consent review",
    category: "Protect",
    categoryKey: "protect",
    due: "Completed Mar 18",
    dueSort: 3,
    points: 10,
    desc: "A review of every named beneficiary on every registered account and insurance policy, plus the continuity consent that allows your advisor to help your family if something happens.",
    expanded: {
      title: "What we look at",
      steps: [
        "RRSP, TFSA, and RRIF beneficiary designations.",
        "Life and critical illness insurance beneficiaries.",
        "Continuity consent language on file.",
        "Alignment with your will and estate plan."
      ],
      resourceLabel: "Beneficiary checklist"
    }
  },
  {
    id: "watch-primer",
    title: "LEARN - protect your identity and data",
    category: "Learn",
    categoryKey: "learn",
    due: "Suggested this week",
    dueSort: 4,
    points: 5,
    desc: "A collection of short videos on identity theft, phishing, secure passwords, and online safety. Watch before your next meeting to understand the risks and how to protect yourself.",
    expanded: {
      title: "Why this matters before we meet",
      steps: [
        "Cybercrime affects 1 in 3 Canadians - understanding the risks protects your financial plan.",
        "Simple habits like two-factor authentication and password managers prevent most attacks.",
        "These videos explain real threats in plain language - no jargon.",
        "Your spouse or a family member can watch with you."
      ],
      resourceLabel: "Play videos",
      resourceUrl: "https://www.youtube.com/playlist?list=PLEzYzSmu1IFQXghAzLrYBmf278UnRbVyo",
      tooltip: "Get Cyber Safe is the Government of Canada's cybersecurity awareness program. <a href='https://www.getcybersafe.gc.ca/en' target='_blank' rel='noopener noreferrer'>Visit Get Cyber Safe</a> for tools and resources, <a href='https://www.cyber.gc.ca/en' target='_blank' rel='noopener noreferrer'>check latest alerts</a>, or <a href='https://www.youtube.com/playlist?list=PLEzYzSmu1IFQXghAzLrYBmf278UnRbVyo' target='_blank' rel='noopener noreferrer'>watch the video series</a> to get started."
    }
  },
  {
    id: "contannuity-build",
    title: "Build your Contannuity™ plan",
    category: "Plan",
    categoryKey: "plan",
    due: "Due Apr 30",
    dueSort: 5,
    points: 25,
    desc: "An 18-question readiness assessment, followed by a one-hour working session to produce a Contannuity plan for the people who depend on you.",
    status: "active",
    expanded: {
      title: "How the build works",
      steps: [
        "Complete the readiness assessment online at your own pace.",
        "Book the working session when you are ready.",
        "We produce the five-part plan together in the session.",
        "You leave with a printable plan and digital copies for the right people."
      ],
      resourceLabel: "Start the assessment"
    }
  },
  {
    id: "mid-year-check",
    title: "Mid-year portfolio check-in",
    category: "Review",
    categoryKey: "review",
    due: "Due Jun 20",
    dueSort: 6,
    points: 10,
    desc: "A 30-minute call to review performance, rebalance if needed, and confirm nothing has changed that we should act on before year-end.",
    expanded: {
      title: "What we cover",
      steps: [
        "Year-to-date performance against benchmarks.",
        "Cash flow, contributions, and withdrawals.",
        "Rebalancing if allocations have drifted.",
        "A preview of year-end planning items."
      ],
      resourceLabel: "Book your mid-year call"
    }
  },
  {
    id: "tax-docs",
    title: "Share your tax slips and return",
    category: "Protect",
    categoryKey: "protect",
    due: "Due May 15",
    dueSort: 7,
    points: 10,
    overdue: true,
    desc: "Upload copies of your T4s, T5s, T3s, and finalized tax return. Seeing your full tax picture lets us plan contributions, withdrawals, and income splitting properly.",
    expanded: {
      title: "What we need from you",
      steps: [
        "T4, T5, T3, and any other income slips.",
        "Your Notice of Assessment from last year.",
        "A copy of your finalized T1 return.",
        "Any capital gains or carry-forward detail you want us to see."
      ],
      resourceLabel: "Upload documents"
    }
  },
  {
    id: "annual-review",
    title: "Annual review and plan refresh",
    category: "Review",
    categoryKey: "review",
    due: "Scheduled Nov 12",
    dueSort: 8,
    points: 15,
    desc: "The full annual conversation. We revisit goals, performance, protection, estate, and continuity, then refresh the plan for the year ahead.",
    expanded: {
      title: "The agenda",
      steps: [
        "Progress against the goals set in January.",
        "Retirement income, tax, and estate planning updates.",
        "Insurance and protection review.",
        "Contannuity plan refresh and team briefing."
      ],
      resourceLabel: "Pre-read: what to bring"
    }
  },
  {
    id: "year-end-moves",
    title: "Year-end planning moves",
    category: "Plan",
    categoryKey: "plan",
    due: "Due Dec 20",
    dueSort: 9,
    points: 10,
    desc: "RRSP, TFSA, RESP, charitable giving, and tax-loss opportunities before the calendar flips. A 20-minute call and a short action list.",
    expanded: {
      title: "What we look at",
      steps: [
        "Remaining contribution room across registered accounts.",
        "Charitable giving for tax efficiency.",
        "Tax-loss harvesting where appropriate.",
        "Income timing for the year ahead."
      ],
      resourceLabel: "Year-end checklist"
    }
  }
];

// 4 phases of the service model
const PHASES = [
  { num: "01", label: "Jan – Feb", title: "Onboard", desc: "We set the goals for the year, confirm your information, and agree the plan." },
  { num: "02", label: "Mar – May", title: "Plan", desc: "We build or refresh the Contannuity plan and handle tax documents together." },
  { num: "03", label: "Jun – Sep", title: "Protect", desc: "We check the portfolio, the beneficiaries, and the insurance picture mid-year." },
  { num: "04", label: "Oct – Dec", title: "Review", desc: "The full annual review, year-end planning, and setting up next year." }
];

// Resource library
const RESOURCES = [
  {
    id: "r-primer",
    kind: "Video",
    kindIcon: "play",
    title: "The Contannuity primer",
    desc: "Four minutes on what Contannuity is, who it is for, and why most plans skip this part.",
    readTime: "4 min",
    date: "Apr 2026",
    topic: "services",
    isNew: true
  },
  {
    id: "r-campaign-retirees",
    kind: "Article",
    kindIcon: "doc",
    title: "A plan for the people you love",
    desc: "The retirees campaign page. Three real scenarios, one five-minute read, the conversation made easy.",
    readTime: "5 min",
    date: "Mar 2026",
    topic: "articles",
    isNew: false
  },
  {
    id: "r-continuity-consent",
    kind: "Explainer",
    kindIcon: "doc",
    title: "What consent actually means",
    desc: "Plain-language explanation of what you are agreeing to when you provide consent for data use, communication, and advice.",
    readTime: "5 min",
    date: "Feb 2026",
    topic: "explainers",
    isNew: true,
    body: `<h3>What does consent mean?</h3>
      <p>Consent means you are giving your advisor permission to collect, use, and share your information so they can provide advice, products, and services that are appropriate for you. <strong>You are always in control.</strong> You can ask questions, limit what you agree to, or withdraw your consent at any time (subject to legal or contractual requirements).</p>
      
      <h3>Why am I being asked for consent?</h3>
      <p>Advisors are required by law and regulation to be transparent about how your information is used and to ensure you agree before certain actions are taken.</p>
      
      <h3>Common types of consent you may see:</h3>
      
      <h4>Personal information (privacy consent)</h4>
      <p>Permission to collect, use, and securely store your personal and financial information to provide advice and maintain your account.</p>
      
      <h4>Sharing information with partners</h4>
      <p>Consent to share your information with insurance companies, investment firms, or other professionals (like accountants or lawyers) when needed to implement your plan.</p>
      
      <h4>Suitability and advice</h4>
      <p>Confirmation that you agree to provide accurate information so your advisor can recommend suitable insurance or investments based on your needs.</p>
      
      <h4>Communication consent</h4>
      <p>Permission to contact you by email, phone, or text for updates, service, and in some cases, marketing (you can opt out of marketing at any time).</p>
      
      <h4>Electronic documents and signatures</h4>
      <p>Agreement to receive documents digitally and sign forms electronically instead of on paper.</p>
      
      <h4>Recording or note-taking (if applicable)</h4>
      <p>Consent for meetings to be recorded or summarized using technology to ensure accuracy and proper documentation.</p>`
  },
  {
    id: "r-disclosure-explained",
    kind: "Explainer",
    kindIcon: "doc",
    title: "What disclosure actually means",
    desc: "Understanding what your advisor is required to share with you so you can make informed decisions.",
    readTime: "5 min",
    date: "Feb 2026",
    topic: "explainers",
    isNew: true,
    body: `<h3>What does disclosure mean?</h3>
      <p>Disclosure means your advisor is required to clearly share important information with you so you can make informed decisions. This includes who they are, how they work, how they are paid, any conflicts of interest, how your information is handled, and other important details about the products, services, and tools they use. In the Canadian context, disclosure is a core part of client protection and relationship transparency.</p>
      
      <h3>Why am I receiving disclosures?</h3>
      <p>Canadian regulators and privacy authorities expect advisors and firms to be transparent so clients understand what is happening, why it matters, and what choices they have. Transparency is especially important where personal information, suitability, digital tools, or potential conflicts are involved.</p>
      
      <h3>Common types of disclosure you may see:</h3>
      
      <h4>Advisor licensing and registration</h4>
      <p>Information about your advisor's registration, licences, and the firm they work through.</p>
      
      <h4>How your advisor is paid</h4>
      <p>An explanation of compensation, such as commissions, fees, or other forms of payment connected to the products or services provided.</p>
      
      <h4>Conflicts of interest</h4>
      <p>Disclosure of situations where the advisor or firm could benefit from a recommendation, along with how those conflicts are addressed.</p>
      
      <h4>Product details, fees, and risks</h4>
      <p>Important information about the products being recommended, including how they work, costs, limitations, and risks.</p>
      
      <h4>Privacy and information handling</h4>
      <p>How your personal information is collected, used, protected, and shared.</p>
      
      <h4>AI and technology use</h4>
      <p>If AI or automated tools are used to help create notes, summarize meetings, support service, generate content, or assist with analysis, you may receive disclosure explaining that technology is being used, how your information may be handled, and what safeguards are in place. Canadian privacy guidance emphasizes openness, explainability, and transparency when organizations use AI, including labelling generative AI use where appropriate.</p>
      
      <p style="margin-top: 1.5em;"><strong>Helpful note for clients:</strong><br>Disclosure does not always mean you need to take action. Often, it is there to help you understand how your advisor works, how decisions are made, and how your information is protected. If anything is unclear, ask.</p>`
  },
  {
    id: "r-disclaimer-explained",
    kind: "Explainer",
    kindIcon: "doc",
    title: "What a disclaimer actually means",
    desc: "Understanding the limits of information, advice, and services—and when to ask for more specific guidance.",
    readTime: "4 min",
    date: "Feb 2026",
    topic: "explainers",
    isNew: true,
    body: `<h3>What is a disclaimer?</h3>
      <p>A disclaimer is a short statement that explains the limits of information, advice, or services being provided. It helps clarify what you can rely on, what requires further review, and where responsibility sits between you and your advisor.</p>
      
      <h3>Why am I seeing a disclaimer?</h3>
      <p>Disclaimers are required by regulators, firms, and compliance policies to make sure information is not misunderstood. They help protect you by setting clear expectations and encouraging informed decisions.</p>
      
      <h3>Common types of disclaimers you may see:</h3>
      
      <h4>General information vs. advice</h4>
      <p>Clarifies when information is educational or general in nature and not personalized advice specific to your situation.</p>
      
      <h4>Accuracy and completeness</h4>
      <p>Notes that information is believed to be accurate at the time provided but may change or depend on the details you've shared.</p>
      
      <h4>Product and investment risk</h4>
      <p>Reminds you that investments can go up and down, and that past performance is not a guarantee of future results.</p>
      
      <h4>Third-party information</h4>
      <p>Indicates when information or tools come from external providers and may not be fully controlled by your advisor.</p>
      
      <h4>Tax and legal limitations</h4>
      <p>Explains that your advisor is not providing tax or legal advice unless specifically qualified, and you may need to consult a specialist.</p>
      
      <h4>Electronic communication</h4>
      <p>Highlights risks related to email or digital communication, including privacy or security considerations.</p>
      
      <h4>AI and technology use</h4>
      <p>Notes that technology, including AI-assisted tools, may be used to support tasks like note-taking or document preparation, and that outputs should be reviewed and confirmed for accuracy.</p>
      
      <p style="margin-top: 1.5em;"><strong>Helpful note for clients:</strong><br>A disclaimer doesn't mean something is wrong. It's there to give you clarity on how to interpret information and when to ask questions or seek more specific advice.</p>`
  },
  {
    id: "r-kyc-prep",
    kind: "Checklist",
    kindIcon: "check",
    title: "Preparing for your KYC refresh",
    desc: "A one-pager of what to have handy for your annual risk and KYC conversation. Saves 20 minutes.",
    readTime: "2 min",
    date: "Jan 2026",
    topic: "checklists",
    isNew: false
  },
  {
    id: "r-tax-bundle",
    kind: "Worksheet",
    kindIcon: "doc",
    title: "Tax season document bundle",
    desc: "The list of slips, statements, and confirmations we need from you before the end of April.",
    readTime: "2 min",
    date: "Feb 2026",
    topic: "tax",
    isNew: false
  },
  {
    id: "r-year-end",
    kind: "Checklist",
    kindIcon: "check",
    title: "Year-end planning checklist",
    desc: "The RRSP, TFSA, charitable giving, and tax-loss moves worth looking at before December 31.",
    readTime: "3 min",
    date: "Nov 2025",
    topic: "checklists",
    isNew: false
  },
  {
    id: "r-beneficiary",
    kind: "Guide",
    kindIcon: "doc",
    title: "Beneficiaries, simplified",
    desc: "Who you name on each account matters more than your will. A short primer on getting this right and keeping it current.",
    readTime: "4 min",
    date: "Mar 2026",
    topic: "guides",
    isNew: true
  },
  {
    id: "r-family-meeting",
    kind: "Checklist",
    kindIcon: "check",
    title: "Hosting a family money meeting",
    desc: "A one-pager on how to gather the people who matter and have the conversation most families keep putting off.",
    readTime: "3 min",
    date: "Feb 2026",
    topic: "guides",
    isNew: false
  },
  {
    id: "r-market-noise",
    kind: "Article",
    kindIcon: "doc",
    title: "What to do when the market looks scary",
    desc: "A short reminder of what your plan already accounts for, and the two things actually worth doing in a downturn.",
    readTime: "3 min",
    date: "Jan 2026",
    topic: "articles",
    isNew: false
  },
  {
    id: "r-rrif-basics",
    kind: "Checklist",
    kindIcon: "check",
    title: "Hosting a family finance meeting",
    desc: "How to bring your family together for important money conversations.",
    readTime: "4 min",
    date: "Nov 2025",
    topic: "checklists",
    isNew: false
  }
];

const RESOURCE_TOPICS = [
  { key: "all", label: "All" },
  { key: "solutions", label: "Solutions (products)" },
  { key: "services", label: "Services" },
  { key: "explainers", label: "Explainers" },
  { key: "checklists", label: "Checklists & Worksheets" },
  { key: "articles", label: "Articles" },
  { key: "guides", label: "Guides" }
];

// Past and upcoming conversations (demo data)
const CONVERSATIONS = {
  past: {
    title: "Q1 check-in - portfolio and risk",
    when: "March 18, 2026 · 45 minutes",
    agenda: [
      "Reviewed Q1 portfolio performance against benchmarks.",
      "Confirmed KYC and updated risk tolerance to reflect upcoming retirement.",
      "Reviewed beneficiary designations across all registered accounts.",
      "Agreed to begin building the Contannuity plan in April."
    ],
    note: "Action confirmed: Daniel to complete the Contannuity readiness assessment before May 1."
  },
  next: {
    title: "Contannuity plan build - working session",
    when: "April 24, 2026 · 60 minutes",
    agenda: [
      "Review your completed readiness assessment, area by area.",
      "Identify any critical or high-priority gaps and how to close them.",
      "Produce the five-part plan in the session.",
      "Decide who receives copies, and how, and where they are stored."
    ],
    note: "Bring: a list of the three or four people you would want contacted first."
  }
};

// ──────────────────────────────────────────────────────────
// Compliance items. Each has owner (client | advisor), status,
// due/completed dates, and an optional renewal date.
// ──────────────────────────────────────────────────────────
const COMPLIANCE = {
  items: [
    {
      id: "privacy-disclosure",
      title: "Privacy & Disclosure",
      desc: "Acknowledgement of how we collect, store, and share your personal information, and the services we provide.",
      owner: "client",
      completed: true,
      completedDate: "Jan 14, 2026",
      renewsOn: "Jan 14, 2028",
      link: true
    },
    {
      id: "casl-consent",
      title: "CASL Consent",
      desc: "Permission to send you commercial electronic messages - service updates, educational content, and planning reminders.",
      owner: "client",
      completed: true,
      completedDate: "Jan 14, 2026",
      link: true
    },
    {
      id: "id-verification",
      title: "ID Verification",
      desc: "Government-issued ID on file. Required by regulation and renewed as your documents expire.",
      owner: "advisor",
      completed: true,
      completedDate: "Jan 14, 2026",
      renewsOn: "Aug 2029 (passport expiry)"
    },
    {
      id: "kyc-current",
      title: "KYC annual refresh",
      desc: "Your financial situation, investment knowledge, risk tolerance, and objectives on file. Re-confirmed annually or when life changes.",
      owner: "advisor",
      completed: false,
      dueDate: "by May 15, 2026",
      overdue: false
    },
    {
      id: "trusted-contact",
      title: "Trusted Contact Person",
      desc: "Someone we can reach out to if we're concerned about your wellbeing, can't reach you, or suspect financial exploitation. Not a decision-maker - just a bridge. Required by CIRO since 2021.",
      owner: "client",
      completed: false,
      dueDate: "by Feb 28, 2026",
      overdue: true,
      link: true
    },
    {
      id: "annual-review",
      title: "Last Annual Review",
      desc: "A formal review of your plan, portfolio, and anything changing in your life. Recorded and shared with you.",
      owner: "advisor",
      completed: false,
      dueDate: "by Jun 30, 2026",
      overdue: false
    }
  ]
};

// ──────────────────────────────────────────────────────────
// COVERAGE MAP - the client's full financial picture at a glance.
// Each pillar has a status (in-place | in-progress | gap | not-started |
// not-offered). Status and note are per-demo-state so the tile grid
// evolves with the demo state the user picks.
//
// status key:
//   in-place     \u2014 confirmed, current, on file (green)
//   in-progress  \u2014 started but not finished (amber)
//   gap          \u2014 identified need, no coverage yet (orange)
//   not-started  \u2014 never discussed (grey, dashed)
//   not-offered  \u2014 advisor does not do this; refer elsewhere (muted)
// ──────────────────────────────────────────────────────────
const COVERAGE_PILLARS = [
  {
    id: "goals",
    title: "Goals & vision",
    short: "What this plan is for",
    desc: "Your retirement lifestyle, the family you want to help, and the outcomes we are building toward.",
    tooltip: "Most people have goals, but few have a plan that connects them to actions. A goals conversation with your advisor ensures your investments, insurance, and tax strategy are all pulling in the same direction - toward what actually matters to you.",
    glyph: "target",
    action: "Book a goals conversation"
  },
  {
    id: "cashflow",
    title: "Cash flow & savings",
    short: "Money in, money out, set aside",
    desc: "Emergency fund, monthly savings rate, and debt paydown. The foundation every other pillar rests on.",
    tooltip: "Cash flow is where every plan starts. If money going out exceeds money coming in, no amount of investing or insurance can fix it. Your advisor can help you see where money is leaking, build a sustainable savings rate, and create breathing room for the rest of your plan.",
    glyph: "wallet",
    action: "Share your budget snapshot"
  },
  {
    id: "investments",
    title: "Investments",
    short: "Portfolio & registered accounts",
    desc: "Your TFSA, RRSP, and non-registered accounts \u2014 invested in line with your risk tolerance and time horizon.",
    tooltip: "Investments are the engine of your plan, but the wrong mix - too conservative, too aggressive, or misaligned with your timeline - can derail decades of saving. Regular reviews ensure your portfolio still fits your life, not someone else's template.",
    glyph: "chart",
    action: "Review my portfolio"
  },
  {
    id: "retirement",
    title: "Retirement income",
    short: "How money shows up at 65",
    desc: "Your RRIF conversion plan, CPP/OAS timing, and how pension and investment income will be sequenced.",
    tooltip: "Retirement planning isn't about having enough saved - it's about turning those savings into reliable income without running out or paying unnecessary tax. The order you draw from accounts, when you start CPP, and how you sequence income can mean tens of thousands of dollars over your lifetime.",
    glyph: "sun",
    action: "Map my income sources"
  },
  {
    id: "tax",
    title: "Tax planning",
    short: "Year-round, not just April",
    desc: "Tax-loss harvesting, RRSP contribution timing, charitable giving, and year-end moves to keep more of what you earn.",
    tooltip: "Most people think of tax once a year when filing. Tax planning happens year-round - timing contributions, harvesting losses, splitting income, and making strategic withdrawals. Small moves add up to significant savings, and your advisor can show you exactly where those opportunities are hiding.",
    glyph: "receipt",
    action: "Schedule tax review"
  },
  {
    id: "life-insurance",
    title: "Life insurance",
    short: "Coverage for the people you love",
    desc: "Term and permanent coverage sized to income replacement, debt, and legacy goals.",
    tooltip: "Life insurance isn't about you - it's about the people who depend on your income. Without it, a mortgage doesn't get paid, kids don't go to school, and a surviving spouse scrambles. The right amount of coverage, at the right price, gives your family options instead of emergencies.",
    glyph: "shield",
    action: "Get a coverage quote"
  },
  {
    id: "living-benefits",
    title: "Living benefits",
    short: "Disability, critical illness, LTC",
    desc: "Protection that pays while you are still here \u2014 income if you cannot work, lump sum on diagnosis, care when you need it.",
    tooltip: "You're statistically more likely to become disabled than to die during your working years, yet most people have no income replacement if they can't work. Living benefits - disability, critical illness, long-term care - protect your plan while you're alive, which is when you actually need the money.",
    glyph: "heart",
    action: "Review living benefits"
  },
  {
    id: "group",
    title: "Group benefits",
    short: "What work already covers",
    desc: "Your employer's benefits booklet reviewed so we know what is covered, what is not, and where the gaps need topping up.",
    tooltip: "Most people assume their group benefits are enough - until they need them and discover the caps, exclusions, and coverage limits. Reviewing your employer's plan with your advisor reveals where you're protected and where personal coverage is worth adding.",
    glyph: "briefcase",
    action: "Upload benefits booklet"
  },
  {
    id: "estate",
    title: "Estate plan",
    short: "Will, POAs, beneficiaries",
    desc: "A current will, powers of attorney for property and personal care, and named beneficiaries on every account.",
    tooltip: "Without an up-to-date will and powers of attorney, your family is left guessing about your wishes and fighting with the government over who makes decisions. An estate review ensures the people you trust are named, your accounts have current beneficiaries, and nothing gets stuck in probate.",
    glyph: "scroll",
    action: "Start estate review"
  },
  {
    id: "contannuity",
    title: "Contannuity\u2122 plan",
    short: "The plan behind the plan",
    desc: "The continuity document that lets your family act decisively when you are unavailable \u2014 passwords, contacts, instructions, intent.",
    tooltip: "Your family knows you have a plan, but do they know where it is, who to call, and what you want done? Contannuity is the instructions your executor, spouse, or power of attorney will actually need when something happens - not legal jargon, but real guidance they can follow immediately.",
    glyph: "key",
    action: "Claim my Contannuity plan"
  },
  {
    id: "family",
    title: "Family & dependents",
    short: "Kids, parents, spouse",
    desc: "Education savings, care for aging parents, and making sure a surviving spouse is not left figuring things out alone.",
    tooltip: "Supporting kids through school, caring for aging parents, and ensuring a surviving spouse isn't overwhelmed - these are real financial obligations that most plans ignore until it's too late. A family review identifies who depends on you, what they'll need, and how to build that into your plan now.",
    glyph: "family",
    action: "Plan for my dependents"
  },
  {
    id: "property",
    title: "Property & debt",
    short: "Home, mortgage, liabilities",
    desc: "Your mortgage terms, real estate, and other liabilities \u2014 renewal timing and how debt interacts with the rest of the plan.",
    tooltip: "Your mortgage is probably your largest liability, yet most people renew without reviewing alternatives or timing it with the rest of their plan. Property and debt planning looks at renewal timing, prepayment opportunities, and how your liabilities fit with your cash flow and retirement timeline.",
    glyph: "home",
    action: "Review my mortgage"
  }
];

// Per-demo-state overrides: { [demoStateKey]: { [pillarId]: { status, note } } }
// Default state (used as base) is 'midyear'.
const COVERAGE_BY_STATE = {
  pristine: {
    goals: { status: "in-progress", note: "Scheduled for your welcome meeting" },
    cashflow: { status: "not-started", note: "We will cover this together" },
    investments: { status: "not-started", note: "Transfer paperwork pending" },
    retirement: { status: "not-started", note: "We will map this after goals" },
    tax: { status: "not-started", note: "First return together next April" },
    "life-insurance": { status: "not-started", note: "Needs analysis pending" },
    "living-benefits": { status: "not-started", note: "Needs analysis pending" },
    group: { status: "not-started", note: "Please upload your booklet" },
    estate: { status: "not-started", note: "We will review your current documents" },
    contannuity: { status: "not-started", note: "Available as an add-on from your advisor" },
    family: { status: "not-started", note: "Covered in goals conversation" },
    property: { status: "not-started", note: "We will review at welcome meeting" }
  },
  midyear: {
    goals: { status: "in-place", note: "Documented Jan 14, 2026" },
    cashflow: { status: "in-place", note: "6-month emergency fund on hand" },
    investments: { 
      status: "in-place", 
      note: "TFSA + RRSP reviewed Feb 2026",
      entries: [
        { carrier: "TD Direct Investing", on_book: true, portal_url: "https://webbroker.td.com", last_reviewed: "Feb 2026" },
        { carrier: "Manulife RRSP", on_book: true, portal_url: "https://my.manulife.ca", last_reviewed: "Feb 2026" }
      ]
    },
    retirement: { status: "in-progress", note: "RRIF strategy drafted, decision in Q3" },
    tax: { status: "in-place", note: "2025 return filed, strategies on track" },
    "life-insurance": { 
      status: "in-place", 
      note: "$1M term through 2035",
      entries: [
        { carrier: "Empire Life", on_book: true, portal_url: "https://myempirelife.ca", last_reviewed: "Jan 2026", policy_type: "Term Life - $1M" }
      ]
    },
    "living-benefits": { 
      status: "gap", 
      note: "No disability coverage identified",
      entries: []
    },
    group: { 
      status: "in-place", 
      note: "Benefits booklet reviewed Jan 2026",
      entries: [
        { carrier: "Sun Life Group", on_book: false, portal_url: "https://my.sunlife.ca", last_reviewed: "Jan 2026" }
      ]
    },
    estate: { status: "in-progress", note: "Will update with lawyer scheduled Jun 10" },
    contannuity: { status: "not-started", note: "Add-on offered by Smith Financial - not yet claimed" },
    family: { status: "in-place", note: "RESP on track, parent care documented" },
    property: { 
      status: "in-place", 
      note: "Mortgage renews Sep 2028",
      entries: [
        { carrier: "RBC Mortgage", on_book: false, portal_url: "https://www.rbcroyalbank.com/onlinebanking", last_reviewed: "Jan 2026" }
      ]
    }
  },
  overdue: {
    goals: { status: "in-place", note: "Documented Jan 14, 2026" },
    cashflow: { status: "in-progress", note: "Emergency fund below 3 months \u2014 review needed" },
    investments: { status: "gap", note: "No KYC on file \u2014 account may be restricted" },
    retirement: { status: "not-started", note: "Income mapping not yet done" },
    tax: { status: "gap", note: "2025 return past due \u2014 slips not received" },
    "life-insurance": { status: "in-place", note: "$1M term through 2035" },
    "living-benefits": { status: "gap", note: "No disability coverage identified" },
    group: { status: "not-started", note: "Benefits booklet not received" },
    estate: { status: "gap", note: "Will references deceased beneficiary \u2014 update urgently" },
    contannuity: { status: "gap", note: "Add-on available \u2014 highly recommended given current gaps" },
    family: { status: "in-progress", note: "RESP open, contribution paused" },
    property: { status: "not-started", note: "Mortgage details not on file" }
  },
  nearcomplete: {
    goals: { status: "in-place", note: "Refreshed at annual review" },
    cashflow: { status: "in-place", note: "6-month emergency fund on hand" },
    investments: { status: "in-place", note: "Portfolio rebalanced Oct 2026" },
    retirement: { status: "in-place", note: "RRIF conversion plan signed off" },
    tax: { status: "in-place", note: "Year-end moves complete" },
    "life-insurance": { status: "in-place", note: "$1M term through 2035" },
    "living-benefits": { status: "in-place", note: "CI + LTD added Aug 2026" },
    group: { status: "in-place", note: "Reviewed at annual meeting" },
    estate: { status: "in-place", note: "Will, POAs, beneficiaries all current" },
    contannuity: { status: "in-place", note: "Plan complete, shared with family Nov 2026" },
    family: { status: "in-place", note: "All dependents accounted for" },
    property: { status: "in-place", note: "Mortgage renewal locked Sep 2028" }
  }
};

// Expose globally for the other Babel scripts
Object.assign(window, {
  DEMO_STATES, ACTIVITIES, PHASES, RESOURCES, RESOURCE_TOPICS, CONVERSATIONS, COMPLIANCE,
  COVERAGE_PILLARS, COVERAGE_BY_STATE
});
