# Status Indicator System

## Objective

Say the same thing about a record's state everywhere that state appears.

A single vocabulary of states with consistent wording and treatment across lists, detail pages, filters, and exports.

## Before You Begin

This feature is being added to an application that already exists and already
works. Do not scaffold a new project, and do not assume a blank slate.

Inspect the codebase first and establish:

- The existing application structure and where code of this kind already lives.
- The framework and version in use.
- The existing design system — colours, spacing, typography, and component conventions.
- Existing UI components you can reuse instead of writing new ones.
- The existing database structure, if this feature needs to persist anything.
- The existing authentication and authorization system, if this feature is user-scoped.
- Dependencies already installed, so you don't add a library that duplicates one.
- The existing test setup and conventions.

Only start writing code once you understand the above. If the application
already implements part of this feature, extend it rather than replacing it.

## Implementation Instructions

1. Enumerate every state each record type can be in as the system actually stores it, then map those internal values onto a small set of user-facing states with fixed wording.
2. Use that wording everywhere the state surfaces: the list column, the detail header, the filter options, the notification copy, and the exported file. A record that is Paused in the table and Suspended in the export reads as two different problems.
3. Handle the states that are not successes or failures — unknown, pending, in progress, expired, and stale — explicitly. These are the ones that get quietly rendered as blank cells.
4. Convey each state with text plus shape or icon, never with a coloured dot on its own, and keep the text present even at the smallest density setting.
5. Do not surface internal enum values, database codes, or provider-specific strings to users. Map them, and when an unmapped value arrives, show a defined fallback rather than printing the raw code.

## UI and UX Requirements

Match the application's existing design system exactly. Reuse its components,
spacing, and typography. This feature should look like it was always there.

## Responsive Requirements

Works on mobile, tablet, and desktop. Touch targets are large enough to hit on a
phone, and nothing overflows horizontally at 320px.

## Accessibility Requirements

- Fully keyboard navigable.
- Correct semantic elements and ARIA roles.
- Visible focus states.
- Meets WCAG AA contrast.
- Dynamic changes are announced to screen readers.
- Respects prefers-reduced-motion.

## Edge Cases

- Colour alone cannot carry state. Red and green are indistinguishable for a meaningful share of users, and neither survives greyscale printing or a monochrome display.
- Unknown, pending, and stale are real states and need their own treatment. Rendering them as an empty cell or defaulting them to the success style misreports the record.
- The same state must use identical wording in every surface. Divergent labels between a filter and a table make the filter appear broken.
- Raw internal codes leaking into the interface are unreadable and expose implementation detail; an unrecognised value must fall back to a defined unknown state, and be logged rather than displayed.
- A state that changes while the user is looking at the record must update in place or be marked as possibly out of date, not silently diverge from the server.
- The visual container for these states is owned by Badge Component; extend it rather than introducing a second pill shape that sits half a pixel off the first.
- Filter options must reflect the states that actually occur in the data, so users are not offered a filter that can never match anything.

## Testing

Exercise the feature end to end in the running application. Cover every edge case
above, then run the existing test suite and confirm nothing regressed.

## Acceptance Criteria

- [ ] Each record type has a documented, closed set of user-facing states.
- [ ] The same state uses identical wording in lists, detail views, filters, and exports.
- [ ] Every state is conveyed by text alongside shape or icon, never colour alone.
- [ ] Unknown, pending, and stale states render explicitly rather than as blanks.
- [ ] No internal enum value or provider code appears in the interface.
- [ ] Unmapped incoming values resolve to a defined fallback state.
- [ ] The feature matches the existing design system.
- [ ] No existing functionality is broken.

## Adaptation Rules

- Match the existing design system. Do not introduce a new colour palette,
  spacing scale, or component library.
- Reuse existing components and utilities wherever they fit.
- Follow the naming, file layout, and code style already present.
- Do not upgrade, replace, or remove existing dependencies to make this
  feature fit. Adapt the feature to the app, not the app to the feature.
- Do not break existing functionality. If a change is genuinely required in
  existing code, make the smallest one that works and say so.
- If something in these instructions conflicts with how the application is
  built, follow the application and explain the deviation.

## Final Verification

Before you report the work as done:

1. Re-read the acceptance criteria above and check each one against what you
   actually built.
2. Run the application and exercise the feature end to end.
3. Run the existing test suite and confirm you have broken nothing.
4. Check the feature on mobile, tablet, and desktop widths.
5. Check keyboard navigation and focus handling.
6. Summarize what changed: files added, files modified, and anything you
   deliberately did differently because of how this application is built.

If any acceptance criterion is unmet, fix it before reporting completion.
