# Purpose

Calculate and display variance between allocated hours and actual hours logged, with color-coded indicators for quick assessment.

# Requirements

## Requirement: Variance calculation

The system SHALL calculate variance percentage as (actual - allocated) / allocated * 100.

### Scenario: Positive variance
- GIVEN allocated hours is 100
- AND actual hours is 120
- WHEN variance is calculated
- THEN variance percentage is +20%

### Scenario: Negative variance
- GIVEN allocated hours is 100
- AND actual hours is 80
- WHEN variance is calculated
- THEN variance percentage is -20%

### Scenario: Zero variance
- GIVEN allocated hours is 100
- AND actual hours is 100
- WHEN variance is calculated
- THEN variance percentage is 0%

## Requirement: Division by zero handling

The system SHALL handle cases where allocated hours is zero.

### Scenario: No allocation with actual
- GIVEN allocated hours is 0
- AND actual hours is 40
- WHEN variance is displayed
- THEN variance shows as infinity (∞%)

### Scenario: No allocation no actual
- GIVEN allocated hours is 0
- AND actual hours is 0
- WHEN variance is calculated
- THEN variance percentage is 0%

## Requirement: Indicator thresholds

The system SHALL use color indicators based on variance percentage.

### Scenario: Green indicator
- GIVEN variance percentage is within ±5%
- WHEN indicator is determined
- THEN indicator is green

### Scenario: Yellow indicator
- GIVEN variance percentage is within ±20% (but outside ±5%)
- WHEN indicator is determined
- THEN indicator is yellow

### Scenario: Red indicator
- GIVEN variance percentage exceeds ±20%
- WHEN indicator is determined
- THEN indicator is red

### Scenario: Gray indicator (no data)
- GIVEN no allocation and no actual exists
- WHEN indicator is determined
- THEN indicator is gray

## Requirement: Display format

The system SHALL display variance with sign and percentage.

### Scenario: Positive display
- GIVEN variance percentage is 15.5%
- WHEN displayed
- THEN shows "+15.5%"

### Scenario: Negative display
- GIVEN variance percentage is -8.2%
- WHEN displayed
- THEN shows "-8.2%"

### Scenario: Infinity display
- GIVEN variance is infinity (actual with no allocation)
- WHEN displayed
- THEN shows "∞%"

## Requirement: Grid cell variance display

The system SHALL show variance in each grid cell.

### Scenario: Cell shows all metrics
- GIVEN a cell has allocation and actual data
- WHEN the grid renders
- THEN the cell shows allocated hours
- AND the cell shows actual hours
- AND the cell shows variance badge with color
