graph LR
    START[💼 Shift<br/>Completed<br/>& Rated]
    
    START --> CALC[📊 INTERNAL<br/><br/>Calculate Invoice<br/>• Hours worked<br/>• Rates × Hours<br/>• Overtime calc<br/>• Platform fees<br/>• Tax amounts]
    
    CALC --> GENERATE[📄 INTERNAL<br/><br/>Generate Invoice<br/>• Create PDF<br/>• Invoice number<br/>• Line items<br/>• Due date]
    
    GENERATE --> SAVE[💾 INTERNAL<br/><br/>Save to Database<br/>• Store invoice<br/>• Status: pending<br/>• Track history]
    
    SAVE --> SEND[📧 API INTEGRATION<br/><br/>SendGrid<br/>• Send email<br/>• Track delivery<br/>• Reliable inbox]
    
    SEND --> CLIENT[📱 Client<br/>Reviews<br/>Invoice]
    
    CLIENT --> DECISION{Approve or<br/>Dispute?}
    
    DECISION -->|⚠️ Dispute| DISPUTE[🔧 INTERNAL<br/><br/>Handle Dispute<br/>• Admin reviews<br/>• Adjustments<br/>• Re-calculate]
    
    DISPUTE --> SAVE
    
    DECISION -->|✅ Approve| PAY[💳 API INTEGRATION<br/><br/>Stripe<br/>• Credit card<br/>• ACH transfer<br/>• Payment tracking]
    
    PAY --> CONFIRM[💾 INTERNAL<br/><br/>Update Status<br/>• Mark as paid<br/>• Record payment<br/>• Update reports]
    
    CONFIRM --> PAYOUT[💰 API INTEGRATION<br/><br/>Stripe Connect<br/>• Pay staff<br/>• Direct deposit<br/>• Automated]
    
    PAYOUT --> RECORD[📊 INTERNAL<br/><br/>Track Payments<br/>• Staff earnings<br/>• Payment history<br/>• Reports]
    
    RECORD --> DONE[✅ Complete]
    
    style START fill:#E1F5FF
    style CALC fill:#FFF9E6,stroke:#F9A825,stroke-width:3px
    style GENERATE fill:#FFF9E6,stroke:#F9A825,stroke-width:3px
    style SAVE fill:#FFF9E6,stroke:#F9A825,stroke-width:3px
    style DISPUTE fill:#FFF9E6,stroke:#F9A825,stroke-width:3px
    style CONFIRM fill:#FFF9E6,stroke:#F9A825,stroke-width:3px
    style RECORD fill:#FFF9E6,stroke:#F9A825,stroke-width:3px
    style SEND fill:#E3F2FD,stroke:#1976D2,stroke-width:3px
    style PAY fill:#E3F2FD,stroke:#1976D2,stroke-width:3px
    style PAYOUT fill:#E3F2FD,stroke:#1976D2,stroke-width:3px
    style DONE fill:#90EE90