# Account pipeline

> The Companies screen of a sales CRM: tags, owners, win probability as segments and twelve weeks of activity, with swings, bursts and cooling flagged.

A sales team’s book of accounts in one table. Each row shows the company’s segment and stage as tags, its owner’s face, open deals and pipeline, the odds of winning as a row of segments from red to green, and twelve weeks of activity as small bars. The cells read their own data: a drop of fifteen points or more keeps the lost segments as red outlines, a burst of activity turns amber, a cooling end turns red, an owner who is away gets a chip. The sidebar picks a team, a region or the slipping deals; the tabs swap the money column; the footer adds totals over the rows in view or the ones selected. Every cell is exported on its own. Light and dark.

A React component by Bruno Delorence: https://brunodelorence.com/components/account-pipeline. MIT License, Copyright (c) 2026 Bruno Delorence.

Category: Dashboards.

## Anatomy

1. **Sidebar**: The app’s mark and name, the views (Companies, a team, a region, Slipping Deals with its count), and the trial card at its foot. A drawer under 760 px.
2. **Header**: The view’s name and its status, then a search that opens in place, the notifications and who is signed in.
3. **Tabs**: Companies, Deals and Forecast: they swap the money column and its total between the open pipeline, the average deal and the weighted pipeline.
4. **Toolbar**: Four menu buttons (sort, owner, stage, last activity), then Export and New Company.
5. **Filter button**: A caption and the value it holds; it turns blue while it narrows the rows.
6. **Row**: A checkbox, the company as the row’s header, then its tags, owner, deals, money, odds, activity and last touch. The first two stay put while the table scrolls.
7. **Stage tags**: Segment and stage in six tones; past two, a +N button opens the rest in a popover.
8. **Owner**: A drawn face or initials, co-owners stacked behind, and an Away chip when the owner is out.
9. **Win meter**: Twenty segments from red to green and the figure; a swing of fifteen points keeps the lost segments as outlines and adds a chip.
10. **Activity bars**: Twelve weeks of touches, the latest at the right; a burst turns amber, a cooling end red, quiet weeks flat.
11. **Footer**: The rows in view or selected, in a live region, and the calculations: toggles that add a total, the average odds and one more.

## Properties

### Meter tone (`WinMeter.tone`)

1. **Scale (default)**: Each segment takes the colour of where it sits, red to amber to green, so a longer fill reaches the greener end. The table’s.
2. **Band**: The whole fill in its band’s colour: red under 35, amber under 60, green above. A low figure reads red at a glance.

Keep `scale` where meters sit in a column and are read against each other. Use `band` when one meter stands on its own and has to give a verdict, as in a side panel or a card.

### Swing (`WinMeter.before`)

1. **Left out (default)**: The figure as it is now, with nothing to compare it to.
2. **Two weeks ago**: A move of 15 points or more keeps the lost segments as red outlines, or lights the gained ones, and adds a chip with the change.

Pass `before` whenever you have the earlier figure. A fall from 58 to 31 is the reading that matters most, and without it the row looks like any other at-risk account.

### Tags shown (`StageTags.max`)

1. **1**: The segment alone; every stage behind +N. For a narrow column.
2. **2 (default)**: The segment and one stage, the rest behind +N.
3. **3**: A third tag, for a wide column with room to spare.

Keep it at two so the column holds one width down the table. Put the segment first and the most current stage second: those are the ones always in sight.

### Trend word (`ActivityBars.note`)

1. **Off (default)**: The bars alone; the colour of the last weeks carries the reading. The table’s.
2. **On**: The reading written beside the bars: Rising, Cooling, Quiet 2w, Spike wk 7.

Leave it off in the table, where the column is narrow and repeated. Turn it on when the bars stand alone or in a report, so the reading is a word as well as a colour.

## When to use

- A sales team’s book of accounts, where each company needs its odds, its money and how warm it is read side by side, and the risky ones have to stand out without a report.
- A list worth cutting several ways: by team, region or a saved view like the slipping deals, then by owner, tag and last touch, with the totals following the cut.
- Rows that carry small readings rather than long text: a probability, a run of weekly counts, a few tags and a face. The cells draw what stands out on their own.
- A CRM screen with its own navigation, where the sidebar, the tabs and the footer come with the table and fold into a drawer on a phone.

## When not to use

- A board of deals moving between stages. Use a kanban with columns per stage; the table shows companies, not the steps of each deal.
- One account in depth. Open its own page with contacts, deals and a timeline; a row has room for a reading, not a history.
- A forecast for the board. Use a chart of the quarter against its target; the Forecast tab only weights each row by its odds.
- Thousands of companies. The table draws every row; past a few hundred, page it on the server and keep the footer’s sums there too.
- Live alerts. A slipping deal only changes colour; send a drop in the odds as a notification to its owner.

### What the cells flag

Each cell reads its own data and draws what stands out, so nobody has to set a flag by hand:

- **A swing in the odds**: 15 points or more since `before`, drawn as outlines or lit segments and a chip.
- **A burst of activity**: a week of six or more touches, three deviations over the others and two and a half times their mean, in amber with a dot.
- **A cooling end**: the last three weeks at half the earlier ones or less, in red. **Quiet**: two or more empty weeks at the end, as flat dashes.
- **Churn risk** carries a warning sign in its tag, and an owner who is away gets a dot and an Away chip with the day they are back.

### Slipping deals

The Slipping Deals view gathers every account that has one of those flags against it: odds down 15 points or more in two weeks, activity cooling or quiet, or tagged Churn risk. Its count sits in the sidebar, so the size of the problem shows before the view is opened.

### Full table vs. a cell on its own

**Full table**
- The book of accounts, to be cut by view, owner and tag and sorted by any column.
- Brings its sidebar, tabs, toolbar and footer, and folds into a drawer on a phone.
- A CRM’s Companies screen.

**A cell on its own**
- One reading somewhere else: the odds on an account’s page, a column in a report.
- `WinMeter`, `ActivityBars`, `StageTags` and `OwnerCell` each work alone; `CellColumn` gives them a header.
- An account panel, a weekly digest.

## Do’s and don’ts

- **Do**: Give every meter in a column the same tone, and pass `before` so the falls stand out from the low figures.
- **Don’t**: Mix `scale` and `band` in one column. The same amber means a position on the track in one row and a verdict in the next.
- **Do**: Pass `null` for an account with no score yet: the track stays empty and says No score.
- **Don’t**: Pass `0` for a missing score. An empty track at 0% reads as a deal that is lost.
- **Do**: Lead with the segment and the most current stage, and let the rest wait behind +N.
- **Don’t**: Raise `max` to show every tag. The column widens for one row, and six tones side by side stop meaning anything.

## Content

The table is scanned more than read: short labels, the same words in every row.

- **Tags of one or two words**, in sentence case: `New logo`, `Land & expand`, `Churn risk`. Each tag keeps one tone wherever it shows, and red is kept for risk: only `Churn risk` wears it.
- **Column headers in title case**, naming what is measured: `Win Probability`, `Activity Trend`, `Last Interaction`.
- **Name views by who or what is in them**: `Strategic AEs`, `EMEA Enterprise`, `Slipping Deals`.
- **Money in whole dollars** with thousands separators, the tab saying which sum it is: the open pipeline, the average deal or the forecast.
- **Company names as they are known**, not legal names: the name is the row’s header and what a screen reader hears first.

## Installation

Install it with the shadcn CLI, into components/account-pipeline of any React project:

```sh
npx shadcn@latest add https://brunodelorence.com/r/account-pipeline.json
```

Or add the registry to components.json once, as a namespace that coding agents and the shadcn MCP server search by name:

```json
{
  "registries": {
    "@brunodelorence": "https://brunodelorence.com/r/{name}.json"
  }
}
```

```sh
npx shadcn@latest add @brunodelorence/account-pipeline
```

Or copy all the source files below into one folder of your project. Either way it needs React 19 and a bundler with CSS Modules (Next.js, Vite).

It has a dark colour scheme. Its colours are CSS light-dark() pairs, kept inside @supports so that builds which rewrite light-dark() for older browsers leave them alone: it follows your page’s color-scheme (light unless the page sets one) or its colorScheme prop, with nothing to configure. Browsers without light-dark() show it light.

Copy these media files to the same paths under your public folder:

- https://brunodelorence.com/experiments/visual-revision/v2/people/ana-96.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/ana-192.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/ana-384.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/ana-768.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/priya-96.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/priya-192.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/priya-384.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/priya-768.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/jonah-96.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/jonah-192.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/jonah-384.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/jonah-768.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/lucia-96.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/lucia-192.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/lucia-384.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/lucia-768.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/kenji-96.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/kenji-192.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/kenji-384.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/kenji-768.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/felix-96.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/felix-192.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/felix-384.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/felix-768.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/amara-96.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/amara-192.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/amara-384.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/amara-768.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/sofia-96.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/sofia-192.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/sofia-384.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/sofia-768.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/yara-96.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/yara-192.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/yara-384.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/yara-768.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/marcus-96.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/marcus-192.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/marcus-384.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/marcus-768.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/diego-96.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/diego-192.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/diego-384.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/diego-768.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/theo-96.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/theo-192.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/theo-384.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/theo-768.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/bruno-96.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/bruno-192.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/bruno-384.webp
- https://brunodelorence.com/experiments/visual-revision/v2/people/bruno-768.webp
- https://brunodelorence.com/experiments/visual-revision/manifests/account-pipeline.json

The ZIP includes the declared local media and provenance manifests under public/. Copy that directory to your project root. The manifests record original sources, generated personas and native or derived resolutions.

## Usage

```tsx
import { AccountPipeline } from './account-pipeline';
import { ActivityBars, OwnerCell, StageTags, WinMeter } from './cells';

export function PipelinePage() {
  return (
    <AccountPipeline
      workspace="Fernbrook"
      user={{ id: 'me', name: 'Bruno Delorence', team: 'strategic' }}
      onOpenAccount={(account) => console.log('Open', account.name)}
      autoplay={false}
    />
  );
}

// Or a cell on its own:
export function DealOdds() {
  return <WinMeter value={31} before={58} />;
}
```

## States

- **Every company**: The default: twenty companies by pipeline value, the money column on the open pipeline.
- **Sorted by win probability**: The likeliest first, from the Sort by menu or the column’s header; the arrow says which way.
- **Slipping deals**: Odds down fifteen points or more in two weeks, activity cooling or quiet, or tagged Churn risk: the outlines, red bars and flags all show at once.
- **A team’s book**: The Strategic AEs view: only the accounts their four people own, with the title following the view.
- **Rows selected, totals on**: Three rows checked: the header box goes mixed, and the footer’s total and average measure those three alone.
- **Owner filter open**: The Filter menu: every owner under their team, with a face and how many accounts they hold.
- **Row actions**: A row’s menu: log a touch, which bumps this week’s bar, or remove it, with Undo in the toast.
- **Forecast tab**: The money column becomes the pipeline weighted by its odds, sorted and totalled the same way.
- **Empty view**: A view with nothing in it yet: a line on why, and a way back to Companies.
- **New company**: New Company puts a row at the top with its name field; Enter keeps it, Escape drops it.
- **Dark**: With `colorScheme="dark"` the window turns near-black and the tags and segments keep their tones a step brighter.
- **Phone, drawer open**: Under 760 px the sidebar slides in over a veil from the menu button, the filters scroll in a row and the footer folds.

## Examples

### Win probability

The meter on the red-to-green scale and in its band’s colour, a drop and a jump flagged against two weeks ago, and an account not scored yet.

```tsx
import { CellColumn, WinMeter } from './cells';

export function WinProbability() {
  return (
    <CellColumn
      title="Win Probability"
      rows={[
        { label: 'Likely, on the scale', cell: <WinMeter value={82} /> },
        { label: 'In play', cell: <WinMeter value={51} /> },
        { label: 'At risk, in its band', cell: <WinMeter value={18} tone="band" /> },
        { label: 'Fell 27 in two weeks', cell: <WinMeter value={31} before={58} /> },
        { label: 'Jumped 23', cell: <WinMeter value={71} before={48} tone="band" /> },
        { label: 'Not scored yet', cell: <WinMeter value={null} /> },
      ]}
    />
  );
}
```

### Activity trend

Twelve weeks of touches read by the cell: steady, rising, a single burst in amber, cooling off in red, and gone quiet, each with its reading beside the bars.

```tsx
import { ActivityBars, CellColumn } from './cells';

export function ActivityTrend() {
  return (
    <CellColumn
      title="Activity Trend"
      rows={[
        {
          label: 'Steady',
          cell: <ActivityBars values={[3, 4, 3, 5, 4, 5, 6, 4, 5, 6, 5, 6]} note />,
        },
        {
          label: 'Rising',
          cell: <ActivityBars values={[1, 1, 2, 1, 2, 2, 3, 4, 5, 6, 7, 8]} note />,
        },
        {
          label: 'One burst',
          cell: <ActivityBars values={[2, 2, 3, 2, 2, 3, 2, 2, 11, 3, 2, 3]} note />,
        },
        {
          label: 'Cooling off',
          cell: <ActivityBars values={[6, 5, 7, 6, 5, 6, 4, 5, 4, 2, 1, 1]} note />,
        },
        {
          label: 'Gone quiet',
          cell: <ActivityBars values={[4, 3, 5, 4, 3, 4, 2, 3, 0, 0, 0, 0]} note />,
        },
      ]}
    />
  );
}
```

### Segment and stage

One tag, a segment with its stage, more behind a +2 popover, a churn-risk flag, and a cell with room for three.

```tsx
import { CellColumn, StageTags } from './cells';

export function SegmentAndStage() {
  return (
    <CellColumn
      title="Segment & Stage"
      rows={[
        { label: 'One tag', cell: <StageTags tags={['Renewal']} /> },
        { label: 'Segment and stage', cell: <StageTags tags={['Enterprise', 'Upsell']} /> },
        {
          label: 'More behind +2',
          cell: <StageTags tags={['Mid-market', 'Co-sell', 'Expansion', 'Pilot']} />,
        },
        { label: 'Flagged at risk', cell: <StageTags tags={['Churn risk', 'Renewal']} /> },
        {
          label: 'Room for three',
          cell: <StageTags tags={['Strategic', 'Land & expand', 'New logo']} max={3} />,
        },
      ]}
    />
  );
}
```

### Account owner

An illustrated face, initials when there is no drawing, an account shared by three, an owner out of office, and one waiting to be assigned.

```tsx
import { CellColumn, OwnerCell } from './cells';
import type { Owner } from './data';

const ANA: Owner = {
  id: 'ana',
  name: 'Ana Ribeiro',
  team: 'strategic',
  face: { skin: '#e7b98f', hair: '#3b2416', style: 'long', bg: '#f2c8a0' },
};

const KENJI: Owner = {
  id: 'kenji',
  name: 'Kenji Mori',
  team: 'strategic',
  face: { skin: '#e7b98f', hair: '#16120f', style: 'short', bg: '#c6e3c0', glasses: true },
};

const FELIX: Owner = {
  id: 'felix',
  name: 'Felix Brandt',
  team: 'mid',
  face: { skin: '#f3d2b8', hair: '#d9b36c', style: 'buzz', bg: '#a9d8d0', glasses: true },
};

const LUCIA: Owner = {
  id: 'lucia',
  name: 'Lucía Ortega',
  team: 'mid',
  face: { skin: '#c98d63', hair: '#2a1a12', style: 'bob', bg: '#d8c6f2' },
  away: '2026-11-03',
};

export function AccountOwner() {
  return (
    <CellColumn
      title="Account Owner"
      rows={[
        { label: 'Editorial portrait', cell: <OwnerCell owner={ANA} /> },
        {
          label: 'Initials',
          cell: <OwnerCell owner={{ id: 'new-person', name: 'New teammate', team: 'sdr' }} />,
        },
        { label: 'Shared with two', cell: <OwnerCell owner={KENJI} coOwners={[FELIX, ANA]} /> },
        { label: 'Out of office', cell: <OwnerCell owner={LUCIA} /> },
        { label: 'Nobody yet', cell: <OwnerCell owner={null} onAssign={() => {}} /> },
      ]}
    />
  );
}
```

## How it works

- The win probability is twenty segments in a track. On the scale tone each segment takes its colour from where it sits (red under 30%, amber under 60%, green above), so a longer fill reaches the greener end; the band tone paints the whole fill in its band’s colour. Given the figure two weeks ago, a swing of fifteen points or more keeps the lost segments as red outlines (or lights the gained ones) and adds a chip with the change.
- The activity trend is twelve bars whose height is a custom property, the week over the run’s busiest. readTrend reads the run: a week three deviations over the others is a burst (amber, with a dot), a last three weeks at half the rest is cooling (red), two or more empty weeks at the end are quiet (flat dashes). Weeks at or over the median are bright, the rest dim.
- Segment and stage tags take one of six tones. Past two, a +N button opens the rest in a native popover, in the top layer, so the table’s scrolling never clips it; it is placed from the button’s box each time it opens and closes on Escape or a press elsewhere.
- Known owners use distinct local editorial photographs. Theo shares the earlier portrait and Bruno uses his existing real project photo. Unknown people keep initials on a tint picked from their name. Co-owners stack behind, an owner who is away gets a dot and an Away chip, and an account with no owner shows a dashed ring that opens a menu of people.
- The sidebar picks the rows: every company, a team’s, a region’s, or the slipping ones (odds down fifteen, activity cooling or quiet, or tagged Churn risk). The tabs swap the money column for the open pipeline, the average deal or the pipeline weighted by its odds; the toolbar sorts and filters by owner, tag and last interaction, and the headers sort too.
- The footer’s calculations are toggles: the total of the money column, the average odds, and one more from Add Calculation (median odds, open deals, accounts at risk). With rows selected, they measure only those. New Company puts an editable row at the top; Export saves the rows in view as CSV; a row’s menu logs a touch or removes it, with Undo.
- The table scrolls inside its own box with the checkbox and company held at its left. Under 760 px of stage the sidebar becomes a drawer behind a menu button and the footer folds into two columns.
- While on screen and untouched, a demo pointer sorts by the odds, turns on the totals, opens the slipping deals and a row’s tags, selects two rows and filters by an owner. Any real input hands it over; it comes back after 9 s of quiet.

## API reference

- **accounts** (`Account[]`, default `a book of twenty`): The companies: name, region, tags, owner and co-owners, open deals, pipeline value, win probability now and two weeks ago, twelve weeks of touches and the last interaction.
- **owners** (`Owner[]`, default `twelve people in three teams`): Everyone who can own an account: name, team, an optional face and an away date.
- **workspace** (`string`, default `'Fernbrook'`): The app’s name beside its mark.
- **user** (`Owner`, default `Bruno Delorence`): Who is signed in, at the top right.
- **onOpenAccount** (`(account: Account) => void`): Called when a company’s name is pressed.
- **autoplay** (`boolean`, default `true`): While on screen and untouched, a demo pointer shows the main interactions. Any real input stops it.
- **defaultState** (`AccountPipelineState`): Opens in a given moment, held still (no demo): the view (all, a team, a region, slipping, or an empty page), the tab, the sort, an owner or stage filter, the rows selected, the footer’s calculations, an open menu (sort, owner, a row’s actions…), a new company being named, the drawer open.
- **colorScheme** (`'light' | 'dark' | 'system'`): Light or dark colours, or the reader’s; without it, the page’s color-scheme.
- **className** (`string`): Classes for the stage.

## Accessibility

### Cells in words

Every cell says in words what it draws, in text kept for screen readers: `31% win probability, at risk, down 27 points in two weeks`. The segments and bars are hidden from assistive technology. On screen the figure is always written, and a swing adds outlines and a chip with an arrow, so colour is never the only signal (WCAG 1.4.1, Use of colour).

### Table structure

- Each company’s name is its row’s header (`th scope="row"`) and the columns have headers, so a cell is read with its company and its column (WCAG 1.3.1, Info and relationships).
- The sortable headers carry `aria-sort` on the column in use, ascending or descending.
- The checkboxes are `role="checkbox"` buttons; the header one is mixed while only some rows are chosen.

### Keyboard

- The tabs are a tablist moved with the arrow keys.
- The filters, the row actions, the notifications and Add Calculation are menu buttons: their menus move with the arrows, Home and End, and close on Escape with focus back on their button.
- The +N tags open a native popover, which closes on Escape or a press elsewhere.

### Status messages

The count of rows in view, or selected, is in a polite live region, and every change to the data (a company added, removed or handed to an owner, a touch logged, an export) is reported in a status toast, so it is heard without moving focus (WCAG 4.1.3, Status messages).

### Timing

- A toast that only reports a change fades after 5.2 s. One that offers Undo has no time limit: it stays until Undo is pressed, Escape is pressed on it, or the next change replaces it (WCAG 2.2.1, Timing adjustable).
- Removing a company moves focus to the actions of the row after it. Undo moves it back to the restored row’s actions; Escape on the toast leaves it on the row after (WCAG 2.4.3, Focus order).
- The demo pointer stops for good at the first touch, key, wheel or pointer move, and doesn’t come back until the table mounts again (WCAG 2.2.2, Pause, stop, hide).

### Contrast

Every word holds 4.5:1 on the surface under it in both schemes, the quietest captions and menu hints included, and the focus outline and checkbox edges hold 3:1 (WCAG 1.4.3 and 1.4.11). The win meter’s segments sit beside the written figure, which carries the same reading.

### In this build

- The sidebar is a navigation with aria-current on its view; the table has column headers that sort (aria-sort), and each company’s name is its row’s header.
- Every cell says in words what it draws: “31% win probability, at risk, down 27 points in two weeks”, “Activity: 1 touches last week, cooling”, the owners’ names and when one is back. The segments and bars themselves are hidden from assistive technology.
- The tabs are a tablist moved with the arrow keys. The filters, the row actions, the notifications and Add Calculation are menu buttons; their menus move with the arrows, Home and End, and close on Escape with the focus back on their button. The +N tags open a native popover.
- The checkboxes are role="checkbox" buttons; the header one is mixed while some rows are chosen. The count of rows in view, or selected, is in a polite live region, and every change is reported in a status toast.
- Under reduced motion nothing slides or fades and the demo never plays. The demo pointer is decorative.

## Source

### account-pipeline/account-pipeline.tsx

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import {
  useEffect,
  useEffectEvent,
  useId,
  useLayoutEffect,
  useMemo,
  useRef,
  useState,
  type ReactNode,
} from 'react';
import { ActivityBars, OwnerCell, StageTags, WinMeter, Avatar, readTrend } from './cells';
import {
  ACCOUNTS,
  OWNERS,
  REGION_NAME,
  SWING,
  TAGS,
  TEAM_NAME,
  TODAY,
  daysAgo,
  money,
  shortDate,
  shortMoney,
  type Account,
  type Owner,
  type Region,
  type Tag,
  type Team,
} from './data';
import { DemoPointer, runDemo, type Point } from './demo-pointer';
import { Icon, Mark, type IconName } from './glyphs';
import { Menu, MenuItem, MenuLabel } from './menu';
import { useAutoplay } from './use-autoplay';
import styles from './account-pipeline.module.css';

/*
 * Account pipeline: the Companies screen of a sales team's CRM.
 *
 * - The sidebar picks the book: every company, one team's, one region's, or the slipping ones
 *   (odds down SWING points or more in two weeks, activity cooling or quiet, or a churn-risk tag).
 * - The tabs swap the money column: the open pipeline, the average deal, or the pipeline weighted
 *   by its odds. The toolbar sorts, filters by owner, by tag and by the last interaction.
 * - Each row reads its cells (cells.tsx): segment and stage tags with a +N popover, the owner's
 *   face, the win probability as segments with its swing flagged, and twelve weeks of activity
 *   with a burst or a cooling drawn on the bars.
 * - The footer adds calculations over the rows in view, or over the selected ones.
 * - While on screen and untouched, a demo pointer sorts by the odds, adds the totals, opens the
 *   slipping deals and a row's tags, selects two rows and filters by an owner, in a loop.
 */

export type { Account, Owner, Tag } from './data';

export type View =
  | { kind: 'all' }
  | { kind: 'team'; team: Team }
  | { kind: 'region'; region: Region }
  | { kind: 'slipping' }
  | { kind: 'empty'; name: string };

export type TabId = 'companies' | 'deals' | 'forecast';
export type SortKey = 'value' | 'win' | 'deals' | 'last' | 'name';
export type Calc = 'median' | 'deals' | 'risk';
type MenuState = { id: string; anchor: HTMLElement; byReader: boolean };
/** A note after a change; with `undo`, the rows to put back, the row removed and its neighbour. */
type Toast = { n: number; text: string; undo?: Account[]; row?: string; next?: string };

const TABS: { id: TabId; label: string; column: string; total: string }[] = [
  { id: 'companies', label: 'Companies', column: 'Pipeline Value', total: 'Sum of pipeline' },
  { id: 'deals', label: 'Deals', column: 'Avg Deal', total: 'Avg deal size' },
  { id: 'forecast', label: 'Forecast', column: 'Weighted', total: 'Weighted forecast' },
];

const SORTS: { id: SortKey; label: string }[] = [
  { id: 'value', label: 'Pipeline Value' },
  { id: 'win', label: 'Win Probability' },
  { id: 'deals', label: 'Open Deals' },
  { id: 'last', label: 'Last Interaction' },
  { id: 'name', label: 'Company' },
];

const RECENCY = [7, 14, 30, 90];

const CALCS: { id: Calc; label: string }[] = [
  { id: 'median', label: 'Median win probability' },
  { id: 'deals', label: 'Open deals' },
  { id: 'risk', label: 'At risk (under 35%)' },
];

const REGION_DOT: Record<Region, string> = { na: 'yellow', emea: 'pink', apac: 'violet' };

/** Slipping: the odds fell hard, the activity went cold, or the account is tagged at risk. */
export function isSlipping(account: Account) {
  const fell =
    account.win !== null && account.winBefore != null && account.winBefore - account.win >= SWING;
  const kind = readTrend(account.trend).kind;
  return fell || kind === 'cooling' || kind === 'quiet' || account.tags.includes('Churn risk');
}

/** A moment to open in, held still: no demo. */
export type AccountPipelineState = {
  /** The book in view: every company, a team's, a region's, the slipping ones, or an empty page. */
  view?: View;
  /** The money column: open pipeline, average deal or weighted forecast. */
  tab?: TabId;
  sort?: { key: SortKey; desc?: boolean };
  /** An owner's id: their accounts, led or shared. */
  owner?: string;
  /** Only the accounts carrying this tag. */
  stage?: Tag;
  /** Rows checked, by account id: the footer measures them alone. */
  selected?: string[];
  /** The footer's calculations shown: the sum, the average odds, and one more. */
  calcs?: { sum?: boolean; avg?: boolean; extra?: Calc };
  /**
   * A menu open: 'sort', 'owner', 'stage', 'recency', 'calc', 'bell', or a row's actions
   * ('row:<account id>').
   */
  menu?: string;
  /** A new company at the top of the table, its name being typed (the text so far). */
  naming?: string;
  /** The sidebar open as a drawer (it only is one on a narrow stage). */
  drawer?: boolean;
};

const amountOf = (account: Account, tab: TabId) =>
  tab === 'deals'
    ? account.openDeals
      ? account.value / account.openDeals
      : 0
    : tab === 'forecast'
      ? (account.value * (account.win ?? 0)) / 100
      : account.value;

const DEFAULTS = {
  view: { kind: 'all' } as View,
  tab: 'companies' as TabId,
  sort: { key: 'value' as SortKey, desc: true },
  owner: null as string | null,
  stage: null as Tag | null,
  recency: 90,
};

const BRUNO: Owner = {
  id: 'me',
  name: 'Bruno Delorence',
  team: 'strategic',
  face: { skin: '#e7b98f', hair: '#2b1d14', style: 'short', bg: '#9fc4ee', beard: true },
};

export function AccountPipeline({
  accounts = ACCOUNTS,
  owners = OWNERS,
  workspace = 'Fernbrook',
  user = BRUNO,
  onOpenAccount,
  autoplay = true,
  defaultState,
  colorScheme,
  className = '',
}: {
  /** The companies listed. */
  accounts?: Account[];
  /** Everyone who can own an account. */
  owners?: Owner[];
  /** The app's name, beside its mark. */
  workspace?: string;
  /** Who is signed in, at the top right. */
  user?: Owner;
  /** Called when a company's name is pressed. */
  onOpenAccount?: (account: Account) => void;
  autoplay?: boolean;
  /** Opens in a given moment, held still (no demo). */
  defaultState?: AccountPipelineState;
  colorScheme?: 'light' | 'dark' | 'system';
  className?: string;
}) {
  const uid = useId();
  const held = defaultState !== undefined;
  const start = defaultState ?? {};
  const { ref: root, playing, take } = useAutoplay<HTMLDivElement>();
  const pointer = useRef<HTMLSpanElement>(null);
  const search = useRef<HTMLInputElement>(null);

  const [rows, setRows] = useState(() =>
    start.naming === undefined ? accounts : [blankAccount(NAMING), ...accounts],
  );
  const [view, setView] = useState<View>(start.view ?? DEFAULTS.view);
  const [tab, setTab] = useState<TabId>(start.tab ?? DEFAULTS.tab);
  const [sort, setSort] = useState(
    start.sort
      ? { key: start.sort.key, desc: start.sort.desc ?? start.sort.key !== 'name' }
      : DEFAULTS.sort,
  );
  const [owner, setOwner] = useState<string | null>(start.owner ?? DEFAULTS.owner);
  const [stage, setStage] = useState<Tag | null>(start.stage ?? DEFAULTS.stage);
  const [recency, setRecency] = useState(DEFAULTS.recency);
  const [query, setQuery] = useState('');
  const [searching, setSearching] = useState(false);
  const [selected, setSelected] = useState<Set<string>>(() => new Set(start.selected));
  const [calcs, setCalcs] = useState<{ sum: boolean; avg: boolean; extra: Calc | null }>({
    sum: Boolean(start.calcs?.sum),
    avg: Boolean(start.calcs?.avg),
    extra: start.calcs?.extra ?? null,
  });
  const [menu, setMenu] = useState<MenuState | null>(null);
  const [toast, setToast] = useState<Toast | null>(null);
  const [drawer, setDrawer] = useState(Boolean(start.drawer));
  const [editing, setEditing] = useState<string | null>(start.naming === undefined ? null : NAMING);
  const [fresh, setFresh] = useState<string | null>(null);

  const ownerOf = (id: string | null) =>
    id === null ? null : (owners.find((person) => person.id === id) ?? null);

  // ---- The rows in view --------------------------------------------------------------------------

  const inView = useMemo(() => {
    const q = query.trim().toLowerCase();
    const list = rows.filter((row) => {
      if (row.id === editing) return true;
      if (view.kind === 'team' && owners.find((p) => p.id === row.owner)?.team !== view.team)
        return false;
      if (view.kind === 'region' && row.region !== view.region) return false;
      if (view.kind === 'slipping' && !isSlipping(row)) return false;
      if (view.kind === 'empty') return false;
      if (owner && row.owner !== owner && !row.coOwners?.includes(owner)) return false;
      if (stage && !row.tags.includes(stage)) return false;
      if (daysAgo(row.last.date) > recency) return false;
      if (q && !row.name.toLowerCase().includes(q)) return false;
      return true;
    });
    const value = (row: Account): number | string => {
      switch (sort.key) {
        case 'value':
          return amountOf(row, tab);
        case 'win':
          return row.win ?? -1;
        case 'deals':
          return row.openDeals;
        case 'last':
          return -daysAgo(row.last.date);
        case 'name':
          return row.name.toLowerCase();
      }
    };
    return [...list].sort((a, b) => {
      if (a.id === editing) return -1;
      if (b.id === editing) return 1;
      const x = value(a);
      const y = value(b);
      const order = x < y ? -1 : x > y ? 1 : 0;
      return sort.desc ? -order : order;
    });
  }, [rows, view, owner, stage, recency, query, sort, tab, editing, owners]);

  const slipping = rows.filter(isSlipping).length;
  const chosen = inView.filter((row) => selected.has(row.id));
  const measured = chosen.length ? chosen : inView;
  const scored = measured.filter((row) => row.win !== null);
  const avgWin = scored.length
    ? Math.round(scored.reduce((sum, row) => sum + (row.win ?? 0), 0) / scored.length)
    : null;
  const total = measured.reduce((sum, row) => sum + amountOf(row, tab), 0);
  const extraValue = (calc: Calc) => {
    if (calc === 'deals') return String(measured.reduce((sum, row) => sum + row.openDeals, 0));
    if (calc === 'risk') return String(scored.filter((row) => (row.win ?? 0) < 35).length);
    const wins = scored.map((row) => row.win ?? 0).sort((a, b) => a - b);
    if (!wins.length) return '—';
    const mid = Math.floor(wins.length / 2);
    return `${wins.length % 2 ? wins[mid] : Math.round((wins[mid - 1] + wins[mid]) / 2)}%`;
  };

  // ---- Changes -----------------------------------------------------------------------------------

  const say = (text: string, undo?: Pick<Toast, 'undo' | 'row' | 'next'>) =>
    setToast((now) => ({ n: (now?.n ?? 0) + 1, text, ...undo }));

  // Focus a row's actions button once the table has drawn; with no row, the tab in use.
  const focusRow = (id?: string) =>
    requestAnimationFrame(() => {
      const box = root.current;
      (
        (id && box?.querySelector<HTMLElement>(`[data-anchor="row:${id}"]`)) ||
        box?.querySelector<HTMLElement>('[role="tab"][aria-selected="true"]')
      )?.focus();
    });

  // A note fades after 5.2 s; one that offers Undo has no time limit (WCAG 2.2.1): it stays until
  // the reader presses Undo, presses Escape on it, or the next change replaces it.
  useEffect(() => {
    if (!toast || toast.undo) return;
    const timer = window.setTimeout(() => setToast(null), 5200);
    return () => window.clearTimeout(timer);
  }, [toast]);

  useEffect(() => {
    if (!fresh) return;
    const timer = window.setTimeout(() => setFresh(null), 1600);
    return () => window.clearTimeout(timer);
  }, [fresh]);

  // A held menu from defaultState, anchored to its trigger once it is drawn.
  useLayoutEffect(() => {
    if (!start.menu) return;
    const anchor = root.current?.querySelector<HTMLElement>(`[data-anchor="${start.menu}"]`);
    if (!anchor) return;
    // A row's actions sit at the table's far end: bring them into its scrolled box.
    const box = anchor.closest<HTMLElement>('[data-part="scroller"]');
    if (box) box.scrollLeft = box.scrollWidth;
    setMenu({ id: start.menu, anchor, byReader: false });
    // Only on the first draw.
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);

  const openMenu = (id: string, anchor: HTMLElement, byReader = true) =>
    setMenu((now) => (now?.id === id ? null : { id, anchor, byReader }));
  const closeMenu = (back: boolean) => {
    if (back) menu?.anchor.focus();
    setMenu(null);
  };

  const go = (next: View) => {
    setView(next);
    setSelected(new Set());
    setDrawer(false);
  };

  const sortBy = (key: SortKey) =>
    setSort((now) => (now.key === key ? { key, desc: !now.desc } : { key, desc: key !== 'name' }));

  const remove = (id: string) => {
    const before = rows;
    const row = rows.find((r) => r.id === id);
    // The row drawn after it, or before it at the end: where focus goes while it is gone.
    const tr = root.current?.querySelector<HTMLElement>(`[data-row="${id}"]`);
    const next = (tr?.nextElementSibling ?? tr?.previousElementSibling) as HTMLElement | null;
    setRows((now) => now.filter((r) => r.id !== id));
    setSelected((now) => {
      const next = new Set(now);
      next.delete(id);
      return next;
    });
    say(`Removed ${row?.name ?? 'the company'}`, {
      undo: before,
      row: id,
      next: next?.dataset.row,
    });
    focusRow(next?.dataset.row);
  };

  const logTouch = (id: string) => {
    setRows((now) =>
      now.map((row) =>
        row.id === id
          ? {
              ...row,
              trend: [...row.trend.slice(0, -1), row.trend[row.trend.length - 1] + 1],
              last: { date: TODAY, kind: 'Note' },
            }
          : row,
      ),
    );
    say(`Logged a touch on ${rows.find((row) => row.id === id)?.name}`);
  };

  const addCompany = () => {
    const id = `new-${Date.now()}`;
    setRows((now) => [blankAccount(id), ...now]);
    setEditing(id);
  };

  const commitName = (id: string, name: string) => {
    const clean = name.trim() || 'Untitled company';
    setRows((now) => now.map((row) => (row.id === id ? { ...row, name: clean } : row)));
    setEditing(null);
    setFresh(id);
    say(`Added ${clean}`);
  };

  const exportCsv = () => {
    const head = ['Company', 'Tags', 'Owner', 'Open deals', 'Pipeline value', 'Win probability'];
    const lines = inView.map((row) =>
      [
        row.name,
        row.tags.join('; '),
        ownerOf(row.owner)?.name ?? '',
        row.openDeals,
        row.value,
        row.win ?? '',
      ]
        .map((cell) => `"${String(cell).replace(/"/g, '""')}"`)
        .join(','),
    );
    const blob = new Blob([[head.join(','), ...lines].join('\n')], { type: 'text/csv' });
    const link = document.createElement('a');
    link.href = URL.createObjectURL(blob);
    link.download = 'companies.csv';
    link.click();
    URL.revokeObjectURL(link.href);
    say(`Exported ${inView.length} companies`);
  };

  // ---- The demo ----------------------------------------------------------------------------------

  const demo = autoplay && !held && playing;
  const dirty = useEffectEvent(
    () =>
      view.kind !== 'all' ||
      sort.key !== 'value' ||
      owner !== null ||
      calcs.sum ||
      calcs.avg ||
      selected.size > 0,
  );
  const reset = useEffectEvent(() => {
    setView(DEFAULTS.view);
    setTab(DEFAULTS.tab);
    setSort(DEFAULTS.sort);
    setOwner(DEFAULTS.owner);
    setStage(DEFAULTS.stage);
    setRecency(DEFAULTS.recency);
    setSelected(new Set());
    setCalcs({ sum: false, avg: false, extra: null });
    setMenu(null);
  });
  const demoClear = useEffectEvent(() => setMenu(null));

  useEffect(() => {
    const stage = root.current;
    const arrow = pointer.current;
    if (!demo || !stage || !arrow) return;
    const find = (name: string) => stage.querySelector<HTMLElement>(`[data-demo="${name}"]`);
    const on = (element: Element | null, fx = 0.5, fy = 0.5): Point => {
      const frame = stage.getBoundingClientRect();
      const scale = frame.width / stage.offsetWidth || 1;
      const rect = element?.getBoundingClientRect() ?? frame;
      return {
        x: (rect.left + rect.width * fx - frame.left) / scale,
        y: (rect.top + rect.height * fy - frame.top) / scale,
      };
    };
    let over: HTMLElement | null = null;
    const stop = runDemo(stage, arrow, async ({ wait, glide, glyph }) => {
      const press = async (name: string, ms: number, after: number, fx = 0.5, fy = 0.5) => {
        const element = find(name);
        if (!element) return;
        const box = element.closest<HTMLElement>('[data-part="scroller"]');
        if (box) {
          const b = box.getBoundingClientRect();
          const r = element.getBoundingClientRect();
          if (r.right > b.right || r.left < b.left) {
            box.scrollBy({ left: r.left - b.left - b.width / 2 + r.width / 2, behavior: 'smooth' });
            await wait(420);
          }
        }
        glyph('arrow');
        await glide(on(element, fx, fy), ms);
        glyph('hand');
        over = element;
        element.dataset.over = '';
        await wait(240);
        const live = find(name) ?? element;
        delete element.dataset.over;
        over = null;
        live.click();
        await wait(after);
      };
      for (;;) {
        if (dirty()) {
          reset();
          await wait(400);
        }
        await wait(900);
        // The likeliest wins first.
        await press('sort', 700, 500, 0.7);
        await press('sort-win', 520, 1300, 0.3);
        // What the book adds up to.
        await press('calc-sum', 700, 700, 0.3);
        await press('calc-avg', 520, 1400, 0.3);
        // The deals that are slipping, and one row's tags.
        await press('nav-slipping', 800, 1500, 0.3);
        await press('more-a12', 700, 1600);
        await press('more-a12', 200, 500);
        // Two of them, measured on their own.
        await press('check-a12', 650, 300);
        await press('check-a3', 420, 1700);
        // Back to everyone, one owner's book.
        await press('nav-all', 750, 700, 0.3);
        await press('owner', 650, 520, 0.7);
        await press('owner-theo', 520, 1900, 0.3);
        glyph('arrow');
        await glide(on(stage, 0.82, 0.92), 800);
        await wait(1800);
      }
    });
    return () => {
      stop();
      if (over) delete over.dataset.over;
      stage.querySelectorAll<HTMLElement>(':popover-open').forEach((open) => open.hidePopover());
      demoClear();
    };
  }, [demo, root]);

  // ---- Drawing -----------------------------------------------------------------------------------

  const tabInfo = TABS.find((t) => t.id === tab)!;
  const allChecked = inView.length > 0 && inView.every((row) => selected.has(row.id));
  const someChecked = inView.some((row) => selected.has(row.id));
  const toggleRow = (id: string) =>
    setSelected((now) => {
      const next = new Set(now);
      if (next.has(id)) next.delete(id);
      else next.add(id);
      return next;
    });

  const title =
    view.kind === 'all'
      ? 'Companies'
      : view.kind === 'team'
        ? TEAM_NAME[view.team]
        : view.kind === 'region'
          ? REGION_NAME[view.region]
          : view.kind === 'slipping'
            ? 'Slipping Deals'
            : view.name;

  const same = (a: View, b: View) => JSON.stringify(a) === JSON.stringify(b);
  const navItem = (
    icon: IconName | { dot: string },
    label: string,
    target: View | (() => void),
    options: { count?: number; demo?: string; current?: boolean } = {},
  ) => {
    const current = options.current ?? (typeof target !== 'function' && same(view, target));
    return (
      <li key={label}>
        <button
          type="button"
          className={styles.navItem}
          data-part="nav-item"
          aria-current={current ? 'page' : undefined}
          data-demo={options.demo}
          onClick={() => (typeof target === 'function' ? target() : go(target))}
        >
          {typeof icon === 'string' ? (
            <Icon name={icon} className={styles.navIcon} />
          ) : (
            <span className={styles.navDot} data-tone={icon.dot} aria-hidden="true" />
          )}
          <span className={styles.navLabel}>{label}</span>
          {options.count !== undefined && <span className={styles.navCount}>{options.count}</span>}
        </button>
      </li>
    );
  };

  const header = (key: SortKey, label: string, className?: string) => {
    const active = sort.key === key;
    return (
      <th
        scope="col"
        className={className}
        aria-sort={active ? (sort.desc ? 'descending' : 'ascending') : undefined}
      >
        <button type="button" className={styles.sortHead} onClick={() => sortBy(key)}>
          {label}
          {active && (
            <Icon
              name={sort.desc ? 'arrowDown' : 'arrowUp'}
              className={styles.sortIcon}
              width={2}
            />
          )}
        </button>
      </th>
    );
  };

  const filter = (id: string, caption: string, value: ReactNode, demo: string, pressed = false) => (
    <button
      type="button"
      className={styles.filter}
      aria-haspopup="menu"
      aria-expanded={menu?.id === id}
      data-active={pressed || undefined}
      data-demo={demo}
      data-anchor={id}
      data-part={`filter-${id}`}
      onClick={(event) => openMenu(id, event.currentTarget)}
    >
      <span className={styles.filterCaption}>{caption}</span>
      <span className={styles.filterValue}>{value}</span>
      <Icon name="chevronDown" className={styles.filterChevron} width={2} />
    </button>
  );

  const calcCell = (
    on: boolean,
    label: string,
    value: ReactNode,
    onPress: () => void,
    demo: string,
  ) => (
    <button
      type="button"
      className={styles.calc}
      data-on={on || undefined}
      data-demo={demo}
      data-part="calc"
      aria-pressed={on}
      onClick={onPress}
    >
      {on ? (
        <>
          <span className={styles.calcLabel}>{label}</span>
          <span className={styles.calcValue}>{value}</span>
        </>
      ) : (
        <>
          <Icon name="plus" className={styles.calcPlus} width={2} />
          {label}
        </>
      )}
    </button>
  );

  const sidebar = (
    <nav
      className={styles.sidebar}
      aria-label="Pipeline"
      data-open={drawer || undefined}
      data-part="sidebar"
    >
      <div className={styles.brand} data-part="brand">
        <Mark className={styles.mark} />
        <span className={styles.brandText}>
          <span className={styles.brandName}>{workspace}</span>
          <span className={styles.brandSub}>Account pipeline</span>
        </span>
        <button
          type="button"
          className={styles.drawerClose}
          aria-label="Close menu"
          onClick={() => setDrawer(false)}
        >
          <Icon name="close" />
        </button>
      </div>
      <ul className={styles.navList}>
        {navItem('building', 'Companies', { kind: 'all' }, { count: rows.length, demo: 'nav-all' })}
        {navItem(
          'board',
          'Deals Board',
          () => {
            go({ kind: 'all' });
            setTab('deals');
          },
          { current: false },
        )}
        {navItem(
          'chart',
          'Forecast',
          () => {
            go({ kind: 'all' });
            setTab('forecast');
          },
          { count: 9, current: false },
        )}
        {navItem(
          'list',
          'Activities',
          () => {
            go({ kind: 'all' });
            setSort({ key: 'last', desc: true });
          },
          { current: false },
        )}
        {navItem('contacts', 'Contacts', { kind: 'empty', name: 'Contacts' }, { count: 38 })}
        {navItem('mail', 'Email Sequences', { kind: 'empty', name: 'Email Sequences' })}
      </ul>
      <p className={styles.navHeading}>Team</p>
      <ul className={styles.navList}>
        {navItem('target', TEAM_NAME.strategic, { kind: 'team', team: 'strategic' })}
        {navItem('compass', TEAM_NAME.mid, { kind: 'team', team: 'mid' })}
        {navItem('users', TEAM_NAME.sdr, { kind: 'team', team: 'sdr' })}
      </ul>
      <p className={styles.navHeading}>Reporting</p>
      <ul className={styles.navList}>
        {navItem(
          'forecast',
          'Q4 Forecast',
          () => {
            go({ kind: 'all' });
            setTab('forecast');
          },
          { current: false },
        )}
        {navItem(
          'alert',
          'Slipping Deals',
          { kind: 'slipping' },
          {
            count: slipping,
            demo: 'nav-slipping',
          },
        )}
      </ul>
      <p className={styles.navHeading}>Pipelines</p>
      <ul className={styles.navList}>
        {(Object.keys(REGION_NAME) as Region[]).map((region) =>
          navItem({ dot: REGION_DOT[region] }, REGION_NAME[region], { kind: 'region', region }),
        )}
      </ul>
      <div className={styles.navFoot}>
        <ul className={styles.navList}>
          {navItem('userPlus', 'Invite Teammates', { kind: 'empty', name: 'Invite Teammates' })}
          {navItem('help', 'Help', { kind: 'empty', name: 'Help' })}
        </ul>
        <div className={styles.trial} data-part="trial">
          <span className={styles.trialText}>
            <strong>14 Days</strong>
            <span>Left on trial</span>
          </span>
          <button
            type="button"
            className={styles.trialButton}
            onClick={() => say('Billing opens in Settings')}
          >
            <Icon name="calendar" />
            Add Billing
          </button>
        </div>
      </div>
    </nav>
  );

  const ownerName = owner ? (ownerOf(owner)?.name ?? 'Owner') : 'All Owners';

  return (
    <div
      ref={root}
      className={`${styles.root} ${className}`}
      data-part="stage"
      data-color-scheme={colorScheme}
      onPointerDownCapture={take}
      onKeyDownCapture={take}
      onWheel={take}
      onPointerMove={(event) => {
        if (event.pointerType !== 'touch') take();
      }}
    >
      <div className={styles.window} data-part="window">
        {sidebar}
        {drawer && (
          <button
            type="button"
            className={styles.scrim}
            aria-label="Close menu"
            tabIndex={-1}
            onClick={() => setDrawer(false)}
          />
        )}

        <main className={styles.main} aria-labelledby={`${uid}-title`}>
          <header className={styles.top} data-part="header">
            <button
              type="button"
              className={styles.menuButton}
              aria-label="Open menu"
              aria-expanded={drawer}
              onClick={() => setDrawer(true)}
            >
              <Icon name="menu" />
            </button>
            <h2 id={`${uid}-title`} className={styles.title}>
              {title}
            </h2>
            <span className={styles.status}>
              <span className={styles.statusDot} aria-hidden="true" />
              Active
            </span>
            <div className={styles.topEnd}>
              <div className={styles.search} data-open={searching || query ? '' : undefined}>
                <button
                  type="button"
                  className={styles.round}
                  aria-label="Search companies"
                  aria-expanded={searching}
                  onClick={() => {
                    setSearching(true);
                    requestAnimationFrame(() => search.current?.focus());
                  }}
                >
                  <Icon name="search" />
                </button>
                <input
                  ref={search}
                  className={styles.searchField}
                  type="search"
                  placeholder="Search companies"
                  aria-label="Search companies"
                  value={query}
                  tabIndex={searching || query ? 0 : -1}
                  onChange={(event) => setQuery(event.target.value)}
                  onBlur={() => setSearching(false)}
                  onKeyDown={(event) => {
                    if (event.key === 'Escape') {
                      setQuery('');
                      setSearching(false);
                    }
                  }}
                />
              </div>
              <button
                type="button"
                className={styles.round}
                aria-label="Notifications, 3 new"
                data-anchor="bell"
                aria-haspopup="menu"
                aria-expanded={menu?.id === 'bell'}
                onClick={(event) => openMenu('bell', event.currentTarget)}
              >
                <Icon name="bell" />
                <span className={styles.bellDot} aria-hidden="true" />
              </button>
              <span className={styles.user}>
                <Avatar owner={user} size={24} />
                <span className={styles.userName}>{user.name}</span>
              </span>
            </div>
          </header>

          <div className={styles.tabs} role="tablist" aria-label="Measure" data-part="tabs">
            {TABS.map((t) => (
              <button
                key={t.id}
                type="button"
                role="tab"
                aria-selected={tab === t.id}
                aria-controls={`${uid}-table`}
                className={styles.tab}
                onClick={() => setTab(t.id)}
                onKeyDown={(event) => {
                  if (event.key !== 'ArrowRight' && event.key !== 'ArrowLeft') return;
                  const i = TABS.findIndex((x) => x.id === tab);
                  const next =
                    TABS[(i + (event.key === 'ArrowRight' ? 1 : TABS.length - 1)) % TABS.length];
                  setTab(next.id);
                  (
                    event.currentTarget.parentElement?.querySelector(
                      `[data-tab="${next.id}"]`,
                    ) as HTMLElement
                  )?.focus();
                }}
                tabIndex={tab === t.id ? 0 : -1}
                data-tab={t.id}
              >
                {t.label}
              </button>
            ))}
          </div>

          <div className={styles.toolbar} data-part="toolbar">
            <div className={styles.filters}>
              {filter('sort', 'Sort by', SORTS.find((s) => s.id === sort.key)?.label, 'sort')}
              {filter('owner', 'Filter', ownerName, 'owner', owner !== null)}
              {filter('stage', 'Stage', stage ?? 'Any', 'stage', stage !== null)}
              {filter('recency', 'Last Activity', `${recency} Days`, 'recency', recency !== 90)}
            </div>
            <div className={styles.actions}>
              <button type="button" className={styles.button} onClick={exportCsv}>
                <Icon name="export" />
                <span className={styles.exportLabel}>Export</span>
              </button>
              <button type="button" className={styles.primary} onClick={addCompany}>
                <Icon name="plus" width={2} />
                New Company
              </button>
            </div>
          </div>

          {view.kind === 'empty' ? (
            <div className={styles.empty} data-part="empty">
              <Icon name="spark" className={styles.emptyIcon} />
              <p className={styles.emptyTitle}>Nothing in {view.name} yet</p>
              <p className={styles.emptyText}>It fills in as your team works the accounts.</p>
              <button type="button" className={styles.button} onClick={() => go({ kind: 'all' })}>
                Back to Companies
              </button>
            </div>
          ) : (
            <div className={styles.scroller} data-part="scroller">
              <table
                className={styles.table}
                id={`${uid}-table`}
                aria-labelledby={`${uid}-title`}
                data-part="table"
              >
                <thead>
                  <tr>
                    <th scope="col" className={styles.checkCol}>
                      <button
                        type="button"
                        role="checkbox"
                        className={styles.check}
                        aria-checked={allChecked ? true : someChecked ? 'mixed' : false}
                        aria-label="Select all companies in view"
                        onClick={() =>
                          setSelected(allChecked ? new Set() : new Set(inView.map((row) => row.id)))
                        }
                      >
                        <Icon name={someChecked && !allChecked ? 'minus' : 'check'} width={3} />
                      </button>
                    </th>
                    {header('name', 'Companies', styles.nameCol)}
                    <th scope="col">Segment &amp; Stage</th>
                    <th scope="col">Account Owner</th>
                    {header('deals', 'Open Deals', styles.num)}
                    {header('value', tabInfo.column, styles.num)}
                    {header('win', 'Win Probability')}
                    <th scope="col">Activity Trend</th>
                    {header('last', 'Last Interaction')}
                    <th scope="col" className={styles.moreCol}>
                      <span className={styles.srOnly}>Actions</span>
                    </th>
                  </tr>
                </thead>
                <tbody>
                  {inView.map((row) => {
                    const lead = ownerOf(row.owner);
                    const co = (row.coOwners ?? []).map(ownerOf).filter((p): p is Owner => !!p);
                    const checked = selected.has(row.id);
                    return (
                      <tr
                        key={row.id}
                        data-selected={checked || undefined}
                        data-fresh={fresh === row.id || undefined}
                        data-part="row"
                        data-row={row.id}
                      >
                        <td className={styles.checkCol}>
                          <button
                            type="button"
                            role="checkbox"
                            className={styles.check}
                            aria-checked={checked}
                            aria-label={`Select ${row.name || 'new company'}`}
                            data-demo={`check-${row.id}`}
                            onClick={() => toggleRow(row.id)}
                          >
                            <Icon name="check" width={3} />
                          </button>
                        </td>
                        <th scope="row" className={styles.nameCol}>
                          {editing === row.id ? (
                            <input
                              className={styles.nameField}
                              aria-label="New company name"
                              placeholder="Company name"
                              defaultValue={held ? start.naming : undefined}
                              ref={(field) => {
                                if (!held) field?.focus({ preventScroll: true });
                              }}
                              onBlur={(event) => commitName(row.id, event.currentTarget.value)}
                              onKeyDown={(event) => {
                                if (event.key === 'Enter') event.currentTarget.blur();
                                if (event.key === 'Escape') {
                                  setRows((now) => now.filter((r) => r.id !== row.id));
                                  setEditing(null);
                                }
                              }}
                            />
                          ) : (
                            <button
                              type="button"
                              className={styles.name}
                              onClick={() => onOpenAccount?.(row)}
                            >
                              {row.name}
                            </button>
                          )}
                        </th>
                        <td>
                          <StageTags tags={row.tags} demo={`more-${row.id}`} />
                        </td>
                        <td>
                          <OwnerCell
                            owner={lead}
                            coOwners={co}
                            onAssign={(button) => openMenu(`assign:${row.id}`, button)}
                          />
                        </td>
                        <td className={styles.num}>{row.openDeals}</td>
                        <td className={styles.num}>
                          <span className={styles.money}>
                            <span className={styles.dollar}>$</span>
                            {money(amountOf(row, tab))}
                          </span>
                        </td>
                        <td>
                          <WinMeter value={row.win} before={row.winBefore} />
                        </td>
                        <td>
                          <ActivityBars values={row.trend} />
                        </td>
                        <td>
                          <span className={styles.last}>
                            <Icon name="calendar" className={styles.lastIcon} />
                            <span className={styles.lastDate}>{shortDate(row.last.date)}</span>
                            <span className={styles.lastKind}>{row.last.kind}</span>
                          </span>
                        </td>
                        <td className={styles.moreCol}>
                          <button
                            type="button"
                            className={styles.more}
                            aria-label={`Actions for ${row.name}`}
                            aria-haspopup="menu"
                            aria-expanded={menu?.id === `row:${row.id}`}
                            data-anchor={`row:${row.id}`}
                            onClick={(event) => openMenu(`row:${row.id}`, event.currentTarget)}
                          >
                            <Icon name="more" width={2.6} />
                          </button>
                        </td>
                      </tr>
                    );
                  })}
                  {inView.length === 0 && (
                    <tr>
                      <td colSpan={10} className={styles.none}>
                        No companies match these filters.
                      </td>
                    </tr>
                  )}
                </tbody>
              </table>
            </div>
          )}

          <footer className={styles.footer} data-part="footer">
            <span className={styles.inView} aria-live="polite">
              <strong>{chosen.length || inView.length}</strong>
              {chosen.length ? ' selected' : ' Companies in view'}
              {chosen.length > 0 && (
                <button
                  type="button"
                  className={styles.clear}
                  onClick={() => setSelected(new Set())}
                >
                  Clear
                </button>
              )}
            </span>
            {calcCell(
              calcs.sum,
              tabInfo.total,
              tab === 'deals'
                ? shortMoney(total / Math.max(1, measured.length))
                : shortMoney(total),
              () => setCalcs((now) => ({ ...now, sum: !now.sum })),
              'calc-sum',
            )}
            {calcCell(
              calcs.avg,
              'Avg win probability',
              avgWin === null ? '—' : `${avgWin}%`,
              () => setCalcs((now) => ({ ...now, avg: !now.avg })),
              'calc-avg',
            )}
            {calcs.extra ? (
              calcCell(
                true,
                CALCS.find((c) => c.id === calcs.extra)!.label,
                extraValue(calcs.extra),
                () => setCalcs((now) => ({ ...now, extra: null })),
                'calc-extra',
              )
            ) : (
              <button
                type="button"
                className={styles.calc}
                aria-haspopup="menu"
                aria-expanded={menu?.id === 'calc'}
                data-anchor="calc"
                onClick={(event) => openMenu('calc', event.currentTarget)}
              >
                <Icon name="plus" className={styles.calcPlus} width={2} />
                Add Calculation
              </button>
            )}
          </footer>
        </main>
      </div>

      {menu && (
        <Menu
          anchor={menu.anchor}
          label={menuLabel(menu.id)}
          align={menu.id === 'bell' || menu.id.startsWith('row:') ? 'end' : 'start'}
          takeFocus={menu.byReader}
          onClose={closeMenu}
        >
          {menu.id === 'sort' &&
            SORTS.map((s) => (
              <MenuItem
                key={s.id}
                radio
                checked={sort.key === s.id}
                demo={`sort-${s.id}`}
                onSelect={() => {
                  setSort({ key: s.id, desc: s.id !== 'name' });
                  closeMenu(true);
                }}
              >
                {s.id === 'value' ? tabInfo.column : s.label}
              </MenuItem>
            ))}
          {menu.id === 'owner' && (
            <>
              <MenuItem
                radio
                checked={owner === null}
                demo="owner-all"
                onSelect={() => {
                  setOwner(null);
                  closeMenu(true);
                }}
              >
                All Owners
              </MenuItem>
              {(['strategic', 'mid', 'sdr'] as Team[]).map((team) => (
                <div key={team} role="group" aria-label={TEAM_NAME[team]}>
                  <MenuLabel>{TEAM_NAME[team]}</MenuLabel>
                  {owners
                    .filter((p) => p.team === team)
                    .map((p) => (
                      <MenuItem
                        key={p.id}
                        radio
                        checked={owner === p.id}
                        demo={`owner-${p.id}`}
                        lead={<Avatar owner={p} size={18} />}
                        trail={
                          rows.filter((r) => r.owner === p.id || r.coOwners?.includes(p.id)).length
                        }
                        onSelect={() => {
                          setOwner(p.id);
                          closeMenu(true);
                        }}
                      >
                        {p.name}
                      </MenuItem>
                    ))}
                </div>
              ))}
            </>
          )}
          {menu.id === 'stage' && (
            <>
              <MenuItem
                radio
                checked={stage === null}
                onSelect={() => {
                  setStage(null);
                  closeMenu(true);
                }}
              >
                Any
              </MenuItem>
              {TAGS.map((tag) => (
                <MenuItem
                  key={tag}
                  radio
                  checked={stage === tag}
                  trail={rows.filter((r) => r.tags.includes(tag)).length}
                  onSelect={() => {
                    setStage(tag);
                    closeMenu(true);
                  }}
                >
                  {tag}
                </MenuItem>
              ))}
            </>
          )}
          {menu.id === 'recency' &&
            RECENCY.map((days) => (
              <MenuItem
                key={days}
                radio
                checked={recency === days}
                onSelect={() => {
                  setRecency(days);
                  closeMenu(true);
                }}
              >
                Last {days} days
              </MenuItem>
            ))}
          {menu.id === 'calc' &&
            CALCS.map((c) => (
              <MenuItem
                key={c.id}
                onSelect={() => {
                  setCalcs((now) => ({ ...now, extra: c.id }));
                  closeMenu(false);
                }}
              >
                {c.label}
              </MenuItem>
            ))}
          {menu.id === 'bell' &&
            rows
              .filter(isSlipping)
              .slice(0, 3)
              .map((row) => (
                <MenuItem
                  key={row.id}
                  lead={<Icon name="alert" className={styles.menuAlert} />}
                  onSelect={() => {
                    go({ kind: 'slipping' });
                    closeMenu(false);
                  }}
                >
                  {row.name} is slipping
                </MenuItem>
              ))}
          {menu.id.startsWith('row:') && (
            <>
              <MenuItem
                lead={<Icon name="note" className={styles.menuIcon} />}
                onSelect={() => {
                  logTouch(menu.id.slice(4));
                  closeMenu(true);
                }}
              >
                Log a touch
              </MenuItem>
              <MenuItem
                tone="danger"
                lead={<Icon name="trash" className={styles.menuIcon} />}
                onSelect={() => {
                  remove(menu.id.slice(4));
                  closeMenu(false);
                }}
              >
                Remove
              </MenuItem>
            </>
          )}
          {menu.id.startsWith('assign:') &&
            owners.map((p) => (
              <MenuItem
                key={p.id}
                lead={<Avatar owner={p} size={18} />}
                onSelect={() => {
                  const id = menu.id.slice(7);
                  setRows((now) => now.map((r) => (r.id === id ? { ...r, owner: p.id } : r)));
                  say(`${p.name} owns it now`);
                  closeMenu(false);
                }}
              >
                {p.name}
              </MenuItem>
            ))}
        </Menu>
      )}

      {toast && (
        <div
          key={toast.n}
          className={styles.toast}
          role="status"
          onKeyDown={(event) => {
            if (event.key !== 'Escape') return;
            // Its button goes with it: focus moves to the row after the one removed.
            if (toast.undo) focusRow(toast.next);
            setToast(null);
          }}
        >
          <span>{toast.text}</span>
          {toast.undo && (
            <button
              type="button"
              className={styles.toastUndo}
              onClick={() => {
                setRows(toast.undo!);
                setToast(null);
                // Its button goes with it: focus moves to the row put back.
                focusRow(toast.row);
              }}
            >
              Undo
            </button>
          )}
        </div>
      )}

      <div className={styles.pointerLayer}>
        <DemoPointer
          ref={pointer}
          className={styles.pointer}
          arrowClass={styles.arrow}
          handClass={styles.hand}
        />
      </div>
    </div>
  );
}

/** The id of the held new company (defaultState.naming). */
const NAMING = 'new-company';

/** A company just added: no owner, no deals, no score yet. */
function blankAccount(id: string): Account {
  return {
    id,
    name: '',
    region: 'na',
    tags: ['New logo'],
    owner: null,
    openDeals: 0,
    value: 0,
    win: null,
    trend: Array(12).fill(0),
    last: { date: TODAY, kind: 'Note' },
  };
}

function menuLabel(id: string) {
  if (id === 'sort') return 'Sort by';
  if (id === 'owner') return 'Account owner';
  if (id === 'stage') return 'Stage';
  if (id === 'recency') return 'Last activity';
  if (id === 'calc') return 'Add calculation';
  if (id === 'bell') return 'Notifications';
  if (id.startsWith('assign:')) return 'Assign owner';
  return 'Company actions';
}
```

### account-pipeline/cells.tsx

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import { useId, useRef, type ReactNode, type ToggleEvent } from 'react';
import { SWING, TAG_TONE, initials, shortDate, type Owner, type Tag } from './data';
import { FaceArt, Icon } from './glyphs';
import styles from './account-pipeline.module.css';
import { OWNER_PHOTOS, portraitSet } from './portraits';

/*
 * The table's cells, each usable on its own: the win probability meter, the activity bars, the
 * segment and stage tags, and the account owner. Each one reads its data and draws what stands
 * out (a swing in the odds, a spike or a cooling in activity, a tag that signals risk, an owner
 * who is away) without being told. CellColumn shows a column of them outside the table.
 */

// ---- Win probability ------------------------------------------------------------------------------

export type WinBand = 'low' | 'mid' | 'high';

/** Under 35 is low, under 60 mid, the rest high. */
export const bandOf = (value: number): WinBand =>
  value < 35 ? 'low' : value < 60 ? 'mid' : 'high';

const BAND_WORD: Record<WinBand, string> = { low: 'at risk', mid: 'in play', high: 'likely' };

/**
 * The win probability as a row of segments and its figure.
 *
 * - `scale` (the table's) colours each segment by where it sits, red to amber to green, so a
 *   longer fill reaches the greener end; `band` paints the whole fill in its band's colour, so a
 *   low one reads red at a glance.
 * - With `before` (the figure two weeks ago) a swing of SWING points or more is flagged: the
 *   segments lost stay as red outlines, the ones gained glow, and a chip gives the change.
 * - Without a figure (null), the track is empty and says No score.
 */
export function WinMeter({
  value,
  before,
  tone = 'scale',
  segments = 20,
}: {
  value: number | null;
  before?: number | null;
  tone?: 'scale' | 'band';
  segments?: number;
}) {
  if (value === null)
    return (
      <span className={styles.win} data-empty="" data-part="win">
        <span className={styles.winTrack} aria-hidden="true">
          {Array.from({ length: segments }, (_, i) => (
            <span key={i} className={styles.seg} />
          ))}
        </span>
        <span className={styles.winNone}>No score</span>
      </span>
    );

  const filled = Math.round((value / 100) * segments);
  const swing = before != null && Math.abs(value - before) >= SWING ? value - before : 0;
  const was = swing ? Math.round((before! / 100) * segments) : filled;
  const band = bandOf(value);
  const fill = (i: number) => {
    if (tone === 'band') return band;
    const at = (i + 0.5) / segments;
    return at < 0.3 ? 'low' : at < 0.6 ? 'mid' : 'high';
  };

  return (
    <span className={styles.win} data-tone={tone} data-band={band} data-part="win">
      <span className={styles.winTrack} aria-hidden="true">
        {Array.from({ length: segments }, (_, i) => (
          <span
            key={i}
            className={styles.seg}
            data-fill={i < filled ? fill(i) : undefined}
            data-lost={swing < 0 && i >= filled && i < was ? '' : undefined}
            data-gained={swing > 0 && i >= was && i < filled ? '' : undefined}
          />
        ))}
      </span>
      <span className={styles.winValue} aria-hidden="true">
        {value}%
      </span>
      {swing !== 0 && (
        <span className={styles.winSwing} data-dir={swing < 0 ? 'down' : 'up'} aria-hidden="true">
          <Icon name={swing < 0 ? 'arrowDown' : 'arrowUp'} width={2.4} />
          {Math.abs(swing)}
        </span>
      )}
      <span className={styles.srOnly}>
        {`${value}% win probability, ${BAND_WORD[band]}`}
        {swing !== 0 && `, ${swing < 0 ? 'down' : 'up'} ${Math.abs(swing)} points in two weeks`}
      </span>
    </span>
  );
}

// ---- Activity trend -------------------------------------------------------------------------------

export type TrendReading = {
  kind: 'steady' | 'rising' | 'cooling' | 'quiet';
  /** The week of an unusual burst, if any. */
  spike: number | null;
  /** Weeks without a touch, at the end. */
  quietWeeks: number;
};

const mean = (values: number[]) =>
  values.length ? values.reduce((sum, v) => sum + v, 0) / values.length : 0;

/** What a run of weekly touches says: a burst, a quiet end, cooling or rising. */
export function readTrend(values: number[]): TrendReading {
  let quietWeeks = 0;
  for (let i = values.length - 1; i >= 0 && values[i] === 0; i -= 1) quietWeeks += 1;
  let spike: number | null = null;
  values.forEach((v, i) => {
    const others = values.filter((_, j) => j !== i);
    const m = mean(others);
    const sd = Math.sqrt(mean(others.map((o) => (o - m) ** 2)));
    if (v >= 6 && v >= m + 3 * sd && v >= m * 2.5 && (spike === null || v > values[spike]))
      spike = i;
  });
  const calm = values.filter((_, i) => i !== spike);
  const head = mean(calm.slice(0, Math.max(1, calm.length - 3)));
  const tail = mean(values.slice(-3));
  const kind =
    quietWeeks >= 2
      ? 'quiet'
      : head > 0 && tail <= head * 0.5
        ? 'cooling'
        : tail >= Math.max(1, mean(values.slice(0, 6))) * 1.6
          ? 'rising'
          : 'steady';
  return { kind, spike, quietWeeks };
}

const TREND_NOTE = {
  steady: 'Steady',
  rising: 'Rising',
  cooling: 'Cooling',
  quiet: 'Quiet',
};

/**
 * Touches a week as a row of small bars, the latest at the right. Weeks at or over the run's
 * median are bright, the others dim. What readTrend finds is drawn on the bars: a burst in amber
 * with a dot over it, a cooling end in red, quiet weeks as flat dashes. `note` adds the reading
 * as a word beside the bars.
 */
export function ActivityBars({
  values,
  note = false,
  height = 18,
}: {
  values: number[];
  note?: boolean;
  /** The tallest bar, in px. */
  height?: number;
}) {
  const reading = readTrend(values);
  const max = Math.max(1, ...values);
  const sorted = [...values].sort((a, b) => a - b);
  const median = sorted[Math.floor(sorted.length / 2)];
  const last = values.length - 1;
  const tone = (v: number, i: number) => {
    if (i === reading.spike) return 'spike';
    if (reading.kind === 'quiet' && i > last - reading.quietWeeks) return 'quiet';
    if (reading.kind === 'cooling' && i > last - 3) return 'cool';
    if (v === 0) return 'quiet';
    return v >= median ? 'bright' : 'dim';
  };
  const words =
    reading.kind === 'quiet'
      ? `no touches in ${reading.quietWeeks} weeks`
      : `${values[last]} touches last week, ${TREND_NOTE[reading.kind].toLowerCase()}`;
  const label =
    reading.kind === 'quiet'
      ? `Quiet ${reading.quietWeeks}w`
      : reading.spike !== null && reading.kind === 'steady'
        ? `Spike wk ${reading.spike + 1}`
        : TREND_NOTE[reading.kind];

  return (
    <span className={styles.trend} data-kind={reading.kind} data-part="activity">
      <span
        className={styles.trendBars}
        style={{ ['--trend-h' as string]: `${height}px` }}
        aria-hidden="true"
      >
        {values.map((v, i) => (
          <span
            key={i}
            className={styles.bar}
            data-tone={tone(v, i)}
            style={{ ['--h' as string]: v === 0 ? 0 : v / max }}
          />
        ))}
      </span>
      {note && (
        <span
          className={styles.trendNote}
          data-kind={reading.spike !== null && reading.kind === 'steady' ? 'spike' : reading.kind}
          aria-hidden="true"
        >
          {label}
        </span>
      )}
      <span className={styles.srOnly}>
        {`Activity: ${words}`}
        {reading.spike !== null &&
          `, a burst of ${values[reading.spike]} in week ${reading.spike + 1}`}
      </span>
    </span>
  );
}

// ---- Segment and stage ----------------------------------------------------------------------------

/** One tag, in its tone. Churn risk carries a warning sign. */
export function TagChip({ tag }: { tag: Tag }) {
  return (
    <span className={styles.tag} data-tone={TAG_TONE[tag]}>
      {tag === 'Churn risk' && <Icon name="alert" className={styles.tagIcon} width={2.2} />}
      {tag}
    </span>
  );
}

/**
 * The account's segment and the stages of its deals, as tags. Past `max`, a +N button opens the
 * rest in a popover (the top layer, so the table's scrolling never clips it).
 */
export function StageTags({
  tags,
  max = 2,
  demo,
}: {
  tags: Tag[];
  max?: number;
  /** A data-demo name for the +N button, for a scripted demo to find it. */
  demo?: string;
}) {
  const id = useId();
  const more = useRef<HTMLButtonElement>(null);
  const shown = tags.slice(0, max);
  const hidden = tags.slice(max);

  // Placed under its button, in the viewport's px, each time it opens.
  const place = (event: ToggleEvent<HTMLDivElement>) => {
    if (event.newState !== 'open' || !more.current) return;
    const at = more.current.getBoundingClientRect();
    const box = event.currentTarget;
    const left = Math.min(at.left, window.innerWidth - box.offsetWidth - 8);
    const below = at.bottom + 6;
    const top =
      below + box.offsetHeight > window.innerHeight - 8 ? at.top - box.offsetHeight - 6 : below;
    box.style.left = `${Math.max(8, left)}px`;
    box.style.top = `${top}px`;
    // It stays where it was placed, so a scroll anywhere closes it.
    const close = () => box.hidePopover();
    window.addEventListener('scroll', close, { capture: true, once: true, passive: true });
    box.addEventListener(
      'toggle',
      () => window.removeEventListener('scroll', close, { capture: true }),
      { once: true },
    );
  };

  return (
    <span className={styles.tags} data-part="tags">
      {shown.map((tag) => (
        <TagChip key={tag} tag={tag} />
      ))}
      {hidden.length > 0 && (
        <>
          <button
            ref={more}
            type="button"
            className={styles.tagMore}
            popoverTarget={id}
            aria-label={`${hidden.length} more: ${hidden.join(', ')}`}
            data-part="tag-more"
            data-demo={demo}
          >
            +{hidden.length}
          </button>
          <div id={id} popover="auto" className={styles.tagPopover} onToggle={place}>
            <span className={styles.tagPopoverTitle}>All tags</span>
            <span className={styles.tagPopoverList}>
              {tags.map((tag) => (
                <TagChip key={tag} tag={tag} />
              ))}
            </span>
          </div>
        </>
      )}
    </span>
  );
}

// ---- Account owner --------------------------------------------------------------------------------

/** A tint for an initials avatar, picked from the name so it stays the same. */
const TINTS = ['#c7d7f7', '#f5d3a6', '#cfe8c8', '#ecc8e4', '#d5cdf6', '#f3c9c4'];
const tintOf = (name: string) =>
  TINTS[[...name].reduce((sum, ch) => sum + ch.charCodeAt(0), 0) % TINTS.length];

/** An owner's face, or their initials on a tint when there is no drawing. */
export function Avatar({ owner, size = 22 }: { owner: Owner; size?: number }) {
  const photo = owner.photo ?? OWNER_PHOTOS[owner.id];
  return (
    <span
      className={styles.avatar}
      style={{ ['--size' as string]: `${size}px`, ['--tint' as string]: tintOf(owner.name) }}
      data-away={owner.away ? '' : undefined}
      aria-hidden="true"
    >
      {photo ? (
        <img
          className={styles.face}
          src={photo}
          srcSet={!owner.photo ? portraitSet(photo) : undefined}
          sizes={`${size}px`}
          width={size}
          height={size}
          alt=""
          decoding="async"
        />
      ) : owner.face ? (
        <FaceArt face={owner.face} className={styles.face} />
      ) : (
        <span className={styles.initials}>{initials(owner.name)}</span>
      )}
    </span>
  );
}

/**
 * Who owns the account: their face and name. Co-owners stack behind the first face and count
 * after the name; an owner who is away gets a dot and an Away chip with the day they are back.
 * With no owner, a dashed ring says so, and is a button when `onAssign` is given.
 */
export function OwnerCell({
  owner,
  coOwners = [],
  onAssign,
}: {
  owner: Owner | null;
  coOwners?: Owner[];
  /** Gets the button, to anchor a menu of owners to it. */
  onAssign?: (button: HTMLButtonElement) => void;
}) {
  if (!owner) {
    const body = (
      <>
        <span className={styles.avatarEmpty} aria-hidden="true">
          <Icon name="plus" width={2.2} />
        </span>
        Assign owner
      </>
    );
    return onAssign ? (
      <button
        type="button"
        className={styles.owner}
        data-part="owner"
        data-empty=""
        aria-haspopup="menu"
        onClick={(event) => onAssign(event.currentTarget)}
      >
        {body}
      </button>
    ) : (
      <span className={styles.owner} data-empty="" data-part="owner">
        {body}
      </span>
    );
  }
  const everyone = [owner, ...coOwners];
  return (
    <span className={styles.owner} data-part="owner">
      <span className={styles.avatarStack} aria-hidden="true">
        {everyone.slice(0, 3).map((person) => (
          <Avatar key={person.id} owner={person} />
        ))}
      </span>
      <span className={styles.ownerName} aria-hidden="true">
        {owner.name}
      </span>
      {coOwners.length > 0 && (
        <span className={styles.ownerMore} aria-hidden="true">
          +{coOwners.length}
        </span>
      )}
      {owner.away && (
        <span className={styles.away} title={`Back ${shortDate(owner.away)}`} aria-hidden="true">
          Away
        </span>
      )}
      <span className={styles.srOnly}>
        {everyone.map((person) => person.name).join(' and ')}
        {owner.away && `, ${owner.name} is away until ${shortDate(owner.away)}`}
      </span>
    </span>
  );
}

// ---- A column on its own --------------------------------------------------------------------------

/**
 * A column of the table's cells outside the table: its header, then one row per cell, each with a
 * short label at the right. For a side panel, a report, or comparing a cell's variations.
 */
export function CellColumn({
  title,
  rows,
  colorScheme,
  className = '',
}: {
  title: string;
  rows: { label: string; cell: ReactNode }[];
  colorScheme?: 'light' | 'dark' | 'system';
  className?: string;
}) {
  return (
    <div className={`${styles.cellColumn} ${className}`} data-color-scheme={colorScheme}>
      <table className={styles.cellTable}>
        <thead>
          <tr>
            <th scope="col">{title}</th>
            <th scope="col" className={styles.cellLabel}>
              Variation
            </th>
          </tr>
        </thead>
        <tbody>
          {rows.map((row) => (
            <tr key={row.label}>
              <td>{row.cell}</td>
              <td className={styles.cellLabel}>{row.label}</td>
            </tr>
          ))}
        </tbody>
      </table>
    </div>
  );
}
```

### account-pipeline/account-pipeline.module.css

```css
/* Account pipeline (account-pipeline.tsx): a CRM window on a grey stage, near-black by night and
   white by day. A sidebar with the app's mark, the views and a trial card; the main column holds
   the title bar, the tabs, the toolbar of filters, the table and its footer of calculations.

   The table scrolls inside its own box, the checkbox and Companies columns held at its left.
   Under 760 px of stage the sidebar becomes a drawer behind a menu button.

   Colours are the tokens below, light-dark(light, dark) where the two differ: the component takes
   the color-scheme it inherits from the page, or the one its colorScheme prop sets
   (data-color-scheme). The cells (cells.tsx) share them, and CellColumn carries them too. */

.root,
.cellColumn {
  --stage: #e9e9ec;
  --window: #ffffff;
  --sidebar: #f8f8f9;
  --line: #ececef;
  --row-line: #f0f0f2;
  --ink: #18181b;
  --ink-2: #6d6d75;
  --ink-3: #6d6d73;
  --hover: #f4f4f6;
  --current: #ffffff;
  --current-edge: #e4e4e8;
  --row-hover: #fafafb;
  --row-selected: #f6f6f8;
  --chip: #f2f2f4;
  --chip-edge: #e6e6ea;
  --primary: #4f4cf0;
  --primary-ink: #ffffff;
  --primary-text: #4f4cf0;
  --check: #f2c230;
  --check-ink: #1a1400;
  --fresh: #eef0ff;
  --menu: #ffffff;
  --shadow: rgb(0 0 0 / 0.1);
  --veil: rgb(20 20 24 / 0.28);
  /* The win meter and the activity bars. */
  --track: #f1f1f4;
  --seg-empty: #e1e1e6;
  --low: #e5605b;
  --mid: #e5b42c;
  --high: #3fb35a;
  --bar-bright: #3aa653;
  --bar-dim: #a8dbb4;
  --bar-quiet: #cfcfd5;
  /* The tags: fill, edge, text. */
  --blue-bg: #ecf2ff;
  --blue-edge: #cddcfc;
  --blue-ink: #2551c4;
  --violet-bg: #f3eeff;
  --violet-edge: #ded1fd;
  --violet-ink: #6a3fd6;
  --green-bg: #e9f7ee;
  --green-edge: #c4e9d0;
  --green-ink: #1c7a3b;
  --amber-bg: #fdf5de;
  --amber-edge: #f2dfa4;
  --amber-ink: #8a6200;
  --orange-bg: #fff1e5;
  --orange-edge: #fad3b2;
  --orange-ink: #b0540e;
  --red-bg: #fdeeee;
  --red-edge: #f6c9c9;
  --red-ink: #c02626;
  /* The mark, the faces' shirts, the status, the region dots. */
  --mark-tile: #18181b;
  --mark: #ffffff;
  --face-shirt: #3f3f46;
  --active: #22b55c;
  --yellow: #f2c230;
  --pink: #f0508a;
  --violet: #9b6cf5;
  /* The same on both schemes. */
  --focus: #6684f0;
  --pointer: #1c1c1e;
  --pointer-edge: #fff;
  --pointer-shadow: rgb(0 0 0 / 0.3);
  --sans: var(--body, Inter, ui-sans-serif, system-ui, sans-serif);
}
@supports (color: light-dark(#fff, #000)) {
  .root,
  .cellColumn {
    --stage: light-dark(#e9e9ec, #2a2a2d);
    --window: light-dark(#ffffff, #141415);
    --sidebar: light-dark(#f8f8f9, #171718);
    --line: light-dark(#ececef, #252527);
    --row-line: light-dark(#f0f0f2, #202022);
    --ink: light-dark(#18181b, #ececee);
    --ink-2: light-dark(#6d6d75, #8e8e95);
    --ink-3: light-dark(#6d6d73, #89898e);
    --hover: light-dark(#f4f4f6, #1f1f21);
    --current: light-dark(#ffffff, #232325);
    --current-edge: light-dark(#e4e4e8, #323235);
    --row-hover: light-dark(#fafafb, #19191b);
    --row-selected: light-dark(#f6f6f8, #1d1d20);
    --chip: light-dark(#f2f2f4, #232325);
    --chip-edge: light-dark(#e6e6ea, #303033);
    --primary: light-dark(#4f4cf0, #5552f6);
    --primary-text: light-dark(#4f4cf0, #7573f8);
    --check: light-dark(#f2c230, #f5c633);
    --fresh: light-dark(#eef0ff, #1d1d33);
    --menu: light-dark(#ffffff, #1c1c1e);
    --shadow: light-dark(rgb(0 0 0 / 0.1), rgb(0 0 0 / 0.5));
    --veil: light-dark(rgb(20 20 24 / 0.28), rgb(0 0 0 / 0.5));
    --track: light-dark(#f1f1f4, #1d1d1f);
    --seg-empty: light-dark(#e1e1e6, #2d2d30);
    --low: light-dark(#e5605b, #ea7570);
    --mid: light-dark(#e5b42c, #ecc449);
    --high: light-dark(#3fb35a, #5ac46d);
    --bar-bright: light-dark(#3aa653, #4cbb62);
    --bar-dim: light-dark(#a8dbb4, #2c6a3a);
    --bar-quiet: light-dark(#cfcfd5, #3a3a3e);
    --blue-bg: light-dark(#ecf2ff, #19233b);
    --blue-edge: light-dark(#cddcfc, #2b3c63);
    --blue-ink: light-dark(#2551c4, #93b2ff);
    --violet-bg: light-dark(#f3eeff, #251d3d);
    --violet-edge: light-dark(#ded1fd, #42336b);
    --violet-ink: light-dark(#6a3fd6, #bba5ff);
    --green-bg: light-dark(#e9f7ee, #15291b);
    --green-edge: light-dark(#c4e9d0, #234a2d);
    --green-ink: light-dark(#1c7a3b, #72d18c);
    --amber-bg: light-dark(#fdf5de, #2c2410);
    --amber-edge: light-dark(#f2dfa4, #554419);
    --amber-ink: light-dark(#8a6200, #f0c85e);
    --orange-bg: light-dark(#fff1e5, #2f1e10);
    --orange-edge: light-dark(#fad3b2, #5b3818);
    --orange-ink: light-dark(#b0540e, #f6a35d);
    --red-bg: light-dark(#fdeeee, #331616);
    --red-edge: light-dark(#f6c9c9, #5c2525);
    --red-ink: light-dark(#c02626, #ff8d8d);
    --mark-tile: light-dark(#18181b, #f2f2f4);
    --mark: light-dark(#ffffff, #141415);
    --face-shirt: light-dark(#3f3f46, #52525b);
  }
}
.root[data-color-scheme='light'],
.cellColumn[data-color-scheme='light'] {
  color-scheme: light;
}
.root[data-color-scheme='dark'],
.cellColumn[data-color-scheme='dark'] {
  color-scheme: dark;
}
.root[data-color-scheme='system'],
.cellColumn[data-color-scheme='system'] {
  color-scheme: light dark;
}

.root {
  position: relative;
  container-type: inline-size;
  width: 100%;
  padding: 28px;
  overflow: hidden;
  overflow: clip;
  border-radius: 18px;
  background: var(--stage);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}
/* Low specificity, so every part's own colour wins. */
:where(.root, .cellColumn, .tagPopover) :where(button, input) {
  font: inherit;
  color: inherit;
}
:where(.root, .cellColumn, .tagPopover) button {
  cursor: pointer;
}
.root :focus-visible,
.cellColumn :focus-visible,
.tagPopover :focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.root svg,
.cellColumn svg {
  flex: none;
  display: block;
}
.srOnly {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- The window ------------------------------------------------------------------------------- */

.window {
  position: relative;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 640px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--window);
  box-shadow: 0 18px 40px -18px var(--shadow);
}

/* ---- Sidebar ---------------------------------------------------------------------------------- */

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 14px 10px 12px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px 16px;
  margin: 0 -10px 10px;
  padding-inline: 16px;
  border-bottom: 1px solid var(--line);
}
.mark {
  width: 30px;
  height: 30px;
}
.brandText {
  display: grid;
  min-width: 0;
}
.brandName {
  font-size: 14px;
  font-weight: 560;
}
.brandSub {
  color: var(--ink-2);
  font-size: 12px;
}
.drawerClose {
  display: none;
}
.navList {
  display: grid;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.navItem {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--ink-2);
  font-size: 13.5px;
  text-align: left;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}
.navItem:hover {
  background: var(--hover);
  color: var(--ink);
}
.navItem[aria-current='page'] {
  border-color: var(--current-edge);
  background: var(--current);
  color: var(--ink);
  box-shadow: 0 1px 2px var(--shadow);
}
.navIcon {
  width: 16px;
  height: 16px;
}
.navDot {
  width: 7px;
  height: 7px;
  margin: 0 4.5px;
  border-radius: 50%;
}
.navDot[data-tone='yellow'] {
  background: var(--yellow);
}
.navDot[data-tone='pink'] {
  background: var(--pink);
}
.navDot[data-tone='violet'] {
  background: var(--violet);
}
.navLabel {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.navCount {
  min-width: 22px;
  padding: 1px 6px;
  border: 1px solid var(--chip-edge);
  border-radius: 6px;
  background: var(--chip);
  color: var(--ink-2);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.navHeading {
  margin: 14px 0 0;
  padding: 12px 10px 6px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.navFoot {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 18px;
}
.trial {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 -10px -12px;
  padding: 12px 12px 12px 18px;
  border-top: 1px solid var(--line);
}
.trialText {
  display: grid;
}
.trialText strong {
  font-size: 13.5px;
  font-weight: 560;
}
.trialText span {
  color: var(--ink-2);
  font-size: 12px;
}
.trialButton {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--current-edge);
  border-radius: 999px;
  background: var(--current);
  font-size: 13px;
  font-weight: 500;
}
.trialButton svg {
  width: 15px;
  height: 15px;
}

/* ---- Main column ------------------------------------------------------------------------------ */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding: 10px 18px;
}
.menuButton {
  display: none;
}
.title {
  margin: 0;
  overflow: hidden;
  font-size: 18px;
  font-weight: 560;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--chip-edge);
  border-radius: 7px;
  background: var(--chip);
  font-size: 12.5px;
}
.statusDot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--active);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--active) 22%, transparent);
}
.topEnd {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.round {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: none;
}
.round:hover {
  background: var(--hover);
}
.round svg {
  width: 16px;
  height: 16px;
}
.bellDot {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 0 0 0 2px var(--window);
}
.search {
  display: flex;
  align-items: center;
}
.searchField {
  width: 0;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  outline: none;
  background: none;
  opacity: 0;
  transition:
    width 0.25s ease,
    opacity 0.2s ease,
    padding 0.25s ease;
}
.search[data-open] .round {
  border-right: 0;
  border-radius: 999px 0 0 999px;
}
.search[data-open] .searchField {
  width: 170px;
  padding: 0 12px 0 2px;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 999px 999px 0;
  opacity: 1;
}
.searchField::-webkit-search-cancel-button {
  display: none;
}
.user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px 0 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 22px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}
.tab {
  position: relative;
  height: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 13.5px;
}
.tab[aria-selected='true'] {
  color: var(--ink);
}
.tab[aria-selected='true']::after {
  content: '';
  position: absolute;
  inset: auto 0 -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}
.filters,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: none;
  font-size: 13px;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}
.filter:hover,
.filter[aria-expanded='true'],
.filter[data-over] {
  background: var(--hover);
}
.filter[data-active] {
  border-color: color-mix(in oklab, var(--primary) 45%, var(--line));
}
.filterCaption {
  color: var(--ink-3);
}
.filterValue {
  font-weight: 500;
}
.filterChevron {
  width: 14px;
  height: 14px;
  color: var(--ink-2);
}
.button,
.primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.button:hover {
  background: var(--hover);
}
.button svg,
.primary svg {
  width: 15px;
  height: 15px;
}
.primary {
  border-color: transparent;
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.18);
}
.primary:hover {
  /* A small lift, so the white words keep 4.5:1 on the dark scheme's brighter fill. */
  background: color-mix(in oklab, var(--primary) 94%, white);
}

/* ---- The table -------------------------------------------------------------------------------- */

.scroller {
  flex: 1;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.table {
  width: 100%;
  min-width: 1120px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
.table th,
.table td {
  height: 46px;
  padding: 0 10px;
  border-bottom: 1px solid var(--row-line);
  background: var(--window);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
.table thead th {
  height: 42px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 400;
  border-bottom-color: var(--line);
}
.table tbody tr:hover > * {
  background: var(--row-hover);
}
.table tbody tr[data-selected] > * {
  background: var(--row-selected);
}
.table tbody tr[data-fresh] > * {
  animation: fresh 1.6s ease;
}
@keyframes fresh {
  from {
    background: var(--fresh);
  }
}
.sortHead {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
}
.sortHead:hover {
  color: var(--ink);
}
.sortIcon {
  width: 13px;
  height: 13px;
}
.checkCol {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 44px;
  padding: 0 4px 0 18px !important;
}
.nameCol {
  position: sticky;
  left: 44px;
  z-index: 1;
  min-width: 170px;
  font-weight: 400;
}
.num {
  font-variant-numeric: tabular-nums;
}
.moreCol {
  width: 40px;
  padding-right: 14px !important;
}
.check {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  padding: 0;
  border: 1.5px solid var(--ink-3);
  border-radius: 4px;
  background: none;
  color: transparent;
}
.check svg {
  width: 12px;
  height: 12px;
}
.check[aria-checked='true'],
.check[aria-checked='mixed'] {
  border-color: var(--check);
  background: var(--check);
  color: var(--check-ink);
}
.check[data-over] {
  border-color: var(--ink-2);
}
.name {
  padding: 0;
  border: 0;
  background: none;
  font-weight: 450;
  text-align: left;
}
.name:hover {
  text-decoration: underline;
  text-decoration-color: var(--ink-3);
  text-underline-offset: 3px;
}
.nameField {
  width: 150px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  outline: none;
  background: var(--window);
}
.money {
  display: inline-flex;
  gap: 6px;
}
.dollar {
  color: var(--ink-2);
}
.last {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.lastIcon {
  width: 15px;
  height: 15px;
  color: var(--ink-2);
}
.lastKind {
  padding-left: 6px;
  border-left: 1px solid var(--line);
  color: var(--ink);
}
.more {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--ink-2);
}
.more:hover,
.more[aria-expanded='true'] {
  background: var(--hover);
  color: var(--ink);
}
.more svg {
  width: 16px;
  height: 16px;
}
.none {
  height: 120px !important;
  color: var(--ink-2);
  text-align: center !important;
}
.empty {
  display: grid;
  flex: 1;
  place-content: center;
  justify-items: center;
  gap: 6px;
  min-height: 320px;
  text-align: center;
}
.emptyIcon {
  width: 22px;
  height: 22px;
  margin-bottom: 4px;
  color: var(--ink-3);
}
.emptyTitle {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}
.emptyText {
  margin: 0 0 8px;
  color: var(--ink-2);
}

/* Footer */
.footer {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}
.inView,
.calc {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 44px;
  padding: 0 18px;
  color: var(--ink-2);
  font-size: 13px;
  white-space: nowrap;
}
.inView strong {
  color: var(--ink);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.inView {
  gap: 0;
}
.inView strong {
  margin-right: 6px;
}
.clear {
  margin-left: 10px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: none;
  font-size: 12px;
}
.calc {
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: none;
  text-align: left;
  transition: background-color 0.15s ease;
}
.calc:hover,
.calc[aria-expanded='true'],
.calc[data-over] {
  background: var(--hover);
}
.calcPlus {
  width: 14px;
  height: 14px;
}
.calcLabel {
  overflow: hidden;
  text-overflow: ellipsis;
}
.calcValue {
  margin-left: auto;
  color: var(--ink);
  font-weight: 560;
  font-variant-numeric: tabular-nums;
}
.calc[data-on] {
  animation: settle 0.3s ease;
}
@keyframes settle {
  from {
    background: var(--hover);
  }
}

/* ---- Cells (cells.tsx) ------------------------------------------------------------------------ */

/* Win probability */
.win {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.winTrack {
  display: inline-flex;
  gap: 2px;
  padding: 4px 5px;
  border-radius: 6px;
  background: var(--track);
}
.seg {
  width: 3px;
  height: 14px;
  border-radius: 1.5px;
  background: var(--seg-empty);
}
.seg[data-fill='low'] {
  background: var(--low);
}
.seg[data-fill='mid'] {
  background: var(--mid);
}
.seg[data-fill='high'] {
  background: var(--high);
}
.seg[data-lost] {
  background: color-mix(in oklab, var(--low) 18%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--low) 70%, transparent);
}
.seg[data-gained] {
  box-shadow: 0 0 5px color-mix(in oklab, var(--high) 70%, transparent);
}
.winValue {
  min-width: 34px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.win[data-tone='band'][data-band='low'] .winValue {
  color: var(--red-ink);
}
.winSwing {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  height: 18px;
  margin-left: -4px;
  padding: 0 5px 0 3px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
}
.winSwing svg {
  width: 11px;
  height: 11px;
}
.winSwing[data-dir='down'] {
  background: var(--red-bg);
  color: var(--red-ink);
}
.winSwing[data-dir='up'] {
  background: var(--green-bg);
  color: var(--green-ink);
}
.win[data-empty] .seg {
  background: none;
  box-shadow: inset 0 0 0 1px var(--seg-empty);
}
.winNone {
  color: var(--ink-3);
  font-size: 12.5px;
}

/* Activity trend */
.trend {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.trendBars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: var(--trend-h, 18px);
}
.bar {
  position: relative;
  width: 4px;
  height: calc(3px + var(--h) * (var(--trend-h, 18px) - 3px));
  border-radius: 1px;
  background: var(--bar-dim);
}
.bar[data-tone='bright'] {
  background: var(--bar-bright);
}
.bar[data-tone='spike'] {
  background: var(--mid);
}
.bar[data-tone='spike']::after {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 0.5px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--mid);
}
.bar[data-tone='cool'] {
  background: var(--low);
}
.bar[data-tone='quiet'] {
  height: 2px;
  background: var(--bar-quiet);
}
.trendNote {
  padding: 1px 7px;
  border: 1px solid var(--chip-edge);
  border-radius: 6px;
  background: var(--chip);
  color: var(--ink-2);
  font-size: 11.5px;
}
.trendNote[data-kind='cooling'] {
  border-color: var(--red-edge);
  background: var(--red-bg);
  color: var(--red-ink);
}
.trendNote[data-kind='spike'] {
  border-color: var(--amber-edge);
  background: var(--amber-bg);
  color: var(--amber-ink);
}
.trendNote[data-kind='rising'] {
  border-color: var(--green-edge);
  background: var(--green-bg);
  color: var(--green-ink);
}

/* Segment and stage */
.tags {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}
.tag[data-tone='blue'] {
  border-color: var(--blue-edge);
  background: var(--blue-bg);
  color: var(--blue-ink);
}
.tag[data-tone='violet'] {
  border-color: var(--violet-edge);
  background: var(--violet-bg);
  color: var(--violet-ink);
}
.tag[data-tone='green'] {
  border-color: var(--green-edge);
  background: var(--green-bg);
  color: var(--green-ink);
}
.tag[data-tone='amber'] {
  border-color: var(--amber-edge);
  background: var(--amber-bg);
  color: var(--amber-ink);
}
.tag[data-tone='orange'] {
  border-color: var(--orange-edge);
  background: var(--orange-bg);
  color: var(--orange-ink);
}
.tag[data-tone='red'] {
  border-color: var(--red-edge);
  background: var(--red-bg);
  color: var(--red-ink);
}
.tagIcon {
  width: 12px;
  height: 12px;
}
.tagMore {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 24px;
  padding: 0 7px;
  border: 1px solid var(--chip-edge);
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink-2);
  font-size: 12.5px;
}
.tagMore:hover,
.tagMore[data-over] {
  color: var(--ink);
}
.tagPopover {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--menu);
  color: var(--ink);
  font-family: var(--sans);
  box-shadow: 0 12px 30px -8px var(--shadow);
}
.tagPopover:popover-open {
  display: grid;
  gap: 8px;
  animation: pop 0.16s ease;
}
.tagPopoverTitle {
  color: var(--ink-2);
  font-size: 11.5px;
}
.tagPopoverList {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 240px;
}
@keyframes pop {
  from {
    opacity: 0;
    translate: 0 -4px;
  }
}

/* Account owner */
.owner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: none;
  white-space: nowrap;
}
.avatarStack {
  display: inline-flex;
}
.avatarStack > * + * {
  margin-left: -7px;
}
.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--size, 22px);
  height: var(--size, 22px);
  border-radius: 50%;
  background: var(--tint);
  box-shadow: 0 0 0 1.5px var(--window);
}
.face {
  display: block;
  object-fit: cover;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}
.initials {
  color: #1d1d22;
  font-size: calc(var(--size, 22px) * 0.4);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.avatar[data-away]::after {
  content: '';
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mid);
  box-shadow: 0 0 0 1.5px var(--window);
}
.ownerName {
  overflow: hidden;
  text-overflow: ellipsis;
}
.ownerMore {
  color: var(--ink-2);
  font-size: 12.5px;
}
.away {
  padding: 1px 6px;
  border: 1px solid var(--amber-edge);
  border-radius: 6px;
  background: var(--amber-bg);
  color: var(--amber-ink);
  font-size: 11.5px;
}
.owner[data-empty] {
  color: var(--ink-3);
}
button.owner[data-empty]:hover {
  color: var(--ink);
}
.avatarEmpty {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1.5px dashed var(--ink-3);
  border-radius: 50%;
}
.avatarEmpty svg {
  width: 11px;
  height: 11px;
}

/* A column on its own */
.cellColumn {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--window);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.35;
}
.cellTable {
  width: 100%;
  border-collapse: collapse;
}
.cellTable th,
.cellTable td {
  height: 52px;
  padding: 0 18px;
  border-bottom: 1px solid var(--row-line);
  text-align: left;
  white-space: nowrap;
}
.cellTable thead th {
  height: 42px;
  border-bottom-color: var(--line);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 400;
}
.cellTable tbody tr:last-child td {
  border-bottom: 0;
}
.cellLabel {
  width: 1%;
  color: var(--ink-2);
  font-size: 12.5px;
  text-align: right !important;
}

/* ---- Layers ----------------------------------------------------------------------------------- */

.menu {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 6;
  display: grid;
  min-width: 200px;
  max-height: 340px;
  padding: 5px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  background: var(--menu);
  box-shadow: 0 16px 36px -10px var(--shadow);
  animation: pop 0.16s ease;
  scrollbar-width: thin;
}
.menuItem {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  outline: none;
  background: none;
  font-size: 13px;
  text-align: left;
}
.menuItem:hover,
.menuItem:focus-visible,
.menuItem[data-over] {
  background: var(--hover);
}
.menuItem[data-tone='danger'] {
  color: var(--red-ink);
}
.menuText {
  flex: 1;
  white-space: nowrap;
}
.menuTrail {
  color: var(--ink-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.menuCheck,
.menuIcon,
.menuAlert {
  width: 15px;
  height: 15px;
}
.menuAlert {
  color: var(--red-ink);
}
.menuLabel {
  padding: 8px 9px 4px;
  color: var(--ink-3);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.toast {
  position: absolute;
  bottom: 44px;
  left: 50%;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--menu);
  box-shadow: 0 14px 34px -10px var(--shadow);
  white-space: nowrap;
  translate: -50% 0;
  animation: rise 0.22s ease;
}
.toastUndo {
  padding: 0;
  border: 0;
  background: none;
  /* The fill's indigo is too deep for words on the dark menu; this one is lighter there. */
  color: var(--primary-text);
  font-weight: 560;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.scrim {
  display: none;
}

/* ---- Narrow stages ---------------------------------------------------------------------------- */

@container (max-width: 1040px) {
  .userName {
    display: none;
  }
  .user {
    padding-right: 5px;
  }
}
@container (max-width: 760px) {
  .root {
    padding: 10px;
  }
  .window {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 4;
    width: 248px;
    translate: -100% 0;
    transition: translate 0.28s cubic-bezier(0.3, 0.7, 0.2, 1);
  }
  .sidebar[data-open] {
    translate: 0 0;
    box-shadow: 18px 0 40px -12px var(--shadow);
  }
  .drawerClose {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    margin-left: auto;
    border: 0;
    border-radius: 8px;
    background: none;
  }
  .drawerClose svg {
    width: 16px;
    height: 16px;
  }
  .scrim {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: block;
    border: 0;
    background: var(--veil);
  }
  .menuButton {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-left: -6px;
    border: 0;
    border-radius: 8px;
    background: none;
  }
  .menuButton svg {
    width: 18px;
    height: 18px;
  }
  .top {
    padding: 10px 12px;
  }
  .status {
    display: none;
  }
  .tabs,
  .toolbar {
    padding-inline: 12px;
  }
  .filters {
    flex-wrap: nowrap;
    width: calc(100% + 24px);
    margin: 0 -12px;
    padding: 0 12px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .search[data-open] .searchField {
    width: 120px;
  }
  .footer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .footer > :nth-child(3) {
    border-left: 0;
  }
  .footer > :nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
  .checkCol {
    padding-left: 12px !important;
  }
  .nameCol {
    min-width: 140px;
    box-shadow: 1px 0 0 var(--line);
  }
}

@container (max-width: 520px) {
  .user {
    display: none;
  }
  .actions {
    flex-wrap: nowrap;
  }
  .exportLabel {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .button:has(.exportLabel) {
    width: 34px;
    padding: 0;
    justify-content: center;
  }
  .footer {
    grid-template-columns: minmax(0, 1fr);
  }
  .footer > * {
    border-left: 0;
  }
  .footer > :nth-child(n + 2) {
    border-top: 1px solid var(--line);
  }
}

/* ---- The demo's pointer ----------------------------------------------------------------------- */

.pointerLayer {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}
.pointer {
  width: 20px;
  height: 20px;
}
.hand {
  visibility: hidden;
}
.pointer[data-glyph='hand'] .arrow {
  visibility: hidden;
}
.pointer[data-glyph='hand'] .hand {
  visibility: visible;
}

@media (prefers-reduced-motion: reduce) {
  .navItem,
  .filter,
  .calc,
  .searchField,
  .sidebar {
    transition: none;
  }
  .menu,
  .toast,
  .tagPopover:popover-open,
  .calc[data-on],
  .table tbody tr[data-fresh] > * {
    animation: none;
  }
}
```

### account-pipeline/data.ts

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

/*
 * The book of accounts the pipeline opens with: twenty companies, the twelve people who own them
 * and the tags their deals carry. Every name is made up. Dates are read against TODAY, so the
 * table looks the same on every load.
 */

export type Region = 'na' | 'emea' | 'apac';
export type Team = 'strategic' | 'mid' | 'sdr';

export type Tag =
  | 'Enterprise'
  | 'Mid-market'
  | 'SMB'
  | 'Strategic'
  | 'New logo'
  | 'Upsell'
  | 'Expansion'
  | 'Renewal'
  | 'Pilot'
  | 'Co-sell'
  | 'Land & expand'
  | 'Churn risk';

/** How a tag is drawn: each tone is a fill, an edge and a text colour in the stylesheet. */
export type TagTone = 'blue' | 'violet' | 'green' | 'amber' | 'orange' | 'red';

export const TAG_TONE: Record<Tag, TagTone> = {
  Enterprise: 'blue',
  'Mid-market': 'green',
  SMB: 'amber',
  Strategic: 'violet',
  'New logo': 'green',
  Upsell: 'violet',
  Expansion: 'green',
  Renewal: 'green',
  Pilot: 'orange',
  'Co-sell': 'orange',
  'Land & expand': 'green',
  'Churn risk': 'red',
};

export const TAGS = Object.keys(TAG_TONE) as Tag[];

/** An illustrated face: drawn by faces.tsx from these few choices. */
export type Face = {
  skin: string;
  hair: string;
  style: 'short' | 'long' | 'bun' | 'curly' | 'buzz' | 'bob' | 'bald';
  /** The circle behind the face. */
  bg: string;
  glasses?: boolean;
  beard?: boolean;
};

export type Owner = {
  id: string;
  name: string;
  team: Team;
  /** Without a face, the avatar shows the initials. */
  face?: Face;
  /** A local photographic profile; omitted, known demo identities resolve by ID. */
  photo?: string;
  /** Out of office until this date (ISO). */
  away?: string;
};

export type Interaction =
  | 'QBR call'
  | 'Demo'
  | 'Security review'
  | 'Legal'
  | 'Exec sync'
  | 'Pilot check-in'
  | 'Pricing'
  | 'Product'
  | 'Renewal'
  | 'Expansion'
  | 'Partner'
  | 'Discovery'
  | 'Note';

export type Account = {
  id: string;
  name: string;
  region: Region;
  tags: Tag[];
  owner: string | null;
  /** Owners who share the account. */
  coOwners?: string[];
  openDeals: number;
  /** The open pipeline, in dollars. */
  value: number;
  /** The win probability now, 0–100, or null before any deal is scored. */
  win: number | null;
  /** The win probability two weeks ago, to show a jump or a drop. */
  winBefore?: number | null;
  /** Touches a week (calls, emails, meetings), the last twelve weeks, oldest first. */
  trend: number[];
  last: { date: string; kind: Interaction };
};

/** The day the data is read against. */
export const TODAY = '2026-10-29';

export const REGION_NAME: Record<Region, string> = {
  na: 'North America',
  emea: 'EMEA Enterprise',
  apac: 'APAC Expansion',
};

export const TEAM_NAME: Record<Team, string> = {
  strategic: 'Strategic AEs',
  mid: 'Mid Market',
  sdr: 'SDR Team',
};

const SKIN = ['#f3d2b8', '#e7b98f', '#c98d63', '#9a6440', '#6e4428'];

export const OWNERS: Owner[] = [
  {
    id: 'ana',
    name: 'Ana Ribeiro',
    team: 'strategic',
    face: { skin: SKIN[1], hair: '#3b2416', style: 'long', bg: '#f2c8a0' },
  },
  {
    id: 'theo',
    name: 'Theo Marsh',
    team: 'strategic',
    face: { skin: SKIN[0], hair: '#c08a4a', style: 'short', bg: '#b9d3f0', beard: true },
  },
  {
    id: 'priya',
    name: 'Priya Nair',
    team: 'strategic',
    face: { skin: SKIN[2], hair: '#1d1512', style: 'bun', bg: '#f5d77e' },
  },
  {
    id: 'kenji',
    name: 'Kenji Mori',
    team: 'strategic',
    face: { skin: SKIN[1], hair: '#16120f', style: 'short', bg: '#c6e3c0', glasses: true },
  },
  {
    id: 'jonah',
    name: 'Jonah Weiss',
    team: 'mid',
    face: { skin: SKIN[0], hair: '#6b4426', style: 'curly', bg: '#f0b7b0' },
  },
  {
    id: 'lucia',
    name: 'Lucía Ortega',
    team: 'mid',
    face: { skin: SKIN[2], hair: '#2a1a12', style: 'bob', bg: '#d8c6f2' },
    away: '2026-11-03',
  },
  {
    id: 'amara',
    name: 'Amara Okafor',
    team: 'mid',
    face: { skin: SKIN[4], hair: '#120d0b', style: 'curly', bg: '#f6c98a' },
  },
  {
    id: 'felix',
    name: 'Felix Brandt',
    team: 'mid',
    face: { skin: SKIN[0], hair: '#d9b36c', style: 'buzz', bg: '#a9d8d0', glasses: true },
  },
  {
    id: 'sofia',
    name: 'Sofia Lund',
    team: 'sdr',
    face: { skin: SKIN[0], hair: '#e2c27a', style: 'long', bg: '#bcd0f5' },
  },
  {
    id: 'marcus',
    name: 'Marcus Hale',
    team: 'sdr',
    face: { skin: SKIN[3], hair: '#1b1411', style: 'bald', bg: '#f1d0a8', beard: true },
  },
  { id: 'yara', name: 'Yara Haddad', team: 'sdr' },
  {
    id: 'diego',
    name: 'Diego Paz',
    team: 'sdr',
    face: { skin: SKIN[2], hair: '#2b1d14', style: 'short', bg: '#e9b9d4' },
  },
];

export const ACCOUNTS: Account[] = [
  {
    id: 'a1',
    name: 'Halden Group',
    region: 'emea',
    tags: ['Enterprise', 'Upsell', 'Renewal', 'Co-sell'],
    owner: 'ana',
    openDeals: 7,
    value: 420000,
    win: 70,
    winBefore: 68,
    trend: [3, 5, 2, 1, 4, 2, 3, 6, 3, 5, 4, 7],
    last: { date: '2026-10-27', kind: 'QBR call' },
  },
  {
    id: 'a2',
    name: 'Corvid Systems',
    region: 'na',
    tags: ['Enterprise', 'New logo'],
    owner: 'theo',
    openDeals: 4,
    value: 311242,
    win: 51,
    winBefore: 49,
    trend: [1, 2, 2, 1, 3, 2, 4, 5, 3, 4, 2, 5],
    last: { date: '2026-10-26', kind: 'Demo' },
  },
  {
    id: 'a3',
    name: 'Tilde Payments',
    region: 'na',
    tags: ['Enterprise'],
    owner: 'priya',
    openDeals: 5,
    value: 124232,
    win: 22,
    winBefore: 47,
    trend: [6, 5, 7, 6, 5, 6, 4, 3, 2, 1, 1, 0],
    last: { date: '2026-10-08', kind: 'Security review' },
  },
  {
    id: 'a4',
    name: 'Solent Air',
    region: 'emea',
    tags: ['Renewal'],
    owner: 'amara',
    openDeals: 2,
    value: 221231,
    win: 77,
    winBefore: 75,
    trend: [2, 3, 1, 4, 3, 2, 4, 1, 3, 4, 2, 5],
    last: { date: '2026-10-21', kind: 'Legal' },
  },
  {
    id: 'a5',
    name: 'Brightmoor',
    region: 'na',
    tags: ['Pilot'],
    owner: 'kenji',
    coOwners: ['felix'],
    openDeals: 6,
    value: 530111,
    win: 82,
    winBefore: 64,
    trend: [1, 2, 1, 3, 2, 3, 4, 3, 5, 4, 6, 7],
    last: { date: '2026-10-24', kind: 'Exec sync' },
  },
  {
    id: 'a6',
    name: 'Marrow Health',
    region: 'na',
    tags: ['Strategic', 'Expansion'],
    owner: 'theo',
    openDeals: 8,
    value: 320222,
    win: 86,
    winBefore: 84,
    trend: [3, 4, 3, 5, 4, 5, 6, 4, 5, 6, 5, 6],
    last: { date: '2026-10-28', kind: 'Pilot check-in' },
  },
  {
    id: 'a7',
    name: 'Foxglove Travel',
    region: 'apac',
    tags: ['Upsell', 'Expansion', 'SMB', 'Co-sell'],
    owner: 'jonah',
    openDeals: 3,
    value: 122230,
    win: 51,
    winBefore: 53,
    trend: [2, 1, 2, 2, 3, 1, 2, 9, 2, 3, 2, 3],
    last: { date: '2026-10-22', kind: 'Pricing' },
  },
  {
    id: 'a8',
    name: 'Vireo Labs',
    region: 'apac',
    tags: ['Enterprise', 'Mid-market'],
    owner: 'lucia',
    openDeals: 5,
    value: 230112,
    win: 61,
    winBefore: 60,
    trend: [2, 3, 3, 2, 4, 3, 4, 3, 4, 5, 4, 4],
    last: { date: '2026-10-19', kind: 'Product' },
  },
  {
    id: 'a9',
    name: 'Ember Analytics',
    region: 'na',
    tags: ['Mid-market', 'Upsell', 'Churn risk', 'Renewal'],
    owner: 'felix',
    openDeals: 2,
    value: 420222,
    win: 38,
    winBefore: 39,
    trend: [4, 3, 5, 4, 3, 4, 2, 3, 0, 0, 0, 0],
    last: { date: '2026-09-28', kind: 'Pricing' },
  },
  {
    id: 'a10',
    name: 'Northgate Retail',
    region: 'emea',
    tags: ['SMB', 'Enterprise', 'Renewal', 'Pilot'],
    owner: 'sofia',
    openDeals: 8,
    value: 112277,
    win: 24,
    winBefore: 27,
    trend: [1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 1],
    last: { date: '2026-10-14', kind: 'Renewal' },
  },
  {
    id: 'a11',
    name: 'Osprey Media',
    region: 'emea',
    tags: ['Mid-market'],
    owner: 'marcus',
    openDeals: 3,
    value: 221221,
    win: 72,
    winBefore: 70,
    trend: [2, 3, 2, 4, 3, 4, 3, 5, 4, 3, 5, 6],
    last: { date: '2026-10-25', kind: 'Pilot check-in' },
  },
  {
    id: 'a12',
    name: 'Calder Energy',
    region: 'emea',
    tags: ['Land & expand', 'Strategic', 'Enterprise'],
    owner: 'ana',
    coOwners: ['priya'],
    openDeals: 5,
    value: 170991,
    win: 31,
    winBefore: 58,
    trend: [4, 5, 4, 6, 5, 4, 5, 3, 2, 2, 1, 1],
    last: { date: '2026-10-12', kind: 'Expansion' },
  },
  {
    id: 'a13',
    name: 'Pinecrest Foods',
    region: 'na',
    tags: ['Co-sell', 'Expansion'],
    owner: 'yara',
    openDeals: 9,
    value: 139007,
    win: 45,
    winBefore: 44,
    trend: [1, 2, 2, 3, 2, 3, 2, 3, 3, 2, 4, 3],
    last: { date: '2026-10-20', kind: 'Renewal' },
  },
  {
    id: 'a14',
    name: 'Wexford Mobility',
    region: 'apac',
    tags: ['Expansion', 'Mid-market'],
    owner: 'kenji',
    openDeals: 8,
    value: 289921,
    win: 38,
    winBefore: 36,
    trend: [2, 2, 3, 2, 2, 3, 2, 2, 11, 3, 2, 3],
    last: { date: '2026-10-16', kind: 'Partner' },
  },
  {
    id: 'a15',
    name: 'Glimmer Studio',
    region: 'apac',
    tags: ['Mid-market', 'Co-sell'],
    owner: 'diego',
    openDeals: 4,
    value: 333221,
    win: 23,
    winBefore: 25,
    trend: [0, 1, 1, 0, 2, 1, 1, 2, 1, 1, 2, 1],
    last: { date: '2026-10-11', kind: 'Discovery' },
  },
  {
    id: 'a16',
    name: 'Lowell Freight',
    region: 'na',
    tags: ['Expansion', 'SMB', 'Renewal'],
    owner: null,
    openDeals: 3,
    value: 442231,
    win: 44,
    winBefore: 46,
    trend: [3, 2, 3, 4, 3, 2, 3, 4, 3, 3, 2, 4],
    last: { date: '2026-10-23', kind: 'Demo' },
  },
  {
    id: 'a17',
    name: 'Larch Insurance',
    region: 'emea',
    tags: ['Enterprise', 'Mid-market'],
    owner: 'lucia',
    openDeals: 6,
    value: 520000,
    win: 24,
    winBefore: 26,
    trend: [2, 1, 2, 3, 2, 2, 1, 2, 3, 2, 2, 3],
    last: { date: '2026-10-09', kind: 'Pricing' },
  },
  {
    id: 'a18',
    name: 'Quarry & Co',
    region: 'na',
    tags: ['Expansion', 'Co-sell', 'Upsell', 'SMB'],
    owner: 'jonah',
    openDeals: 2,
    value: 210123,
    win: 52,
    winBefore: 50,
    trend: [1, 2, 3, 2, 3, 2, 4, 3, 2, 4, 3, 5],
    last: { date: '2026-10-27', kind: 'QBR call' },
  },
  {
    id: 'a19',
    name: 'Tamsin Bank',
    region: 'emea',
    tags: ['Strategic', 'Enterprise'],
    owner: 'priya',
    openDeals: 4,
    value: 610400,
    win: null,
    trend: [0, 0, 0, 0, 0, 1, 0, 2, 1, 2, 3, 2],
    last: { date: '2026-10-18', kind: 'Discovery' },
  },
  {
    id: 'a20',
    name: 'Saltmarsh Games',
    region: 'apac',
    tags: ['New logo', 'SMB'],
    owner: 'felix',
    openDeals: 1,
    value: 64800,
    win: 63,
    winBefore: 61,
    trend: [0, 1, 1, 2, 1, 2, 2, 3, 2, 3, 3, 4],
    last: { date: '2026-10-26', kind: 'Demo' },
  },
];

// ---- Reading the data ---------------------------------------------------------------------------

const DAY = 24 * 3600 * 1000;

/** Days from `date` to TODAY. */
export const daysAgo = (date: string) => Math.round((Date.parse(TODAY) - Date.parse(date)) / DAY);

const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];

/** "Oct 27". */
export const shortDate = (date: string) => {
  const [, m, d] = date.split('-').map(Number);
  return `${MONTHS[m - 1]} ${d}`;
};

/** "$ 420,000": the dollar sign stands apart, as the table sets it. */
export const money = (value: number) => Math.round(value).toLocaleString('en-US');

/** "$1.2M", "$640K": for the footer's totals. */
export const shortMoney = (value: number) =>
  value >= 1e6
    ? `$${(value / 1e6).toFixed(value >= 1e7 ? 0 : 2)}M`
    : `$${Math.round(value / 1e3)}K`;

export const initials = (name: string) =>
  name
    .split(/\s+/)
    .map((part) => part[0])
    .slice(0, 2)
    .join('')
    .toUpperCase();

/** A drop or a jump of this many points in two weeks is flagged. */
export const SWING = 15;
```

### account-pipeline/portraits.ts

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.
// Fictitious editorial identities; Theo reuses his existing photo, and Bruno uses his real photo.
export const OWNER_PHOTOS: Record<string, string> = Object.fromEntries(
  [
    'ana',
    'theo',
    'priya',
    'kenji',
    'jonah',
    'lucia',
    'amara',
    'felix',
    'sofia',
    'marcus',
    'yara',
    'diego',
    'me',
  ].map((id) => [
    id,
    `/experiments/visual-revision/v2/people/${id === 'me' ? 'bruno' : id}-192.webp`,
  ]),
);
export const portraitSet = (src: string) =>
  src.replace('-192.webp', '-96.webp') +
  ' 96w, ' +
  src +
  ' 192w, ' +
  src.replace('-192.webp', '-384.webp') +
  ' 384w';
```

### account-pipeline/menu.tsx

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import {
  useEffect,
  useLayoutEffect,
  useRef,
  useState,
  type KeyboardEvent as ReactKeyboardEvent,
  type ReactNode,
} from 'react';
import { Icon } from './glyphs';
import styles from './account-pipeline.module.css';

/*
 * The menus: placed on the stage under their trigger (over it when there is no room below), in
 * the stage's own px, since a gallery card may scale the whole stage. The arrows, Home and End
 * move between items; Escape closes and gives the focus back; a press elsewhere closes.
 */

const ITEMS = '[role="menuitem"], [role="menuitemradio"]';

export function Menu({
  anchor,
  label,
  align = 'start',
  takeFocus,
  onClose,
  children,
}: {
  anchor: HTMLElement;
  label: string;
  align?: 'start' | 'end';
  /** Moves the focus to the checked or first item: when the reader opened it, not the demo. */
  takeFocus: boolean;
  /** `back`: give the focus back to the trigger. */
  onClose: (back: boolean) => void;
  children: ReactNode;
}) {
  const box = useRef<HTMLDivElement>(null);
  const [at, setAt] = useState<{ x: number; y: number } | null>(null);

  useLayoutEffect(() => {
    const menu = box.current;
    const frame = menu?.offsetParent as HTMLElement | null;
    if (!frame || !menu) return;
    const place = () => {
      const s = frame.getBoundingClientRect();
      const scale = s.width / frame.offsetWidth || 1;
      const a = anchor.getBoundingClientRect();
      const left = (a.left - s.left) / scale;
      const right = (a.right - s.left) / scale;
      const top = (a.top - s.top) / scale;
      const bottom = (a.bottom - s.top) / scale;
      const w = menu.offsetWidth;
      const h = menu.offsetHeight;
      let x = align === 'end' ? right - w : left;
      x = Math.max(8, Math.min(x, frame.clientWidth - w - 8));
      let y = bottom + 6;
      if (y + h > frame.clientHeight - 8 && top - h - 6 > 8) y = top - h - 6;
      setAt({ x, y });
    };
    place();
    const observer = new ResizeObserver(place);
    observer.observe(menu);
    return () => observer.disconnect();
  }, [anchor, align]);

  useEffect(() => {
    if (!takeFocus || !at) return;
    box.current
      ?.querySelector<HTMLElement>('[aria-checked="true"], [role^="menuitem"]')
      ?.focus({ preventScroll: true });
    // Only when it first shows.
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [takeFocus, at === null]);

  useEffect(() => {
    const away = (event: PointerEvent) => {
      const target = event.target as Node;
      if (box.current?.contains(target) || anchor.contains(target)) return;
      onClose(false);
    };
    document.addEventListener('pointerdown', away);
    return () => document.removeEventListener('pointerdown', away);
  }, [anchor, onClose]);

  const onKeyDown = (event: ReactKeyboardEvent) => {
    const items = [...(box.current?.querySelectorAll<HTMLElement>(ITEMS) ?? [])];
    const index = items.indexOf(document.activeElement as HTMLElement);
    const move = (to: number) => {
      event.preventDefault();
      items[(to + items.length) % items.length]?.focus();
    };
    if (event.key === 'ArrowDown') move(index + 1);
    else if (event.key === 'ArrowUp') move(index - 1);
    else if (event.key === 'Home') move(0);
    else if (event.key === 'End') move(items.length - 1);
    else if (event.key === 'Escape') {
      event.preventDefault();
      event.stopPropagation();
      onClose(true);
    } else if (event.key === 'Tab') onClose(false);
  };

  return (
    <div
      ref={box}
      role="menu"
      tabIndex={-1}
      aria-label={label}
      className={styles.menu}
      data-part="menu"
      style={{
        transform: at ? `translate(${at.x}px, ${at.y}px)` : undefined,
        visibility: at ? undefined : 'hidden',
      }}
      onKeyDown={onKeyDown}
    >
      {children}
    </div>
  );
}

export function MenuItem({
  onSelect,
  checked,
  radio,
  tone,
  demo,
  lead,
  trail,
  children,
}: {
  onSelect: () => void;
  checked?: boolean;
  /** One of a set: it shows a check when chosen. */
  radio?: boolean;
  tone?: 'danger';
  demo?: string;
  /** Before the text: an icon, a face. */
  lead?: ReactNode;
  /** At the right end: a count. */
  trail?: ReactNode;
  children: ReactNode;
}) {
  return (
    <button
      type="button"
      role={radio ? 'menuitemradio' : 'menuitem'}
      aria-checked={radio ? !!checked : undefined}
      tabIndex={-1}
      className={styles.menuItem}
      data-tone={tone}
      data-demo={demo}
      onClick={onSelect}
    >
      {lead}
      <span className={styles.menuText}>{children}</span>
      {trail !== undefined && <span className={styles.menuTrail}>{trail}</span>}
      {radio && checked && <Icon name="check" className={styles.menuCheck} width={2.2} />}
    </button>
  );
}

export function MenuLabel({ children }: { children: ReactNode }) {
  return (
    <div className={styles.menuLabel} role="presentation">
      {children}
    </div>
  );
}
```

### account-pipeline/glyphs.tsx

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

import type { Face } from './data';

/*
 * The drawings: the interface's line icons (a 24-unit box, drawn with currentColor), the app's
 * mark, and the owners' illustrated faces.
 */

const PATHS = {
  building:
    'M4 21V5a1 1 0 0 1 1-1h8a1 1 0 0 1 1 1v16M14 9h5a1 1 0 0 1 1 1v11M3 21h18M8 8h2M8 12h2M8 16h2',
  board: 'M4 5h16v14H4zM9.5 5v14M14.5 5v14',
  chart: 'M5 20V12M10 20V6M15 20v-9M20 20V9',
  list: 'M9 6h11M9 12h11M9 18h11M4.5 6h.01M4.5 12h.01M4.5 18h.01',
  contacts:
    'M5 4h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5zM9 4v16M13 10.5a1.8 1.8 0 1 0 0-.01M10.5 16a2.6 2.6 0 0 1 5 0',
  mail: 'M3.5 6.5h17v11h-17zM4 7l8 6 8-6',
  target:
    'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 16.5a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9zM12 12.5a.5.5 0 1 0 0-1',
  compass: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM15.5 8.5l-2 5-5 2 2-5z',
  users:
    'M9 11a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7zM3 20a6 6 0 0 1 12 0M16 4.5a3.5 3.5 0 0 1 0 6.5M18 14.5a6 6 0 0 1 3 5.5',
  forecast: 'M4 20h16M6 20v-6h3v6M10.5 20V9h3v11M15 20v-8h3v8',
  alert: 'M12 4 2.8 19.5h18.4zM12 10v4.5M12 17.2h.01',
  userPlus:
    'M9.5 11a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7zM3.5 20a6 6 0 0 1 10.8-3.6M18.5 14v6M15.5 17h6',
  help: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM9.6 9.3a2.5 2.5 0 0 1 4.8.9c0 1.6-2.4 2.2-2.4 3.6M12 16.8h.01',
  calendar: 'M4.5 6h15v14h-15zM4.5 10h15M8.5 3.5v4M15.5 3.5v4',
  search: 'M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14zM20 20l-4-4',
  bell: 'M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15zM10 20.5a2 2 0 0 0 4 0',
  export: 'M12 15V4M7.5 8.5 12 4l4.5 4.5M5 14v6h14v-6',
  plus: 'M12 5v14M5 12h14',
  chevronDown: 'M7 10l5 5 5-5',
  more: 'M6 12h.01M12 12h.01M18 12h.01',
  check: 'M5 12.5l4.5 4.5L19 7.5',
  minus: 'M6 12h12',
  close: 'M6 6l12 12M18 6 6 18',
  menu: 'M4 7h16M4 12h16M4 17h16',
  sidebar: 'M4 5h16v14H4zM9.5 5v14',
  arrowDown: 'M12 5v14M6.5 13.5 12 19l5.5-5.5',
  arrowUp: 'M12 19V5M6.5 10.5 12 5l5.5 5.5',
  trash: 'M5 7h14M10 4h4M7 7l1 13h8l1-13',
  note: 'M6 4h9l3 3v13H6zM9 11h6M9 15h4',
  spark: 'M12 3.5v4M12 16.5v4M3.5 12h4M16.5 12h4',
} as const;

export type IconName = keyof typeof PATHS;

export function Icon({
  name,
  className,
  width = 1.75,
}: {
  name: IconName;
  className?: string;
  width?: number;
}) {
  return (
    <svg
      viewBox="0 0 24 24"
      className={className}
      fill="none"
      stroke="currentColor"
      strokeWidth={width}
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
    >
      <path d={PATHS[name]} />
    </svg>
  );
}

/** The app's mark: a fern frond, three leaves on a stem, in a rounded tile. */
export function Mark({ className }: { className?: string }) {
  return (
    <svg viewBox="0 0 32 32" className={className} aria-hidden="true">
      <rect width="32" height="32" rx="9" fill="var(--mark-tile)" />
      <g fill="var(--mark)">
        <path d="M16 6.5c2.6 1.6 3.9 3.7 3.9 6.1-2.4.1-4.4-.9-5.9-3 .4-1.2 1.1-2.3 2-3.1z" />
        <path d="M15.4 13.6c-2.7-1.6-5.4-1.7-7.9-.3 1.4 2.4 3.6 3.6 6.4 3.6.6-1 1.1-2.1 1.5-3.3z" />
        <path d="M16.6 17.1c2.7-1.6 5.4-1.7 7.9-.3-1.4 2.4-3.6 3.6-6.4 3.6-.6-1-1.1-2.1-1.5-3.3z" />
      </g>
      <path
        d="M16 9.5c-.7 5.2-.6 10.1.4 15.5"
        fill="none"
        stroke="var(--mark)"
        strokeWidth="1.6"
        strokeLinecap="round"
      />
    </svg>
  );
}

/** The hair, by style: drawn behind the head (`back`) and over its top (`front`). */
const HAIR: Record<Face['style'], { back?: string; front?: string }> = {
  short: {
    front:
      'M8.6 13.4c-.4-4.4 2.4-7.2 7.4-7.2s7.8 2.8 7.4 7.2c-1.4-1.9-3.9-3-7.4-3.1-3.5.1-6 1.2-7.4 3.1z',
  },
  long: {
    back: 'M7.6 14c0-5.2 3.3-8.2 8.4-8.2s8.4 3 8.4 8.2v9.4H7.6z',
    front:
      'M8.7 13.6c.2-4.3 3-6.6 7.3-6.6s7.1 2.3 7.3 6.6c-2.6-.6-5-2-6.4-3.9-1.6 2-4.6 3.4-8.2 3.9z',
  },
  bun: {
    back: 'M16 2.6a3.2 3.2 0 1 1 0 6.4 3.2 3.2 0 0 1 0-6.4z',
    front: 'M8.7 13.4c.1-4.3 3-6.8 7.3-6.8s7.2 2.5 7.3 6.8c-2-1.9-4.5-2.9-7.3-2.9s-5.3 1-7.3 2.9z',
  },
  curly: {
    front:
      'M8.2 13.6c-1.3-1.6-.6-4 1.2-4.4.2-2 2-3.3 3.8-2.6 1.2-1.6 4.4-1.6 5.6 0 1.8-.7 3.6.6 3.8 2.6 1.8.4 2.5 2.8 1.2 4.4-1.6-1.2-4.4-2-7.8-2s-6.2.8-7.8 2z',
  },
  buzz: { front: 'M9 12.6c.3-3.8 3-5.9 7-5.9s6.7 2.1 7 5.9c-1.8-1-4.2-1.6-7-1.6s-5.2.6-7 1.6z' },
  bob: {
    back: 'M7.8 13.6c0-4.9 3.2-7.7 8.2-7.7s8.2 2.8 8.2 7.7v5.8H7.8z',
    front:
      'M8.6 13.8c.2-4.2 3-6.9 7.4-6.9s7.2 2.7 7.4 6.9c-3.6-.2-6.6-1.4-8.6-3.4-1.4 1.8-3.4 3-6.2 3.4z',
  },
  bald: {},
};

/**
 * An owner's face, flat and round: the circle behind, shoulders, the head, the hair, and glasses
 * or a beard when they wear one. Decorative: the owner's name is always beside it.
 */
export function FaceArt({ face, className }: { face: Face; className?: string }) {
  const hair = HAIR[face.style];
  return (
    <svg viewBox="0 0 32 32" className={className} aria-hidden="true">
      <circle cx="16" cy="16" r="16" fill={face.bg} />
      {hair.back && <path d={hair.back} fill={face.hair} />}
      <path d="M5.5 32c.6-5.6 4.8-8.6 10.5-8.6s9.9 3 10.5 8.6z" fill="var(--face-shirt)" />
      <path d="M13.6 20.6h4.8v4.2a2.4 2.4 0 0 1-4.8 0z" fill={face.skin} />
      <ellipse cx="16" cy="14.6" rx="7.1" ry="7.6" fill={face.skin} />
      {face.beard && (
        <path
          d="M9.4 15.6c.4 4.6 3 6.8 6.6 6.8s6.2-2.2 6.6-6.8c-1.2 1.6-2.4 2.2-3.6 2.2-1.1-.9-4.9-.9-6 0-1.2 0-2.4-.6-3.6-2.2z"
          fill={face.hair}
        />
      )}
      {hair.front && <path d={hair.front} fill={face.hair} />}
      <circle cx="13.3" cy="15.2" r=".85" fill="#2a1d17" />
      <circle cx="18.7" cy="15.2" r=".85" fill="#2a1d17" />
      <path
        d="M14.4 18.6c.9.6 2.3.6 3.2 0"
        fill="none"
        stroke="#7a3f2e"
        strokeWidth=".8"
        strokeLinecap="round"
      />
      {face.glasses && (
        <g fill="none" stroke="#1d1d1f" strokeWidth=".8">
          <circle cx="13.2" cy="15.2" r="2.1" />
          <circle cx="18.8" cy="15.2" r="2.1" />
          <path d="M15.3 15.1h1.4" />
        </g>
      )}
    </svg>
  );
}
```

### account-pipeline/demo-pointer.tsx

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import type { CSSProperties, Ref } from 'react';

/*
 * The demo's pointer, and the steps that move it. A demo is a script of awaited steps: wait, or
 * glide the pointer somewhere. Stopping the demo (the reader takes over, or it scrolls away) ends
 * the step in progress at once: its promise rejects, which ends the script right there, and the
 * pointer fades out.
 *
 * Each glide is a curved flight played by the Web Animations API, so nothing runs frame by frame.
 * The points of the flight are handed to whoever wants to move along with it. The arrow and the
 * hand are HTML boxes
 * that swap by their visibility: a change of style inside an SVG would lay the SVG out again.
 */

export type Point = { x: number; y: number };

/** A glide's path and timing, for an animation that plays along with it. */
export type Flight = { points: Point[]; timing: KeyframeAnimationOptions };

export type Demo = {
  /** Resolves after `ms`. */
  wait: (ms: number) => Promise<void>;
  /** Glides the pointer to `to`, in the stage's own px, in `ms`; `along` gets the flight. */
  glide: (to: Point, ms: number, along?: (flight: Flight) => void) => Promise<void>;
  /** Shows the arrow, or the hand a link shows. */
  glyph: (name: 'arrow' | 'hand') => void;
};

/** What a stopped demo's pending step rejects with. */
class Stopped extends Error {}

/** Where the arrow's tip is, as shares of its box: the point the pointer stands on. */
const TIP: Point = { x: 0.15, y: 0.1 };

/** How many points a flight is drawn through. */
const SAMPLES = 24;

/** Plays `script` with the pointer over `stage`; returns the function that stops it. */
export function runDemo(
  stage: HTMLElement,
  pointer: HTMLElement,
  script: (demo: Demo) => Promise<void>,
): () => void {
  let alive = true;
  let flight: Animation | null = null;
  // The stylesheet sizes the pointer from the stage's width; its tip is where it stands.
  const tip = { x: pointer.offsetWidth * TIP.x, y: pointer.offsetHeight * TIP.y };
  const place = ({ x, y }: Point) => `translate(${x - tip.x}px, ${y - tip.y}px)`;
  const timers = new Set<number>();
  const pending = new Set<() => void>();
  // The pointer comes in from the lower right.
  let at: Point = { x: stage.offsetWidth * 0.8, y: stage.offsetHeight * 0.9 };

  /** Settles like `promise`, or rejects as soon as the demo stops. */
  const step = (promise: Promise<unknown>) =>
    new Promise<void>((resolve, reject) => {
      if (!alive) return reject(new Stopped());
      const cancel = () => reject(new Stopped());
      pending.add(cancel);
      promise.then(
        () => {
          pending.delete(cancel);
          if (alive) resolve();
        },
        () => {
          pending.delete(cancel);
          reject(new Stopped());
        },
      );
    });

  const wait = (ms: number) =>
    step(
      new Promise<void>((resolve) => {
        const timer = window.setTimeout(() => {
          timers.delete(timer);
          resolve();
        }, ms);
        timers.add(timer);
      }),
    );

  const glide: Demo['glide'] = (to, ms, along) => {
    const from = at;
    at = to;
    const dx = to.x - from.x;
    const dy = to.y - from.y;
    // A gentle curve, as a hand moves: the control point sits off the straight line.
    const bend = { x: (from.x + to.x) / 2 - dy * 0.18, y: (from.y + to.y) / 2 + dx * 0.18 };
    const points: Point[] = [];
    for (let i = 0; i <= SAMPLES; i += 1) {
      const t = i / SAMPLES;
      const u = 1 - t;
      points.push({
        x: u * u * from.x + 2 * u * t * bend.x + t * t * to.x,
        y: u * u * from.y + 2 * u * t * bend.y + t * t * to.y,
      });
    }
    const timing: KeyframeAnimationOptions = {
      duration: ms,
      easing: 'cubic-bezier(0.45, 0, 0.25, 1)',
    };
    flight?.cancel();
    // Where it rests once the flight is over.
    pointer.style.transform = place(to);
    flight = pointer.animate(
      points.map((point) => ({ transform: place(point) })),
      timing,
    );
    along?.({ points, timing });
    return step(flight.finished);
  };

  const glyph: Demo['glyph'] = (name) => {
    pointer.dataset.glyph = name;
  };

  pointer.dataset.glyph = 'arrow';
  pointer.style.transform = place(at);
  pointer.style.opacity = '1';
  script({ wait, glide, glyph }).catch((error: unknown) => {
    if (!(error instanceof Stopped)) throw error;
  });

  return () => {
    if (!alive) return;
    alive = false;
    timers.forEach((timer) => window.clearTimeout(timer));
    flight?.cancel();
    pending.forEach((cancel) => cancel());
    pointer.style.opacity = '0';
  };
}

/**
 * The pointer's box: it moves, on a layer of its own. Its size comes from its class, its colours
 * from the stage's tokens (account-pipeline.module.css).
 */
const POINTER: CSSProperties = {
  position: 'absolute',
  top: 0,
  left: 0,
  zIndex: 2,
  display: 'block',
  pointerEvents: 'none',
  opacity: 0,
  transition: 'opacity 0.3s ease',
  filter: 'drop-shadow(0 1px 1.5px var(--pointer-shadow))',
  willChange: 'transform',
};

/** One glyph over the other, each filling the box. */
const GLYPH: CSSProperties = { position: 'absolute', inset: 0, display: 'block' };
const DRAWING: CSSProperties = {
  display: 'block',
  width: '100%',
  height: '100%',
  overflow: 'visible',
};
/** The arrow is dark on a white edge, the hand white on a dark one, as the system draws them. */
const ARROW: CSSProperties = { fill: 'var(--pointer)', stroke: 'var(--pointer-edge)' };
const HAND: CSSProperties = { fill: 'var(--pointer-edge)', stroke: 'var(--pointer)' };

/**
 * The pointer the demo moves around: an arrow, or a pointing hand over what it can press. It is
 * decorative: what it does shows on the table itself. The stylesheet shows one glyph at a time,
 * from the box's data-glyph.
 */
export function DemoPointer({
  ref,
  className,
  arrowClass,
  handClass,
}: {
  ref: Ref<HTMLSpanElement>;
  className?: string;
  arrowClass?: string;
  handClass?: string;
}) {
  return (
    <span ref={ref} className={className} style={POINTER} aria-hidden="true">
      <span className={arrowClass} style={GLYPH}>
        <svg viewBox="0 0 20 20" style={DRAWING}>
          <path
            d="M3 2v14.5l3.6-3.3 2.6 5.6 2.4-1.1-2.6-5.5h5.2z"
            style={ARROW}
            strokeWidth="1.3"
            strokeLinejoin="round"
          />
        </svg>
      </span>
      <span className={handClass} style={GLYPH}>
        <svg viewBox="0 0 20 20" style={DRAWING}>
          {/* The tip of the finger sits where the arrow's tip is. */}
          <path
            d="M6.4 3.3c0-.8.6-1.4 1.3-1.4S9 2.5 9 3.3v5.5c.2-.5.6-.8 1.2-.8.7 0 1.2.5 1.2 1.2v.5c.2-.5.6-.8 1.2-.8.7 0 1.2.5 1.2 1.2v.7c.2-.4.6-.7 1.1-.7.7 0 1.2.5 1.2 1.2v3.5c0 2.8-1.9 4.9-4.6 4.9h-1.2c-1.8 0-3.1-.8-4.1-2.3l-2.6-3.9c-.4-.6-.2-1.3.4-1.7.6-.3 1.3-.2 1.7.4l.6.9z"
            style={HAND}
            strokeWidth="1.1"
            strokeLinejoin="round"
            transform="translate(-4.7 0.1)"
          />
        </svg>
      </span>
    </span>
  );
}
```

### account-pipeline/use-autoplay.ts

```tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.

'use client';

import { useCallback, useEffect, useRef, useState } from 'react';

/*
 * When a demo may play on its own: while part of it is on screen and the tab is visible, never
 * under reduced motion, and never again once the reader has used it. `take()` hands it to the
 * reader for good: the first real input stops the demo until the component mounts again (WCAG
 * 2.2.2).
 */
export function useAutoplay<T extends HTMLElement>() {
  const ref = useRef<T>(null);
  const [visible, setVisible] = useState(false);
  const [reduced, setReduced] = useState(true);
  const [taken, setTaken] = useState(false);

  useEffect(() => {
    const element = ref.current;
    if (!element) return;
    let onScreen = false;
    const update = () => setVisible(onScreen && !document.hidden);
    const observer = new IntersectionObserver(
      ([entry]) => {
        onScreen = entry.isIntersecting;
        update();
      },
      { threshold: 0.3 },
    );
    observer.observe(element);
    document.addEventListener('visibilitychange', update);
    const motion = window.matchMedia('(prefers-reduced-motion: reduce)');
    const readMotion = () => setReduced(motion.matches);
    readMotion();
    motion.addEventListener('change', readMotion);
    return () => {
      observer.disconnect();
      document.removeEventListener('visibilitychange', update);
      motion.removeEventListener('change', readMotion);
    };
  }, []);

  const take = useCallback(() => setTaken(true), []);

  return { ref, take, visible, reduced, playing: visible && !reduced && !taken };
}
```