/* =====================================================================
   control-patterns.css — the shared button + form-control vocabulary for the
   Tailwind families (10 client dashboard pages, 16 admin pages).
   Added 2026-09-10 by the Button and Control Modernisation sweep.
   Full inventory, tier rationale and leave-alone list: BUTTON_AUDIT.md
   =====================================================================

   WHY PLAIN CSS AND NOT TAILWIND UTILITIES
   ----------------------------------------
   Two reasons, both from real incidents in this project:

   1. The Tailwind CDN's JIT compiler emits NO CSS at all for a utility it does
      not recognise, and does not error (row 165: `bg-navy` on an admin page
      rendered a fully transparent button with white text — present, laid out,
      clickable, invisible). Plain CSS cannot fail that way.
   2. None of the three treatments below (a gradient, a sweeping highlight, a
      directional icon shift) is expressible as a utility string anyway.

   HOW IT LAYERS WITH tap-targets.css
   -----------------------------------
   `tap-targets.css` sets `min-height: 44px` on every button below 1024px.
   `min-height` constrains the USED value after `height` resolves, so a Tier C
   control is 40px on desktop and 44px on mobile with no extra rule. That is the
   intended behaviour, not a collision — do not "fix" it.

   THE THREE TIERS
   ---------------
   A single 54px height applied to everything would break the dense contexts:
   a table-row action grown from 28px to 54px adds ~26px to every row on every
   Approval Gate page. Tier C is the same palette, border treatment and states
   at a density a table row can carry — the same relationship `.btn-sm` already
   has to `.btn` on the public site, not a new invented pattern.

     Tier A  .mw-btn.mw-btn-primary     54px  committing action, gradient + sweep
     Tier B  .mw-btn.mw-btn-secondary   54px  cancel / back / neutral
     Tier C  .mw-btn.mw-btn-sm          40px  in-row action, tab, pill, chip

   Admin keeps its own slate/amber palette (locked rule) — the SHAPE and
   BEHAVIOUR converge, the colour does not. Use .mw-btn-admin / .mw-btn-approve
   / .mw-btn-danger there, never .mw-btn-primary.
   ===================================================================== */

/* ---- Base geometry, shared by every tier ---- */
.mw-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 54px;
  min-width: 150px;
  padding: 0 24px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  overflow: hidden;
  transition: background 0.18s, border-color 0.18s, color 0.18s,
              box-shadow 0.18s, transform 0.12s ease-out;
}

/* A trailing icon shifts on hover; a LEADING icon does not. `:not(:first-child)`
   is what distinguishes "chevron after the label" (directional, should move)
   from "icon before the label" (decorative, should not). */
.mw-btn > svg:last-child:not(:first-child) {
  transition: transform 0.25s;
  flex-shrink: 0;
}
.mw-btn:hover > svg:last-child:not(:first-child) { transform: translateX(3px); }
.mw-btn.mw-btn-back:hover > svg:first-child { transform: translateX(-3px); }
.mw-btn.mw-btn-back > svg:first-child { transition: transform 0.25s; flex-shrink: 0; }

.mw-btn:disabled,
.mw-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Focus is never removed, only replaced — these are real form controls. */
.mw-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(var(--brand-navy-ground-rgb),0.28);
}

/* ---- The light sweep (Tier A only). Ported verbatim from login.html's
   .gate-btn — the one reference in this project that actually carries it.
   Deliberately NOT on Tier C: at 40px in a table row it reads as noise. ---- */
.mw-btn-primary::before,
.mw-btn-admin::before,
.mw-btn-approve::before,
.mw-btn-danger::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  left: -50%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  transition: left 0.6s ease;
  pointer-events: none;
}
.mw-btn-primary:hover::before,
.mw-btn-admin:hover::before,
.mw-btn-approve:hover::before,
.mw-btn-danger:hover::before { left: 110%; }

.mw-btn-sm::before { content: none; }

/* ---- Tier A, client family (navy) ---- */
.mw-btn.mw-btn-primary {
  /* IncMarketry: primary buttons are Terracotta Deep with white text (rebrand stage B). */
  background: linear-gradient(135deg, var(--brand-terracotta-deep), var(--brand-copper-deep));
  color: #FFFFFF;
  box-shadow: 0 14px 28px -12px rgba(51, 35, 55, 0.6),
              inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.mw-btn.mw-btn-primary:hover:not(:disabled) {
  box-shadow: 0 18px 36px -12px rgba(51, 35, 55, 0.65),
              inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

/* The flat sibling — signup.html's own .signup-btn-next treatment. Same
   geometry, no gradient, no sweep. For a page with several primary-ish
   actions where a sweep on each would be noise. */
.mw-btn.mw-btn-flat {
  background: var(--primary, var(--brand-navy-ground));
  color: #FFFFFF;
  box-shadow: 0 8px 20px rgba(var(--brand-navy-ground-rgb),0.18);
}
.mw-btn.mw-btn-flat:hover:not(:disabled) {
  background: var(--brand-navy-dark);
  transform: translateY(-1px);
}

/* ---- Tier A, admin family (slate/amber — locked, never navy) ---- */
.mw-btn.mw-btn-admin {
  background: linear-gradient(135deg, #322336, var(--brand-ink));
  color: #FFFFFF;
  box-shadow: 0 14px 28px -12px rgba(var(--brand-ink-rgb), 0.55),
              inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.mw-btn.mw-btn-admin:hover:not(:disabled) {
  box-shadow: 0 18px 36px -12px rgba(var(--brand-ink-rgb), 0.6),
              inset 0 1px 0 rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}
.mw-btn.mw-btn-admin:focus-visible { box-shadow: 0 0 0 3px rgba(253, 151, 99, 0.35); }

/* Approve / Reject keep their existing emerald + red semantics — those carry
   real meaning on a queue page and are not decoration. */
/* The ramp is emerald-700 -> emerald-800, NOT the emerald-600 the old buttons used.
   Measured against white: emerald-600 is 3.77:1, genuinely below the 4.5:1 floor, and
   every Approve/Credit button in the admin tool had been shipping at that ratio long
   before this sweep. Carrying it forward as the light stop of a gradient would have
   preserved a real failure under new paint. emerald-700 is 5.48:1 and emerald-800 is
   7.68:1, so both ends of the ramp pass. Do not lighten this back toward -600. */
.mw-btn.mw-btn-approve {
  background: linear-gradient(135deg, #077570, #025D59);
  color: #FFFFFF;
  box-shadow: 0 14px 28px -12px rgba(2, 93, 89, 0.5),
              inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.mw-btn.mw-btn-approve:hover:not(:disabled) {
  box-shadow: 0 18px 36px -12px rgba(2, 93, 89, 0.58),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}
.mw-btn.mw-btn-approve:focus-visible { box-shadow: 0 0 0 3px rgba(3, 147, 143, 0.35); }

.mw-btn.mw-btn-danger {
  background: linear-gradient(135deg, #DB2149, #B8183B);
  color: #FFFFFF;
  box-shadow: 0 14px 28px -12px rgba(184, 24, 59, 0.5),
              inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.mw-btn.mw-btn-danger:hover:not(:disabled) {
  box-shadow: 0 18px 36px -12px rgba(184, 24, 59, 0.58),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}
.mw-btn.mw-btn-danger:focus-visible { box-shadow: 0 0 0 3px rgba(219, 33, 73, 0.35); }

/* ---- Tier B — secondary. One neutral treatment shared by both families:
   it carries no brand colour, so it needs no per-tool variant. ---- */
.mw-btn.mw-btn-secondary {
  background: rgba(255, 255, 255, 0.72);
  border: 1.5px solid #DCD4C9;
  color: #5f4e63;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(var(--brand-ink-rgb), 0.04);
}
.mw-btn.mw-btn-secondary:hover:not(:disabled) {
  background: #F7F3EC;
  border-color: #C9BFB1;
  color: var(--brand-text);
}
.mw-btn.mw-btn-secondary:focus-visible { box-shadow: 0 0 0 3px rgba(95, 78, 99, 0.25); }

/* An outlined action that still needs to read as the brand (e.g. "Request
   Allocation" on a product card) — navy border and text, fills on hover. */
.mw-btn.mw-btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary, var(--brand-navy-ground));
  color: var(--primary, var(--brand-navy));
}
.mw-btn.mw-btn-outline:hover:not(:disabled) {
  background: var(--primary, var(--brand-navy-ground));
  color: #FFFFFF;
}

/* ---- Tier C — the in-context size. Same palette and states, sweep removed,
   min-width released so it can sit inside a table cell. ---- */
.mw-btn.mw-btn-sm {
  height: 40px;
  min-width: 0;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 13px;
  gap: 6px;
}
.mw-btn.mw-btn-sm:hover:not(:disabled) { transform: none; }

/* ROW 171'S FLOOR, RESTORED EXPLICITLY — do not remove this block.
   `tap-targets.css` guarantees min-width/min-height 44px on every `button` below
   1024px, but it does so with an ELEMENT selector (0,0,1). `.mw-btn.mw-btn-sm`'s
   own `min-width: 0` above is (0,2,0) and silently out-specifies it, which took
   Tier C pills down to 40.3px wide on mobile — measured, not theorised, and caught
   by verify-control-patterns.mjs on its first real run. Re-declaring the floor here
   keeps it independent of source order between the two stylesheets. Height needs no
   equivalent: `min-height` constrains the used value after `height` resolves, so
   tap-targets' own rule already wins there. */
@media (max-width: 1023.98px) {
  .mw-btn.mw-btn-sm,
  .mw-btn.mw-btn-block,
  .mw-btn.mw-btn-grow { min-width: 44px; }
}

/* Pill variant of Tier C, for filter pills and notification chips, which were
   already round and should stay round. */
.mw-btn.mw-btn-pill { border-radius: 999px; }

/* ---- Full-width / flex-child helpers. `flex-1` (Tailwind) still works on
   these because it only sets flex-grow/shrink/basis; min-width is what would
   fight it, so release it explicitly. ---- */
.mw-btn.mw-btn-block { width: 100%; min-width: 0; }
.mw-btn.mw-btn-grow { flex: 1 1 0%; min-width: 0; }

/* Two 150px buttons plus a gap overflow a modal's content box at 320px, so the
   floor is released at the public site's own established narrow breakpoint. */
@media (max-width: 480px) {
  .mw-btn { min-width: 0; padding: 0 16px; }
}

/* =====================================================================
   FORM CONTROLS
   The box treatment from signup.html's own .fld input/select: 54px, 12px
   radius, 1.5px #D8D4CD, #FCFBF9 ground, real focus ring, custom chevron.

   NOT the floating LABEL, deliberately — see BUTTON_AUDIT.md. That needs each
   label relocated to be its input's next sibling plus placeholder=" ", across
   72 controls and several JS template strings, where a wrong move silently
   breaks the for/id association a screen reader depends on. Logged as its own
   task rather than folded in here.
   ===================================================================== */
.mw-field {
  width: 100%;
  height: 54px;
  padding: 0 16px;
  border: 1.5px solid #DCD4C9;
  border-radius: 12px;
  background: #FCFBF9;
  font-family: inherit;
  font-size: 14px;
  color: var(--brand-text);
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.mw-field::placeholder { color: var(--brand-muted); }  /* was #9A9690, a measured 2.84:1 — below the
   4.5:1 floor for text, and a placeholder IS text. Pre-existing, fixed here because this
   sweep owns this declaration and the same tone is already proven elsewhere (4.93:1). */
.mw-field:hover:not(:disabled) { border-color: #C9BFB1; background: #FFFFFF; }
.mw-field:focus {
  outline: none;
  border-color: var(--primary, var(--brand-navy-ground));
  background: #FFFFFF;
  box-shadow: 0 0 0 4px rgba(var(--brand-navy-ground-rgb),0.10);
}
.mw-field:disabled { opacity: 0.55; cursor: not-allowed; }

/* Admin keeps its amber focus ring — the locked palette rule applies to focus
   states too, not just fills. */
.mw-field-admin:focus {
  border-color: #FD9763;
  box-shadow: 0 0 0 4px rgba(253, 151, 99, 0.22);
}

/* A textarea is not a fixed-height control. */
textarea.mw-field {
  height: auto;
  min-height: 110px;
  padding: 14px 16px;
  line-height: 1.55;
  resize: vertical;
}

/* Custom chevron — the exact data-URI from signup.html's own .fld select, so
   the two families cannot drift. */
select.mw-field {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236E5C73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 42px;
}

/* A compact field for filter bars, matching Tier C's density. */
.mw-field.mw-field-sm {
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 13px;
}
select.mw-field.mw-field-sm { padding-right: 36px; background-position: right 12px center; }

/* ---- Native date input.
   ACHIEVABLE: the box (height, radius, border, ground, focus ring, font) —
   all inherited normally, which is what .mw-field above supplies.
   NOT ACHIEVABLE cross-browser: the picker indicator glyph
   (::-webkit-calendar-picker-indicator is Chromium-only; Firefox renders its
   own and Safari differs again) and the internal segment layout. Deliberately
   left native rather than replaced with a custom date component — see
   BUTTON_AUDIT.md. The one thing done here is to stop the indicator sitting
   flush against the border. ---- */
input[type="date"].mw-field { padding-right: 12px; }
input[type="date"].mw-field::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s;
}
input[type="date"].mw-field::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* ---- FIELD SYMMETRY (lane 2, 2026-11-07; Promise's iPhone Safari screenshot of /transactions' filter card) ----
   Cause: a native date input carried only the generic .mw-field box. iOS WebKit kept its own appearance (it sized the
   box from its internal ::-webkit-date-and-time-value part, ignoring height: ~150 vs ~97 for the selects beside it),
   and its intrinsic min-content width beat width:100% inside a grid track (no min-width: 0), so it ran past the card.
   ONE rule set for every field in a row: border-box, min-width 0 (shrinks to its track, never past the container), and
   for the date / time family no native appearance, a block box at the field's own height, a left-aligned value part
   with its own min-height and line-height. An empty one shows "Select date" on the same value line (data-empty, set by
   dashboard-common.js, also when a script clears it). */
.mw-fld { min-width: 0; }
input.mw-field, select.mw-field, textarea.mw-field { box-sizing: border-box; min-width: 0; max-width: 100%; }
input.mw-field[type="date"], input.mw-field[type="time"], input.mw-field[type="datetime-local"], input.mw-field[type="month"], input.mw-field[type="week"] {
  -webkit-appearance: none; appearance: none; display: block; text-align: left; line-height: 1.25;
}
input.mw-field[type="date"]::-webkit-date-and-time-value, input.mw-field[type="time"]::-webkit-date-and-time-value,
input.mw-field[type="datetime-local"]::-webkit-date-and-time-value, input.mw-field[type="month"]::-webkit-date-and-time-value,
input.mw-field[type="week"]::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.25em; line-height: 1.25; }
input.mw-field[type="date"]::-webkit-datetime-edit, input.mw-field[type="time"]::-webkit-datetime-edit,
input.mw-field[type="datetime-local"]::-webkit-datetime-edit, input.mw-field[type="month"]::-webkit-datetime-edit,
input.mw-field[type="week"]::-webkit-datetime-edit { padding: 0; line-height: 1.25; }
/* the empty value line: the native one is blank on iOS and "mm/dd/yyyy" elsewhere, so one shared line replaces both */
input.mw-field[data-empty]:not(:focus)::-webkit-datetime-edit { color: transparent; }
.mw-fld:has(> input.mw-field[data-empty]:not(:focus))::after {
  content: "Select date"; position: absolute; left: 13.5px; right: 40px; top: 21px; bottom: 6px;
  display: flex; align-items: center; font-size: 14px; font-weight: 400; color: var(--brand-muted); pointer-events: none;
  white-space: nowrap; overflow: hidden;
}
.mw-fld:has(> input.mw-field[type="time"][data-empty]:not(:focus))::after { content: "Select time"; }
.mw-fld:has(> input.mw-field[type="month"][data-empty]:not(:focus))::after { content: "Select month"; }

/* ---- Native file input ---- REMOVED 2026-09-10.
   `.mw-file` styled `::file-selector-button` on a bare native input. Every one of the five
   file inputs in this project is now the accessible `.mw-upload` component instead (register
   row 189), so these rules had no users left and were deleted rather than kept as a second,
   half-styled way to do the same thing. The reasoning about what IS and IS NOT stylable on a
   native file input is preserved in BUTTON_AUDIT.md 5.2, where it is still the record of why
   the component was needed. ---- */

/* =====================================================================
   ACCESSIBLE FILE SELECTION  (.mw-upload)  — register row 189
   Added 2026-09-10. Replaces the `<div>` + click-handler pattern, which was
   keyboard-inaccessible: no tabindex, no role, no keydown, and the real input
   behind it was `hidden` and therefore out of the tab order too. Both signup
   uploads are REQUIRED steps, so that blocked account opening outright for
   keyboard-only and screen-reader users.

   ★ WHY A VISUALLY-HIDDEN REAL INPUT AND NOT A BUTTON WITH ARIA
   -------------------------------------------------------------
   The input is a genuine `<input type="file">`, hidden with the clip technique
   (NOT display:none / visibility:hidden, either of which removes it from the
   tab order AND from the accessibility tree), with real `<label for>` elements
   as its visible face. Everything is then inherited rather than reimplemented:

     - Tab order, focus, and Space/Enter activation are native. No keydown
       handler exists to get wrong, and they work with JS entirely disabled.
     - Clicking the label opens the picker natively — again, no JS.
     - The accessible name comes from real labels, so it survives any future
       refactor that an aria-label string would not.
     - `required`, form association and constraint validation keep working,
       which a detached `<button>` + hidden input silently loses.

   A `<button>` driving a hidden input would have to re-create every one of
   those, and JS failing would leave the control completely dead rather than
   merely unstyled. The one thing the native route costs is that focus lands on
   an invisible element, so the ring has to be drawn on the label instead —
   handled below, and cheap next to what it buys.

   ★ visibility:hidden is NOT an acceptable way to hide this input. It removes
   the node from the accessibility tree entirely (measured: role becomes none,
   ignored becomes true, and the computed name goes empty). Use the clip block
   below unchanged.
   ===================================================================== */
.mw-upload { position: relative; }

.mw-upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* The visible face. A real <label for>, so it is natively clickable and
   natively contributes to the input's accessible name. */
.mw-upload-face {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 14px 18px;
  border: 1.5px dashed #C9BFB1;
  border-radius: 12px;
  background: #FCFBF9;
  color: #5f4e63;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, color 0.18s, box-shadow 0.18s;
}
.mw-upload-face:hover {
  border-color: var(--primary, var(--brand-navy-ground));
  background: #FFFFFF;
  color: var(--brand-text);
}
.mw-upload-face svg { flex-shrink: 0; }

/* Focus lands on the clipped input, so the ring is drawn on its label. This is
   the one real cost of the native approach and it must not be dropped: without
   it a keyboard user has no idea where they are. */
.mw-upload-input:focus-visible + .mw-upload-face {
  outline: none;
  border-color: var(--primary, var(--brand-navy-ground));
  border-style: solid;
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(var(--brand-navy-ground-rgb),0.28);
}
.mw-upload-input:disabled + .mw-upload-face { opacity: 0.5; cursor: not-allowed; }

.mw-upload.has-file .mw-upload-face {
  border-style: solid;
  border-color: var(--primary, var(--brand-navy-ground));
  background: rgba(var(--brand-navy-ground-rgb),0.04);
  color: var(--brand-text);
}

.mw-upload-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.mw-upload-hint { font-size: 12px; color: #656066; margin: 0; }
.mw-upload-state { font-size: 13px; color: var(--brand-text); font-weight: 500; margin: 0; }
.mw-upload.is-empty .mw-upload-state { color: #656066; font-weight: 400; }

/* A real <button>, so it is reachable and activatable natively too. It carries
   `hidden` when there is nothing to clear, which keeps it out of the tab order
   rather than leaving a dead stop for keyboard users. */
.mw-upload-clear {
  /* small-button-exempt: Tier C 40px on desktop; floored to 44px below lg by the rule after it (OPEN ROWS 1 R2) */ 
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: 1.5px solid #DCD4C9;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  color: #5f4e63;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s, box-shadow 0.18s;
}
.mw-upload-clear:hover { background: #F7F3EC; border-color: #C9BFB1; color: var(--brand-text); }
.mw-upload-clear:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(95, 78, 99, 0.3); }
/* OPEN ROWS 1 R2 (2026-10-23): Remove on a chosen file was 40px on a phone (this class out-specifies tap-targets.css's
   button floor). Re-declared below lg, the .mw-sort way. */
@media (max-width: 1023.98px) { .mw-upload-clear { min-height: 44px; } }

/* The error is associated with the control via aria-describedby, not merely
   placed near it, so a screen reader reads it as part of the field. */
.mw-upload-error { font-size: 12.5px; color: var(--brand-loss); font-weight: 500; margin: 6px 0 0; }
.mw-upload-input[aria-invalid="true"] + .mw-upload-face { border-color: #A54816; border-style: solid; }

.mw-upload-admin .mw-upload-face:hover,
.mw-upload-admin.has-file .mw-upload-face { border-color: var(--brand-ink); }
.mw-upload-admin.has-file .mw-upload-face { background: rgba(var(--brand-ink-rgb), 0.04); }
.mw-upload-admin .mw-upload-input:focus-visible + .mw-upload-face {
  border-color: var(--brand-ink);
  box-shadow: 0 0 0 3px rgba(253, 151, 99, 0.35);
}

@media (max-width: 480px) {
  .mw-upload-meta { flex-direction: column; align-items: flex-start; gap: 8px; }
  .mw-upload-clear { width: 100%; justify-content: center; }
}

/* =====================================================================
   FLOATING LABELS  (.mw-fld)  — register row 190
   Added 2026-09-10. The box treatment landed with the button sweep; this is
   the label half, deferred at the time because relocating ~127 labels can
   break a for/id association with NO VISUAL SYMPTOM. It is done now behind
   scripts/verify-label-association.mjs, which reads the COMPUTED ACCESSIBLE
   NAME out of Chrome's accessibility tree before and after.

   STRUCTURE — the label MUST follow the control, because the float is driven
   by the adjacent-sibling selectors below:

     <div class="mw-fld">
       <input id="x" class="mw-field" placeholder=" ">
       <label for="x">Label</label>
     </div>

   `placeholder=" "` (a single space, not empty) is load-bearing: the resting
   state is detected with :placeholder-shown, which only matches when a
   placeholder attribute is actually present.

   ★ .mw-fld--static IS NOT A HALF-CONVERSION. :placeholder-shown never matches
   a <select>, and is unreliable on date/time inputs, so those keep the label
   permanently raised. That is the same variant signup.html's own .fld already
   uses (.fld--static) — one pattern with a documented sub-case, not two
   competing patterns.
   ===================================================================== */
.mw-fld { position: relative; }

/* Room for the raised label. This overrides .mw-field's own centred padding,
   so it must stay more specific than it. */
.mw-fld > .mw-field {
  height: 54px;
  padding: 21px 16px 6px;
}
.mw-fld > select.mw-field { padding-right: 42px; }
.mw-fld > textarea.mw-field {
  height: auto;
  min-height: 110px;
  padding: 24px 16px 12px;
}

.mw-fld > label {
  position: absolute;
  left: 17px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  font-weight: 400;
  color: var(--brand-muted);
  line-height: 1;
  /* Clicks fall through to the control beneath, which fills the whole box. The
     label still names the control in the accessibility tree — pointer-events
     affects hit testing only, never semantics. */
  pointer-events: none;
  transition: top 0.16s ease, font-size 0.16s ease, color 0.16s ease;
  max-width: calc(100% - 34px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mw-fld > .mw-field:focus + label,
.mw-fld > .mw-field:not(:placeholder-shown) + label,
.mw-fld--static > label {
  top: 9px;
  transform: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #656066;
}
.mw-fld > .mw-field:focus + label { color: var(--primary, var(--brand-navy)); }
.mw-fld--admin > .mw-field:focus + label { color: var(--brand-ink); }

/* A textarea's label sits at the top rather than vertically centred — there is
   no single line to centre against. */
.mw-fld > textarea.mw-field + label { top: 20px; transform: none; }
.mw-fld > textarea.mw-field:focus + label,
.mw-fld > textarea.mw-field:not(:placeholder-shown) + label { top: 9px; }

.mw-fld > .mw-field:disabled + label { opacity: 0.55; }

/* ★ A REAL PLACEHOLDER AND A RESTING LABEL OCCUPY THE SAME PIXELS.
   The float pattern is usually taught as `placeholder=" "`, because at rest the label sits
   centred over the field and any visible placeholder text renders straight through it. But
   several of these fields carry placeholders that are genuine guidance the label cannot
   give — "As it appears on your bank account" against a label of "Account Holder Name" —
   and deleting 68 of those to satisfy a selector trick would be losing real content to
   style.
   It is not necessary. `:placeholder-shown` matches on whether the field is EMPTY, not on
   whether the placeholder is legible, so hiding the text costs the float nothing: the hint
   is transparent while the label is resting on top of it, and fades in once focus has
   lifted the label clear. Fields whose placeholder was only ever the `" "` helper are
   unaffected — there is nothing to reveal. */
.mw-fld > .mw-field::placeholder {
  color: transparent;
  transition: color 0.16s ease;
}
.mw-fld > .mw-field:focus::placeholder { color: var(--brand-muted); }  /* 4.93:1 on the focused white ground; #9AA1A8 measured 2.61:1 */

/* The compact filter-bar variant is retired by this conversion: a raised label
   and a value cannot both fit in 40px. Every field is one height now, which is
   the uniformity row 190 asked for rather than a mixed estate. */
.mw-fld > .mw-field.mw-field-sm { height: 54px; padding: 21px 12px 6px; font-size: 14px; }
.mw-fld > select.mw-field.mw-field-sm { padding-right: 38px; background-position: right 14px center; }

/* =====================================================================
   SORTABLE COLUMN HEADERS — .mw-sort (2026-09-19, register row 252)
   =====================================================================

   One markup shape, built by sortHeaderHTML() in format-helpers.js and used by every
   sortable table in the PM tool (the client list, the approval gate's history, the
   products page). Read this before adding a fourth.

   WHAT WAS WRONG, measured on the three tables as they stood (so the same three
   mistakes are not made again on the next one):

   1. THE HIT AREA WAS THE GLYPH BOX. Two of the three pages styled their header
      buttons with `all: unset` / `padding: 0` and an explicit `min-height: 0` — a
      (0,1,1) rule that silently out-specifies tap-targets.css's own `button
      { min-height: 44px }` (0,0,1). Measured: 14.3px tall at EVERY width, including
      the client list at 390px, where its head stays visible. The row-171 "0 controls
      under 44x44" sweep never saw them, because those buttons are rendered by the
      page's async data load and the sweep reads the DOM ~900ms after readyState —
      a control that is not on screen yet cannot fail a size check.
   2. THE DIRECTION MARK WAS A TEXT GLYPH APPENDED INTO THE LABEL, ONLY WHEN ACTIVE.
      So an inactive header gave no sign it was sortable at all, and activating one
      CHANGED ITS WIDTH ("Portfolio" 55px -> "Portfolio ▾" 73px): on a right-aligned
      column the label's left edge jumped 18px, and the ▾ sat on the text baseline
      of a different face, which is the "chevrons don't sit right" complaint.
   3. THE ACTIVE STATE WAS A COLOUR CHANGE ALONE, #475569 -> #0F172A, on 9.5px
      uppercase text — and one page put `aria-sort` on the <button>, where it is not
      a valid attribute (it belongs on a columnheader role this div-grid does not
      carry), so assistive tech was told nothing either way.

   The gate's history was the one that got two of the three right — an ALWAYS-present
   indicator that flips direction rather than appears, and the accent colour on the
   active mark — and that is the pattern kept here. Its remaining gaps were a 22px
   min-height and no accessible direction.

   THE PATTERN
   - The indicator is a CSS mask on ::after, so it is always present, always the same
     width, and never part of the label text. Inactive: a paired up/down mark in
     #64748B (4.6:1 on the #FAFBFC head — a real colour, not an opacity, because an
     affordance is a UI component and 1.4.11 applies to it). Active: a single chevron
     in the accent #B45309, rotated for ascending. The label never changes width.
   - The hit area grows OUTWARD via negative margin into the head row's own padding,
     so the label's edge stays exactly where the column's own cells align it —
     28px tall on desktop, 44px below `lg` (re-declared here, the Tier C precedent).
   - A right-aligned (figures) column uses .mw-sort-end: row-reverse, so the mark
     LEADS and the label stays flush with the numbers beneath it.
   - The accessible name carries the state: aria-label="Price, sorted descending" /
     "Price, not sorted" — set by the builder from the same `dir` the CSS keys on.
   - The page's own click dispatch keys on its own data attribute (`data-sort`,
     `data-cl-sort`) exactly as before; only the markup inside the cell changed.
   ===================================================================== */
.mw-sort {
  /* small-button-exempt: 28px on desktop; floored to 44px below lg by its own re-declared rule (row 252) */ 
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-sizing: border-box;
  min-height: 28px;
  min-width: 0;
  margin: -8px -6px;          /* outward: the head's 11px padding absorbs it */
  padding: 0 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  line-height: 1;
  color: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.12s, background-color 0.12s;
}
.mw-sort::after {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  background-color: #7F6C84;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 6.5 8 3l3.5 3.5'/%3E%3Cpath d='M4.5 9.5 8 13l3.5-3.5'/%3E%3C/svg%3E") center / 10px 10px no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 6.5 8 3l3.5 3.5'/%3E%3Cpath d='M4.5 9.5 8 13l3.5-3.5'/%3E%3C/svg%3E") center / 10px 10px no-repeat;
  transition: transform 0.12s;
}
.mw-sort:hover { color: var(--brand-ink); background-color: rgba(var(--brand-ink-rgb), 0.06); }
.mw-sort:hover::after { background-color: var(--brand-ink); }
.mw-sort:focus-visible { outline: 2px solid var(--brand-terracotta-deep); outline-offset: 1px; }
.mw-sort[data-dir="asc"],
.mw-sort[data-dir="desc"] { color: var(--brand-ink); }
.mw-sort[data-dir="asc"]::after,
.mw-sort[data-dir="desc"]::after {
  background-color: var(--brand-terracotta-deep);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5l4-4'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5l4-4'/%3E%3C/svg%3E");
}
.mw-sort[data-dir="asc"]::after { transform: rotate(180deg); }
/* A right-aligned column: the mark leads, the label stays flush with its figures. */
.mw-sort.mw-sort-end { flex-direction: row-reverse; }

/* Row 171's floor, re-declared for the same reason the Tier C block above does it:
   `.mw-sort`'s own min-height is (0,1,0) and would out-specify tap-targets.css's
   element selector. The vertical margin grows with it so the head row's own box
   only grows to the floor (11 + 22 + 11 = 44), not past it. */
@media (max-width: 1023.98px) {
  .mw-sort { min-height: 44px; min-width: 44px; margin-block: -11px; }
}
