# ScanWin Admin — Bootstrap 5.3.2 migration

Working context for this repo. Read this first in a new session.

**Repo root for this work:** `ScanWinFinal 2/admin/` (admin portal only — do not touch sibling portals).
**Branch:** one per page, `refactor/bootstrap-<page>`, merged to `main` via PR. **Main:** `main`.

---

## 1. The brief

The project was contractually specified to be built on **Bootstrap 5.3.2** and will be integrated into
**Laravel Blade**. Two problems were flagged by the client and backend team:

1. **Bootstrap wasn't used.** It loads via CDN, but ~98% of styling was hand-written custom CSS
   instead of Bootstrap's grid, components and utilities.
2. **Duplicated, page-local assets.** Every page carried its own CSS/JS with the same code
   copy-pasted across pages — causing style/JS conflicts (dropdowns and select inputs breaking)
   and making a Blade layout impossible.

### The three rules that override everything

1. **The design must not change.** Not by a pixel a client would notice. This is a refactor of *how*
   styling is implemented, not *what* it looks like. If a migration would alter output and you can't
   preserve it — **stop and report**, don't ship "close enough."
2. **Use Bootstrap as much as humanly possible within Rule 1.** The burden of proof is on custom CSS.
   Default answer is "use the Bootstrap class." Custom CSS must be justified **in writing, in the CSS
   file, naming the doc page checked**.
3. **Shared code goes in shared files; nothing is duplicated.** Anything used by >1 page belongs in a
   common file. Page-specific code is the minimal exception. End state must slot into a Blade layout.

**Target:** Bootstrap ~80–90% of structure/layout/spacing/typography/components; custom ~10–20% for
brand refinement only — and that 10–20% lives in shared files.

### Mandatory: check the docs before any "Bootstrap can't do this"

**Do not work from memory.** Open the actual docs for every pattern:
- Components https://getbootstrap.com/docs/5.3/components/
- Utilities https://getbootstrap.com/docs/5.3/utilities/
- Layout https://getbootstrap.com/docs/5.3/layout/
- Forms https://getbootstrap.com/docs/5.3/forms/
- CSS variables https://getbootstrap.com/docs/5.3/customize/css-variables/

Routinely missed: `.hstack`/`.vstack`, Utilities API, component `--bs-*` variables, `.object-fit-*`,
`.ratio`, `.text-bg-*`, `.focus-ring`, `.icon-link`, `.z-*`, `.placeholder`, `.visually-hidden`,
`.sticky-top`, `.order-*`, `.row-cols-*`, floating labels, `.list-group` variants, `.table-*`
variants, color modes (`data-bs-theme`).

Any keep-as-custom decision **must cite the doc page checked**. Uncited = not acceptable.

### Decisions already made by the user

- **No Sass build.** CDN + CSS custom-property theming only.
- **Use Bootstrap JS** (`data-bs-*` / the JS API) wherever behavior matches; keep custom JS only where
  Bootstrap genuinely can't express it, but still adopt Bootstrap markup/classes.
- **One page at a time**, full verification, its own commit, then **stop for approval**.

---

## 2. Current status

**All 25 pages migrated** (dashboard merged as PR #18; messages is this branch), plus the shared-asset restructure, the shared button layer, the
shared `.sw-dd`→`.btn` layer and the shared `.sw-sheet`→Bootstrap-Modal layer.
Every step verified at 0.0000%.

| # | Page | Commit |
|---|---|---|
| 1 | password-updated | `5fcbd7a` |
| 2 | check-email | `1ab78e6` |
| 3 | forgot-password | `59067e7` |
| 4 | reset-password | `f284c3a` |
| 5 | contact-support | `1cc68fc` |
| 6 | login (+ modal, asset split, shell pass) | `55c8682`, `3815a18`, `db4ff90`, `f30ea26`, `bb455b2` |
| 7 | **profile** (+ 2 deepening passes) | `18af3ee`, `4ac01a0`, `855ebe3` |
| 8 | notifications | `0515ea7` |
| 9 | data-warehouse (+ Bootstrap Modal) | `114c2dd`, `2186ef0` |
| — | shared JS + CSS dedupe | `280692e` |
| 10 | **analytics** | `90e4bb2`, `a3e6d67` |
| — | `admin-components.css` extraction | `a683baa` |
| — | shared button themes + disabled-blue fix | `e7cd4fa` |
| 11 | **roles** (+ Edit-permissions sheet, + deepening pass) | `8e31820`, `fecd09e`, `daae8ea`, `884c452` |
| — | **shared `.sw-dd__toggle` → `.btn`** (all 123 toggles, 14 pages) | `df3cc13` |
| 12 | **reports** (+ New-report sheet) | `ac79c4f` |
| — | all `.btn` focus rings aligned to the brand ring | `e17b56c` |
| 13 | **users + advertisers** (+ 6 dialogs, + 2 deepening passes) | `63fe9b7`, `221ba1a`, `0de5e1f` |
| — | **shared `.sw-sheet` → Bootstrap Modal** (all 23 sheets, 13 pages) | `6ad7e44`…`9db3672` |
| 14 | **products** (+ list view, create/edit/delete sheets, + deepening pass) | `1ca94d2`, `c58b117`, `bb92e9c`…`42e5882` |
| 15 | **ad-campaigns + sales-campaigns + influencer** (cluster, `admin-campaigns.css`) | `45544c9`…`3e74b7a`, `c43534e`…`586e48f` |
| 16 | **merchants + chains + distributors + divisions + locations** (cluster, `admin-merchants.css`; + rows-per-page dropdown fix + 2 deepening passes) | `385f865`, `3adbc39`, `c274a3b`, `a4c0fb5` |
| 17 | **messages** (two-pane chat: utility adoption in the visible chat) | this branch |
| 18 | **dashboard** (+ shared `.sw-card__*` card-chrome & KPI lockstep across analytics/data-warehouse/reports) | PR #18 |

**Remaining order:** none — all 25 pages migrated (dashboard PR #18, messages PR #19).

**Post-migration: shared-asset dead-code prune** (`refactor/prune-dead-shared`). A usage scan (every
style.css class vs all HTML `class=""` + JS `className`/`querySelector`) found **~56% of `style.css`
was dead-in-admin**: three modal families the *other* portals use but admin never renders —
**share / QR / generate-link** (846 decls, no markup anywhere in admin, and their `main.js` handlers
bail on `if (!modal) return`) — plus 96 truly-dead legacy declarations (`.sw-card` container [dashboard
moved to `.card`], `.sw-btn-live`, `.sw-icon-btn`, `.sw-verify-badge`, `.sw-view-all`,
`.sw-streak__icon`, `.sw-sidebar__drawer-foot`). Removed the CSS (`style.css` 1693 → 751 custom, −56%;
+ 3 dead rules in `responsive.css`) and the matching `main.js` handlers (1368 → 805 lines, −41%),
keeping every live system (dropdowns, toasts, notifications, sheet-modals) — `node --check` clean,
`dd-test`/`dd-portal-test` green with **0 console errors**. Exact by construction: `1693 − 942 dead
(846 modal + 96 legacy) = 751`, braces balanced 186/186. Verified all **303 page shots** unchanged
(0.0000% + the same pre-existing residuals). **Trap avoided:** false positives — `.sw-toast--success`
etc. are JS-*templated* (`"sw-toast--" + kind`), so they scan as "unused" but are live; kept.

**Follow-up prune — `admin-components.css` (`refactor/prune-dead-components`).** The same usage scan
found this file is **almost entirely live** (it is the shared component library — `.sw-dd`, `.sw-sheet`,
`.sw-modal`, `.sw-eu-*`, `.sw-cu-*`, form fields, toolbar; 53 `--bs-*` inputs already), NOT dead like
style.css. Only **7 orphaned legacy classes** survived from before the create-user form was re-shelled to
`.sw-eu-*`/`.sw-cu-*`/`.sw-sheet`: `.sw-modal--form`/`__head`/`__sub`/`__form`, `.sw-field-row`,
`.sw-field__hint`, `.sw-uselect` (all **0** html/js references, direct-grep confirmed; their live
siblings `.sw-modal__close`/`__title`, `.sw-field`/`__label`/`__input`, `.sw-seg`, `.sw-ufilters` stay).
Removed **8 pure-dead rules (22 declarations, 755 → 733)** + stripped the dead `.sw-uselect,` token from
the `.sw-uselect, .sw-ufilters` mixed comma-rule (declarations unchanged — the conservative
`selectorFullyDead` guard keeps any comma-rule with one live part). Braces balanced 206/206. Verified
**0.0000%** across 127 page shots + 45 form-modal shots (adv + users, branch-vs-clean-main via worktree —
the exact modals that neighbour the removed classes), `dd-test`/`dd-portal-test` green, 0 console errors.
**The buggy first scan flagged 118 "dead" classes** (all of `.sw-dd`/`.sw-sheet`/`.sw-modal`…) — a shell
mangled the inline `\b` regex; the file-based literal-substring scanner gave the real 7. Beyond this dead
code, admin-components.css has no no-markup-change Bootstrap left: the rest is register-justified bespoke
(the `.sw-dd` select-replacement, the Modal shells, the segmented control) or flex/spacing that would need
a **cross-page markup lockstep across all 19 app pages** to move to utilities.

Pages share stylesheets, so a page's turn may also require re-verifying its cluster:
- `admin-campaigns.css` → ad-campaigns, sales-campaigns, influencer
- `admin-merchants.css` → merchants, chains, distributors, divisions, locations
- `admin-users.css` → users, advertisers **only** — these are the sole two pages that `<link>` it.
  (An earlier note claimed 4 more pages — ad-campaigns, sales-campaigns, influencer, reports — also
  loaded it; that was stale. The actual `<link>` was removed from all four back in `a683baa` when
  `admin-components.css` was extracted; only leftover comments naming `admin-users.css` survived,
  since corrected. Re-verified: the only `admin-users.css` class any of those four references is
  `.sw-btn-ghost`, and that is defined in `admin-components.css`, so nothing is uniquely provided.)

---

## 3. Asset structure (Blade-ready — established, do not regress)

Uniform load order on all 19 app pages; maps 1:1 onto a Blade master layout:

```
Bootstrap 5.3.2 CDN css   (exactly once)
style.css                 brand tokens + Bootstrap theme inputs, app shell, modals, toasts   ← all 25
responsive.css            shell breakpoints                                                  ← all
admin.css                 admin shell + dashboard widgets                                    ← 19 app pages
admin-components.css      SHARED component library                                           ← 19 app pages
[admin-users.css]         users + advertisers table               ← LOADED by 2, USED by 2
admin-<page>.css          page-specific deltas ONLY
--- end of body ---
Bootstrap 5.3.2 bundle js (exactly once)
main.js                   shared behaviour
admin-<page>.js           page-specific behaviour ONLY
```

The 6 **auth** pages use a parallel chain — `login.css` is their shell, the counterpart to
`admin-components.css`:

```
style.css
responsive.css            ← NOTE: login.html alone does not load this (pre-existing, unresolved)
login.css                 AUTH SHELL — showcase + form panel + auth field/checkbox/button   ← 6 pages
[forgot-password.css]     check-email, forgot-password, reset-password, password-updated     ← 4 pages
[contact-support.css]     contact-support only
[login-choose-profile.css] login only — the Bootstrap-Modal profile chooser
```

- **`login.css` is a shell, not a page file** despite its name. Anything used by only one auth page
  goes in that page's own file. The choose-profile modal lived in it until `db4ff90`, making the
  other five pages download ~10.8 KB they could never match.
- **Zero** inline `<style>` blocks, inline `style=` attributes, or inline event handlers on migrated
  pages. Keep it that way.
- `admin-components.css` (~1285 lines) holds: page header + toolbar, `.sw-dd` brand dropdown
  (+ portal/toolbar variants), `.sw-sheet`, modals, buttons, form fields, import dropzone,
  `.sw-eu-*` modal shell, `.form-switch` skin, pager, and the shared components' responsive rules.
- **Never** put shared rules back into a page file. Before adding a rule, grep whether another page
  uses the class (`grep -l "class=\"[^\"]*sw-foo" *.html`).

### Shared JS API (`main.js`)

```js
window.swInitDropdowns(root | ddElement)  // wire/re-wire .sw-dd (idempotent, portal-aware)
window.swCloseDropdowns(except)
window.swNotify({ kind, title, body })    // toast; kind: success | error | info
window.swToast({...})                     // lower-level toast primitive
// selection fires a bubbling `dd:change` event with detail.value
```

**Why this matters:** `.sw-dd` used to be copy-pasted into 8 page scripts. On pages loading two
scripts (`influencer.html` loads `admin-campaigns.js` *and* `admin-influencer.js`) every toggle was
wired twice — that was the client's "dropdowns and select inputs breaking." One implementation now.
`notify()` was likewise redefined in 11 files. **Do not reintroduce either.**

---

## 4. Verification harness (`.visual/`) — non-negotiable

```bash
cd .visual
npm install                       # first time only (playwright, pixelmatch, pngjs)
npx playwright install chromium   # first time only

node capture.mjs baseline [page…] # write .visual-baseline/
node capture.mjs current  [page…] # write .visual-current/
node compare.mjs          [page…] # diff, threshold 0.1%, overlays -> .visual-diff/

node dd-test.mjs                  # drives a dropdown on all 25 pages
node dd-portal-test.mjs           # dropdowns inside dialogs (portal path)
node dialog-shot.mjs <suffix>     # data-warehouse's reject dialog (desktop + phone sheet)
node cp-modal-shot.mjs baseline|current   # login's choose-profile modal, 2 states x 5 widths
node ep-modal-shot.mjs baseline|current   # roles' Edit-permissions sheet, 2 states x 5 widths
node nr-modal-shot.mjs baseline|current   # reports' New-report sheet, 2 states x 5 widths
node adv-modal-shot.mjs baseline|current  # advertisers' 2 dialogs x 5 widths
node pf-modal-shot.mjs baseline|current    # profile's 2FA modal, 2 states (Verify
                                          #   disabled / enabled) x 3 widths — the
                                          #   ONLY place a .sw-btn-primary renders disabled
node sheets-shot.mjs baseline|current [page…]  # config-driven: the merchants cluster,
                                          #   products, influencer and both campaign
                                          #   wizards. Each case carries an `upTo` width —
                                          #   a filter sheet's trigger is display:none above
                                          #   a per-page breakpoint, so it is only shot where
                                          #   it actually exists.
node users-modal-shot.mjs baseline|current # users' SIX dialogs (filters, create, view, edit,
                                          #   suspend, delete) x 5 widths = 30 shots
                                          # SW_SRC=<other admin/> shoots a baseline from a
                                          # worktree that has no node_modules of its own
node products-list-shot.mjs baseline|current  # products' [hidden] list-view surface x 5 widths
node camp-filter-shot.mjs baseline|current    # the campaigns cluster's [hidden] filter popover,
                                          #   only at the per-page widths where its trigger exists
node wiz-steps-shot.mjs baseline|current       # both campaign wizards, ALL 5 steps x 2 widths.
                                          #   capture.mjs / sheets-shot open the wizard on step 1
                                          #   only, so steps 2-5 had no baseline without this.
node messages-shot.mjs baseline|current        # messages' JS-only states: the mobile inbox
                                          #   master view (data-view="inbox", <992) and the
                                          #   sw-msg-app--empty placeholders. Page load only
                                          #   ever shows data-view="chat", so neither has a
                                          #   baseline from capture.mjs.
```

**Fixed-script full-suite count is 248 shots**, enumerated: 25 pages x 5 widths = 125, +
`roles--560`, + `analytics--520`, + 2 data-warehouse dialog states, + 10 login choose-profile,
+ 10 roles Edit-permissions, + 10 reports New-report, + 10 advertisers dialogs, + 30 users
dialogs, + 5 products list view, + 8 campaigns filter popover, + 20 campaign-wizard steps
(2 pages x 5 steps x 2 widths), + 6 messages JS-states (2 mobile-inbox + 4 empty). **On top of
that**, `sheets-shot.mjs` adds config-driven cases — the merchants cluster's filter/create/edit
sheets, plus products' and influencer's create/edit sheets.

**JS-opened UI has no baseline unless you make one.** `capture.mjs` only shoots page load, so
modals/sheets/popovers are invisible to it. `cp-modal-shot.mjs` writes `<name>--<width>.png` into
the same directories, so `compare.mjs login-cp-open login-cp-selected` picks them up unchanged —
follow that naming for any future state capture. **Capture the baseline BEFORE migrating**, or
there is nothing to verify against.

- 25 pages × 5 widths (375/768/992/1440/1920), full-page, reduced-motion, fonts settled.
- Chromium runs with **`--disable-lcd-text`** — it silently flips between subpixel and grayscale
  antialiasing per composited layer during full-page capture, producing phantom text diffs with
  identical geometry. Do not remove this flag.
- **Never run two `compare.mjs` at once** — they share `.visual-diff/` and produce bogus results.
- Screenshots can't see behavior. Modals/dropdowns need `dialog-shot.mjs` / `dd-test.mjs`.
- **Any shared-file change ⇒ re-run all 127 page shots** (125 + `roles--560` + `analytics--520`)
  **plus every JS-state script**, not just the current page.

### Per-page workflow

1. Say which page and what you plan to change.
2. Read the page + its CSS + its JS. Check Bootstrap docs per pattern.
3. Migrate: grid/layout → components → utilities → variables → cleanup.
4. `capture.mjs current <page> [cluster pages]` + `compare.mjs`. Investigate anything >0.1%.
5. Drive the interactive behavior in Playwright (dropdowns, modals, toggles, validation, focus).
6. Commit `refactor(bootstrap): migrate <page>`, report, **stop for approval**.

---

## 5. Patterns established (reuse; don't re-litigate)

### Bootstrap theming already in place
- `style.css :root` maps brand tokens to Bootstrap inputs: `--bs-primary(-rgb)`,
  `--bs-body-font-family`, `--bs-body-color(-rgb)`, `--bs-secondary-color`, `--bs-tertiary-color`,
  `--bs-border-color`. So `.text-body-secondary` / `.text-body-tertiary` are on-brand — use them
  instead of custom color declarations.
- Global `.card` theme: `--bs-card-border-color`, 16px radius, `--bs-card-spacer-*: 20px`
  (16px on phones), soft shadow. Use `.card`/`.card-body`; don't re-declare padding.
- `.card > .list-group` inherited borders are neutralized globally.
- `.modal-backdrop` themed brand-dark.
- Buttons: theme via `--bs-btn-*` variables on the brand class (`.sw-create`, `.sw-export`,
  `.sw-btn-submit`, `.sw-qact--ok`…), never by overriding `.btn` output.

### Component conversions proven
| Pattern | Bootstrap | Notes |
|---|---|---|
| Cards | `.card` / `.card-body` / `.card-header` | + `h-100` inside grid cols |
| Card grids | `.row .row-cols-2 .row-cols-xl-4 .g-3` | design's 1200px = `xl`; 16px gap = `g-3` |
| Divided row lists | `.list-group .list-group-flush` + `--bs-list-group-*` | docs-canonical for rows in a card |
| Pills/badges | `.badge` (+`.rounded-pill`) + `--bs-badge-*` | **must** restore `line-height: var(--bs-body-line-height)` — badge hardcodes 1 |
| Toggles | `.form-check.form-switch` + skin | 44×26 track, thumb shadow baked into the SVG thumb image; keyboard-focusable |
| Confirm dialogs | `.modal` + `.modal-dialog-centered` + `--bs-modal-*` | dual-mode: phone bottom-sheet via `.modal-dialog` transform override. **Proven pixel-identical** |
| Auth inputs | `.form-control` + `.sw-auth-input` | icons via `position-absolute top-50 translate-middle-y` |
| Alerts | `.alert` + `--bs-alert-*` | |
| Checkbox | `.form-check-input` + `--bs-form-check-bg-image` | custom glyph at native size |
| Bare text buttons ("Edit", "Change") | `.btn` + `--bs-btn-padding-*: 0`, `--bs-btn-border-width: 0` | strips `.btn` to plain text via its own inputs; `.btn` supplies `cursor: pointer`. **See gotcha 9** |
| Hand-rolled overlay + backdrop + sheet | `.modal.fade` + `.modal-dialog-centered` + `.modal-content` + `--bs-modal-*` | Bootstrap builds the backdrop; delete the custom one. Phone sheet = `.modal-dialog` transform override. **See gotchas 12, 15** |
| Card grid that restacks 2→1 at 576px | `.row .row-cols-1 .row-cols-sm-2 .align-items-start` + `--bs-gutter-x/y` | design's 576px break *is* `sm`; `align-items-start` stops equal-height stretch. Put `role="none"` on `.col` to preserve `radiogroup`→`radio` |
| Utility-styled element with state changes | keep the utility, re-point its `--bs-*` input | `.border` + `--bs-border-color`/`-width` on `:hover`/`.is-selected` restyles without fighting the utility's `!important` |

### Hard-won gotchas (each cost a debugging cycle — don't rediscover)
1. **`.fs-*` utilities are RFS-responsive** below 1200px viewports. They cannot hold an exact px size.
   Exact sizes stay in CSS. (`fs-5` = 20px is below the scaling threshold, so it's safe.)
2. **Utility classes are `!important`** — `gap-3` overrode a responsive 12px gap. Responsive-varying
   values stay in CSS.
3. **Bootstrap's own selectors out-specify a bare class.** `.form-check-input:checked[type=checkbox]`
   beats `.my-class:checked`; match the `[type=…]` to win. Same for `.card > .list-group`.
4. **`.flex-grow-1` ≠ `flex: 1`** (basis `auto` vs `0`) — changes wrapping at phone widths.
5. **`.list-group-item` sets `text-align: inherit`**; a `<button>`'s UA `center` is lost — add
   `.text-center` if the design centers it.
6. **`.list-group-item-action` color** must come from `--bs-list-group-color` (the item rule
   out-cascades the action rule at rest).
7. **`.badge` hardcodes `line-height: 1`.**
8. Replacing `.sw-card` with `.card` also drops responsive.css's phone padding — re-add it.
9. **Base `.btn` leaves `--bs-btn-hover-color`, `--bs-btn-active-color` and
   `--bs-btn-focus-shadow-rgb` UNDEFINED** — only the `.btn-*` color variants set them. On a bare
   `.btn` they are guaranteed-invalid substitutions, so `color: var(--bs-btn-hover-color)` falls
   back to `inherit` (your brand color turns body-dark on hover) and the focus ring collapses to
   nothing **while `.btn:focus-visible` still applies `outline: 0`** — i.e. no visible focus
   indicator at all. Always set all three when using `.btn` without a color variant.
10. **`.text-break` ≠ `overflow-wrap: anywhere`.** The utility sets `word-break: break-word`, which
   does not affect min-content sizing the same way. Not a substitute inside narrow grid columns.
11. **Count CSS declarations with a comment-stripped, `;`-aware counter.** A line-anchored
   `grep '^\s*prop:'` silently misses every declaration after the first on a single-line rule —
   it under-reported this repo's page CSS by ~2×.
12. **A unitless `0` in a `--bs-*` variable can invalidate a `calc()`.** `--bs-modal-margin: 0`
   breaks `.modal-dialog-centered`'s `min-height: calc(100% - var(--bs-modal-margin) * 2)` — you
   cannot subtract a unitless number from a percentage, so the whole expression is dropped and
   `min-height` falls back to `0`. The phone bottom sheet then renders at the **top** of the
   viewport. Always write `0px` when a variable feeds a `calc()`.
13. **A `<button>` is fit-content sized even with `display: flex`.** Inside a CSS grid it stretched
   via `justify-self`; inside a flex `.col` it does not, so button-cards shrink to their text and
   each ends up a different width. Add `.w-100`. (A `<div>` would have filled it — this bites only
   on form controls.)
14. **Sample computed styles AFTER transitions settle.** A `transition: box-shadow .15s` makes
   `getComputedStyle` return the interpolation start (`rgba(0,0,0,0) 0 0 0 0`) if read immediately
   after focus — which reads exactly like a missing focus ring. Wait ~400ms before asserting.
15. **`.btn-close` is not a drop-in for a custom close glyph.** It paints its X as a
   `background-image` of a **filled** path at `1em`. A design using an inline **stroked** SVG with
   round caps cannot be matched by it — keep the SVG and put `.btn` on the button instead.
16. **Re-pointing a `--bs-*` variable only works where the component reads it.** `.form-check-input`
   draws `border: var(--bs-border-width) solid var(--bs-border-color)`, so the variables control the
   **rest** state — but `.form-check-input:checked` sets `border-color` as *direct output* at
   `(0,2,0)`, which out-cascades that `(0,1,0)` shorthand. Re-pointing the variable silently leaves
   the checked border at Bootstrap's `#0d6efd`. Check for a state rule that writes the property
   directly before converting it to a variable. (Same family as gotcha 3.)
17. **`.form-control:focus` hardcodes its focus ring** — `box-shadow: 0 0 0 .25rem
   rgba(13,110,253,.25)`. It does **not** read `--bs-focus-ring-*`. The `.focus-ring` utility would
   only beat it on source order inside `bootstrap.css`, which is not a documented guarantee. Keep a
   custom `box-shadow` on themed inputs.
18. **A sub-threshold diff still has a cause.** A 0.0096% diff bounding-boxed to a 20×20 region —
   one checkbox — and turned out to be gotcha 16. `compare.mjs` only writes an overlay above 0.1%,
   so for small diffs, bounding-box the differing pixels and then diff computed styles.
   **But first prove it's yours:** `git worktree add /tmp/x main` and run the same comparison there.
   Five data-warehouse shots (0.015–0.043%) reproduce identically on clean `main` — that drift is
   pre-existing, not something this branch introduced.
19. **Gotcha 8 also runs in reverse.** Adopting `.card` *imports* style.css's phone rule that tightens
   `--bs-card-spacer-*` to 16px below 576px. A custom card with a flat inset at every width must pin
   **both** spacers, or 375/520 drift while the desktop widths stay clean.
20. **A design breakpoint between two capture widths is invisible.** Analytics' KPI grid steps at
   479.98px, which lies between the 375 and 768 shots — `.row-cols-1 .row-cols-sm-2` would have
   stacked at 576 instead and still reported 0.0000%. Bootstrap's smallest breakpoint is `sm`/576,
   so any design break below that needs a media query **and** an extra capture width
   (`SW_WIDTHS=520 node capture.mjs …`).
21. **`.btn-primary` is the brand's solid violet button — don't re-declare it.** style.css re-skins
   it once; pages pair `.btn .btn-primary` and add geometry only. Four page files had each
   hand-copied 9–13 of those variables. Same for `.sw-btn-outline` (the white/hairline secondary) in
   `admin-components.css`.
22. **Before extracting a "shared theme", diff the COMPLETE variable set.** Sampling
   bg/color/hover-bg made five button pairs look identical; reading every variable showed only one
   true duplicate. The rest differed in hover identity, and merging them would have changed the
   design. A class with one consumer is indirection, not reuse.
23. **Scope `sed -i` to the files you mean.** `sed -i … *.html` rewrote all 25 pages, changing line
   endings on the 20 it never matched. They stage as no-ops (git normalizes), but `git status` shows
   them modified and the noise hides real changes.
24. **The CSS files are CRLF — multi-line `perl -0777` patterns using `\n` SILENTLY match nothing.**
   This bit twice in one session: the substitution reports success, exits 0, and changes nothing, so
   the old declaration survives alongside the new utility and the layout doubles up. Use the Edit
   tool for multi-line CSS edits, or `\R` / `\r?\n` in the pattern. `sed` is line-based and is fine
   — but only if the rule is still formatted the way you last read it (the linter reflows
   single-line rules to multi-line, which silently breaks single-line `sed` patterns too).
25. **Convert ONE pattern at a time, verify, then the next.** Batching ~15 markup conversions before
   stripping the matching CSS means both apply at once: utilities are `!important` so they win where
   they overlap, the original declarations still apply where they don't, and the page grows. The
   diff then tells you *that* it broke, not *which* of the fifteen did it. Section 4's per-page
   workflow says migrate then verify per pattern — follow it.
26. **`repeat(N, 1fr)` and `.row-cols-N` are NOT bit-identical.** CSS Grid spreads the leftover
   1/64px LayoutUnits across the tracks so they sum exactly to the container — roles' 5-up shadow
   grid measures `202.1875 / 202.2031 ×3 / 202.1875` at 1440. Bootstrap's columns are a flat
   `width: 20%`, which is uniform, so the shortfall accumulates left to right and the last card sits
   **3/64px = 0.047px** early. The exact math is identical (col inner width and every x are equal to
   the last decimal); only Blink's rounding differs. It shows up as ~10 antialiased sub-pixels on one
   glyph — 0.0008%. Irreducible while the grid is Bootstrap's. Grids whose free space happens to
   divide evenly into 1/64ths (analytics' 2-up and 4-up) hit 0.0000% and hide this.
27. **A comment containing `*/` inside a glob closes it early.** Writing `.text-bg-*/.bg-*` or
   `.w-*/.h-*` in a CSS doc comment terminates the comment at that slash, so the rest of the prose
   parses as declarations and the following rule is destroyed. Cost two edit cycles in one session
   — the linter flags it as "at-rule or selector expected" several lines *below* the real cause.
   Write "the .w- and .h- families" instead.
28. **A `.d-*` utility will beat your own `display: none` in a max-width media query.** Adopting
   `.d-grid` on the matrix rows silently *un-hid* the header row that `@media (max-width: 1199.98px)`
   hides, because the utility is `!important` and the media rule is not — the page grew 2.7% at 375
   and 1.5–2% at 560/768/992. This is gotcha 2, but note the direction: a display utility **reveals**
   content, it does not just misalign it. When the design's break coincides with a Bootstrap
   breakpoint, express it as the responsive pair (`.d-none .d-xl-grid` for a 1200px break) and delete
   the media rule; otherwise leave `display` in CSS.
29. **`display: inline-flex` + `align-items: center` on a fixed-height button is NOT redundant with
   the UA default once the label wraps.** A `<button>` centres its own content, so the pair looks
   deletable — and is, until the content **overflows** the fixed height. At 375 "Save permissions"
   wraps to two lines inside a 40px button, and Chrome rounds that *negative* free space differently
   for UA button centring than for flex centring: the label sits 1px lower as a block. Deleting the
   pair cost 0.0936%. Test "obviously redundant" declarations rather than reasoning about them.

30. **Alias a component's state variables, never write literals — and alias them to the RIGHT state.**
   A custom property reference resolves against the ELEMENT's cascaded value, not the rule that
   declared it, so `--bs-btn-hover-bg: var(--bs-btn-bg)` in a shared rule means every page skin that
   re-points `--bs-btn-bg` gets a matching hover for free. Literals would have given all nine
   re-skinned `.sw-dd` toggles a white hover they never had. But `--bs-btn-active-*` must alias
   **hover**, not rest: with no `:active` rule of its own an element keeps showing its hover style
   while pressed, so aliasing active to rest made the kebab and "Set all" toggles drop their hover
   grey on mouse-down. **Screenshots see none of this** — every one of these passed 147 shots.
31. **`.btn` sets `vertical-align: middle`, and that moves inline-level components.** `.sw-dd__toggle`
   is `inline-flex` inside its `.sw-dd` block, so it sits in a line box and vertical-align genuinely
   applies — `middle` lifted every toggle 0.375px off the baseline. Invisible where the toggle is the
   only thing on its line (all 126 page shots stayed 0.0000%), but it moved every dropdown in the
   roles Edit-permissions sheet, up to 0.4658%. Pin `vertical-align: baseline` when putting `.btn` on
   anything that is not already a block or flex item.
32. **Putting `.btn` on an existing control rewrites THREE invisible states, not one.** Beyond hover:
   (a) `.btn:focus-visible` forces `outline: 0`, replacing the UA focus ring with Bootstrap's box-shadow
   ring — **this project keeps the brand ring** (set `--bs-btn-focus-shadow-rgb: 110, 93, 248`), so this
   is a wanted change, not one to undo; (b) Bootstrap paints `:focus-visible` with the **hover** colors
   (`--bs-btn-hover-*`); when a control's hover differs from its rest that shows on keyboard focus too —
   accepted as normal `.btn` behaviour here; (c) `--bs-btn-focus-box-shadow` is reused by
   `:active:focus-visible`, so the brand ring also appears on mouse-down — likewise accepted. (To opt a
   FUTURE control out entirely: `--bs-btn-focus-box-shadow: none` + `:focus-visible { outline: revert }`
   + `:focus-visible:not(:hover)` re-asserting rest colors. Not used anywhere now — see 6d's decision.)
   Still budget a rest/hover/focus/active/open computed-style diff against `main` for any `.btn`
   adoption — the screenshot harness is blind to all of it.
33. **A state driven by a variable can lose a cascade fight it used to win.** `.sw-dd.is-open` set
   `border-color` as direct output, and page skins beat it on source order at equal specificity.
   Converting those skins to `--bs-btn-border-color` silently flipped the winner, turning the
   notifications dropdown violet when open. Fix: make the state rule write the **variable** too, so
   the original specificity/order relationship is preserved. Same family as gotcha 16 — before
   converting a skin to variables, check every state rule that writes the same property directly.
34. **Do not trust a synthetic `classList.add()` to verify a state; drive the real flow.** Toggling
   `.is-open` by script reported two false regressions on custom-property-derived borders that a real
   opener-then-click disproved. Worse, three cases were silently "passing" because the click errored
   on **both** sides and the two error strings compared equal — a state test must assert the state was
   actually reached and must report errored cases separately, or absence of a diff means nothing.

35. **`.card` sets `min-width: 0`; a legacy card box did not.** That removes the automatic minimum a
   block box has. Reports’ two cards sit in a 1fr grid track at phone widths and their content is
   wider than the track (347.25px of content in a 328px track) — the design has always let them
   overrun the gutter. Adopting `.card` shrank them to fit and re-wrapped every row inside: 0.6029%
   at 375 while all four desktop widths stayed 0.0000%. Hand it back with `min-width: auto`.
36. **A `<button>` with no `padding` declaration is silently using the UA’s `1px 6px`, and `.btn`
   zeroes it.** Usually harmless — padding is symmetric so centred content does not move. It bites
   when the content is LARGER than the resulting content box: reports’ 28px close button has an 18px
   SVG, so the UA padding left a 16px content box that flex-SHRANK the icon to 16px. Zeroing padding
   let it render at its true 18px, 2px wider. Check any icon button whose glyph is within ~12px of
   the button width before accepting `--bs-btn-padding: 0`.

37. **A class converted to depend on a Bootstrap class must be chased into the JS.** Moving
   `.sw-rpill`/`.sw-spill` onto `.badge` meant the CSS rule only supplies `--bs-badge-*` inputs — so
   every pill the page BUILDS AT RUNTIME (`el.className = "sw-rpill sw-rpill--" + role`, 4 sites in
   `admin-users.js`) silently lost its font-size, weight, padding and radius and fell back to inherited
   16px/400. All page screenshots stayed 0.0000%; only the modal captures caught it. **grep the JS for
   every class you convert** (`className =`, `innerHTML`, `insertAdjacentHTML`) before trusting a
   page-level pass.
38. **`.card` is `display: flex`, so it stops child margins collapsing.** The users table’s last row
   (12px bottom margin) and its foot (4px top margin) collapse to 12px in block flow; under `.card`
   they summed to 16px and every width below 1200 grew exactly 4px. Pinning the foot margin fixes the
   populated table but not the JS-toggled empty state, which has no margin and legitimately sits 4px
   from the foot. There is no way to opt a `.card` out of flex — when a layout depends on margin
   collapsing, `.card` is the wrong component.
39. **`.card` sets `word-wrap: break-word`, and that property is INHERITED.** Every prior `.card`
    hand-back (gotchas 8, 19, 35, 38) was a property `.card` sets *on the box itself*; this one leaks
    down the whole subtree. The campaigns table cards adopted `.card`, and below 576px every long
    campaign/merchant NAME began breaking mid-word — the cards grew ~16px (3.5% at 375). The names
    have no class that sets `overflow-wrap`, so they took the inherited `break-word` straight from the
    card. Desktop widths stayed 0.0000% because the names fit; only the phone widths, where they
    wrap, exposed it. Fix: pin `overflow-wrap: normal` (the UA default) back on the card. Check any
    `.card` adoption whose descendants contain long unbroken tokens (names, emails, IDs, URLs) at the
    narrow capture widths, not just the desktop ones.
40. **A `.d-*` utility (`!important`) out-ranks an inline `style="display:none"` set by JS.** Gotcha
    28 is the media-query form; this is the JS form, and it is worse because the screenshot harness
    never sees it. `messages.js` filters the inbox by writing `conv.style.display = "none"` inline —
    a *normal-priority* inline declaration. Adopting `.d-flex` on `.sw-conv` made its display
    `flex !important`, which beats that inline rule (class-`!important` > inline-normal in the
    cascade), so the role-tab filter silently stopped hiding anything. All 11 message shots were
    0.0000% because the default state has no filter applied. **Any element whose display is toggled
    by JS inline style must keep `display` in CSS** — same rule as gotcha 28, extended to `.style.x`
    writes. And its sibling: **JS that BUILDS DOM (`el.className = "sw-msg-row…"`) must be given the
    same utilities you moved to markup** (gotcha 37) — the composer's new-bubble rows needed
    `d-flex ms-auto` / `d-flex flex-column mw-100` added in the JS, or a sent message renders
    unstyled. grep the page's JS for both `.style.display` and `className =` before converting a
    layout property that either one touches.

41. **A `.form-control` sized by `height` re-rounds placeholder AA vs an old borderless input.**
    Converting products' `.sw-cp-control` icon-input (a 42px bordered flex WRAPPER holding a
    borderless 22.25px `<input>` centred by flex) to a `.form-control` overlay, the natural move is
    `.form-control { height: 42px }`. Text-start X and vertical centre both measured **identical**,
    yet the empty-field PLACEHOLDER glyphs diffed ~0.03% on the wide (full-width) name field at
    desktop only — Chrome rasterises the single text line differently when it lives in the full 40px
    content box vs a 20.25px line-box centred in a taller box. Fix: make the 42px height out of
    **`padding` not `height`** (`padding: 9.875px 14px` = (42 − 20.25 linebox − 2 border)/2), so the
    text line sits in a 20.25px content band like the old input. 0.0000%. Sku/other narrower fields
    never surfaced it; only the wide name field + only at desktop. Horizontal inset also needs the
    old input's UA `1px 2px` folded back in (wrapper 12 + UA 2 = 14px padding; icon 40px; icon
    overlay `left: 13px` to re-add the wrapper's 1px border inset).

42. **A `:hover/:focus` colour reassert on a segmented-control/tab button repaints the ACTIVE one,
    because clicking a tab focuses it.** Every seg→Tabs page counters `.nav-link`'s hover-blue with
    `#modal .sw-seg__btn:hover, :focus { color: --sw-text-muted }`. That selector is `(0,3,0)` — equal
    to the active-colour rule and later in source — so the moment a tab is clicked (→ `:focus`) it
    out-cascades `.active` and the active tab text turns grey instead of dark. The sheet captures never
    caught it: they shoot the modal at OPEN, where the first tab is active but NOT focused; only driving
    a real tab click surfaces it. Fix: scope the reassert `:not(.active):not(.is-active)` — the active
    tab's `.active` rule beats `.nav-link:focus` `(0,2,0)` unaided, so it stays dark on focus. Was latent
    on products + merchants + campaigns (identical unscoped reassert); users escaped it by triggering
    Bootstrap Tab via `role="tab"` WITHOUT `.nav-link` (no hover-blue → no reassert needed). Screenshots
    of a resting modal will NOT show this — drive a tab click and read the active tab's computed `color`.

### Keep-as-custom register (checked, justified)
| Kept | Doc checked | Why |
|---|---|---|
| `.sw-dd` select-replacement | /components/dropdowns | Bootstrap dropdown has no `<select>` semantics (selected check rows, meta tags, hidden input, body-portaling) |
| Grid pseudo-tables that restack to cards | /content/tables | `.table-responsive` scrolls; it does not restack to `grid-template-areas` + `attr(data-label)` cards |
| Chat UI (messages.css) | /components/ | No analog |
| 5-step wizard + stepper | /components/ | No stepper component |
| Permission matrix, tree-table | /content/tables | Bespoke |
| Date-range calendar popover | /forms/ , /components/ | No datepicker in Bootstrap |
| Chip/token input, import dropzones | /forms/ | No equivalent |
| Brand visuals: gradients, striped progress fill, glass card, toast progress bar, entrance cubic-beziers, `prefers-reduced-motion` guards | /utilities/ | Brand-specific |
| Off-scale metrics (11–28px type; 3/6/7/12/13/14/18px gaps) | /utilities/spacing , /customize/css-variables | Not on Bootstrap's 4/8/16/24/48 scale; `.fs-*` is RFS |
| `color` on a link that has a `:hover` | /utilities/colors | `.text-body-secondary/-tertiary` are `!important` and beat the `:hover` rule. Keep `color` in CSS whenever a hover/active state changes it |
| A descendant selector covering many repeated children | /utilities/ | e.g. `.sw-legal a` → 2 declarations vs 36 class tokens across 6 pages. Utilities are for one-off adjustments (Step 5) |
| A class repeated dozens of times in one table | /utilities/flex , /utilities/sizing | roles' `.sw-pmchip` ×72: 4 of its 6 declarations have utility equivalents, but adopting them costs 288 class tokens — and the other 2 (a fixed 26px box) have none, since `.w-`/`.h-` are percentage-based, so the rule must exist anyway |
| Responsive-varying values (`text-align` inside a media query) | /utilities/ | Utilities are unconditional; `.text-center` would apply at every width |

---

## 6. Admin Profile page — status (the pilot, already done)

`profile.html` + `assets/css/admin-profile.css` + `assets/js/admin-profile.js`.

All counts below are comment-stripped and `;`-aware (see gotcha 11 — the figures published before
`855ebe3` were produced by a line-anchored grep and under-reported by ~2×).

| Metric | Original (`18af3ee~1`) | After `4ac01a0` | Now (`855ebe3`) |
|---|---|---|---|
| Markup Bootstrap share of `<main>` | 0% (0 of 81 tokens) | — | **73%** (178 of 243) |
| Page CSS declarations | 161 | 91 | **80** |
| — of which `--bs-*` inputs | 0 | 24 | **41** |
| — of which custom | 161 | 67 | **39** |
| Bootstrap-input share of page CSS | 0% | 26% | **51%** |
| `!important` | — | 0 | **0** |
| Inline `<style>` / `style=` / handlers / `<script>` | — | — | **0 / 0 / 0 / 0** |
| Visual diff | — | 0.0000% | **0.0000%** at all 5 breakpoints |

Uses: `.card`/`.card-header`, `.list-group.list-group-flush` (info + security rows), `.row`/`.col-6`/
`.g-3`, `.badge.rounded-pill` + `--bs-badge-color` (role/tier/streak/status), `.form-check.form-switch`
(2FA), `.btn` + `--bs-btn-*` (Edit profile, Sign out all devices, **and the three bare text buttons**),
`.fw-bold`/`.fw-semibold`, `.flex-shrink-0`, `.justify-content-center`,
`text-body-secondary/tertiary`, flex/gap utilities, `flex-column flex-sm-row` responsive stacking.

Remaining 39 custom declarations, all doc-cited in-file: off-scale paddings/gaps (22/24/18/14/12px),
11–26px type sizes (`.fs-*` is RFS), `line-height: 1.1` (off the `.lh-*` scale), `letter-spacing`
(no utility exists), `min-width: 0` ×3 (no utility exists), `overflow-wrap: anywhere` (see gotcha 10),
brand tints (violet avatar, pill backgrounds, hairline dividers, danger red), the 76px avatar and
15px icon (sizing utilities are percentage-based), and the 2fr/1fr card split — Bootstrap's col
padding model puts content at `0.667W − g` vs the design's `0.667(W − g)`, an 8px shift at `g=24`.

**Genuinely exhausted.** Two deepening passes have taken this page from 161 custom declarations to 39,
and every survivor has a written, doc-cited justification. There is no known remaining migration here:
the `.sw-prof-card` sections could take `.nav-pills`/`.tab-pane` only if the design gains tabs, and it
has none. Treat this page as the reference implementation, not as further work.

**Two-factor turn-on modal (new feature, from Figma).** Added a 6-digit-code verification modal to the
Security section (`#twoFactorModal`). Built on the shared **`.sw-modal` confirm shell** (Bootstrap `.modal`
+ `.modal-dialog-centered`) centred with `.text-center`; the OTP boxes are **`.form-control`** in a
`.d-flex .justify-content-between` group, buttons/text/layout are utilities, and the only custom deltas are
the violet icon tint (`.sw-modal__icon--brand`), the OTP box geometry + its brand focus ring (gotcha 17),
the resend link, and `--bs-modal-width: 440px` to match the design's compact width. Wired in
`admin-profile.js` (a self-contained IIFE): toggling 2FA **on** opens the modal; Cancel/backdrop/Escape
**reverts** the switch, "Verify and turn on" (6 digits) keeps it on. OTP boxes auto-advance / backspace /
accept a pasted code; a countdown ticks from 09:41 and Resend restarts it — Bootstrap's Modal drives
open/close. Verified: profile **resting look 0.0000% ×5** (modal is `display:none` at load); a Playwright
drive confirmed opens / verify-enables-at-6 / closes-on-verify / toggle-stays-on / reverts-on-cancel,
**0 console errors**; desktop + mobile renders match the Figma. **Note:** the modal opens on the switch's
off→on transition, so it starts on at rest (design preserved) — demo path is toggle off, then on.

**Modal-forms playbook pass (`refactor/bootstrap-profile`).** Profile already satisfied the contract:
the 2FA modal is a Bootstrap `.modal`, the 6 OTP boxes are `.form-control`, "Verify and turn on" is a
native `type="submit"` inside `#twoFactorForm`, and the content is static. Its open is a **genuine
switch→modal flow** (turning 2FA on starts verification; dismiss reverts the switch) — real behaviour
with no Bootstrap analog (OTP auto-advance/backspace/paste, countdown, resend), so it stays JS, NOT a
demo. Two changes: **(1) session sign-out → backend-owned** — the "Sign out" / "Sign out all other
devices" buttons were a demo IIFE (toast + `row.remove()`), a stand-in for a server revoke; deleted the
whole IIFE and made the buttons **plain `<button>`s** Laravel wires to their revoke routes (the buttons
stay direct `.list-group` children — user asked for a normal button, no `<form>` wrapper / `form=`).
**(2) `var`→`const`/`let`** (step 8) in the remaining 2FA IIFE (14 `const` + 4 `let` — `verified`, `tick`,
`left`, the `j` loop counter; checked TDZ/scope). `admin-profile.js` 122 → 96 lines. Dead-code scan clean
(0 dead classes; the one `.sw-prof-row` "dup" is base + `@media`). Verified **11 shots 0.0000%** (page ×5 +
2FA modal 6) + a Playwright drive (switch-opens / verify-enables-at-6 / verify-keeps-on / dismiss-reverts,
0 console errors) + `dd-test` (no dropdowns). Solo `admin-profile.css` — no cluster.

**Audit follow-up (`refactor/bootstrap-profile-audit`) — the last flagged bit applied.** A fresh
category-by-category audit confirmed profile at its floor: Forms fully done (6 OTP boxes `.form-control`,
2FA switch `.form-check.form-switch`, Verify native submit), badges/cards/list-groups/buttons/modal all
`--bs-*` (47 inputs), health clean, dead-CSS scan 0, and the 2FA JS genuinely irreducible (the OTP UX has
no analog). The **one** remaining exact-match utility — `.sw-otp__box { text-align: center }` → **`.text-center`**
on the 6 boxes (idiomatic for a centred `.form-control` OTP input; 6 tokens is not bloat) — was applied
(**admin-profile.css 53 → 52 custom**). Verified **11 shots 0.0000%** (page ×5 + 2FA modal both states ×3
via `pf-modal-shot`) + a drive (switch opens the modal, OTP computed `text-align:center`, auto-advance +
verify-enables-at-6, 0 console errors). Everything else stays register-justified (off-scale type/spacing,
the 76px avatar + 48/52px OTP boxes, the 2fr/1fr grid, the OTP focus ring gotcha 17, brand tints).

---

## 6b. Roles & access page — status

`roles.html` + `assets/css/admin-roles.css` (+ unchanged `assets/js/admin-roles.js`).

| Metric | Original (`main`) | Now |
|---|---|---|
| Markup Bootstrap share of `<main>` | 0% (0 of 442 tokens) | **51%** (460 of 902) |
| Page CSS declarations | 373 | **276** |
| — of which `--bs-*` inputs | 0 | **98** |
| — of which custom | 373 | **178** |
| `!important` | 0 | **0** |
| Inline `<style>` / `style=` / handlers / `<script>` | — | **0 / 0 / 0 / 0** |
| Visual diff, page (375/560/768/992) | — | **0.0000%** |
| Visual diff, page (1440/1920) | — | **0.0008% / 0.0006%** — gotcha 26, see below |
| Visual diff, Edit-permissions sheet (10 shots) | — | **0.0000%** |

Uses: `.card`/`.card-body`/`.card-header`, `.row .row-cols-2 .row-cols-md-3 .row-cols-xl-5 .g-3`,
`.btn` + `--bs-btn-*` (8 role pills, 5 shadow buttons, **27 segmented options**, and the bare
"Reset to defaults" text button), `.badge.rounded-pill` + `--bs-badge-*` (the VIEWING AS pill and the
3 section counts), `.border`/`.border-top`/`.border-bottom` + `--bs-border-color` (all six brand
hairlines), `.rounded`/`.overflow-hidden`/`.overflow-auto`, `.d-grid`/`.d-none .d-xl-grid` (matrix
rows; the design's 1200px break *is* `xl`), `.order-1 .order-md-0` (the phone footer reflow),
`.text-truncate`/`.text-nowrap`, `.flex-shrink-0`, `.text-body-secondary`/`-tertiary`,
`.fw-bold`/`.fw-semibold`, `.m-0`/`.mb-3`/`.mt-3`, `.gap-1`/`.gap-2`/`.gap-3`, and flex/wrap/
alignment utilities throughout the modal head, legend and footer.

**Deepening pass — what the remaining 178 actually are.** 41 off-scale spacing, 41 fixed px sizes
(sizing utilities are percentage-based), 34 brand colors with no Bootstrap equivalent, 27 layout
(mostly the register-protected pseudo-table and responsive-varying values), 25 off-scale type,
10 borders/radii off the `.rounded-*` scale. **27 of the 178 are the two `.sw-dd` toggle skins**
(`.sw-dd--rolepick`, `.sw-dd--setall`) — they are overriding the *shared, custom* `.sw-dd__toggle`
in `admin-components.css`, which writes `border`/`background`/`height`/`font-*` as direct output.
Those 27 cannot become `--bs-btn-*` inputs from a page file; the lever is migrating the shared
`.sw-dd__toggle` to `.btn`, which touches 19 pages and needs the full 125-shot re-run. **That is the
single biggest remaining reduction available in this file and it is a shared-layer job, not a roles
job.** The working rule applied here: convert layout/spacing/border properties wherever an exact
utility exists; leave a declaration in CSS when its rule must survive anyway for an off-scale value,
and when the element repeats enough that utilities would bloat the markup (`.sw-pmchip` ×72,
`.sw-pmcell` ×89).

**In-file comments were stripped from `admin-roles.css` by the user in `884c452`** (comments only —
byte-identical CSS, re-verified). So this file is the one exception to rule 2's "justified in
writing, in the CSS file": its justifications live in this section instead. Do NOT read the absence
of comments as "these declarations were never justified", and do not delete a survivor because it
looks redundant — three of them are load-bearing in ways that only the harness reveals (gotchas 7,
28, 29). If comments are ever restored here, terse one-liners with the doc page cited are enough.

**`.sw-seg` → `.sw-permseg` rename.** `admin-components.css:655` already owns a shared `.sw-seg`
(a different component, `.sw-seg__btn` children, used by the create-user / advertiser / campaign /
merchant / product modals). Roles' permission control has `__opt` children and never wanted that
skin — the two only collided by name, so the shared `gap: 3px` leaked in and had to be cancelled
with a `gap: 0`, and `border-radius`/`padding` were re-declared verbatim (rule 3). Renamed in
`roles.html` + `admin-roles.css` + `admin-roles.js`; pixel-identical, track still exactly 126px.

**The 1440/1920 residual is gotcha 26** — `.row-cols-xl-5` puts the fifth shadow tile 3/64px (0.047px)
left of where `repeat(5, 1fr)` did, surfacing as ~10 antialiased sub-pixels on one glyph of the last
tile's button label. Nothing resizes; every other breakpoint is 0.0000%. It predates this pass (it
came in with the grid conversion) and is irreducible while the grid is Bootstrap's.

Kept as custom, all doc-cited in-file: the permission matrix's `grid-template-areas` pseudo-table and
its `attr(data-label)` card restack (register: /content/tables), the segmented control's tinted
**track** (`.btn-group` + `.btn-check` renders no container — /forms/checks-radios,
/components/button-group), `.sw-pmchip` ×72 (register, new row), off-scale type (11/11.5/12/12.5/13/
13.5/14/17/19px — `.fs-*` is RFS, gotcha 1), off-scale gaps and insets (2/6/7/9/10/11/12/14/18/22px),
`min-width: 0` ×3 and `max-width: 780px` (no utilities), the 539.98px 2→1 step (below Bootstrap's
smallest breakpoint — gotcha 20, which is why `roles--560.png` is baselined), and brand tints.

### 6b-2. Roles — `.btn-check` segments + native form + playbook-pure (`refactor/bootstrap-roles-audit`)

A fresh audit found roles' JS is a **genuine interactive RBAC editor** (matrix source-of-truth, role
simulator, the Edit-permissions sheet), NOT a demo — so this is a Forms restructure, not a delete. Done
in verified stages:
- **`.sw-permseg` segments → Bootstrap `.btn-check` radios.** Each hand-rolled `role="radiogroup"` with
  `role="radio"` `.btn` buttons + JS `.is-on` became native `<input type="radio" class="btn-check"
  name="perm[cap]" …>` + `<label class="sw-permseg__opt btn" for=…>` (9 segs × 3 = 27 controls, via a
  script). The tinted **track** stays custom (register). The active tint moved from
  `.sw-permseg__opt.is-on[data-val]` (rest vars) to `.btn-check:checked + .sw-permseg__opt[data-val]`
  using **`--bs-btn-active-*`** — Bootstrap's `.btn-check:checked + .btn` reads the active vars; the
  (0,4,0) selector out-ranks Bootstrap's (0,3,0) AND `.btn:hover` (0,2,0) so the checked tint holds on
  hover with **no hover vars** (leaner: CSS 277→268 decls). JS `setSeg` now sets `.checked` (native radio
  unchecks siblings + owns aria/keyboard); the per-option click handler is deleted (native selection).
- **Edit sheet → native `<form>`.** `.modal-content` is a `<form data-ep-form>` with a hidden
  `<input name="role">` that `loadRole` syncs; "Save permissions" is a native `type="submit"` (the role +
  `perm[cap]` radios POST to Laravel, which persists + re-renders). The JS **save handler is gone**
  (no client write-back/toast) → `setCell`/`segPerm`/`ICON` went dead and were pruned. **Shadow views →
  backend-owned** (demo toast removed; Laravel opens the read-only dashboard + audit-logs). The genuine
  editor logic STAYS: `loadRole`, set-all cascade, reset-to-defaults, the role simulator. `admin-roles.js`
  **193 → 156 lines**.

Verified **16 shots 0.0000%** (page ×5 + `roles--560` + ep-modal open/bottom ×5) + drives: segments load
(one checked radio each), native click selects + unchecks siblings, reset restores defaults, **role-pick +
set-all `.sw-dd` still open/portal/cascade inside the `<form>`** (the portaled-menu selector trap cost two
test reruns — the menu moves to `<body>` on open), the role simulator activates, save fires a native form
submit, shadow buttons inert. `dd-test` roles 0 errors, dead-CSS scan 0, 0 leftover `is-on`/`aria-checked`. `admin-roles.js` also
`var`→`const`/`let` (0 var, 1 let = `currentRole` the only reassigned binding, 22 const), `node --check`
clean, re-verified (ep-modal 10 shots 0.0000% + editor drive green).

## 6c. Shared `.sw-dd` toggle — migrated to `.btn`

`.sw-dd__toggle` is now `.btn` + `--bs-btn-*` in `admin-components.css`; all **123 toggles across 14
pages** carry `.btn`. Across every toggle rule in the codebase: **89 declarations, all custom → 94,
of which 48 are `--bs-btn-*` inputs and 46 custom.** `admin-roles.css` alone went 178 → 164 custom
and 98 → 113 `--bs-*`.

Verified: all **147 shots** match the pre-change control exactly (data-warehouse ×5 and roles ×2 are
the known pre-existing residuals; everything else 0.0000%), plus `dd-test`, `dd-portal-test`, and a
purpose-built **rest / hover / open / active / focus** computed-style diff against clean `main` for
**all 12 toggle variants** (base, field, field-in-sheet, inline, tool ×3 pages, kebab, idd, nr-field,
nr-body-field, cp-body-field, rolepick, setall) — zero differences in every state. Four of those live
inside sheets Playwright cannot lay out, so they were driven through their real opener-then-click
flow rather than a synthetic class toggle (gotcha 34).

**Nothing about the design changed, in any state — but four regressions had to be caught first, and
the screenshot harness passed all four.** In order: a violet ring flashed on every mouse-down
(`--bs-btn-focus-box-shadow` is reused by `:active:focus-visible`); keyboard focus replaced the UA
outline with the brand ring (`.btn:focus-visible` forces `outline: 0`); the kebab and "Set all"
toggles lost their hover grey while pressed (active must alias hover, not rest); and the notifications
dropdown turned violet when open (its skin used to out-rank `.sw-dd.is-open` as direct output and
stopped doing so once it became a variable). See gotchas 30, 32, 33.

**Layout deliberately stays in the CSS rule, not in utilities.** 13 kebab toggles also carry
`.sw-cact`, which re-centres them with `justify-content: center` at equal specificity via load order.
`.justify-content-between` as a utility is `!important` and would have out-ranked it, breaking every
row-action button in the campaigns and influencer tables. Only *theming* moved to variables.

**The focus ring is deliberately NOT the brand ring here.** Unlike the buttons this migration created
from scratch, `.sw-dd__toggle` already existed and showed the UA outline, so rule 1 applies:
`--bs-btn-focus-box-shadow: none` plus `.sw-dd__toggle:focus-visible { outline: revert }` hand it
back, and `:focus-visible:not(:hover)` re-asserts the rest colors because Bootstrap paints
`:focus-visible` with the hover ones. Do not "tidy" these three rules away — each one is load-bearing
and none of them is visible to `capture.mjs`.

**DONE (`refactor/dedupe-sw-dd-tool`) — `.sw-dd--tool` framed skin deduped via an additive
`.sw-dd--framed` modifier.** The byte-identical `.sw-dd--tool .sw-dd__toggle { --bs-btn-color:#474f5c;
--bs-btn-border-color:#e5e8ec; padding:0 12px 0 14px }` copies in `admin-merchants.css` +
`admin-products.css` moved to ONE rule `.sw-dd--framed .sw-dd__toggle` in `admin-components.css`;
`.sw-dd--framed` added to the 14 tool-dropdown sites (merchants cluster 5 + products). It could NOT be
baked into `.sw-dd--tool` (campaigns' `.sw-dd--tool` deliberately keeps the base `--sw-text`/`--sw-border`
look — Rule 1), so an **additive** modifier, not a rename, was the fix — campaigns files were never
touched. Same **(0,2,0)** specificity as the old page-file rules, so the violet open-state border
(`.sw-dd.is-open .sw-dd__toggle`, 0,3,0) still out-ranks it (verified: framed rest = `#474f5c`/`#e5e8ec`/
`14px 12px` exact, open border = violet). Verified **40 shots 0.0000%** (merchants cluster + products +
campaigns, ×5) + `dd-test` all-pass / 0 console errors. Campaigns' `.sw-dd--tool` icon-size + media
rules in `admin-campaigns.css` are untouched (a different selector, not a dup).

## 6c-2. Shared toolbar buttons `.sw-export` / `.sw-create` — completed to `.btn`

`.sw-export` (white/hairline) and `.sw-create` (violet solid) are the page-header toolbar buttons in
`admin-components.css`. They were **half-migrated**: only 2 of 11 `.sw-export` and 3 of 19 `.sw-create`
sites carried `.btn`; the rest rendered off concrete fallback CSS (`background`/`border`/`color` +
`:hover`). Completed the adoption (`refactor/bootstrap-toolbar-buttons`, stacked on
`refactor/prune-dead-components`):

- **Markup (24 sites, 14 pages):** bare `class="sw-export"` → `btn sw-btn-outline sw-export`, bare
  `class="sw-create"` → `btn btn-primary sw-create`. The `.sw-btn-outline` skin already existed as pure
  `--bs-btn-*`; `.btn-primary` is style.css's brand-violet re-skin (gotcha 21).
- **CSS (admin-components.css, −5 net → 728 decls):** removed the now-redundant concrete
  `.sw-export`/`.sw-export:hover`/`.sw-create`/`.sw-create:hover` color blocks (8 decls). `.sw-btn-outline`
  matches `.sw-export`'s concrete in **every** state, so export needed nothing. `.sw-create` needed a
  **2-line override** (`--bs-btn-hover-border-color`/`--bs-btn-active-border-color: var(--sw-violet)`)
  and this is load-bearing, NOT tidy-away-able: concrete `.sw-create:hover` changed only `background`,
  leaving the border at `--sw-violet` (#6e5df8), but `.btn-primary`'s hover/active set it to
  `--sw-violet-600` (#5a47e8) — a visible 1px border shift on the violet-600 fill. The override hands the
  original border back. Also pinned `vertical-align: baseline` on the shared geometry rule (gotcha 31 —
  harmless since these are flex items, but defensive for any inline-level use).

**Verified:** 127 page shots **0.0000%** (all 24 buttons are page-toolbar, captured at load), 45
adv+users modal shots **0.0000%** (branch-vs-clean-main via worktree), a **computed rest+hover
state diff** identical branch-vs-main across 11 buttons (the `.sw-create` hover border stays violet),
`dd-test`/`dd-portal-test` green, 0 console errors. No migrated button renders inside a dialog
(influencer's is a toolbar `data-bs-toggle` trigger). **The one intended change is the focus ring:**
per §6d's "align forwards" decision, the 24 newly-`.btn` sites now show the brand violet
`:focus-visible` ring instead of the UA outline — matching the 5 already-migrated sites and the
project convention (user-approved; keyboard-only, invisible to `capture.mjs`).

## 6c-3. Shared confirm/footer buttons `.sw-btn-ghost` / `.sw-btn-primary` / `.sw-btn-danger` — completed to `.btn`

The last concrete shared button classes (the sibling `.sw-btn-warning` was already `--bs-btn-*`).
Defined in `admin-components.css`, used **bare** (no `.btn`) across **14 pages / 70 sites** (33 ghost +
34 primary + 3 danger). All page-file rules that touch them (`admin-campaigns/products/reports/roles/
users.css`) are **layout-only** context selectors (`.X__foot .sw-btn-* { flex:1 / width:100% /
centering }`) — none re-skin colour, so the base conversion was safe. Branch
`refactor/bootstrap-btn-ghost-primary` (off `main`).

- **Markup (70 sites, 14 pages):** `sed` added `.btn` to every `sw-btn-ghost|primary|danger` token
  (word-boundaried, single-token → CRLF-safe gotcha 24; scoped to the 14 files → gotcha 23). Verified
  70 paired / 0 double-`.btn` / 0 bare-remaining.
- **CSS (`admin-components.css`):** the three concrete rules (+ their `:hover`/`:disabled`) became
  self-contained `--bs-btn-*` skins mirroring `.sw-btn-warning`'s structure (active aliases hover
  gotcha 30; `vertical-align: baseline` gotcha 31; `height: 40px` stays direct — `.btn` has no height
  var; `cursor: pointer` dropped — `.btn` supplies it).
- **Focus ring matches the fill** (per `.sw-btn-warning`'s `217,119,6` precedent, and §6d "align
  forwards"): brand violet `110,93,248` for ghost/primary, danger red `220,38,38` for danger. This is
  the one intended change — UA outline → tinted `:focus-visible` ring, keyboard-only, invisible to
  `capture.mjs`.
- **Disabled needed explicit vars, and this was the load-bearing trap.** `.btn:disabled` defaults to
  `opacity: .65`; the originals showed **no dim** for ghost/primary (opacity 1) and `.45` for danger.
  The **profile 2FA "Verify" button renders `.sw-btn-primary` DISABLED at rest**, so without
  `--bs-btn-disabled-opacity: 1` it would have greyed to 65% — a visible regression the page-load
  shot can't see (modal is `display:none`). Added a new **`pf-modal-shot.mjs`** (opens `#twoFactorModal`,
  shoots `profile-2fa` = Verify disabled + `profile-2fa-on` = 6 digits, Verify enabled) to cover it —
  the only place a disabled `.sw-btn-primary` renders.

**Verified: 319 shots 0.0000%** — 127 page (125 + roles-560 + analytics-520) + 171 modal (adv, users,
ep, nr, sheets, wiz-steps, camp-filter) + 6 profile-2fa, branch-vs-baseline-from-clean-tree. Plus a
**computed rest/hover/disabled diff identical branch-vs-clean-main** across ghost/primary/danger
(`primary_disabled` identical confirms the opacity fix), `dd-test` all-pass / 0 console errors,
`dd-portal-test` green (its 2 skips are pre-existing stale openers, unrelated). **Only the 14 pages
that use these classes were touched** (blast radius = exactly those files + the shared CSS); the other
11 pages are untouched.

## 6d. Reports page — status

`reports.html` + `assets/css/admin-reports.css` (JS untouched). Solo file — no other page loads it,
so no cluster re-verification.

| Metric | Original (`main`) | Now |
|---|---|---|
| Markup Bootstrap share of `<main>` | 0% (1 of 232 tokens) | **42%** (165 of 394) |
| Page CSS declarations | 234 | **167** |
| — of which `--bs-*` inputs | 0 | **48** |
| — of which custom | 234 | **119** |
| `!important` | 0 | **0** |
| Visual diff, page (5 widths) | — | **0.0000%** |
| Visual diff, New-report sheet (10 shots) | — | **0.0000%** |

Uses: `.card`/`.card-body` (both surfaces — style.css’s global theme is an exact match for the legacy
`.sw-card`), `.btn` + `--bs-btn-*` (12 metric chips with `.rounded-pill`, the saved-report run button,
the modal close button), `.form-control` (the report-name input), `.d-grid` + `.align-items-center`
(field grids, results table), `.border`/`.border-top`/`.rounded`/`.overflow-hidden`/`.overflow-auto`,
`.text-truncate` (16 table cells + saved names/meta), `.d-flex`/`.flex-column`/`.flex-wrap`/
`.flex-shrink-0`, `.gap-2`/`.gap-3`, `.mt-3`/`.mb-1`/`.m-0`, `.fw-bold`/`.fw-semibold`/`.fw-medium`,
`.text-body-secondary`/`-tertiary`, `.text-uppercase`.

**Two regressions caught by the harness, both now gotchas 35 and 36:** adopting `.card` brought
`min-width: 0` and collapsed both cards at 375 (0.6029%); and `.btn` zeroed the close button’s
inherited UA padding, un-squeezing its SVG from 16px to its true 18px (0.0001%).

**Focus ring: the brand ring, everywhere (decided — "align forwards").** Every `.btn` in this migration
shows Bootstrap's `:focus-visible` ring tinted brand violet (`--bs-btn-focus-shadow-rgb: 110, 93, 248`).
That is the agreed project convention and applies to controls that previously showed the UA outline too,
including this page's chips / run button / close button and the shared `.sw-dd__toggle`. The UA-preserving
opt-out (`--bs-btn-focus-box-shadow: none` + `:focus-visible { outline: revert }`) was removed from all of
them; keep gotcha 32 only as the reference for how to opt a *future* control out if one ever needs to.

Kept as custom, doc-cited in-file: the modal skin greys (#6b7280 / #0f1020 / #2b3345 are not the brand
tokens), `flex: 1` ×2 (`.flex-fill` is `1 1 auto`, gotcha 4), `min-width: 0` ×4 and `min-width: auto`
×2 (no utilities), the bespoke `grid-template-columns` track lists, off-scale type (12/13/14/17/20/
28px — `.fs-*` is RFS, gotcha 1), off-scale spacing (6/7/10/12/13/14/18/20/22px), `letter-spacing`,
`line-height: 1.2`, the input’s focus ring (gotcha 17), and brand tints.

**Floor confirmed (later pass).** A full candidate map found reports at its register floor — the only
actionable declarations were on `.sw-rep-new` (the New-report toolbar button, `.btn .btn-primary
.sw-create`): a **redundant `gap: 8px`** already supplied by the shared `.sw-create` geometry (rule-3
dup, deleted) and `flex-shrink: 0` → `.flex-shrink-0` in markup. Its `height: 40px`/`padding: 0 18px`
are intentional overrides of `.sw-create`'s 36px/`0 16px` and stay. **113 custom decls**, 0.0000% ×5,
`dd-test` PASS (16 dropdowns, 0 errors). Everything else is media/state/descendant/off-scale/tint.

**Modal-forms playbook pass (`refactor/bootstrap-reports`, `docs/bootstrap-modal-forms-playbook.md`).**
The New-report modal already met most of the contract (close = `data-bs-dismiss`, Generate = native
`type="submit"` `form="newReportForm"`, `report_name` = `.form-control`, no seg, no per-row prefill —
the `.sw-dd` selects stay custom per register). The **one gap was the native open**: the "New report"
button was `data-action="new-report"` → JS `openSheet(bootstrap.Modal.show())`. Converted it to
`data-bs-toggle="modal"` `data-bs-target="#newReportModal"` and **stripped the now-dead JS**: the
`openSheet`/`closeSheet` forwarders, the `[data-sheet-close]` wiring (0 markup matches), the legacy
`.sw-sheet.is-open` Escape handler (Bootstrap owns Escape), and the `new-report` action branch.
**Metric chips → Bootstrap `.btn-check` (form-submitting).** The 12 `.sw-rchip` were `<button>`s; a button's
toggle state does NOT submit with a form, so for a native Generate (below) they became **`.btn-check`
checkbox toggle buttons** — `<input type="checkbox" class="btn-check" name="metrics[]" value="…" id="…"
checked>` + `<label class="sw-rchip btn rounded-pill" for="…">` (docs /components/buttons + /forms/checks).
Unique id prefixes `rb-m-*` (builder) / `nr-m-*` (modal) since both sets share metric values. State selector
`.sw-rchip.is-on` → **`.btn-check:checked + .sw-rchip`**; 0.0000% because the base `.sw-rchip` aliases
`--bs-btn-active-*: var(--bs-btn-hover-*)` → `var(--bs-btn-bg)` (gotcha 30), so overriding the REST vars on
the checked label cascades to Bootstrap's `.btn-check:checked + .btn` output — no separate active vars.
**One catch (fixed):** the chip was a `<button>` (auto-centres its text in the fixed 32px height); a
`<label class="btn">` is `inline-block` and does NOT, so the text sat high → 0.1–0.55% on every chip. Fix:
`display:inline-flex; align-items:center; justify-content:center` on `.sw-rchip` (what the button did
implicitly). **"Build a report" is now a `<form id="reportBuilderForm">`** (block wrapper inside `.card-body`,
layout-neutral): Generate = native `type="submit"`, Export CSV = native `type="submit" formaction="#"`
(Laravel fills the export route), and every field submits — the `.sw-dd` hidden inputs + the 6 metric
checkboxes. **Playbook-pure — the whole page JS is gone.** With the modal native, the chips on Bootstrap's
`.btn-check`, and the `.sw-dd`
selects wired by `main.js`, the only thing left in `admin-reports.js` was the demo form-submit toast + the
export/generate/run-saved demo toasts — all backend-owned. Removed them, **deleted `admin-reports.js`
(~120 → 0) and its `<script>` tag**, and pruned the 6 now-dead `data-action` hooks (the buttons stay
semantic `<button>`s Laravel wires to routes; the New-report form POSTs natively). **reports has zero
page JS.** `nr-modal-shot.mjs` opener moved off the removed `[data-action]` hook to the stable
`.sw-rep-new` class. Verified **15 shots 0.0000%**
(page ×5 + nr-modal open/bottom ×5) + behaviour with **no page JS** (native open, chips toggle via
Bootstrap, modal `.sw-dd` opens/portals via `main.js`, Cancel `data-bs-dismiss` closes, Generate is a
native `type="submit"`, 0 console errors) + `dd-test`/`dd-portal-test` green. Solo stylesheet — no cluster.

## 6e. Users + Advertisers — status

`users.html` + `advertisers.html` + `assets/css/admin-users.css` + `assets/js/admin-users.js`.
The two pages share the stylesheet, so both were verified on every step.

| Metric | Original (`main`) | Now |
|---|---|---|
| Markup Bootstrap share, users `<main>` | 1% (3 of 218 tokens) | **61%** (339 of 554) |
| Markup Bootstrap share, advertisers `<main>` | 1% (3 of 218) | **58%** (299 of 514) |
| `admin-users.css` declarations | 251 | **190** |
| — of which `--bs-*` inputs | 0 | **57** |
| — of which custom | 251 | **133** |
| `!important` | 0 | **0** |
| Visual diff, both pages (5 widths) | — | **0.0000%** |
| Visual diff, 6 dialogs (30 shots) | — | **0.0000%** |

Uses: `.badge.rounded-pill` + `--bs-badge-*` (all 28 role/status enum pills, markup **and** the 4
JS-generated ones), `.btn` + `--bs-btn-*` (48 row actions incl. the danger variant, the audit-log text
button, the suspend confirm button), `.d-grid` + `.align-items-center` (table head + rows, the view
modal field grids), `.d-none .d-xl-grid` (the header row; the design 1200px break *is* `xl`),
`.text-truncate` (names, emails), `.border-top`/`.border-bottom` + `--bs-border-color`,
`.overflow-auto`, `.rounded-circle`, `.text-center`, `.d-flex`/`.flex-column`/`.flex-wrap`/
`.flex-shrink-0`/`.justify-content-*`, `.gap-2`, `.fw-bold`/`.fw-semibold`,
`.text-body-secondary`/`-tertiary`.

**Three regressions caught, all of them `!important` utilities beating a media query or a needed
declaration** (gotcha 2, three different shapes): `.d-grid` on the table head un-hid the header row
below 1200 (advertisers overflowed 375 to 614px); `.m-0` on the view-modal section label killed its
10px bottom margin; `.align-items-center` on the view-modal footer beat the `<768px` `stretch` that
makes it stack. Plus gotcha 37 — the JS-generated pills.

**`.sw-utable` DID adopt `.card`, on the second attempt.** The first try was reverted because `.card`
is `display: flex` and flex does not collapse child margins (gotcha 38) — every width below 1200 grew
4px. The fix was to stop depending on collapsing at all: measure both states on the unmodified page
first (12px after a row, 4px after the JS-toggled empty block), then state each gap outright — foot
`margin-top: 0`, `.sw-urow` keeps its 12px, `.sw-utable__empty` gains 4px. Both re-measured identical
afterwards. `position` is also pinned back to `static`: `.card` sets `position: relative`, which
changes no geometry at all (every rect bit-identical to four decimal places) but repaints the box —
1176 antialiased sub-pixels, 0.0001%. Nothing in the table is absolutely positioned, so `static` is
free. Net: four custom declarations replaced by the component.

**Deepening pass — measured, not assumed.** Every candidate utility was probed in the real page
(`getComputedStyle` on an injected element) before adoption, because the CDN stylesheet is
cross-origin and `cssRules` is unreadable. Confirmed and adopted: `.rounded-circle` = `50%`
(identical to the old `999px` on a square avatar, 18 of them), `.flex-fill` = exactly `1 1 auto`,
`.text-body` = `rgb(26,18,50)` = `--sw-text`, `.text-break` = `word-break` **and**
`overflow-wrap: break-word` (a superset, verified pixel-identical), `.mb-1` = 4px, `.mb-2` = 8px.
Also deleted one genuinely redundant declaration: `.sw-vu__avatar` re-declared `flex-shrink: 0`
that the markup already carried. 151 to 137 custom.

**Rejected after checking, with reasons.** `.vstack`/`.hstack` also set `flex: 1 1 auto` and
`align-self: stretch`, which would change `.sw-uav-meta` inside its flex row — `.d-flex .flex-column`
is the safe equivalent and is what is used. `.z-*` only reaches 3, so `.sw-sheet--confirm` keeps its
`z-index: 1086`. Bootstrap has no `grid-template-columns` / `grid-area` / `justify-self` utilities,
which is most of the responsive card-restack block. And per the register, a descendant selector
beating many child tokens stays: `.sw-utable__head span` and `.sw-urow__scope, .sw-urow__active` each
keep one `color` declaration rather than take 12 and 32 class tokens — both rules must exist anyway
for their off-scale `font-size`.

Kept as custom, doc-cited in-file: the table surface (above), the `grid-template-areas` card restack
(register: /content/tables), the bespoke track lists, `flex: 1` x2 (`.flex-fill` is `1 1 auto`,
gotcha 4), `min-width: 0` x4 (no utility), the 38px/52px/30px fixed boxes (sizing utilities are
percentage-based), off-scale type (12/13/14/18/20px — `.fs-*` is RFS, gotcha 1), off-scale spacing
(6/10/12/14/18/22px), `line-height: 1.55`, `word-break`, and the role/status brand tints.

## 6f. Shared `.sw-sheet` — migrated to Bootstrap Modal

All **23 sheets across 13 pages** are now `bootstrap.Modal`. The component provides the backdrop,
Escape, the focus trap, scroll locking and stacking, which deletes the fixed-position root, the
`[hidden]` state, the hand-rolled `.sw-sheet__backdrop` and the `.is-open` transitions. What remains
under `.sw-sheet__panel` is only the sheet's own skin.

**All six copy-pasted `openSheet`/`closeSheet` pairs are gone** — `admin-users`, `admin-advertisers`,
`admin-merchants`, `admin-products`, `admin-roles`, `admin-reports`, plus influencer's own
`open()`/`close()` and the campaigns wizard's `openWiz`/`closeWiz`. This was the same duplication
that produced the client's original complaint; it is now one implementation in `main.js`.

Markup pattern: `.sw-sheet` gains `.modal.fade`, the panel gains `.modal-content` inside a new
`.modal-dialog.modal-dialog-centered`, the backdrop div is deleted, closers become
`data-bs-dismiss="modal"` and triggers `data-bs-toggle`.

### What `main.js` still has to do, and why
Three things Bootstrap cannot express per-modal, all in one shared block:
- **Backdrop opacity.** Sheets are 45%, Bootstrap defaults to 50%, and `.modal-backdrop` is appended
  to `<body>` so it cannot be reached by ancestor. It is tagged `.sw-sheet-backdrop` on the way in.
  The data-warehouse dialog genuinely IS 50% (its pre-migration CSS was `rgba(15,16,32,.5)`, checked
  at `2186ef0~1`), so the global default is left alone — the two opacities are a pre-existing design
  inconsistency, not migration damage.
- **Stacked z-index.** Bootstrap does not bump z-index for a second modal, so a confirm opened over
  an edit sheet would get a backdrop BELOW the sheet underneath it. Each backdrop is pinned just
  under its own modal, read off the live value, so a variant only declares `--bs-modal-zindex`.
- **Stacked Escape.** It reached the sheet UNDERNEATH and closed it, stranding the confirm on top
  (Bootstrap's docs: overlapping modals are not supported). Every sheet sets
  `data-bs-keyboard="false"` and `main.js` closes the top-most by z-index; focus is pushed to each
  newly shown sheet so the lower one's trap stops pulling it back.

Also moved here: `swCloseDropdowns(null)` on `hide.bs.modal`. A `.sw-dd` menu inside a sheet is
PORTALED to `<body>` while open, and without this it is left floating over the page after the sheet
closes. Every page script that had a sheet carried its own copy.

### Two traps worth keeping
**Desktop centring is deliberately NOT `.modal-dialog-centered`'s flex.** The legacy sheet centred
with an absolutely-positioned fractional `translate(-50%,-50%)`. Both place the panel identically —
panel and every child measured bit-identical to four decimal places — but a fractional transform
promotes its own layer and Chrome rasterises 1px dividers onto a different sub-pixel. Flex centring
cost 0.02–0.14% of softened hairlines inside the taller sheets, over threshold on one. Doing it the
legacy way also restores the design's real entrance (fade + 4% drift over .22s) which Bootstrap
would otherwise replace with its 50px slide — **and screenshots cannot see an entrance**, so that
would have shipped silently.

**Widths are declared as `<variant>.modal` — exactly two classes — at every level** (base 420,
`--lg` 560, then page variants: `--perms` 620, `--wiz` 660, `.sw-icamp-modal` 660, and the
advertisers/report modals). So the cascade resolves by FILE ORDER, which is the order the layers are
meant to apply in. Three classes made `--lg` out-rank every page variant and pin them all to 560; a
single class made it lose to the base and pin them all to 420. Both silently resize every dialog.
A page that pinned a hard `width` on the PANEL must move it to `--bs-modal-width`: under Bootstrap
`.modal-dialog` sizes the modal, so a panel width is capped by the dialog rather than widening it.

**Two behaviours Bootstrap ADDS**, agreed and kept: Escape-to-close and a focus trap. Neither is
visual. Some pages (advertisers, influencer) already had their own Escape handler; those are deleted
in favour of the shared one.

## 6g. Products page — status

`products.html` + `assets/css/admin-products.css` (+ `assets/js/admin-products.js`). Solo stylesheet
(the `.sw-dd--tool` framed skin it once byte-shared with merchants is now the shared `.sw-dd--framed`
modifier in `admin-components.css` — deduped, see §6c).

| Metric | Original (`main`) | Now |
|---|---|---|
| Markup Bootstrap share of `<main>` | ~0% (3 of 430 tokens) | **63%** (514 of 818) |
| `admin-products.css` declarations | 430 | **340** |
| — of which `--bs-*` inputs | 3 | **69** |
| — of which custom | 427 | **271** |
| `!important` | 0 | **0** |
| Visual diff, both views (5 widths) | — | **0.0000%** |
| Visual diff, list view + create/edit sheets | — | **0.0000%** |

Uses: `.btn` + `--bs-btn-*` (view-toggle segments, row actions, the modal close and bare text
buttons), `.badge` + `--bs-badge-*` (status/category pills, markup and JS-generated), `.card`/
`.card-body` (product tiles), `.form-control` (Add-product fields), `.d-grid`/`.d-flex`/`.flex-column`
/`.align-items-*`/`.justify-content-*`, `.border`/`.border-top`/`.rounded`/`.overflow-auto`/
`.overflow-hidden`, `.object-fit-cover` (the tile image), `.text-truncate`, `.gap-*`, `.m-*`,
`.fw-bold`/`-semibold`, `.text-body-secondary`/`-tertiary`.

**One regression, user-visible, now the reason `.sw-uact` lives in `admin-components.css`.** The
list-view row-action buttons rendered as empty boxes: their base rule was in `admin-users.css`, which
products does not load. Fixed by **moving** `.sw-uact` to the shared component library (rule 3, not a
copy), then re-verifying users + advertisers byte-identical. This is exactly the client's original
"duplicated page-local assets" complaint and is why the base lives shared now.

Kept as custom, doc-cited in-file: the list-table `grid-template-areas` pseudo-table + card restack
(register: /content/tables), bespoke `grid-template-columns` track lists, off-scale type
(12/13/14/17/20px — `.fs-*` is RFS, gotcha 1), off-scale spacing, `min-width: 0`/`min-width: auto`
(no utility), the fixed tile-image box (sizing utilities are percentage-based), and brand tints.

### 6g-2. Products — Bootstrap-forms deep pass (branch `refactor/bootstrap-products`)

Same treatment as merchants §6i-2, on the Add-product modal. Verified **0.0000% across 17 shots**
(page + list-view + add + filter, ×5 widths) + behavior ALL PASS (native open, Tabs, per-form
submit, form-switch, in-modal dropdown, grid⇄list view toggle, 0 console errors).

- **Segmented control → Bootstrap Tabs** — split `#addProductForm` into two `.tab-pane`
  native-submit forms (store / import) with per-form footers + `display:contents`. The three
  merchants seg fixes (`.is-active`→`.active`, `.nav-link` padding `1px 6px`, `.nav-link:hover/:focus`
  reassert) baked in upfront → 0.0000% first try. `.sw-cp__body` base gap already = the old
  `[data-cp-panel]` 16px, so no gap override needed.
- **`.sw-switch` → `.form-check.form-switch`.**
- **`.sw-cp-control` icon-inputs → `.form-control`** (products' own 42px overlay — NOT the shared
  `.sw-eu-field` 40px). `.sw-cp-control__input` themed like `.sw-cp-textarea` (`--bs-border-color`/
  `--bs-border-radius`, gotcha-17 focus ring); icon → absolute `.sw-cp-control__ic`. Two subtleties,
  both now **gotcha 41**: the old input's UA `1px 2px` padding had to be folded back (`padding: 0 14px`,
  icon-field `padding-left: 40px`, icon `left: 13px`), and the 42px height must come from **padding not
  `height`** or the wide name field's placeholder re-rounds AA (~0.03%, desktop only).
- **Native `data-bs-toggle="modal"` opens** (add + filter), Apply → native `data-bs-dismiss`; dropped
  `openSheet`/`closeSheet` forwarders; template demo → `<a href download>`; submit interceptor removed;
  `var`→`const`/`let` (16). Toolbar "Import CSV" button → native `<label class="btn">` wrapping a
  `.visually-hidden` (focusable) file input — opens the picker with no JS and stays keyboard-accessible
  (`.sw-pimport:has(input:focus-visible)` surfaces the brand ring on the label); its change→toast is the
  demo stand-in for the server POST. Kept: the filter Reset (clears the custom `.sw-dd` filters
  client-side — a native `type="reset"` can't) and the import dropzone (genuine drag-and-drop — no
  native/Bootstrap analog for dropping a file onto a custom zone). Updated
  `sheets-shot.mjs` products-filter opener `[data-filter-open]`→`.sw-pfilter`.
- **Grid⇄list view toggle → Bootstrap Tabs** (dropped its ~24-line JS + localStorage persistence,
  per user). The two `.sw-pview__btn` (already `.btn`) got `data-bs-toggle="tab"`/`data-bs-target` +
  `role="tab"`/`aria-selected` (**no `.nav-link`** — it would repaint the `currentColor` icons
  link-blue; the buttons qualify as tab children via `role="tab"`); `.sw-pview` got `.nav` (needed
  only so Bootstrap's `Tab` finds `closest('.nav')` — visually inert here: its `padding-left:0` loses
  to `.sw-pview{padding:3px}` on source order) + `role="tablist"`; `.is-active`→`.active` in CSS. The
  two view panels wrap in `.tab-content > .tab-pane` — a **plain-block wrapper** (no `.fade`, so the
  switch is instant like before), which keeps `.sw-pgrid`'s grid and `.sw-plist-wrap`'s table intact
  (unlike the create-modal seg, the panels ARE the layout elements, so they can't take
  `display:contents` — wrap, don't convert). Verified list-view **0.0000% ×5 branch-vs-clean-main**
  (nesting preserved) + behavior ALL PASS (grid default, list on click, aria-selected flips, restores,
  0 errors). `products-list-shot.mjs` made dual-selector (new `#pvListTab`/`#pvList`, old
  `[data-view-btn]`/`[data-view-panel]`) so baseline (main) + current (branch) shoot the same surface.
- **`.sw-dd--tool` dedup — DONE** (`refactor/dedupe-sw-dd-tool`): the framed skin moved to a shared
  `.sw-dd--framed` modifier in `admin-components.css`; products' page-file copy deleted. See §6c.

## 6h. Campaigns cluster — status

`ad-campaigns.html` + `sales-campaigns.html` + `influencer.html`, all on the **shared**
`assets/css/admin-campaigns.css` (+ `admin-campaigns.js`; influencer additionally loads
`admin-influencer.js` — the historical double-script that once double-wired every dropdown, now
harmless since `.sw-dd` is shared, see section 3). All three pages verified on every step.

| Metric | Original (`main`) | Now |
|---|---|---|
| Markup Bootstrap share, ad-campaigns `<main>` | — | **41%** (232 of 569) |
| Markup Bootstrap share, sales-campaigns `<main>` | — | **41%** (190 of 469) |
| Markup Bootstrap share, influencer `<main>` | — | **48%** (204 of 428) |
| `admin-campaigns.css` declarations | 582 | **545** |
| — of which `--bs-*` inputs | 9 | **163** |
| — of which custom | 573 | **382** |
| `!important` | 0 | **0** |
| Visual diff, 3 pages (15 shots) | — | **0.0000%** |
| Visual diff, wizard open (15) + filter popover (8) + wizard steps 1–5 (20) | — | **0.0000%** |

Uses: `.badge` + `--bs-badge-*` (all status/type pills), `.btn` + `--bs-btn-*` (row actions, tabs'
filter button, the popover clear / draft / add-section bare text buttons, the 5-step wizard's
footer buttons), `.border`/`.bg-white`/`.rounded`/`.rounded-pill`/`.rounded-circle` +
`--bs-border-color`/`--bs-border-radius` (the KPI cards, filter popover, chip inputs, wizard
toggles/levels, stepper badges), `.d-flex`/`.d-inline-flex`/`.d-grid`/`.flex-column`/`.flex-wrap`/
`.align-items-*`/`.justify-content-*`/`.align-self-start`/`.flex-shrink-0`, `.overflow-auto`,
`.text-nowrap`/`.text-truncate`, `.m-0`, `.fw-bold`/`-semibold`, `.gap-*`.

**Four regressions caught, all invisible to the page screenshots:**
1. **`.card` inherited `word-wrap: break-word`** broke long names mid-word below 576px, growing the
   cards 3.5% at 375 — the first `.card` hand-back that propagates down the subtree. **Gotcha 39.**
2. **`.sw-wbonus`** (a stretch-children column) was mis-mapped to `.align-items-center`, shrinking
   wizard step 5 rows 612→462px — only `wiz-steps-shot.mjs` caught it (the wizard opens on step 1).
3. **Filter border went grey on hover** — `.sw-cfilter.is-open` re-pointed only the *rest* border
   variable, so `.btn:hover` (pointer still on the button after the click) painted the grey
   `--bs-btn-hover-border-color`. Fixed by re-pointing hover/active border too (gotcha 33 family).
4. **Kebab dots shifted 7px** when `.sw-cact` centring moved to markup utilities the kebab markup
   lacks — reverted; the 13 kebab toggles inherit `justify-content: center` from `.sw-cact`, so that
   stays in CSS (same reason as 6c's `.justify-content-between` note).

Kept as custom, doc-cited in-file: the KPI card shadow (different from the global `.card` theme, so
`.card` is not a fit), the filter popover's radius/shadow/position (all change in the `<576px`
bottom-sheet variant, and `.rounded` would be unconditional `!important` — gotcha 28), the chip-input
border (`:focus-within` re-colours it, a `.border` utility would out-rank the focus state — gotcha 17
family), `.sw-cact` centring and `.sw-crow__actions` `align-items` (both flip in a media query —
gotcha 2), `.sw-step__label` font-weight (`.is-active` raises it to 600), `flex: 1` on the wizard body
(`.flex-fill` is `1 1 auto` — gotcha 4), overflow-x + scrollbar-hide (no utilities), off-scale radii
(12/14px → variables), off-scale type/spacing, and brand tints.

### 6h-2. `admin-influencer.css` — Create-influencer modal deepened

Solo page file (only `influencer.html` loads it), so no cluster re-verification — a normal page-scoped
pass. The `.sw-icamp` create-influencer modal is **static markup** (`admin-influencer.js` builds none of
it — grep-confirmed, so no gotcha-40 exposure). Converted the **single-occurrence** `.sw-icamp__*`
structural elements (head, head-row, title, sub, body, caption, foot) to exact-match utilities:
`display:flex`/direction/alignment → `.d-flex`/`.flex-column`/`.align-items-center`/
`.justify-content-between`/`-end`/`.d-inline-flex`, `flex-shrink:0` → `.flex-shrink-0`,
`font-weight:700/600` → `.fw-bold`/`.fw-semibold`, the three brand text colours → `.text-body`/
`-secondary`/`-tertiary` (verified exact: `--bs-body/secondary/tertiary-color` map to
`--sw-text`/`-muted`/`-faint` in style.css `:root`), `margin:0` → `.m-0`, and
`border-top:1px solid var(--sw-border)` → `.border-top` (`--bs-border-color` = `--sw-border`). Also
moved the `.sw-icamp__foot .sw-btn-*` centring onto the 2 footer buttons in markup and deleted the
descendant rule. **admin-influencer.css 67 → 47 custom decls (−20, −30%)**, braces 19/19.

**Kept custom (register):** the `.sw-ireward` reward rows repeat **7×**, so their flex/`flex:1`
(gotcha 4)/`min-width:0`/off-scale sizes and the custom input's focus ring (gotcha 17) stay in CSS —
utilities would bloat 7 rows and the rules must survive for the off-scale/no-utility props anyway; the
`.sw-idd` dropdown-icon descendant selector; the `--bs-modal-width`/`max-height` media block; and brand/
state tints (`.sw-cstat__num--warn`, `.sw-cic--sales`, non-token grey `#2b3345`). **The footer buttons
`.sw-btn-ghost`/`.sw-btn-primary` are custom shared classes (not `.btn`)** — migrating them to `.btn` is
a separate shared-layer job, deliberately out of scope. Verified **0.0000%** across influencer page ×5 +
create-modal ×5 (`sheets-shot`), `dd-test`/`dd-portal-test` green, 0 console errors.

### 6h-2b. `influencer` — forms-playbook pass + page JS deleted (`refactor/bootstrap-influencer`)

The last un-playbooked create modal. §6h-2 had done its CSS/markup *structure*; this finished the
**form controls + native submit**, bringing influencer in line with the two campaign wizards it shares
`admin-campaigns.css` with. Solo — no cluster re-verification.

- **7 `.sw-ireward__input` reward fields → `.form-control` + `.flex-shrink-0`.** The rule drops to
  `--bs-*` inputs: `border` → `--bs-border-color: var(--sw-border-strong)`, `border-radius` →
  `--bs-border-radius: 9px`. `color`/`background`/`border-width`/`font-family` were **removed** — they
  already equal `.form-control`'s output for this theme (`--bs-body-color` = `--sw-text`, `--bs-body-bg`
  = `#fff`, reboot inherits the font). Placeholder (faint vs form-control's muted) + the brand focus
  ring (gotcha 17) stay. **admin-influencer.css 48 → 44 decls, 1 → 3 `--bs-*`, 47 → 41 custom.**
  0.0000% — these were already bordered, `height`-sized inputs, so **no gotcha-41 placeholder re-round**
  (that trap is only for a borderless flex-centred wrapper).
- **Playbook-pure — `admin-influencer.js` DELETED (27 → 0) and its `<script>` tag removed.** The whole
  file was a FRONTEND DEMO (submit → toast + close); the form already had native `type="submit"`
  `form="createInfluencerForm"` and the `<!-- Laravel: action=route(...) @csrf -->` comment, so it now
  POSTs natively (server flash → toast), exactly like reports §6d. Bonus: this removes influencer's
  historical **double-script** (§3) — the page now loads only `main.js` + `admin-campaigns.js`. Modal
  open/close is native `data-bs-toggle`/`data-bs-dismiss`; the campaign `.sw-dd` is wired by `main.js`.
- Removed 2 dead hooks (`data-create-open`, `data-icamp-submit` — 0 JS refs). `sheets-shot.mjs`
  influencer opener moved off `[data-create-open]` to the stable `.sw-create`.

Verified **10 shots 0.0000%** (page ×5 + create modal ×5) **against a fresh clean-`main` worktree
baseline** (`SW_SRC`) — the committed page baseline is stale by ~18px (gotcha 18, pre-existing, §6h-3),
which showed as a spurious 0.055% until re-baselined from main. Behaviour drive: native open, 7
form-controls, brand focus ring (not Bootstrap blue), in-modal dropdown selects, native submit
navigates, **0 console errors, 0 page JS**. `dd-test`/`dd-portal-test` green.

### 6h-3. Campaigns cluster — forms pass: switch + Manual/Import seg → Bootstrap Tabs (`refactor/bootstrap-campaigns`)

Full forms pass on both campaign wizards (the app's most complex modal), matching products §6g-2 /
merchants §6i-2.

**Switch → `.form-check.form-switch`.** The two wizards were the **last users of the old `.sw-switch`
skin**. Converted the 3 wizard toggles (ad: `location_based` step 2 + `bundle` step 3; sales:
`location_based` step 2) to the shared `.form-check.form-switch` + `.form-check-input.sw-switch-input
float-none ms-0 m-0` pattern; **deleted the now-dead `.sw-switch`/`.sw-switch__track` rules** from
`admin-components.css` (0 references remain anywhere — the shared skin is now purely Bootstrap's). All 3
static (no gotcha-40).

**Manual/Import seg → Bootstrap Tabs.** Same shape as products (two sibling panes toggled by the seg)
plus external stepper/footer chrome. Seg buttons → `.nav-link` + `data-bs-toggle="tab"`/`data-bs-target`
+ `role="tab"`; the manual `<form>` and the `.sw-camp-import` panel wrap in `.tab-pane`s inside
`.sw-camp-tabs.tab-content`, both **`display:contents`** (`#modal .sw-camp-tabs, #modal .tab-pane.active`)
so they flow as the modal body's direct flex children exactly as the old `.is-import` show/hide did. The
stepper, Save-draft and footer alignment sit OUTSIDE the panes and still swap by mode — JS keeps a
`.is-import` class, now toggled from a **`shown.bs.tab`** handler (was a click→`setMode`); `openWiz()`
resets to the manual tab via `bootstrap.Tab` + an explicit `setMode("manual")` (Tab.show() is a no-op
when manual is already active, so the chrome reset must be explicit). The three products/merchants
`.nav-link` seg fixes were applied (`padding:1px 6px`, `.active` dark, `:hover/:focus` reassert).

**NEW gotcha 42 — a `:focus` reassert on a seg tab repaints the ACTIVE tab, because clicking a tab
focuses it.** The `#modal .sw-seg__btn:hover, :focus { color: --sw-text-muted }` reassert (added on
every seg→Tabs page to counter `.nav-link`'s hover-blue) is `(0,3,0)`, the same as the active-colour
rule, and sits later in source — so once a tab is clicked (→ focused) it out-cascaded `.active` and the
active tab text went **grey instead of dark**. Invisible in the sheet captures (they shoot the modal at
OPEN, first tab active but NOT focused), caught only by driving a tab click (the import shot). Fix: scope
the reassert `:not(.active):not(.is-active)` — the active tab's `.active` rule beats `.nav-link:focus`
`(0,2,0)` on its own, so it stays dark on focus. **This bug pre-existed on products and merchants too**
(identical unscoped reassert) — fixed all three. **users was already correct** (its seg uses `role="tab"`
WITHOUT `.nav-link`, so there is no hover-blue to counter and it never had a reassert).

**Reformat is SAFE here — do reformat (the earlier "keep minified" worry was wrong).** An initial read
blamed the `htmlWhitespaceSensitivity:"ignore"` expansion for an ~18px page-shot drift, but a direct
reformatted-vs-clean-main capture (via `capture.mjs` `SW_SRC`, added this pass) came back **0.0000%** —
the 18px was the *stale committed page baseline* (gotcha 18), not the reformat. So the campaigns HTML is
committed **expanded/readable** like every other page.

**Verified: 64 shots 0.0000% vs a fresh clean-main worktree baseline** — ad/sales/influencer pages ×5 +
both wizards' 5 steps + create sheets + filter popovers (58 manual-mode) + **6 import-mode** shots (new
`camp-import-shot.mjs`, since capture/sheets open the wizard in manual mode only). Behavior: seg-Tabs
drive 24/24 both wizards (panes switch, stepper hides in import, title swaps, restores), wizard `.sw-dd`
opens/selects (portaled from inside the tab-pane), switch toggles, `dd-test`/`dd-portal-test` green, 0
console errors. Computed seg colours checked on products/merchants/users/campaigns (active dark on focus,
inactive muted on hover).

**Utility deepening (doc-audited).** A pass over the shared `admin-campaigns.css` against the BS 5.3
docs moved four more patterns to Bootstrap: `.sw-cname`/`.sw-cadv` truncation trio → **`.text-truncate`**
(helpers/text-truncation — both sit in a `min-width:0` flex column); `.sw-cic` row-icon `display/align/
flex-shrink` → **`.d-inline-flex.align-items-center.justify-content-center.flex-shrink-0`** (matching its
already-migrated sibling `.sw-cstat__ic`); `.sw-wiz__foot-right` `align-items` → **`.align-items-center`**;
and removed a **redundant** `display:flex;align-items;justify-content` block from `.sw-pop__head` (the
markup already carried those utilities). All three cluster pages (ad/sales/influencer — the list table is
on all three) edited in lockstep. Verified **64 shots 0.0000%** (list-table cells show in page shots, the
footer in wiz-steps, the popover in camp-filter) + `dd-test` 0 errors. **Left for a follow-up:**
`.sw-cfilter__badge` → `.badge.rounded-pill` (it is `display:none` at load — needs a filter-count state to
verify), and `.sw-rlevel__addrule` → `.btn` (shares its rule with the dashed `.sw-rlevel__add`, whose
dashed border fights `.btn`'s hardcoded `solid`).

**Dead-code prune:** removed the `cancelBtn` variable + its 3 `if (cancelBtn) …hidden` no-ops and the
`[data-wiz-close]` listener wiring from `admin-campaigns.js` — `data-wiz-close` appears 0× in the markup
(Cancel and the close-X are native `data-bs-dismiss="modal"` since the sheet became a Bootstrap Modal), so
`cancelBtn` was always null and the code never ran. `closeWiz()` stays (draft/launch/import still call it).
Verified: open / step / Cancel-closes / reopen-resets, 0 console errors.

**Harness added:** `capture.mjs` `SW_SRC` (baseline a page from a clean-main worktree without switching
branches); `camp-import-shot.mjs` (both wizards' import panel ×3 widths).

### 6h-4. Campaigns wizard — modal completion to the contract rules (`refactor/bootstrap-campaigns`)

Finished the campaign wizards against the five contract rules (native modal / Bootstrap form controls /
separate Manual+Import forms / shared assets):

- **Native open** — the "Create …" button is now `data-bs-toggle="modal"` `data-bs-target="#…Modal"`; the
  JS `openWiz()` + its `[data-create-open]` click wiring are gone, replaced by a **`show.bs.modal`**
  listener that resets to the manual tab at step 1. Bootstrap opens/closes; JS only resets.
- **Bootstrap form controls** — `.sw-field__input` → **`.form-control`** on all **23** campaigns fields
  (19 inputs + 4 `.sw-wta` textareas). **Scope reality:** `.sw-field__input` reads as "9 pages" but **7
  were already `.form-control`** (users/advertisers via `.sw-eu__body`, merchants via `.sw-eu-field`) —
  only the two campaign wizards were still bare, so this finished them. The shared `.sw-field__input` skin
  in `admin-components.css` (44px, hairline, 10px radius, violet focus) is **unchanged** — it already
  pairs with `.form-control` on the other 7 pages, so adding the class was **markup-only** and the other 7
  pages are untouched. The `.sw-dd` fancy selects stay custom (user-confirmed; register — no `<select>`
  semantics). **0.0000%** — form-control's `width:100%`/line-height matched the existing skin (no gotcha-41
  placeholder re-round, since these were already-bordered `height`-sized inputs, not a borderless wrapper).
- **Separate Manual + Import forms** — the import pane's `<div class="sw-camp-import">` became a
  `<form id="…ImportForm">`; the manual side stays `<form id="…Form">`. Both footer submits are native
  `type="submit"` with a `form="…"` association (the shared footer sits outside the panes). JS listens on
  each form's **`submit`** (demo toast + close), not button clicks; the manual form guards `if (step !==
  TOTAL) return` so an Enter-key implicit submit on steps 1–4 is a no-op. **Page-agnostic:** the JS finds
  the forms by class (`wizEl.querySelector("form.sw-wiz__body" / "form.sw-camp-import")`), not the
  per-page ids, so the one shared script works on both ad + sales.

Verified **64 shots 0.0000%** vs a fresh clean-main worktree + a Phase-A behaviour drive (16/16 both
wizards: native open, reset-to-step-1, import-is-a-form, import native-submit closes, reopen resets, reach
step 5, launch native-submit closes) + `dd-test` 0 console errors. **Rule 4 (header/footer/nav in shared
files)** is the Blade-layout extraction step — the shell markup repeats per static page today; its CSS/JS
is already shared. **`capture.mjs` gained `SW_SRC`** so a page baseline can come from a clean-main worktree.

## 6i. Merchants cluster — status

`merchants.html` + `chains.html` + `distributors.html` + `divisions.html` + `locations.html`, all on
the **shared** `assets/css/admin-merchants.css` (+ `admin-merchants.js`; the four siblings carry no page
CSS/JS of their own and reuse the same tree-table, KPI strip, toolbar and pills). All five verified on
every step. Commits `385f865` (migration), `3adbc39` (dropdown fix), `c274a3b` (deepening pass),
plus a second deepening pass — layout utilities + a rule-3 dedup (this branch).

| Metric | Original (`main`) | After `c274a3b` | Now |
|---|---|---|---|
| `admin-merchants.css` declarations | 415 | 298 | **281** |
| — of which `--bs-*` inputs | 2 | 40 | **40** |
| — of which custom | 413 | 258 | **241** |
| `!important` | 0 | 0 | **0** |
| Visual diff, 5 pages (25 shots) | — | 0.0000% | **0.0000%** |
| Visual diff, filter + add sheets (45 shots) | — | 0.0000% | **0.0000%** |

Uses: `.badge` + `--bs-badge-*` (level pills `.sw-lvpill` at radius 6px via `--bs-badge-border-radius`,
status pills `.sw-mstatus` with `.rounded-pill` + a kept `::before` dot; markup and enum tints),
`.btn` + `--bs-btn-*` (row expand toggles `.sw-texpand`, the phone filter button `.sw-mfilter`),
`.row .row-cols-2 .row-cols-sm-4 .g-3` (KPI strip — `.col`-wrapped tiles + `.h-100`; gutter overridden
to 12px `<576`), `.d-grid` / `.d-none .d-xl-grid` (tree rows / head — the design 1200px break *is*
`xl`), `.d-none .d-xl-flex` (desktop-only toolbar tools), `.bg-white`/`.border` (KPI tiles, network
card), `.d-flex`/`.d-inline-flex`/`.flex-column`/`.align-items-*`/`.justify-content-*`/`.flex-shrink-0`/
`.ms-auto`, `.rounded-circle`/`.rounded-pill`/`.overflow-hidden`/`.h-100`/`.d-block`/`.position-*`,
`.text-truncate`, and — from the deepening pass — `.fw-bold`/`.fw-semibold` + `.text-body`/`-secondary`/
`-tertiary` on every heading, caption, stat number, label and tree name that has no state variant.

**Second deepening pass (this branch) — 258 → 241 custom, all exact-match utility swaps.** Moved
`flex-shrink: 0` → `.flex-shrink-0` (`.sw-mtools`, `.sw-mfilter`, `.sw-am-seg-wrap`, `.sw-texpand`),
the `.sw-texpand` and `.sw-mfilter` `display: inline-flex; align-items/justify-content: center` →
`.d-inline-flex .align-items-center .justify-content-center`, `border-top`/`border-bottom:
1px solid var(--sw-border)` → `.border-top`/`.border-bottom` (`.sw-tfoot`, `.sw-tree__head` — the
utilities read `--bs-border-color`, already themed to `--sw-border`), and `white-space: nowrap` →
`.text-nowrap` (`.sw-tfoot__rpp`, `.sw-am-auto`). **Plus a rule-3 dedup:** `admin-merchants.css`
carried a byte-identical copy of `.sw-dd__lead` (width/height/color/flex-shrink) that
`admin-components.css` already defines and loads first — deleted (−4). Verified across 25 page + 45
sheet shots at 0.0000%, `dd-test` and `dd-portal-test` green. **`.sw-thcell` was deliberately left
alone** — it is the class that triggered harness catch #1 below (a missed `is-sorted` variant), and its
`white-space`/`text-align` survivors are part of its `<button>` reset that must stay anyway; two
declarations were not worth re-risking a documented failure. `.sw-licon`'s `border-radius: 8px`
(= `.rounded-3`) was also left — 34 markup edits across five files for one declaration.

**Cluster mechanics (the decisive constraint).** Converting a class used on >1 cluster page means
editing all five HTML files **in lockstep**: stripping a declaration from the shared CSS while only one
page's markup carries the replacement utility silently breaks the other four (Rule 1). So the shared
components (KPI strip, toolbar, tree, pills, footer) were converted across all five at once; the
merchants-only network card / donut / hbars were done in `merchants.html` alone. Blast radius is exactly
these five pages (only they load `admin-merchants.css`); the other 20 are untouched.

**Two harness catches worth keeping:**
1. **Exact class-string matching misses a variant combo.** The batch adding `.d-inline-flex
   .align-items-center` to `.sw-thcell` matched `class="sw-thcell"` but not `class="sw-thcell
   is-sorted"` — so the one sorted header, stripped of `display:inline-flex` in the shared CSS,
   blockified inside the grid and its chevron lost the 5px flex gap, shifting 2px (0.0007%, one glyph,
   desktop only). **Convert every variant of a class, not just its bare form.**
2. **`.row-cols-N` was bit-identical to `repeat(N, 1fr)` here** (unlike roles' 5-up, gotcha 26): the
   4-up KPI grid's free space divides evenly into 1/64ths, so 0.0000% at 1440/1920.

**Dropdown fix (`main.js`, `3adbc39`) — pre-existing, not migration damage.** The tree footer's
rows-per-page `.sw-dd` menu opened but was invisible (identical on clean `main`): `main.js` portals a
menu to `<body>` only inside `.sw-sheet`/`.modal`, and this one sits in `.sw-tree`, which is
`overflow:hidden` for its rounded corners — so it was clipped. Fix: (1) add `.sw-tree` to the portal
condition; (2) `place()` forced every portaled menu to its toggle's width, clipping the compact
rows-per-page labels, so `.sw-dd--tool` menus now size to content (`max-content`, min = toggle width,
cap 260px) while field/sheet menus keep toggle width. `dd-test` 12 PASS/0 FAIL; `dd-portal-test` passes.

**In-file comments were stripped from `merchants.html` + `admin-merchants.css`** by the user (same as
`admin-roles.css` in `884c452`) — justifications live in this section, not in-file. The four sibling
HTML files keep their comments.

Kept as custom, register-justified: the bespoke `grid-template-columns` track lists (network-card 3-col,
tree 8-col) and the tree's `grid-template-areas` card restack `<1200` (/content/tables); off-scale type
(10/11.5/12/12.5/13/13.5/14/17/22/24px — `.fs-*` is RFS, gotcha 1); off-scale spacing
(2/5/6/9/10/12/14/18/24/28px); fixed px boxes (9/20/30/40/44/160px — sizing utils are %-based);
`letter-spacing`/`min-width:0`/`overflow-wrap:anywhere` (no utilities — gotcha 10); the custom card
radius/padding (18/16/14px, off the `.rounded-*` scale) and the tree/netcard surfaces that reset in a
media query, so `.border`/`.bg-white` stay in CSS there (gotcha 28); the weight/color of the three
state-variant text elements (`.sw-netstat__num--up`, `.sw-thcell.is-sorted`, `.sw-tcell--muted`); the
Chart.js donut `<canvas>`; and brand tints.

**`.sw-dd--tool` dedup — DONE** (`refactor/dedupe-sw-dd-tool`): the framed skin moved to a shared
`.sw-dd--framed` modifier in `admin-components.css`; the merchants-cluster page-file copy deleted and
`.sw-dd--framed` added to its tool dropdowns. Campaigns kept its distinct look (additive modifier, no
rename). See §6c.

### 6i-2. Merchants cluster — Bootstrap-forms + Tabs + Collapse + progress (this branch, `refactor/bootstrap-merchants`)

A second, deeper pass over the cluster's add-`<node>` modal + the merchants network card. All verified
at **0.0000%** (70 cluster shots: 25 page + 25 add + 20 filter, ×5 widths) + behavior suites green
(`dd-test`, `dd-portal-test`, purpose-built modal + tree-cascade drives), 0 console errors.

- **Add-modal fields → Bootstrap controls (all 5 pages):** icon inputs `.sw-eu-input` → `.sw-eu-field`
  overlay (`.form-control`) — merchants was the LAST user of `.sw-eu-input`'s icon pattern (only the
  readonly `--auto` Stores field keeps it, register); plain inputs → `+.form-control`; `.sw-switch` →
  `.form-check.form-switch`. Eye-toggle JS chased `.sw-eu-input`→`.sw-eu-field` (`closest()`, gotcha 37/40).
- **merchants seg → Bootstrap Tabs:** the segmented control became `.sw-seg.nav` + `.nav-link` +
  `data-bs-toggle="tab"`; the single `#addMerchantForm` split into **two `.tab-pane` native-submit forms**
  (`store` / `import`) with per-form footers + `display:contents` (mirrors users, §6e). Three seg fixes the
  harness caught, all gotcha-32 family: `.is-active`→`.active` selector (active text had gone violet),
  `.nav-link` padding re-rounding glyph AA (reverted to `1px 6px`), `.nav-link:hover/:focus` painting the
  inactive tab Bootstrap-blue (mouse-flaky, only at 992 — reassert rest colours). Found via a clean-main
  computed-rect diff.
- **Tree expand/collapse → Bootstrap Collapse (merchants only; user chose ANIMATED):** the flat rows were
  nested into 4-level `.collapse` containers (the only way the "hide the whole subtree" cascade works on a
  flat list); toggles → `data-bs-toggle="collapse"`; chevron `.sw-trow.is-collapsed` → `.sw-texpand.collapsed`;
  `:last-child` scoped to `.sw-tree > .sw-trow` so nested rows keep dividers; **narrow-width card gap** — the
  `<1200` card layout spaces via `.sw-tree`'s flex `gap:12px` between DIRECT children, so nested cards lost it
  (page 66px short) → `.sw-tree .collapse.show, .collapsing { display:flex; flex-direction:column; gap:12px }`.
  ~30 lines of tree recompute JS deleted. Siblings' trees are **flat** (6 L0 rows, 0 toggles) → no nesting;
  the shared CSS/JS changes are no-ops for them.
- **`.sw-netcard__bars` → Bootstrap `.progress`/`.progress-bar`:** `.sw-hbar__track` → `.progress`
  (`--bs-progress-height:6px; --bs-progress-bg:#eef0f4; --bs-progress-border-radius:999px`), `.sw-hbar__fill`
  → `.progress-bar` (`--bs-progress-bar-bg:var(--sw-violet)`) + `role="progressbar"`/`aria-value*`. Dropped
  `rounded-pill`/`overflow-hidden`/`d-block`/`h-100` (the component provides them). `.sw-mstat`/`.sw-netstat`
  checked and left at register floor (`.sw-netstat__num` color stays in CSS — `--up` state variant a
  `.text-body` utility would `!important`-override).
- **Native + cleanup:** add/filter sheets open via native `data-bs-toggle="modal"` (deleted the
  `openSheet`/`closeSheet`/`[data-sheet-close]` forwarders); export/sort-header/template demos removed
  (export + template → `<a href download>` like §6e/users); JS submit interceptor removed (native per-form
  submit); tab-reset dropped; `var`→`const` (27); the dead `.sw-eu-input__eye` rules pruned from shared
  `admin-components.css`; the redundant `data-ancestors` (old flat-recompute hook, replaced by the nesting)
  removed from the tree rows. A dead-code scan (90 CSS classes, 233 HTML `sw-*` tokens) otherwise came back
  clean — the migration removed hooks as it went.
- **`.prettierrc` added — `{ "htmlWhitespaceSensitivity": "ignore" }`.** The default `"css"` mode was gluing
  adjacent inline `<span>`s (`</svg></span>` crammed); `"ignore"` formats uniformly. Verified layout-safe
  (70 shots 0.0000% after reformatting all 5) — the icon+text spans sit in `d-flex` containers, which discard
  inter-item whitespace. **Project-wide**: the other 20 pages will `"ignore"`-format on next save — re-verify
  those when touched (low risk; only inline-text-flow contexts could shift).

## 6j. Messages page — status

`messages.html` + `assets/css/messages.css` (the shared two-pane **chat component**) +
`assets/css/admin-messages.css` (a thin admin layer) + `assets/js/messages.js`. Solo — only
`messages.html` loads these two stylesheets, so no cluster re-verification.

| Metric | Original (`main`) | Now |
|---|---|---|
| Markup Bootstrap share of `<main>` | — | **68%** (314 of 465) |
| `messages.css` declarations (custom) | 509 | **399** (+9 `--bs-*`) |
| `admin-messages.css` declarations (custom) | 50 | **48** (scroll-fix flex chain, below) |
| `!important` | 0 | **0** |
| Visual diff, page (5 widths) | — | **0.0000%** |
| Visual diff, mobile-inbox + empty states (6 shots) | — | **0.0000%** |

**Scope — this is a component, not a page like the others.** The register marks the chat UI
"no Bootstrap analog" at the *component* level (there is no messenger component), and that stands:
the two-pane grid, bubbles, composer and master-detail structure stay bespoke. What moved is the
*utility layer inside* it — flex containers → `.d-flex`/`.d-inline-flex` + `.flex-column`/
alignment, `border-radius: 999px` → `.rounded-circle`/`.rounded-pill` (avatars, dots, tabs, count
badges), the truncation trio → `.text-truncate`, on-scale gaps → `.gap-1/2/3`, `width/ max-width:
100%` → `.w-100`/`.mw-100`, and the empty-state centring → utilities. Done in verified batches
(A rounded/truncate, B1/B2 inbox/chat flex, C pills+letter-avatars, D on-scale gaps, E empty state).

**Border deepening (F/G/H).** The off-brand hairlines (`#ece9e0`/`#f3f4f6`/`#e5e7eb`) went to
`.border`/`.border-top`/`.border-bottom` + a per-element `--bs-border-color` (7 static elements),
so each `border:` shorthand became a `--bs-*` input. The message BUBBLE too — but it is built by
the composer JS, so `border` was added to `bubble.className` (gotcha 40) and the `--out` variant
re-points `--bs-border-color: var(--sw-violet)` so `.border` reads it (gotcha 30); a live send
confirms the built out-bubble gets a 1px violet border. Plus two 8px radii → `.rounded-3`. **Left in
CSS:** the `.sw-inbox`/`.sw-chat` panel borders (removed at <992 by the media query — a `.border`
utility is `!important` and would out-rank that, gotcha 28) and `.sw-conv`'s divider (`:last-child`
drops it — the utility would force one on the last row).

**Text-utility deepening (I).** `color: #1a1232` → `.text-body` and `color: #9ca3af` →
`.text-body-tertiary` (both EXACT — `#1a1232` = `--sw-text` = `--bs-body-color`, `#9ca3af` =
`--sw-text-faint` = `--bs-tertiary-color`; `#6b7280`/`#0f1020` have no token so they stay),
`font-weight: 600` → `.fw-semibold`, `margin: 0` → `.m-0` — on conv name/time, both letter avatars,
chat name/day, and the empty title. Left in CSS: `.sw-inbox-tab` weight (`.is-active` flips 500→600),
`.sw-empty__text` colour (the `--lg` variant re-colours to `#6b7280`), and `.sw-msg-row__time` colour
(JS-built). **One regression the empty baselines caught:** `.m-0` on `.sw-empty__text` (`!important`)
out-ranked `.sw-chat__empty .sw-empty__title--lg + .sw-empty__text--lg { margin-top: -10px }`, pushing
the chat-empty subtitle down 10px (0.19–0.73%). Reverted — `.sw-empty__text` keeps `margin` in CSS
(gotcha 2: a utility beats an adjacent-sibling rule too). messages.css 509 → 412 custom.

**Reset/position deepening (J).** The last exact swaps: `flex-shrink: 0` → `.flex-shrink-0` (6
avatars/dots/times/composer buttons), `position: relative`/`absolute` → `.position-relative`/
`.position-absolute` (composer box + send), `background: #fff` → `.bg-white` (composer),
`text-decoration: none` → `.text-decoration-none` (the `.sw-conv` link), and `border: 0` → `.border-0`
(hr divider + reset buttons). Skipped the state/hover-varying ones (`.sw-inbox-tab`/`.sw-chat__send`
`background` flips; `.sw-chat__action-btn`/`.sw-msg-bubble` `background`). messages.css 412 → 399 custom
(68% markup share). **This page is now exhausted** — every remaining declaration is off-scale
type/spacing/radii, a fixed-px box, a media/state/variant-varying property, the bespoke grid + flex
height-chain, a non-token grey (`#6b7280`/`#0f1020`), a brand tint, or a rule that is dead in admin
(the shared component's inbox-header / per-message-photo / quote / reply-preview markup other profiles
use, which can't be deleted here).

**Forms pass (`refactor/bootstrap-messages-forms`) — the two inputs adopted `.form-control`.** §6j had
called the page exhausted on the *utility* axis, but rule 2 (default to the Bootstrap class) still put
the burden on the two bare `<input>` resets (the inbox **search** + the chat **composer**). Both sit as
a borderless input inside a themed `.border` + grey-bg + radius **wrapper** (`.sw-inbox__search-input` /
`.sw-chat__input-wrap`). Adopted `.form-control` on each input for real form semantics, kept the wrapper
as the visible frame, and layered custom CSS to strip form-control's own frame back to the transparent
reset the design wants — `border:0`, `border-radius:0`, `background:transparent`, `box-shadow:none` (kills
the gotcha-17 blue focus ring — verified `boxShadow:none` on focus), `height:auto`, and **`padding:1px 2px`
= the bare input's UA default (gotcha 36)**. That padding is load-bearing: the first attempt zeroed it,
which shrank the input 20→18px and re-centred the placeholder 1px in the flex wrapper — a real 0.0175–
0.0859% diff caught by the harness and traced by a computed-style diff vs clean-`main`. Flex-centred not
height-sized, so **no gotcha-41 re-round**. `.input-group` was rejected (its segmented addon box would
move the inline icon → Rule 1); the overlay restructure was rejected (gotcha-41 risk for no gain). This
is a **semantics** adoption, not a reduction — messages.css 408 → 418 decls (+10 override decls) for two
genuine `.form-control`s. Verified **11 shots 0.0000%** (page ×5 + mobile-inbox ×2 + empty ×4) vs a fresh
branch baseline, and a behaviour drive: both inputs are `.form-control`, composer still sends via
`messages.js` (`#msgInput`) and clears, focus shows no blue ring, 0 console errors. **`messages.js` also
`var`→`const` (17, all const — none reassigned; `.scrollTop`/`.value` writes are property mutations not
rebindings), `node --check` clean, behaviour drive green (conv-click active, role-tab filter still hides
via `.style.display`, composer send).**

**Components pass + playbook-pure (`refactor/bootstrap-messages-components`).** Three changes, each
verified before the next:
- **Count pill → `.badge`** (the 3 `.sw-inbox-tab__count`). Flex-centred (markup `d-inline-flex`), so
  `.badge`'s `line-height:1` (gotcha 7) is harmless. Themed via `--bs-badge-*`; the background stays a
  direct declaration (base `.badge` sets none) and `.rounded-pill` (markup) supplies the radius. **In
  admin the count is RED** (`admin-messages.css` `.sw-message__content` override, base + active), not the
  shared component's violet.
- **Role tabs → `.nav .nav-pills`** — the strip is `.nav .nav-pills`, each tab `.nav-link`, active via
  Bootstrap's `.active`. Base colour/size/weight/padding from `--bs-nav-link-*`, the active pill from
  `--bs-nav-pills-link-active-*`; only the hover BACKGROUND (no nav var), the active font-weight (no nav
  var) and the 6px icon-gap stay custom. **Switching the active class `.is-active`→`.active` is the whole
  trap:** `messages.js` toggles it AND `admin-messages.css:54` re-colours the active count red off it. I
  updated the JS + messages.css but first missed `admin-messages.css` → the active count rendered violet
  (shared default) instead of red — a real 0.0089–0.0435% diff, bounded to an 18×18 px box and traced by
  a computed-style diff (`bg #ef4444`→`#6e5df8`) to the stale `.is-active` selector. Fixed it there too.
  The `.sw-conv` rows keep `.is-active` (a *different* state — not touched). **messages.css 399→395 custom,
  9→24 `--bs-*`** (a genuine reduction + adoption, unlike the Forms pass).
- **Playbook-pure — composer send demo deleted** (`messages.js` 105→83). The submit handler built a
  message bubble in the DOM (the frontend stand-in for a real send); removed it + the now-unused
  `composer` const, keeping `chatBody`/`input` (used by new-message focus + auto-scroll). The `<form>` is
  now backend-owned — a `<!-- Laravel: wire … Livewire/AJAX … -->` comment on it + in the JS. The rest of
  `messages.js` STAYS (responsive master-detail view swap, wheel→horizontal tab scroll, conv-click,
  role-tab filter) — genuine client behaviour with no server analog, so this is NOT a whole-file delete
  like reports/influencer.

Verified **11 shots 0.0000%** (page ×5 + mobile-inbox ×2 + empty ×4) across all three changes, and drives:
count is `.badge`, tabs are `.nav-pills` (active moves, only one active, filter hides convs, active count
stays red), new-message focus works, composer form intact, **0 console errors**.

**A large part of `messages.css` is deliberately untouched — it is dead in the admin context.**
The shared component carries an inbox header (`.sw-inbox__head/__title/__count/__compose`), a
`.sw-conv__role-badge`, per-message avatars (`.sw-msg-row__photo`), quoted replies
(`.sw-msg-quote*`), a reply-preview bar (`.sw-chat__reply-*`), an empty-state CTA and an online-dot
— none of which appear in admin's markup (the admin design uses a role subtitle, no per-message
avatars, no quote/reply UI). Those rules render nothing here, can't be verified, and belong to the
component for other profiles, so they were left alone.

**Two regressions the harness could NOT see, both fixed — now gotcha 40.** (1) `.sw-conv` got
`.d-flex` in B1, whose `display:flex !important` out-ranked the inline `display:none` that
`messages.js` writes to filter the inbox by role — filtering silently broke. Reverted: `.sw-conv`
keeps `display`/`align-items` in CSS (JS-toggled). (2) The composer BUILDS bubble rows in JS
(`el.className = "sw-msg-row…"`); once their layout moved to markup utilities, the JS had to add
`d-flex ms-auto` / `d-flex flex-column mw-100` itself or a sent message rendered unstyled. Both were
caught only by a Playwright behaviour test (role-tab filter hides/restores convs; composer builds a
flex, right-aligned bubble; mobile conv-tap/back swaps `data-view`) — 13/13 green.

**Display that is toggled stays in CSS (gotcha 28 + 40).** The master-detail hides `.sw-inbox`/
`.sw-chat` via `[data-view]` and hides `.sw-chat__head/__body/__composer` + the empty placeholders
via `.sw-msg-app--empty`; `.sw-chat__back` is media-toggled. All of those keep `display` in CSS —
only their non-display layout props (alignment, direction, gap, radius) moved. `messages-shot.mjs`
baselines the two states page-load can't reach (mobile inbox, empty).

**Scroll behaviour fix (post-migration, requested).** Desktop used to size `.sw-msg-app` with a
magic `calc(100svh − 262px)` + `min-height: 520px`; the 262 underestimated the real chrome (~273px)
so the whole page BODY scrolled instead of the panes, and short viewports overflowed hard (min-height
forced it). Replaced with a `:has(.sw-message__content)`-scoped flex height-chain in `admin-messages.css`
(`@media (min-width: 992px)`): cap the shell to `100vh`, let `.sw-message__content` be a
`min-height:0; overflow:hidden` flex column, and `.sw-msg-app` `flex: 1 1 0`. Now ONLY `.sw-conv-list`
and `.sw-chat__body` scroll; the body never does. Mobile (<992) full-bleed scroll is untouched. The
desktop `messages--{992,1440,1920}` + `messages-empty--{992,1440}` baselines were re-captured (the app
is now viewport-bounded, ~11–154px shorter depending on width); mobile shots stayed 0.0000%.

**Role-tabs horizontal scroll (post-migration, requested).** The inbox role tabs (All / Merchant /
… / Admin) used to wrap to two rows in the narrow inbox column. Changed to a single non-wrapping row
that scrolls horizontally with a hidden scrollbar — `flex-wrap` → `flex-nowrap` on `.sw-inbox__filters`,
`.flex-shrink-0` on each `.sw-inbox-tab` (so they keep width and overflow instead of compressing), and
`overflow-x: auto; scrollbar-width: none` + `::-webkit-scrollbar { display: none }` in `admin-messages.css`
(the same pattern as `.sw-ctabs`/`.sw-stepper`; replaced the old `row-gap: 6px` wrap rule). Affects only
the widths where the tabs overflow the inbox (≥992 desktop ~380px column, and 375 mobile inbox; 768 fits
on one row already, stayed 0.0000%). Those baselines were re-captured.

**…and a wheel-to-horizontal handler (`messages.js`).** A hidden scrollbar + horizontal overflow is
unreachable with a desktop MOUSE — the wheel scrolls vertically and there is no bar to grab (touch and
trackpads scroll horizontally natively; a plain mouse does not). So `messages.js` translates vertical
wheel to `scrollLeft` on `.sw-inbox__filters` while it overflows (`{ passive: false }` + `preventDefault`).
JS-only, no visual change. This is the general trap with the `.sw-ctabs`/`.sw-stepper` hidden-scrollbar
pattern: it is only mouse-scrollable if the strip never overflows on desktop, or JS bridges the wheel.

Kept as custom, register-justified: the two-pane `grid-template-columns` and the desktop flex
height-chain above (bespoke app-shell sizing, no utility), off-scale type (10/11/11.5/12/13/14/15/18/22px — `.fs-*`
is RFS, gotcha 1), off-scale spacing (2/6/10/12/14/16/18/20/22/24/28/32/80px gaps and paddings),
fixed avatar/button boxes (28–112px — sizing utils are %-based), the off-brand hairlines
(`#ece9e0`/`#f3f4f6`/`#e5e7eb`, not `--sw-border`, so `.border` would need per-element
`--bs-border-color`), `flex: 1` (gotcha 4), `min-width: 0` (no utility), the responsive `padding`/
`height` in the media queries, and brand tints (violet avatars, the red unread badge, bubble fills).

## 6k. Dashboard page — status

`dashboard.html` — **the last page, and the only one with NO page-specific CSS/JS**. Its ~96 widget
rules live in the shared `admin.css` (lines ~218–831), plus the `.sw-card` chrome in `style.css`.
No Chart.js — visualizations are CSS/SVG. Branch `refactor/bootstrap-dashboard` (off `main`).

**Scope decision (user): dashboard-only widgets + safe shared; keep the cross-page bespoke classes
custom.** Verified: dashboard **0.0000%** at all 5 widths after each batch; sibling pages sharing
`admin.css`/`style.css` unaffected (only data-warehouse's documented pre-existing 0.015–0.043% drift,
gotcha 18, plus sub-threshold capture noise).

- **Batch 1** — the 4 content cards `.sw-card` → Bootstrap `.card` + `.card-body` (wrapper added; the
  global `.card` theme is a documented exact match for legacy `.sw-card`: 16px radius, 20px/16px-phone
  `--bs-card-spacer`, `--sw-border`, soft shadow). `.sw-card` is used only by dashboard, but its
  definition stays in `style.css` (harmless, dead elsewhere).
- **Batch 2** — dashboard-only widget flex containers → utilities (`display`/`align`/`justify`/
  `direction`/`flex-shrink`): alerts, ingestion streams, activity, ops streak, leaderboard, dash-head.
- **Batch 3** — dashboard-only widget text → utilities (`.fw-semibold`/`.fw-bold`, `.text-body`/
  `-secondary`/`-tertiary` — exact token matches, `.m-0`, `.text-nowrap`, `.flex-shrink-0`).

**Then, lockstep migrations of the SHARED classes (user opted in, "use more Bootstrap in admin.css"):**
- **Card-chrome** `.sw-card__head`/`__title`/`__link`/`__sub`/`__head-l` → utilities across ALL 4
  pages that use it (analytics, data-warehouse, reports, dashboard), stripped from `admin.css` **and**
  `style.css`. Variants: `--stack` → `.flex-column .align-items-start`; analytics' `--top` →
  `.align-items-start` (a blanket `.align-items-center` overrode it — caught as a consistent 0.02–0.08%
  across all analytics widths, fixed).
- **KPI card internals** `.sw-kpi`/`__top`/`__ic`/`__value`/`__label` → utilities — these are
  dashboard-only (analytics uses its own already-migrated `.sw-akpi*`). Plus the shared
  `.sw-kpi__trend`/`__delta-cap` lockstep across analytics + dashboard (`.sw-akpi .sw-kpi__trend`
  margin override preserved).
- Net: `admin.css` **512 → 411 custom** (−101, −20%), `style.css` −6.

**Kept custom:** `.sw-dash-grid` (5-page bespoke grid), `.sw-kpis` grid, the KPI surface + icon boxes +
delta/flag pills, `.sw-dash-range` (analytics), `.sw-status`/`.sw-pill` (data-warehouse — the badge
conversion is either markup-only-no-reduction or risky), the `.sw-role-switch` topbar switcher
(25-page shell), and the register floor: off-scale type/spacing, fixed-px boxes, brand tints, the
striped progress fill, `+`-sibling dividers.

**The trap that cost a reverted batch:** a container class can be page-local while its BEM CHILDREN are
shared. `grep '\bsw-card\b'` matched only `.sw-card` (dashboard-only) and reported the family as
dashboard-only — but `\bsw-card\b` does **not** match `sw-card__title` (the `_` is a word char, so
there is no boundary). `.sw-card__head`/`__title` are shared by 4 pages; migrating them moved
analytics and data-warehouse 3–6%. **Classify each BEM child with its own `grep "class=\"[^\"]*CHILD"`,
never infer a child's scope from its container's.**

**Range-dropdown fix (later).** The dashboard's `.sw-dash-range` date button did nothing — its markup
was **incomplete** (bare `<button>`, no `.sw-dash-range-wrap` + `.sw-dash-range__menu`). The component is
shared: `main.js`'s progressive handler (explicitly "analytics / dashboard") wires any
`.sw-dash-range-wrap` with a menu, and `admin.css` fully styles it. Fix was **markup-only** — wrapped the
button and added the 5-option menu (7d/30d/90d/12m/all) matching analytics, minus its `admin-analytics.js`-only
custom-range + calendar. **Zero new JS/CSS.** This is the documented select-replacement pattern (register:
Bootstrap's Dropdown has no `<select>` semantics — selected check-rows, label sync), NOT a Bootstrap
Dropdown, so it stays consistent with analytics' identical control. Verified: dashboard resting look
0.0000% ×5 (menu is `display:none` at load), and a Playwright drive confirmed opens/selects (label +
check + `data-range` update)/closes on select+outside-click+Escape, 0 console errors.

**Ops-streak progress bar → Bootstrap `.progress`/`.progress-bar` (`refactor/bootstrap-dashboard-progress`).**
§6k had left the ops-streak "To Tier 4 Guardian" bar custom (it is the "striped progress fill" in the
kept-custom list). But §6i-2 later proved a brand fill rides fine on Bootstrap's component, so the same
mirror was applied: `.sw-ops__track` → `.progress` (`--bs-progress-height:8px`/`--bs-progress-border-radius:
999px`/`--bs-progress-bg:#ece9f8`), `.sw-ops__fill` → `.progress-bar` (`--bs-progress-bar-bg:var(--sw-violet)`).
`role="progressbar"`+aria were already on the track (Bootstrap's own placement) and the `style="width:82%"`
stays inline (Bootstrap's documented pattern — merchants keeps it too). **Only the diagonal stripe
(`background-image`) stays custom** — `.progress-bar-striped` uses a different 45deg gradient, so the brand
`-45deg` overlay has no Bootstrap analog (register). The bar's **8 custom decls → 4 `--bs-progress-*` inputs
+ 1 custom** (`admin.css` now 405 custom / 4 `--bs-*`). Dashboard-only class (only `dashboard.html` renders
`.sw-ops__*`), so despite `admin.css` being shared the blast radius is one page. Verified **0.0000% ×5 vs a
fresh clean-`main` baseline**, plus merchants/analytics/data-warehouse **0.0000%** (the other `.progress`
user + the admin.css widget pages — no leak; the shared component was untouched, only the scoped
`.sw-ops__*` rules changed), `dd-test` 0 console errors.

## 6l. `admin-notifications.css` — deepened

Solo page file (only `notifications.html`), static markup (`admin-notifications.js` builds **0** DOM —
grep-confirmed, no gotcha-40), no modals. The notification LIST was already heavily utility-migrated
(`.list-group-flush`, `.d-flex`, `.fw-semibold`, `.text-body-secondary/-tertiary`, `.gap-2`, `.mb-0`);
this pass took the **rules panel + page header** the rest of the way. Converted the single/low-occurrence
structural elements to exact utilities: `.sw-nr-head__title` (`fw-bold`/`text-body`/`m-0`),
`.sw-nr__title` (`fw-bold`/`m-0`), `.sw-nr-crumb` (`d-block` — resolves as the responsive pair
`.d-block .d-lg-none`, gotcha 28's fix, since `.d-lg-none` follows `.d-block` in bootstrap source),
`.sw-nr-scope` (`d-grid` — display never varies, only `grid-template-columns` does in the media query),
`.sw-nt-group` ×2 (`fw-semibold`/`text-body-secondary`/`text-uppercase`), `.sw-nr-sec-label` ×2
(`fw-bold`/`text-uppercase`). **admin-notifications.css 87 → 75 custom decls (−12), braces 47/47.**

**Kept custom (register):** the 4–5× repeated `.sw-nr-field__label`/`.sw-nr-event__label`/`.sw-nt__dot`/
`.sw-nt-row`/`.sw-nt__ic` families (rules must survive for off-scale sizes / non-token greys anyway;
utilities would bloat 4–5 elements each), `flex:1`/`min-width:0` (gotcha 4 / no utility), the responsive
title font-size + `.sw-nr-scope` column media queries, the `--bs-list-group-*` list styling, the
`.sw-dd--field` skin, and brand/enum tints (`.sw-nt__ic--*`, `.sw-nt__dot`, non-token greys
`#0f1020`/`#9499a8`/`#474f5c`). Verified **0.0000%** across notifications ×5, `dd-test` PASS (4
dropdowns, 0 console errors).

**Forms + playbook-pure (`refactor/bootstrap-notifications`) — `admin-notifications.js` DELETED (59 → 0).**
The CSS was already at its §6l floor (untouched here); the gap was the Forms/JS axis. The JS was, by its
own header, "front-end demo behaviour": mark-a-row-read on click, mark-all-read (toggle dots + toast),
save-rule (toast), new-rule (smooth-scroll). All reducible/backend-owned:
- **Rule editor `<article class="card sw-nr" id="deliveryRules">` → `<form>`**, Save rule → native
  `type="submit"` (backend saves; `<!-- Laravel: action=route … @csrf -->`). The 4 channel toggles were
  ALREADY `.form-check.form-switch`; the scope selects stay `.sw-dd` (register, wired by `main.js`).
- **"New rule" `<button data-action>` → native anchor `<a href="#deliveryRules" class="btn …">`** — it
  only jumped to the on-page editor; a native in-page anchor does that with no JS (smooth-scroll dropped,
  a behaviour not a pixel). `.btn` on `<a>` renders identical → 0.0000%.
- **"Mark all read"** → plain backend-owned `<button>` (Laravel POST); **row-click read** → gone, the
  backend persists read state. `data-read` STAYS — `admin-notifications.css:99`
  (`.sw-nt-row[data-read="true"] .sw-nt__dot`) reads it to hide the unread dot, so it is a Blade binding
  hook, not JS cruft (same lesson as data-warehouse's `data-count`).
- Removed all `data-action` hooks (0 left) + the `<script>` tag. **Zero page JS** (only `main.js`).

Dead-code scan clean (0 dead CSS classes, 0 orphaned hooks). Verified **page 0.0000% ×5**, `dd-test`
PASS (4 dropdowns, 0 errors), and a drive (no page JS, rule editor is a `<form>`, Save is native submit,
New-rule is an anchor to `#deliveryRules`, form-switch toggles, scope `.sw-dd` opens, 0 console errors).
Solo file — no cluster.

## 6m. `admin-analytics.css` — audit + at-floor cleanup (`refactor/bootstrap-analytics`)

Solo page file (only `analytics.html` loads it). A full audit found analytics is **already one of the
most-migrated pages**: the 14 horizontal bars are Bootstrap `.progress`/`.progress-bar` (data-driven
`style="width:X%"` is Bootstrap's own documented pattern, not an inline-style violation — the only 14
inline styles on the page, all legitimate), the KPIs are `.card h-100` in a `row-cols-2 row-cols-xl-4
g-3` grid, buttons are `--bs-btn-*`, the chart legend dots are `.rounded-circle`, and the markup is
comprehensively `.d-flex`/`.fw-*`/`.text-body-*`. 55 `--bs-*` inputs already. Two small actionable
items only:
- **Dead code:** `.sw-card__head--top {}` was an **empty** rule and its markup token was redundant (the
  `--top` behaviour is now `.align-items-start`, already on the same element) — removed both.
- **`.sw-chart-wrap`:** `position:relative` → `.position-relative`, `width:100%` → `.w-100` (markup),
  and the `.sw-chart-wrap > canvas { max-width:100% }` child rule → `.mw-100` on the canvas (whole rule
  eliminated). `min-width:0` (no utility) + the responsive `height` stay. Chart.js canvas verified
  pixel-identical.

**admin-analytics.css 143 → 140 custom (−3), 55 `--bs-*`, braces 78/78.** Verified **0.0000%** across
analytics ×5 **+ the special `--520`** (gotcha 20), `dd-test` 0 console errors, and a behaviour drive
(chart renders, range dropdown opens, custom-range calendar opens with 37 day cells, 0 errors). The
rest is register floor: the bespoke date-range **calendar** (no Bootstrap datepicker), off-scale
type/spacing (28/14/13/11/6px…), fixed boxes (8px dots, 10px rank, 30/34px calendar, 280px chart —
sizing utils are %-based), `flex:1`/`min-width:0` (gotcha 4 / no utility), the striped bar fill
(register) and brand tints. **`admin-analytics.js` was also reformatted (prettier + comment trim) in
this commit — formatting only, no logic change (`node --check` clean, behaviour drive green).**

## 6n. `admin-data-warehouse.css` — audit + at-floor cleanup (`refactor/bootstrap-data-warehouse`)

Solo page file. Audit found it **already one of the most-migrated pages** (72 `--bs-*`): buttons
(`.sw-dw-refresh`/`.sw-dw-stream__retry`/`.sw-qact`/`.sw-dwc__btn`) are `--bs-btn-*`, the pills
(`.sw-dpill`/`.sw-pill--queue`) are `--bs-badge-*`, the review queue is `.list-group` (`--bs-list-group-*`),
the KPI/stream strips are `.row`/`.col` (`--bs-gutter-*`), and the reject dialog is a Bootstrap Modal
(`--bs-modal-*`, dual desktop/phone-sheet). Health clean (0 inline styles/handlers). The topbar search
(`.sw-topbar__search`) is the **shared 25-page shell**, not page content — out of scope for a solo pass.
Two small actionable items, both in the reject modal:
- **`.sw-dwc__icon`** → `.d-inline-flex .align-items-center .justify-content-center .rounded-circle` in
  markup (the 48px danger-tint box + margin stay). `.rounded-circle` = `50%` = the old `999px` on a
  square box.
- **`.sw-dwc__foot`** → the `display:flex`/`align-items`/`justify-content` were **redundant** (the element
  already carried `.d-flex .align-items-center .justify-content-end` in markup; utilities are `!important`
  so they already won) — stripped, only the off-scale `gap:10px` stays.

**admin-data-warehouse.css 148 → 141 custom (−7), 72 `--bs-*`, braces 72/72.** Verified **0.0000%**:
page ×5 (vs a fresh branch baseline — the committed page baseline carries the pre-existing gotcha-18
drift) **+ the reject dialog desktop & phone** (`dialog-shot.mjs`, the only place the modal renders) +
a modal drive (opens, icon `border-radius:50%`, cancel closes, 0 console errors). Rest is register floor:
off-scale type (28/23/15/14/13/12px), fixed boxes (38/40/48px icons — sizing utils are %-based), the
bespoke 2-col stat grid, the spinner keyframes, the phone bottom-sheet modal variant, and brand/enum tints.

**Playbook-pure — `admin-data-warehouse.js` DELETED (155 → 0), zero page JS.** The whole review-queue was
a FRONTEND DEMO: approve/reject removed the row + resynced the count pill + toasted, refresh-all/retry-job
spun/dimmed + toasted — all stand-ins for backend POSTs. The only thing that looked "genuine frontend" was
the reject CONFIRMATION filling per-row copy — but that's reducible too: **in Laravel the confirm sheet's
copy is server-rendered** (Blade per-row, or Livewire), so the reject button opens the sheet **natively
via `data-bs-toggle="modal"`** (8 buttons) and the sheet keeps its **static generic copy** ("Reject this
item? This will remove the item from the review queue."). The confirm button carries `data-bs-dismiss`
(closes in the demo) + a `<!-- Laravel: submit the reject POST … -->` note; the Laravel dev restores
per-row copy server-side. **One intended, user-approved visible change:** the demo sheet now shows generic
copy instead of the JS-filled "Reject this *receipt*? This will decline *[name]* …" — the price of zero
JS. Verified **page 0.0000% ×5** vs a fresh clean-`main` worktree (the sheet is `display:none` at load) +
a drive (no page JS loaded, reject opens the sheet natively with the generic title, confirm closes, 0
console errors). `dialog-shot.mjs` opener moved off `[data-action=reject]` to `.sw-qact--no`.

**Dead-code prune (post-JS-delete).** Dead CSS: **none** (all 48 `admin-data-warehouse.css` classes still
referenced). Dead HTML: the JS deletion orphaned the **`data-action="*"` hooks** (approve×8 / refresh-all
/ retry-job / view-log×3 / review-all×2 = 15) — read by no CSS/JS, undocumented, and Blade wires those
buttons via forms/routes (reports §6d precedent), so removed. **Trap avoided:** a first pass also stripped
`data-count` as "JS-written dead" — but an in-file comment documents it as a **server-bind placeholder**
("bind server-side"), so it is a real Blade hook; reverted and kept. Same for `data-item-id` (also the
`dialog-shot` opener), `data-queue`/`data-stream` (entity ids the backend routes from) and
`data-dwc-title`/`data-dwc-text` (per-row copy injection). Lesson: after deleting page JS, an undocumented
behaviour hook (`data-action`) is dead, but a data-* carrying a VALUE the server renders is a binding
point — check for a "bind server-side" comment before pruning.

## 6o. Auth pages — audit (`refactor/bootstrap-auth`)

Sweeping the 6 auth pages (login + check-email/forgot-password/reset-password/password-updated/
contact-support), which share `login.css` (the auth shell). All already migrated (inputs are
`.form-control .sw-auth-input` per the register, submits native).

**login — choose-profile cards → `.btn-check` (login-only, `login-choose-profile.css`).** The one Forms
gap: the profile chooser's `.sw-cp-card`s were a hand-rolled `role="radiogroup"` (`<button role="radio">`
+ JS `.is-selected`) — same shape as roles' segments, but rich cards (icon + name + desc), NOT `.btn`.
Converted the 4 cards to native `<input type="radio" class="btn-check" name="profile">` + `<label
class="sw-cp-card">` (via script). CSS remap: `.sw-cp-card.is-selected` → `.btn-check:checked +
.sw-cp-card`, `.sw-cp-card:focus-visible` → `.btn-check:focus-visible + .sw-cp-card` (focus lives on the
hidden radio now), and the check-glyph reveal likewise. JS: selection moved from a card-click handler to
the radio **`change`** event (the `.sw-cp-card` label is `input.nextElementSibling`); `resetSelection`
unchecks the radios instead of toggling `.is-selected`. **Then playbook-pure (user chose it):** login is
BACKEND-OWNED, so the `DEMO_ACCOUNTS` email→profiles map + `hrefFor`/`openModal` + the **submit intercept**
were deleted — the login form (already `method="POST"` + native submit, now with a `route('login')` @csrf
comment) **POSTs natively**; the server authenticates and returns the redirect-or-chooser (an email→profiles
map can't live in the browser). `admin-login.js` **123 → 73 lines**, `var`→`const`/`let`. What STAYS: the
password show/hide toggle (genuine) and the choose-profile chooser's **selection behaviour** — the backend
triggers the modal after a multi-profile login, and this JS only drives card-select → enable/label Continue.
**The chooser is itself a native `<form>`** (user asked): `.modal-content` → `<form
action="{{ route('login.profile') }}" method="POST">`, the `profile` `.btn-check` radios submit, and
Continue is `type="submit"` (the old `window.location = data-href` click handler is gone — the server reads
the `profile` value and redirects). So the JS is down to: enable + label the submit button on selection,
and reset on close. **The demo form is GET, not POST** — a static host (Live Server) returns **HTTP 405**
for POST to a `.html` file, so `method="POST"` gave a "page isn't working" screen on Continue; the demo
uses GET → `dashboard.html?profile=…` (served fine), and the Laravel comment carries the production
`method="POST" @csrf`. (Same reason the other native-submit forms in this project are GET-default in the
demo — reports/roles.) **A thin DEMO opener stays** (user: "I need to open the
modal"): submitting the login form `e.preventDefault()`s and `bootstrap.Modal…show()`s the chooser so the
multi-profile flow is demonstrable on the static page — but with NO `DEMO_ACCOUNTS` map (that was the
objectionable bit); production POSTs to `route('login')` and the server decides. So `cp-modal-shot.mjs` is
**unchanged** (its `requestSubmit()` still opens the chooser). (A brief detour that removed the opener
entirely surfaced a harness trap: opening via `Modal.show()` without filling the email left a 0.0805% band
at width 700 — the *empty* email field showing through the backdrop, not a modal diff; moot once the submit
opener returned.) Verified **15 shots 0.0000%** (page ×5 + choose-profile open/selected ×5 — the
*selected* state proves btn-check renders identical to `.is-selected`) + drives (password toggle, **login
submit opens the chooser** (demo opener), card-select enables+labels Continue, dismiss→reset, 0 console
errors). Dead-code prune: dead CSS **0** (login-choose-profile.css vs login; login.css vs all 6 auth
pages — the shared shell), 0 leftover `is-selected`/`aria-checked`/`role=radio`, and the 4 card
**`data-href`** attrs removed (the Continue click handler that read them is gone — the native form submits
the `profile` radio instead; `data-label` stays, the JS labels the button from it). Kept `data-auth-form`
(unreferenced by CSS/JS but a plausible backend/analytics marker on the login + contact-support forms).

**Forgot-password cluster (pages 2–5, `refactor/bootstrap-auth-forgot`).** check-email / forgot-password /
reset-password / password-updated share `forgot-password.js` (174 lines, 3 IIFEs). Inputs were already
`.form-control` + native submit + `required` + `type="email"`; the work was the JS. Playbook-pure:
- **forgot-password** — deleted the submit handler + `EMAIL_RE`/`showError`/`clearError`; the form now
  submits **natively as GET** (`action="check-email.html"` → `?email=…`; production POSTs
  `route('password.email')`), and `type="email" required` (dropped `novalidate`) does the validation.
- **check-email** — kept the thin **`?email` reader** (personalises the demo chain; Laravel renders it in
  prod); the **resend** button is backend-owned now (deleted the fake "Email sent ✓" timer — user chose).
- **reset-password** — kept the genuine UX: the 2 password **eye toggles** and the **live requirement
  checklist** (`.sw-pw-req.is-met`, real-time). Deleted `showError`/`clearError` + the rule/match
  enforcement (server validates). The form stays `method="POST"` with a **thin demo-submit** (`e.prevent
  Default()` → `password-updated.html`) because a static host 405s on POST **and** a GET would put the
  password in the URL — production removes it. `required` (dropped `novalidate`) guards empty fields.

**`forgot-password.js` 174 → 71 lines.** Verified **20 shots 0.0000%** (4 pages ×5) + drives (forgot GETs
`check-email.html?email=`, the reader shows it, resend inert, reset eye-toggle + 4/4 live checklist, empty
reset blocked by `required`, filled → `password-updated.html`, 0 console errors). **Dead-code:** `.sw-form-
error` (created by the deleted `showError`) is NOT dead — `contact-support.js` still uses it; kept. 0 other
orphans. (Superseded below: contact-support's `showError` is now gone too, but `.sw-form-error` has **no
CSS rule anywhere**, so there is nothing to clean.)

**contact-support (page 6, `refactor/bootstrap-auth-forgot`).** The form already used `.form-control` +
`.form-label` + native `type="submit"`; the inputs carry `required` + `type="email"`. Three fixes:
- **The one inline `style="opacity: 0"`** (on the invisible spacer "Back" link that balances the header)
  → Bootstrap **`.opacity-0`** utility. contact-support now has **0 inline styles** — the last page-level
  inline style in the app is gone.
- **Dropped `novalidate`** so native `required`/`type="email"` validate the fields.
- **`contact-support.js` DELETED (95 → 0) — zero page JS.** It was a *documented* demo ("Frontend-only…
  remove before going live") that hand-validated 4 fields (now native `required`/`type=email`) and built an
  inline success `<div>` via `innerHTML`. The success is now a **static Bootstrap `.alert`** in the markup
  (`#contactSent`, themed by `.sw-form-success`'s `--bs-alert-*`) **revealed by CSS `:target`** — the form
  `action="#contactSent" method="get"` navigates to the fragment on submit, `#contactSent:target{display:
  flex}` shows it, no JS. The **`.sw-form-success` was already a Bootstrap alert theme** (`--bs-alert-bg`/
  `-color`/…), so this is a true Bootstrap component, not a re-skin. Production swaps to
  `action="{{ route('support.store') }}" method="POST"` and flashes the alert server-side. **Trade-off
  (documented):** the demo GET puts the fields in the URL (`?…#contactSent`) — fine for a short demo
  message, and the Laravel POST removes it; that's the cost of no-JS success on a static host (a thin
  submit handler was rejected — user wanted the file gone).

Verified **5 shots 0.0000%** (alert `display:none` at load) + a drive (no contact-support.js loaded, empty
submit blocked by native `required`, valid submit → `#contactSent` `:target` shows the Bootstrap `.alert`,
0 console errors). Dead-CSS scan 0. **Auth sweep complete — all 6 pages done.**

## 6p. `main.js` shell controls — three verdicts + two conversions

A block-by-block audit of `main.js` for "can this be a Bootstrap component?". The deciding test:
**a menu (nav/actions) → Bootstrap Dropdown; a `<select>`-replacement (selected-check rows +
trigger-label sync + a value) → stays custom like `.sw-dd` (register).**

- **Avatar menu (`.sw-user-menu-wrap`, 19 pages) → Bootstrap Dropdown.** It is a `role="menu"` of nav
  links, no value semantics. `+.dropdown` on the wrap, `data-bs-toggle="dropdown"
  data-bs-display="static"` on the toggle (**no `.dropdown-toggle`** — keeps its own chevron),
  `.dropdown-menu.dropdown-menu-end` on the menu. **Deleted the ~40-line IIFE.** CSS: chevron rotate
  `.sw-user-menu-wrap.is-open` → `.sw-user-menu.show`; skin drops `position/top/right/display` and gains
  `padding:0`. **Trap:** `data-bs-display="static"` still sets `data-bs-popper="static"`, so
  `.dropdown-menu[data-bs-popper]{top:100%;left:0}` (0,2,0) overrode the skin's `right:0` and pushed the
  300px menu off-screen. Fix = `.dropdown-menu-end` → Bootstrap positions it `top:100%` +
  `--bs-dropdown-spacer`(2px)+`right:0` = the old `calc(100%+2px)`/`right:0` exactly, **`transform:none`**
  (static, no rasterization — gotcha 31 avoided).
- **Sidebar drawer-profile (`.sw-drawer-profile`, 19 pages) → Bootstrap Collapse (animated).** Chip →
  `data-bs-toggle="collapse"` + `.collapsed` (initial) + `aria-controls`; expand `+.collapse` + id.
  **Deleted the IIFE.** CSS: chevron `.is-open` → `.sw-drawer-profile__chip:not(.collapsed)`; expand
  `display:none`→`display:flex` (the §6i-2 tree pattern — `.collapse.show` does NOT force `display:block`,
  and a `<div>` defaults to block, which would kill the `gap:8px`).
- **Mobile sidebar itself = already a Bootstrap Offcanvas** (`.sw-sidebar.offcanvas-lg.offcanvas-end` +
  `data-bs-toggle="offcanvas"`, 0 custom JS). Neither Collapse nor Navbar fits a slide-in sidebar;
  `offcanvas-lg` uniquely gives "drawer on mobile, static at `lg`+" from one component. Nothing to do.
- **Kept custom (register, `<select>`-replacements):** the Role/"Viewing as" switcher and the analytics/
  dashboard date-range dropdown (selected-check rows + label sync + `data-role`/`data-range` value) — same
  reason `.sw-dd` stays custom (§6k already settled date-range). Bootstrap Dropdown has no value semantics.

`main.js` 804 → 747 (−57, pure deletion, CRLF-preserved). Both are hidden at load, so `capture.mjs`
never sees them — verified via new committed harness `avatar-dd-shot.mjs` (open menu, element-clip +
rect) and `drawer-shot.mjs` (offcanvas open → chip expanded): **avatar-dd 0.0000% ×3** (992/1440/1920,
768/375 skip — mobile uses the drawer) + **behavior 12/12**, **drawer-expand 0.0000% ×2** (768/375) +
**behavior 14/14**, all **127 page shots 0.0000%**, `dd-test`/`dd-portal-test` green, 0 console errors.
Branch `refactor/bootstrap-shell-controls`. (Sibling branch `refactor/prune-dead-main-js`: the earlier
dead Settings-switcher + notif-gear prune, `main.js` −72.)

## 6q. `swToast` → native Bootstrap Toast (`refactor/bootstrap-toast`)

`window.swToast` (the shared notification system: backend flash → `swNotify` → `swToast`) moved onto the
Bootstrap **Toast** component. **A toast has no declarative trigger** (there is no `data-bs-toggle="toast"`
like modal/dropdown/collapse) — the message is event-driven (a save, a Laravel flash), so it MUST be
JS-created + `.show()`-ed; "no-JS" is impossible here. The win is handing the lifecycle to Bootstrap:
- `bootstrap.Toast.getOrCreateInstance(el, { autohide: true, delay })` owns show/hide **and autohide, which
  in 5.3 natively pauses on hover/focus** — so the custom `setTimeout` timer + `mouseenter`/`mouseleave`/
  `hide.bs.toast` handlers + `dismiss()` are all deleted. What remains: build el, one `hidden.bs.toast`
  → `remove()`+`dispose()`, `show()`. Close = `data-bs-dismiss="toast"` (custom click handler gone).
- **Skin + slide-in motion stay custom CSS.** `.toast sw-toast sw-toast--kind`; `.sw-toast` (after Bootstrap
  in source) overrides `.toast`'s var-based defaults (bg #fff vs translucent, 360px, radius, shadow) so the
  design is unchanged. The motion moved from `.is-open`/`.is-leaving` to Bootstrap's **`.showing`**:
  `.sw-toast.showing { transform: translateX(110%) }` (mobile translateY), opacity:0 from `.toast.showing`;
  shown = default translateX(0)/opacity:1; `.toast:not(.show)` owns display. Our transition (transform+opacity)
  beats `.fade`'s opacity-only one on source order; `animation:true` makes Bootstrap await it.

**Two deliberate/known changes, both MOTION (invisible to `capture.mjs` — toasts never render at load):**
1. **Progress bar DROPPED** (user-approved). Native `autohide` can't sync a countdown bar: Bootstrap's `delay`
   starts *after* the entrance and adds its own hide wait, so the bar (counting from render) emptied ~1s
   before dismiss. Keeping it in sync needs the custom timer (rejected as "less JS"). So the bar span + all
   `.sw-toast__bar` CSS + `@keyframes sw-toast-bar` + the `:hover` pause were removed; reduced-motion guard
   simplified to `.sw-toast { transition: none }`. **The toast now intentionally differs from clean-main**
   (no 2px strip) — so its baseline is captured from the BRANCH, not diffed against main.
2. **Entrance ~0.32s delayed** — Bootstrap waits one transition-duration before removing `.showing`, so the
   toast sits off-screen/invisible briefly, then slides in (old: immediate). Resting look + the slide itself
   unchanged.

Verified: **all 127 page shots 0.0000%**, toast **behavior 16/16** (renders as `.toast`, native pause-on-hover,
autohide, `data-bs-dismiss` close, 3 kinds, dispose+remove, no bar) 0 console errors, `dd-test`/`dd-portal-test`
green. Resting **look was 0.0000% while the bar still existed** (proving the skin survived the `.toast` adoption);
new no-bar baselines committed via `toast-shot.mjs` (3 kinds × 2 widths). **Register update:** the "toast progress
bar" + "entrance cubic-beziers" brand-visuals note (§5) is now partly moot — the bar is gone and the entrance is
Bootstrap's; the slide-in itself stays custom. Kept custom (register, `<select>`-replacements): Role switcher +
date-range dropdown, unchanged.

## 6r. KPI stat strips — users / advertisers / products (new sections from Figma)

**New feature, not a migration.** Three Figma nodes (users 4584:3353, advertisers 4587:3472, products
4584:3425) each add a 4-card stat strip between the page header (`.sw-uhead`) and the toolbar. All three
are the **same component**, so one shared implementation:
- **Markup (Bootstrap-maximal, mirrors the merchants `.sw-mstat` KPI pattern):** `.sw-ustrip.row.row-cols-2
  .row-cols-sm-4` (4-up desktop, 2-up phone) → `.col` → `.sw-ustat.d-flex.align-items-center.bg-white
  .border.h-100`; icon box `.sw-ustat__ic.d-inline-flex…`; `.fw-bold` number + `.fw-medium` label. Each strip
  carries `data-feed="…-kpis"` and each tile a `data-metric` (Laravel binds the counts).
- **CSS lives in the SHARED `admin-components.css`** (NOT a page file). It started in `admin-users.css`
  (users+advertisers share it) but products loads `admin-components.css` not `admin-users.css`, so when the
  third page needed it the rule was **promoted to the shared library** (Rule 3) alongside `.sw-uhead`/
  `.sw-utoolbar`/`.sw-uact`. One copy, three consumers, zero duplication. Custom = off-scale sizes (38px icon
  box, 18/11.5px type, 14px gutter, 14px radius) + brand tints (`#f3f1fe` box, `--sw-violet` icon, `#0f1020`
  number, `#c7800d` amber for card 2, `#9499a8` label). Border = the shared `--sw-border` (`.border`) so the
  cards match the search box below them — the Figma showed `#e5e8ec`, but the built pages standardised on the
  page's own border, and consistency-with-neighbours wins over a one-off shade.
- **Icons are the exact Figma-exported SVG vectors** (fetched from the asset URLs, not hand-drawn), inlined
  with `stroke="currentColor"` so the violet comes from CSS — matching the codebase's inline-SVG,
  no-external-asset convention (Blade-ready). users: users/user/mail/shield; advertisers: briefcase/
  megaphone/dollar/eye; products: bag/grid/cart/star.

**Verification model differs from a migration** — these pages legitimately CHANGE (a section is added), so the
goal is *match the Figma*, not 0.0000%-vs-main. Confirmed: each strip renders pixel-faithful to its Figma
frame (rendered-vs-Figma) with exact computed tokens; **full 127-page-shot run shows ONLY users/advertisers/
products changed** (5 shots each, taller pages — intended) and **all 16 other pages 0.0000%** (the shared-CSS
addition is inert — new selectors, no matching markup elsewhere); `dd-test` green on all three; 0 console
errors. The 3 pages' baselines were regenerated (with-strip) so future `compare.mjs` stays accurate.

## 6s. Footer moved outside `<main>` + sticky footer (`refactor/footer-outside-main`)

The legal footer (`.sw-app-footer`) was the last child *inside* `<main class="sw-app__content">`. A
`<footer>` scoped inside `<main>` is NOT the page's `contentinfo` landmark — moving it out restores that.
Design-preserving wrap (all 19 app pages): the layout container keeps the class, `<main>` wraps only the
content, footer becomes its sibling: `<div class="sw-app__content"><main>…content…</main><footer></div>`.

- **Markup (18 standard pages, scripted with perl, CRLF-safe):** rename the opening `<main
  class="sw-app__content">` → `<div>`+`<main>`, insert `</main>` before the `<footer[^>]*class="sw-app-footer`
  (matches the same-line, extra-utility-class, AND multi-line footer variants — the `class="sw-app-footer"`
  exact-match missed 3 pages: data-warehouse/notifications/profile), and turn the LAST `</main>` → `</div>`
  (roles has modals *inside* main after the footer; users' modals are *after* `</main>` — "last `</main>`"
  handles both). 72/36 diff, structure-only.
- **Sticky footer (`style.css`):** now that content is a single `<main>`, `.sw-app__content` becomes a flex
  column and `> main { flex:1 }` so the footer sits at the BOTTOM on short pages instead of floating up.
  **Trap:** making `<main>` a flex item (a BFC) stops its last child's `margin-bottom:16px` collapsing into
  the footer's `margin-top:24px` — the gap doubled to 40px, +16px per page. That 16px was always collapsed
  away, so `> main > :last-child { margin-bottom:0 }` restores gap=24 everywhere. Tall pages 0.0000%; short
  pages (content < viewport, e.g. reports/chains/profile at 1440/1920) now show the footer at the bottom —
  that ~0.1% "diff" IS the fix (no size change). Baselines regenerated for those.
- **Messages (`admin-messages.css`) — the hard one.** Its `<main class="sw-app__content sw-message__content">`
  is ONE flex height-chain (chat capped to 100vh, `.sw-msg-app` flex:1) and its footer is visible (desktop +
  mobile-inbox). Split into `<div class="sw-app__content"><main class="sw-message__content">…</main><footer>`,
  then: (1) the sticky rules are scoped `:not(:has(.sw-message__content))` so they DON'T touch messages;
  (2) the wrapper carries the height cap + flex column (`≥992`) and the inner main gets `flex:1`; (3) footer
  selectors retarget `.sw-message__content …` → `.sw-app__content:has(…) …` (the uhead hide stays — it's still
  inside the inner main); (4) **mobile full-bleed restored** — the original content was `padding:0` at `<992`
  (each section self-pads), but the split let the wrapper pick up responsive.css's `padding:16px`, growing
  the page +16px; `@media(max-width:991.98px){ .sw-app__content:has(.sw-message__content){ padding:0 } }`
  fixes it. Messages 0.0000% across ALL states (desktop chat, mobile inbox, both empty placeholders).

Verified: full 127-page-shot run — the only non-zero shots are the short-at-wide sticky-footer pages
(footer-to-bottom, intended, no size change); everything else incl. all messages states 0.0000%.
`dd-test`/`dd-portal-test` green. The footer is now the `contentinfo` landmark on every app page — and this
is exactly the shell markup that slots into the Blade master layout (footer outside `@yield('content')`).

## 7. Reporting expectations

After each page, report: what changed; visual-diff numbers per breakpoint; what was **not** migrated
with the doc page justifying it; any shared-file change and its all-pages diff result; then **stop for
approval**. Final report per page: before/after custom CSS count, Bootstrap-vs-custom ratio, every
remaining custom rule with justification, and confirmation nothing is inline.

Be honest about residual diffs — report the number and the cause rather than rounding it to "done."
