# Manager Report:
- Manager ID: {manager_id}
- Program: {program_slug}

## Tools to call (in this order)
1.- get_manager_sales('{manager_id}', '{program_slug}') - Returns structured sales data with rankings (List of EmployeeSales)
2.- get_visits_by_manager('{manager_id}', '{program_slug}') - Returns structured visit performance data (List of VisitsByManager)

Wait for both results before writing the report.

## Data dictionary (EmployeeSales)
- visitor_name: str
- visitor_email: str
- total_sales: int | null
- sales_current_week: int | null
- sales_previous_week: int | null
- sales_previous_month: int | null
- current_ranking: int | null
- previous_week_ranking: int | null
- previous_month_ranking: int | null

## Output guardrails
- If a field needed for a calculation is missing/0, display "n/a" for that calculation and still complete the rest.
- Do not infer employee names or stores beyond the tool outputs.

## REQUIRED REPORT FORMAT (exactly this; no extra text; no bold in headers)
# 1. Executive Summary

## Manager Name
### {program_slug}, ({manager_id})

## Sales Ranking
- Rank all employees by total_sales descending.
- Calculate week-over-week growth rate comparison ((`sales_current_week` - `sales_previous_week`) / `sales_previous_week` * 100) from 'get_employee_sales'
Display as: Rank | Employee Name | Total Sales | Growth Rate
[Provide a markdown table with columns: Rank | Employee Name | Total Sales | WoW Growth]

## Visits Ranking
  - Rank employees by total_visits and performance
  - Identify visit consistency patterns
## Performing Employees
### Top Performing Employee
- Identify the Top-3 employees with the highest sales and Top-3 employees with the highest visits performance, with their names and values.
### Bottom Performing Employee
- Identify the Top-3 employees with the lowest sales and Top-3 employees with the lowest visits performance, with their names and values.

## Store Performance
- Top-5 Most Visited stores with visit counts based on `most_frequent_store`.
[provide a markdown table]
## Visit Duration Summary
- using visit_duration, calculate the average visit duration for all employees.

## Top Reps by Total Duration (minutes)
Rank all employees by visit_duration
Display as: Employee Name: `visit_duration` min, `total_visits` visits, `average_visit_duration` min/visit.

## Visits Summary
### Hourly Visits Summary
Calculate average hour_of_visit across all employees
Identify peak visit hours and outliers
### Day of Week Visits Summary
using the day_of_week vs current_visits calculate the average visits per day of the week for all employees and extract the most frequent day of the week with the highest visits.
Determine most frequent visit day across the team

# 2. Visits Performance:
## Total Visits
Calculate the number of visits
## Average Visits per Employee
Use visit_duration to provide the average visits duration per employee.
## Visit Duration Comparison
Compare the visit duration of the top-performing employee (highest minutes) with the bottom-performing employee.
## Visits Distribution
    - **Day Distribution:** Group visits by day_of_week, calculate percentages
    - **Hour Distribution:** Group visits by hour_of_visit ranges (morning/afternoon/evening)
    - **Outlier Detection:** Identify employees with significant deviations from team averages in timing or duration

# 3. Sales Performance:
## Sales Trend Analysis
For each employee, show, calculate and display:
    - Current Week Sales: `sales_current_week`
    - week-over-week change: (`sales_current_week` - `sales_previous_week`) / `sales_previous_week` * 100
    - Previous-month change: (`sales_current_week` - `sales_previous_month`) / `sales_previous_month` * 100
    - Trend indicators:
      - ↑ (Positive growth >5%)
      - ↓ (Negative growth <-5%)
      - → (Stable growth -5% to +5%)
    Display as a markdown table with columns:
    Employee | Current Week Sales | WoW % (↑/↓/→) | Prev-Month % (↑/↓/→)

# 4. Team Insights and Recommendations:
## Key Findings
Use the correlation analysis to summarize the key findings from the team performance, including any significant correlations or trends observed.
## Key Strengths
Identify the team's key strengths based on sales and visits performance.
## Recommendations
Provide specific recommendations for the team to enhance their sales and visits performance.
## Actionable Insights
List concrete next steps including:
- Manager implementation steps
- Individual coaching areas
- Team-wide improvements
- KPIs to track

**CRITICAL FORMATTING REQUIREMENTS:**
- Use ONLY the markdown structure shown above with # for main headings and ## for subheadings
- ALL data must be presented in markdown tables where multiple items are shown
- Include ALL sections and subsections exactly as formatted above
- Present data with actual numbers from the tool results, not the formulas.
- Do NOT add any introductory text, disclaimers, or additional commentary beyond the specified structure
- Do NOT use bold (**) for section headers - use proper markdown heading levels only
