You are a Senior Full Stack Engineer.

Project:
Training Management System (TMS)

Current status:

- Auth.js role mapping is completed.
- Sidebar displays menu by role.
- Employee Training Records module is completed.
- HRD Review Workflow is completed.

Current task:
Implement Sprint 4: Training Policy and Course Master Enhancement.

Important constraints:

- Do NOT change existing folder structure.
- Do NOT create a new project.
- Do NOT migrate ORM.
- Use existing Drizzle ORM.
- Use existing Auth.js session.
- Reuse existing UI components.
- Reuse existing /dashboard route structure.
- Make minimal-impact changes only.

Part 1: Training Policy Module

Requirements:

1. Create Training Policy page.
   Route:
   /dashboard/training-policy

2. HRD can create and update yearly training policy.

Fields:

- year
- totalHours
- kHours
- sHours
- aHours
- isActive

3. Validation:

- year is required.
- totalHours is required.
- kHours is required.
- sHours is required.
- aHours is required.
- kHours + sHours + aHours must equal totalHours.

4. Default policy example:

- Total Hours = 30
- K = 12
- S = 12
- A = 6

5. Dashboard must use Training Policy instead of hardcoded values.

6. Only HRD can access and manage Training Policy.

Part 2: Course Master Enhancement

Requirements:

1. Update existing Course Master without changing module structure.

2. Ensure Course Master supports these fields:

- courseCode
- courseName
- description
- defaultCategory (K/S/A)
- defaultHours
- provider
- status
- mandatory
- certificateRequired
- validityMonths
- trainingCost

3. If existing fields already exist, reuse them.
4. If field names differ, map them carefully.
5. Do not remove existing course data.
6. Add Zod validation.
7. Add create/edit/list UI fields.
8. Add loading, empty, success, and error states.

Part 3: Output Review File

After implementing code changes, create a review output file in the project:

Path:
docs/sprint-4-training-policy-course-master-review.md

The file must include:

1. Summary of changes
2. Files changed
3. Database changes
4. Migration commands
5. New routes
6. Validation rules
7. Permission rules
8. Manual test checklist
9. Known limitations
10. Next recommended sprint

Manual Test Checklist must include:

- HRD can open Training Policy page.
- Employee cannot open Training Policy page.
- HRD can create policy.
- HRD can edit policy.
- System blocks invalid K/S/A sum.
- Dashboard uses policy values.
- HRD can create course.
- HRD can edit course.
- Course Master supports certificateRequired.
- Course Master supports trainingCost.

Return:

- Complete code changes with file paths.
- Content of docs/sprint-4-training-policy-course-master-review.md.
- Any commands required to run migration.
