graph TB
    INDEX["index.tsx<br/>(MsalProvider)"] --> APP["App.tsx<br/>(Auth Gate + Router)"]
    APP --> UP["UserProvider<br/>(UserContext)"]
    UP --> AC["AppContent"]

    AC --> SB["Sidebar"]
    AC --> AFB["AgencyFilterBar"]

    AC --> HOME["Home View"]
    AC --> CAMP["Campaigns"]
    AC --> ANAL["Analytics"]
    AC --> AUDIT["Auditing"]
    AC --> WIP["WIPReviewer"]
    AC --> KB["KnowledgeBase"]
    AC --> SET["Settings"]
    AC --> USERMGMT["UserManagement"]
    AC --> PROF["Profile"]
    AC --> COPY["CopyGenAI"]
    AC --> LOGIN["Login"]

    HOME --> HERO["Hero<br/>(Upload / Analyze)"]
    HOME --> CO["ChecksOverview<br/>(Agent Results)"]
    HOME --> FR["FeedbackReport<br/>(PDF Export)"]

    CAMP --> CL["Campaign List"]
    CAMP --> CD["Campaign Detail"]
    CD --> PL["Proof List"]
    CD --> PV["Proof Version Viewer"]

    KB --> KBL["KB List"]
    KB --> KBD["KB Detail"]
    KBD --> DOCS["Source Documents"]
    KBD --> SPEC["Spec Versions"]
    KBD --> DIFF["Version Diff"]

    subgraph "Services"
        GS["geminiService.ts<br/>(WebSocket Client)"]
        AS["apiService.ts<br/>(REST Client)"]
        AUTH["authService.ts<br/>(MSAL Auth)"]
    end

    HERO --> GS
    CAMP --> AS
    KB --> AS
    APP --> AUTH

    classDef root fill:#006DE3,stroke:#1A2142,color:#fff
    classDef view fill:#1A2142,stroke:#006DE3,color:#fff
    classDef component fill:#01A1A2,stroke:#1A2142,color:#fff
    classDef service fill:#C3FB5A,stroke:#1A2142,color:#1A2142

    class INDEX,APP,UP,AC root
    class HOME,CAMP,ANAL,AUDIT,WIP,KB,SET,USERMGMT,PROF,COPY,LOGIN view
    class SB,AFB,HERO,CO,FR,CL,CD,PL,PV,KBL,KBD,DOCS,SPEC,DIFF component
    class GS,AS,AUTH service
