/* =============================================================================
   HF Hub — Components (slice 2: controls)
   -----------------------------------------------------------------------------
   Buttons, badges and form inputs. Every colour, radius, duration and easing
   comes from tokens.css, and this file declares no hex values.

   Two dimension families are in play, and they are kept separate on purpose:
     - Control sizing (heights, control padding, toggle/knob, badge padding,
       choice size) consumes the --control-* / --toggle-* / --badge-* / --choice-*
       tokens. These are ergonomic constants, decoupled from the spacing scale.
     - Genuine spacing (gaps between controls, the label→field margin, padding
       inside the drop zone) still consumes --space-*.

   Hairline BORDER widths (1px / 2px) are the one intentional literal: they match
   the convention already set in base.css (1px rules, the 2px focus ring) and are
   stroke weights, not layout spacing.
============================================================================= */

/* =============================================================================
   BUTTONS
   Four variants × three sizes. Every variant is correct in both themes purely
   by consuming semantic tokens. Focus is inherited from base.css :focus-visible
   — buttons never define their own ring.
============================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-h-md);
  padding: 0 var(--control-pad-x-md);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  /* Body size + family from the token; weight lifted to 500, sentence case. */
  font: var(--type-body);
  font-weight: 500;
  text-transform: none;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
  transition:
    background-color var(--motion-micro) var(--ease),
    border-color var(--motion-micro) var(--ease),
    color var(--motion-micro) var(--ease);
}
.btn svg {
  width: 1em;
  height: 1em;
  flex: none;
}

/* --- Sizes ---------------------------------------------------------------- */
.btn--sm {
  height: var(--control-h-sm);
  padding: 0 var(--control-pad-x-sm);
  font: var(--type-body-sm);
  font-weight: 500;
}
.btn--md {
  height: var(--control-h-md);
  padding: 0 var(--control-pad-x-md);
}
.btn--lg {
  height: var(--control-h-lg);
  padding: 0 var(--control-pad-x-lg);
}

/* --- Variants ------------------------------------------------------------- */
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.btn--primary:not(:disabled):not(.is-loading):hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn--secondary {
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn--secondary:not(:disabled):not(.is-loading):hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn--ghost {
  color: var(--text-secondary);
  border-color: transparent;
}
.btn--ghost:not(:disabled):not(.is-loading):hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.btn--destructive {
  color: var(--negative);
  border-color: var(--negative);
}
.btn--destructive:not(:disabled):not(.is-loading):hover {
  background: var(--negative);
  border-color: var(--negative);
  color: var(--accent-contrast);
}

/* --- Disabled ------------------------------------------------------------- */
/* Hover effects are already suppressed by the :not(:disabled) guards above.

   ⚠ NO OPACITY, AND THAT IS THE WHOLE POINT. This rule was `opacity: 0.45` and nothing else.
   Element-level opacity composites the foreground and the background toward the SAME backdrop, so it
   scales both sides of the contrast ratio together and can only ever move it toward 1:1 — no value of
   that property can make a disabled button legible. It is not that 0.45 was too low.

   Measured before the change, composited as the screen actually draws it, light theme, over the three
   surfaces a button sits on (--surface-page / --surface-raised / --surface-sunken):
       primary      1.28 · 1.26 · 1.30      ghost        1.71 · 1.74 · 1.68
       secondary    2.77 · 2.80 · 2.74      destructive  2.01 · 2.04 · 1.97
   Twelve of twelve failed AA body (4.5) and AA large (3.0). Dark theme failed eleven of twelve; the one
   exception, secondary at 3.31–3.60, cleared AA large only — and buttons carry body-size text.

   So all four variants flatten to ONE disabled treatment built from tokens, following the precedent
   .field:disabled already sets below: a ground, an edge, a text colour, no opacity. A disabled primary
   therefore stops looking like a primary. That is intended — an unavailable control should read as
   unavailable rather than as a faded version of its own emphasis.

   ⚠ THE LOADING ARC INHERITS --text-disabled DELIBERATELY, not by accident. .btn.is-loading::after is
   drawn in currentColor, and referral-signup.html and referral-partners.html both set .is-loading AND
   .disabled on the same button, so this combination is real. Under the old rule the spinner faded with
   everything else; now it is painted in the disabled text colour and stays legible at the same 4.6:1.
   A busy-and-unavailable button still visibly spins, which is what aria-busy claims.

   ⚠ .btn NOW DIVERGES FROM THE REST OF THE DISABLED VOCABULARY, on purpose and not yet everywhere.
   .checkbox:disabled, .radio:disabled, .toggle:disabled, .choice.is-disabled and
   .shell__nav-item.is-disabled are all still opacity: 0.45 and are all still UNMEASURED. They are
   different controls with different contrast profiles — a checkbox is not text on a ground — and each
   deserves its own measurement rather than inheriting this conclusion. Do not sweep them to match. */
.btn:disabled,
.btn.is-disabled {
  background: var(--surface-disabled);
  border-color: var(--border-disabled);
  color: var(--text-disabled);
  cursor: not-allowed;
}

/* --- Done (M452) ---------------------------------------------------------
   An action that is already complete, with nothing left to do — "Published ✓" on the News and Videos editors, when
   the website shows exactly what is saved. It takes the primary button's place (same size, same spot) and is
   disabled, but in the positive tint rather than the grey disabled look: grey says "you can't yet", this says
   "already done". The text colour is --positive on --surface-positive, the pairing the badge contrast work in
   tokens.css measured. Sets no display, so it needs no [hidden] guard. Declared AFTER .btn:disabled so that, at
   equal specificity, the disabled done button keeps this look. */
.btn--done,
.btn--done:disabled {
  background: var(--surface-positive);
  border-color: var(--border-positive);
  color: var(--positive);
  cursor: default;
}

/* --- Icon-only ------------------------------------------------------------ */
/* Square at the size height; aspect-ratio derives width from height. */
.btn--icon {
  padding-inline: 0;
  aspect-ratio: 1;
}

/* --- Loading -------------------------------------------------------------- */
/* Hide the label but keep it in flow (visibility) so the width never jumps.
   The arc is a three-quarter ring in the current text colour. Markup also sets
   aria-busy="true". */
.btn.is-loading {
  position: relative;
  pointer-events: none;
}
.btn.is-loading .btn__label {
  visibility: hidden;
}
.btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1em;
  height: 1em;
  border: 2px solid;
  border-color: currentColor currentColor currentColor transparent; /* 3/4 arc */
  border-radius: var(--radius-pill);
  animation: hf-spin var(--motion-data) linear infinite;
}
@keyframes hf-spin {
  to { transform: rotate(360deg); }
}
/* Reduced motion: freeze on the static three-quarter arc. */
@media (prefers-reduced-motion: reduce) {
  .btn.is-loading::after { animation: none; }
}

/* =============================================================================
   SYNC CONTROL  (.hf-sync-control — M371)
   "Last synced …" and a refresh icon, sitting beside a page heading: how current the caches behind the page
   are, and the one control that asks the server to refresh them. Behaviour lives in public/js/sync-control.js
   (HFSyncControl.init); this is its look. Built from what already exists rather than new parts: the button is
   .btn .btn--ghost .btn--icon .btn--sm, and while syncing it is .btn.is-loading with aria-busy — the icon sits in
   .btn__label, which is-loading hides in place while its arc spins, so the button never changes size.

   Four states, each in the styleguide: IDLE (the age, muted); SYNCING (the arc, aria-busy="true"); ERROR (the
   reason beside the icon, in --negative, announced by role="alert"); STALE (.is-stale on the status — the age is
   older than the page says it should ever be, in --warning, with a title saying so). With no sync recorded the
   status is empty and takes no space: an absent time is not dressed up as an age.
   ============================================================================= */
.hf-sync-control { display: inline-flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; min-width: 0; }
.hf-sync-control[hidden] { display: none; }
.hf-sync-control__status { color: var(--text-tertiary); font: var(--type-body-sm); white-space: nowrap; }
.hf-sync-control__status:empty { display: none; }
.hf-sync-control__status.is-stale { color: var(--warning); }
.hf-sync-control__error { color: var(--negative); font: var(--type-body-sm); }
.hf-sync-control__error:empty { display: none; }

/* =============================================================================
   BADGES
   A pill in the micro type style. Background is a ~12% tint of the functional
   colour mixed against the current page surface, so it re-tints automatically
   on theme change; text is the solid functional colour. Registered domain
   meanings are named so a page never invents its own status colour.
============================================================================= */
.badge {
  /* ⚠ --badge-text-quiet, NOT --text-secondary. The badge paints its colour as text AND as a 12% tint
     of itself, so it needs a value darker than body copy to clear AA on its own fill. See tokens.css. */
  --badge-color: var(--badge-text-quiet);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--badge-pad-y) var(--badge-pad-x);
  border-radius: var(--radius-pill);
  font: var(--type-micro);
  letter-spacing: var(--track-micro);
  text-transform: uppercase; /* micro is uppercase-by-style */
  background: color-mix(in srgb, var(--badge-color) 12%, var(--surface-page));
  color: var(--badge-color);
}

/* Functional meanings */
.badge--positive { --badge-color: var(--positive); }
.badge--warning  { --badge-color: var(--warning); }
.badge--negative { --badge-color: var(--negative); }
.badge--info     { --badge-color: var(--info); }
.badge--neutral {
  --badge-color: var(--badge-text-quiet);
  background: var(--badge-surface-quiet); /* solid and OPAQUE, not a functional tint — see tokens.css */
}

/* The accent badge — a COUNT on an icon button, not a status.
   Used by the note and canvass controls on Contract Timeline (M303).

   ⚠⚠ IT OVERRIDES THE 12% TINT, AND THE NUMBER IS MEASURED RATHER THAN CHOSEN. The rule above this
   file's .badge warns that the badge paints its colour as text AND as a tint of itself, so the colour
   has to be darker than body copy to clear AA on its own fill. No accent-family token manages it at
   12%: --accent (#B6815D) as badge-color scores 2.96:1, --text-accent (#8F6244) scores 4.46:1, and AA
   needs 4.5:1 at this size. --text-accent on an UNTINTED surface scores 5.00-5.25, so the fill is what
   costs the contrast. At 6% it is 4.73:1 — passing with margin rather than by a rounding error.
   Dark mode is not close to the line (--text-accent is --brand-taupe there, ~6.7:1).

   ⚠ For the record, the page-local pill this replaced was WORSE: white on solid --accent is 3.34:1.
   The promotion fixes a contrast failure that was already shipping, it does not introduce a risk.

   ⚠ --text-accent AND --accent, never --brand-caramel. The brand primitive is not for components to
   reach: --accent is the semantic alias and --text-accent is the readable-on-light variant of it. */
.badge--accent {
  --badge-color: var(--text-accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface-page));
}

/* Registered domain meanings → functional mapping (single source of status colour) */
.badge--offer-accepted,
.badge--live,
.badge--compliant       { --badge-color: var(--positive); }

.badge--under-offer,
.badge--awaiting-landlord,
.badge--beta,
.badge--due             { --badge-color: var(--warning); }

.badge--overdue,
.badge--error           { --badge-color: var(--negative); }

.badge--available,
.badge--edited          { --badge-color: var(--info); }

.badge--dev,
.badge--auto,
.badge--stale {
  --badge-color: var(--badge-text-quiet);
  background: var(--badge-surface-quiet);
}

/* Leading-dot variant: drops the pill fill for dense table cells, keeping only
   a small functional-colour dot before the label. */
.badge--dot {
  background: transparent;
  padding-inline: 0;
}
.badge--dot::before {
  content: "";
  width: 0.5em;
  height: 0.5em;
  border-radius: var(--radius-pill);
  background: var(--badge-color);
  flex: none;
}

/* =============================================================================
   REPORT-ROW WRITE-BACK  (referrals inbox, slice B1 — the first mutating report page)
   -----------------------------------------------------------------------------
   The shared bits of the write-back pattern, promoted out of the referrals inbox so the styleguide can
   demonstrate them from one source and later mutating pages consume them rather than re-inventing:
     · two TERMINAL status-badge weights (built on .badge) so a status column separates live from finished;
     · the "empty but real" state labels (Unattributed / Unassigned read as states, never blank cells);
     · the drill-down ACTIONS card, its inline write-error line, and the in-flight busy lock.
   Page-specific composition (the detail grid, the definition list, the event history) stays page-local.
============================================================================= */
/* Active pipeline stages take .badge--neutral; the two terminal states are weighted apart — a win reads
   positive, a dead lead reads quiet — so the column separates still-live from finished at a glance. */
.ref-status--done { --badge-color: var(--positive); }
/* ⚠ THE QUIET/LOST DISTINCTION COLLAPSES HERE, and it is a real loss rather than an oversight.
   .ref-status--lost was --text-tertiary, which measured 2.31:1 on its own tint — the worst badge in the
   set. Reaching 4.5 on a pale tint forces a specific darkness, and there is not enough room between that
   darkness and --badge-text-quiet for two distinguishable greys: the value derived from --text-tertiary
   (#706967) and the quiet token (#6E6565) land two points apart. So a lost lead no longer reads lighter
   than an active one. The FILL still differs (a 12% tint of itself, versus the solid
   --badge-surface-quiet of .badge--neutral), but the weighting the design intended is mostly gone.
   Worth seeing live. */
.ref-status--lost { --badge-color: var(--badge-text-quiet); }

/* Empty-but-real labels: a muted italic so an unattributed referrer or an unassigned row reads as a genuine
   state, never a blank cell.
   ⚠ THE ref- PREFIX IS HISTORICAL, NOT A SCOPE. It started on the referral pages and it is the general
   in-cell "this blank means something" treatment — the Sales report's conversion table uses it to keep
   "no data", "no appraisals" and a real 0% from all looking like the same blank. Do NOT add a parallel
   class for a non-referral page; that is how one treatment becomes three that drift apart.
   ⚠ AND NOT .table__empty, WHICH IS A DIFFERENT THING ENTIRELY: that is a ROW class for the whole-table
   empty banner and it styles through `.table__empty > td`, so on a span it matches nothing and silently
   renders as ordinary body text. The first draft of the conversion table used it and looked plausible. */
.ref-quiet { color: var(--text-tertiary); font-style: italic; }
.ref-sub   { color: var(--text-tertiary); font-size: 0.9em; }

/* The drill-down actions card — the "do something" zone, set apart from the read-only detail beside it. */
.ref-actions {
  padding: var(--space-4);
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: grid;
  gap: var(--space-4);
}
.ref-action__label { display: block; margin-bottom: var(--space-1); }
.ref-action__row { display: grid; gap: var(--space-2); }
/* Inline, per-record write error — visible, leaving the rest of the row unchanged; collapses when empty. */
.ref-actions__error { margin: 0; color: var(--negative); font: var(--type-body-sm); }
.ref-actions__error:empty { display: none; }
/* --- Progress track (shared; demonstrated in the styleguide) ------------------------------------------
   A horizontal run of segments showing how far along a fixed-length sequence something is. Built for the
   contractor portal's referral cards, where a pipeline has a known number of stages and a referral sits at
   one of them.

   ⚠ SEGMENTS, NOT A FILLED BAR. A bar implies a continuous quantity — 60% done — and a pipeline is not
   continuous: it is five or seven discrete steps, and "step 4 of 7" is the honest statement. Segments also
   survive a count changing without the geometry lying about it.

   ⚠ IT RENDERS NOTHING WHEN THERE IS NO POSITION. A lost or uncategorised referral has no place in a
   sequence, and an empty track reads as "no progress" rather than "not applicable" — which is a different
   and wronger statement. The CALLER omits the element entirely; there is deliberately no empty variant to
   reach for. See the styleguide entry, which shows that case as an absence.

   Flat on the canvas, no box, no shadow. The accent carries the completed run; the remainder is the plain
   border colour, so the contrast is scale-and-weight rather than two competing hues. */
.progress-track {
  display: flex;
  align-items: center;
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.progress-track__seg {
  flex: 1 1 0;
  height: 4px;
  min-width: 6px;
  border-radius: var(--radius-sm);
  background: var(--border-subtle);
}
/* Everything up to and including the current step. */
.progress-track__seg.is-done { background: var(--accent); }
/* The current step, emphasised by height rather than a third colour. */
.progress-track__seg.is-current { background: var(--accent); height: 6px; }
/* A completed sequence — the last step reached — reads positive rather than merely accented. */
.progress-track--complete .progress-track__seg.is-done,
.progress-track--complete .progress-track__seg.is-current { background: var(--positive); }
/* The caption beside it: "Step 4 of 7". Never the only signal — the stage label says it in words above. */
.progress-track__caption {
  margin: var(--space-1) 0 0;
  color: var(--text-secondary);
  font: var(--type-micro);
  letter-spacing: var(--track-micro);
  text-transform: uppercase;
}

/* The EVIDENCE a decision is being made from, sitting directly under the control that decides. Distinct from
   .ref-branch-note, which explains why a control is constrained: this carries data the agent is reading, not
   an explanation. Quiet, tight to the control above it, and never an error. */
.ref-evidence { margin: var(--space-1) 0 0; color: var(--text-secondary); font: var(--type-body-sm); }
/* Ranked referrer matches, offered under the evidence line as one-click attributions. A SUGGESTION, never a
   verdict — the agent is being offered a shortcut to the selector above, not told an answer, so these are
   secondary buttons rather than anything that reads as a recommendation the page is confident about.

   ⚠ THERE IS NO EMPTY STATE, BY DESIGN. When nothing scores above the floor the whole block is absent — no
   "no matches found". A page that reports having looked and found nothing invites the agent to read that as
   "this landlord's referrer is not a partner", which is a conclusion the string matcher has not earned and
   cannot support. Silence leaves the selector to do its job unprompted. */
.ref-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: var(--space-2) 0 0; }
.ref-suggest__label { margin: 0; color: var(--text-secondary); font: var(--type-body-sm); }
/* The score, carried INSIDE the button so it travels with the thing it describes and cannot be misread as
   applying to the next one along. Quiet by size and colour — it is corroboration, not the label. */
.ref-suggest__score { margin-left: var(--space-1); color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
/* Which field won the match, carried inside the button for the same reason the score is. ⚠ ONLY EVER RENDERED
   FOR A STAFF HIT. A name or company hit is already the button's own label, so a via line there would repeat
   what is an inch to its left; a staff hit is the one case where the thing that matched appears NOWHERE on
   the button, and a partner offered at 100% against a name the agent cannot see reads as a bug. Quieter than
   the label it qualifies, louder than the score, because it is the reason rather than the corroboration. */
.ref-suggest__via { margin-left: var(--space-1); color: var(--text-secondary); font: var(--type-body-sm); }
/* Explains a CONSTRAINED control rather than reporting a failure — an uncategorised referral can only reach
   the branch-agnostic statuses, and this says why instead of leaving a short dropdown looking broken. Quiet,
   not an error: nothing has gone wrong. Sits between the branch and status rows in the actions card. */
.ref-branch-note { margin: calc(var(--space-3) * -1) 0 0; color: var(--text-secondary); font: var(--type-body-sm); }
/* While a write is in flight the actions dim and stop accepting input, so a second click cannot race the first. */
.ref-busy { opacity: 0.6; pointer-events: none; }
/* Empty-report message — a fresh inbox says so rather than showing a bare table. */
.ref-empty { margin: var(--space-7) 0; text-align: center; color: var(--text-secondary); }

/* =============================================================================
   FORM INPUTS
============================================================================= */
/* Label: the label type style but NOT uppercased, sitting above its field. */
.field-label {
  display: block;
  font: var(--type-label);
  letter-spacing: var(--track-label);
  text-transform: none;
  color: var(--text-secondary);
  margin-bottom: var(--space-1); /* 4px clearance */
}

/* Shared field style for text inputs, selects and textareas. */
.field {
  width: 100%;
  height: var(--control-h-md);
  padding: 0 var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-primary);
  font: var(--type-body);
  transition:
    border-color var(--motion-micro) var(--ease),
    background-color var(--motion-micro) var(--ease);
}
.field::placeholder { color: var(--text-tertiary); }
.field:hover { border-color: var(--border-strong); }
/* The 2px --focus-ring outline + 1px offset is inherited from base.css; the
   field additionally moves its border to the accent on focus. */
.field:focus-visible { border-color: var(--border-accent); }
.field:disabled {
  background: var(--surface-sunken);
  color: var(--text-tertiary);
  cursor: not-allowed;
}

select.field { cursor: pointer; }

/* Textareas are multi-line: auto height, symmetric padding, vertical resize. */
.field--textarea {
  height: auto;
  min-height: var(--space-8); /* 64px */
  padding: var(--space-3);
  resize: vertical;
}

/* Error state + message. Styleguide markup wires aria-describedby field→message. */
.field--error { border-color: var(--negative); }
.field-error {
  font: var(--type-body-sm);
  color: var(--negative);
  margin-top: var(--space-1);
}

/* Warning variant of the field state — the same shape as the error state on the warning token, for a value
   that is advisable rather than blocking (a figure still being decided). It never sets aria-invalid, since
   the value is not wrong; the message is associated the same way. */
.field--warn { border-color: var(--warning); }
.field-warning {
  font: var(--type-body-sm);
  color: var(--warning);
  margin-top: var(--space-1);
}

/* Checkboxes & radios, tinted with the accent. */
.checkbox,
.radio {
  width: var(--choice-size);
  height: var(--choice-size);
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── The third state: indeterminate ──────────────────────────────────────────
   For a parent checkbox whose children are PARTLY selected — some but not all.
   Used by a select-all header sitting above a group of options.

   ⚠ INDETERMINATE IS A DOM PROPERTY AND CANNOT BE SET IN MARKUP. There is no
   attribute for it: `<input type="checkbox" indeterminate>` does nothing at all.
   It is set only in script — element.indeterminate = true — and cleared the same
   way. Setting or removing an *attribute* named indeterminate will silently do
   nothing, which is the mistake this note exists to prevent. It is also not
   sticky: any user click clears it, because clicking resolves the ambiguity.

   THE BAR ITSELF IS THE BROWSER'S. .checkbox is a NATIVE control (no
   appearance: none — see .toggle below for the one that is custom-drawn), so the
   engine draws the horizontal bar and tints it from accent-color. That is
   deliberate: it means indeterminate reads as the same control in a different
   state rather than a parallel treatment sitting next to it. The trade is that
   the bar's exact weight and inset vary slightly between engines. That variation
   is ACCEPTED. Converting .checkbox to appearance: none and drawing all three
   states from tokens is a deliberate control-styling pass across the whole app,
   not something to smuggle in beside one new state.

   So what is below is only what native does NOT give for free: the accent
   restated so the state is declared rather than inherited by accident, and the
   disabled and focus parity that .checkbox never had. */
.checkbox:indeterminate {
  accent-color: var(--accent);
}

/* Disabled parity across all three states. .choice.is-disabled dims the LABEL;
   this dims the control itself, which is what a disabled checkbox outside a
   .choice row was previously missing. */
.checkbox:disabled,
.radio:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Focus parity across all three states. The global :focus-visible ring in
   base.css already applies; the offset is set here so the ring clears the box
   rather than sitting on its edge, where at 16px it reads as a thicker border
   instead of a ring. */
.checkbox:focus-visible,
.radio:focus-visible {
  outline-offset: 2px;
}

/* Toggle switch, built from a checkbox: pill track that fills with the accent
   when checked; the knob slides at the standard duration. Track, knob and the
   centring inset all resolve from the control-sizing tokens, so the knob stays
   centred and the travel stays correct if those tokens are retuned. */
.toggle {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: var(--toggle-w);
  height: var(--toggle-h);
  border: none;
  border-radius: var(--radius-pill);
  background: var(--border-default);
  cursor: pointer;
  transition: background-color var(--motion-standard) var(--ease);
}
.toggle::before {
  content: "";
  position: absolute;
  /* (track - knob) / 2 centres the knob within the track. */
  top: calc((var(--toggle-h) - var(--toggle-knob)) / 2);
  left: calc((var(--toggle-h) - var(--toggle-knob)) / 2);
  width: var(--toggle-knob);
  height: var(--toggle-knob);
  border-radius: var(--radius-pill);
  background: var(--surface-raised);
  transition: transform var(--motion-standard) var(--ease);
}
.toggle:checked { background: var(--accent); }
/* Travel = track width − track height (= width − knob − 2×inset). */
.toggle:checked::before { transform: translateX(calc(var(--toggle-w) - var(--toggle-h))); }
.toggle:disabled { opacity: 0.45; cursor: not-allowed; }

/* Choice row: a checkbox, radio or toggle sitting inline with its label. Appears
   on almost every form, so it is a real class rather than a repeated inline style. */
.choice {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font: var(--type-body);
  cursor: pointer;
}
.choice.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
/* A row of choices. */
.choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

/* Segmented control: radio inputs + styled labels (arrow-key nav is native).
   Moved here from layout.css. That stylesheet carries the application shell —
   sidebar, header, drawer — and client-facing pages deliberately do not load it,
   so a form control living there could not be reached without importing all of
   it. referral.html had rebuilt this shape page-local for exactly that reason.

   It carries NO JavaScript of its own and nothing here reads or writes .checked:
   selection is the native radio group's, which is also where the arrow-key
   navigation comes from. filter-bar.js:87 reads a label's text for its summary
   chip. External callers do write it — filter-bar.js sets .checked on its office
   radios at :116 (URL restore), :141 (clear a summary chip) and :170 (reset) —
   so the component is unscripted, not untouched. */
.segmented {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1);
  border: 1px solid var(--border-default);   /* the group carries the subtle border */
  border-radius: var(--radius-md);
  background: var(--surface-page);
}
.segmented__option { position: relative; display: inline-flex; }
.segmented__option input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.segmented__label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-h-sm);
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  white-space: nowrap;
  transition: background var(--motion-micro) var(--ease), color var(--motion-micro) var(--ease);
}
.segmented__option input:hover + .segmented__label { color: var(--text-primary); }
/* Active: raised surface + accent text; the rest stay transparent. */
.segmented__option input:checked + .segmented__label { background: var(--surface-raised); color: var(--text-accent); }
.segmented__option input:focus-visible + .segmented__label { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* Chipset: a row of individually-bordered selectable chips. Promoted from
   referral.html, where it was .rf-choice; the rename is the only change.

   A SEPARATE COMPONENT, not a .segmented modifier. The two share a markup shape
   — hidden radio, painted label — and nothing else. A modifier would have to
   override the container's border, radius, padding, background and gap, and the
   child's height, horizontal padding, border, colour, weight, hover, checked and
   transition: every property of both, which is a new component wearing another
   one's name. They also mean different things. .segmented is one control whose
   segments are alternatives within it; a chipset is a row of separate answers
   that happen to be exclusive, which is why each chip carries its own border.

   The input is visually hidden but NOT display:none and NOT hidden — it must stay
   focusable and stay in the accessibility tree, or the keyboard and screen-reader
   behaviour this markup was chosen for is lost. The label beside it is what is
   painted, and :checked / :focus-visible on the input drive its state. */
.chipset { display: inline-flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.chipset__option { position: relative; display: inline-flex; }
.chipset__option input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.chipset__label {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--control-h-lg); padding: 0 var(--control-pad-x-lg);
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  color: var(--text-primary); font: var(--type-body); font-weight: 500;
  white-space: nowrap; cursor: pointer;
  transition: background var(--motion-micro) var(--ease), border-color var(--motion-micro) var(--ease),
              color var(--motion-micro) var(--ease);
}
.chipset__option input:hover + .chipset__label { background: var(--surface-hover); border-color: var(--border-strong); }
/* Selected: the accent fill, matching .btn--primary so a chosen answer reads as firmly as the submit. */
.chipset__option input:checked + .chipset__label {
  background: var(--accent); border-color: var(--accent); color: var(--accent-contrast);
}
.chipset__option input:focus-visible + .chipset__label { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* File drop zone. */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  color: var(--text-secondary);
  text-align: center;
  transition:
    border-color var(--motion-micro) var(--ease),
    background-color var(--motion-micro) var(--ease);
}
.dropzone.is-dragover {
  border-color: var(--border-accent);
  background: var(--surface-selected);
}

/* =============================================================================
   METRIC
   Three stacked elements — label, value, delta — with NO card, border or shadow.
   The value (display-2 Presti 700) is the dominant element by a clear margin.
   The delta colour is driven entirely by attribute selectors on the root, so a
   server-rendered metric is the right colour before any script runs.
============================================================================= */
.metric {
  --metric-delta-color: var(--text-secondary); /* default / flat */
  display: flex;
  flex-direction: column;
}

.metric__label {
  font: var(--type-label);
  letter-spacing: var(--track-label);
  text-transform: uppercase; /* label style is uppercase-by-style */
  color: var(--text-secondary);
}

.metric__value {
  /* Query container for the sparkline (see the sparkline block). It lives here
     rather than on .metric because .metric is a subgrid in a row, and a query
     container establishes layout containment, which would disable that subgrid. */
  container-type: inline-size;
  display: flex;
  align-items: baseline;        /* sparkline sits on the value's baseline */
  gap: var(--space-3);
  margin-top: var(--space-2);   /* rhythm: label → value */
  font: var(--type-display-2);
  letter-spacing: var(--track-display-2);
  color: var(--text-primary);
}

.metric__delta {
  display: flex;
  align-items: baseline;
  margin-top: var(--space-1);   /* rhythm: value → delta */
  font: var(--type-body-sm);
  color: var(--text-secondary);
}
/* ⚠ THE nowrap MOVED OFF THIS ELEMENT AND ONTO THE FIGURE, WHICH IS WHAT IT WAS ACTUALLY FOR. It used
   to sit here with the comment "a delta must never wrap across two lines", and that protected the
   arrow-and-amount from splitting — which still holds below. The NOTE is a different thing: it is a
   phrase, and phrases that outgrow one line were being cut with an ellipsis, recoverable only through
   the title metric.js sets. On a touch device there is no hover, so the tail was simply unreachable.
   The Sales report's Sold SSTC foot is three segments joined by a middot and routinely outruns one
   line, which is what surfaced it. */
/* The arrow + amount take the functional colour and are the information, so they
   stay fully visible; the phrase is context, so it truncates with an ellipsis if
   the column is too narrow (metric.js adds a title with the full text when so). */
.metric__delta-figure {
  flex: none;
  white-space: nowrap;   /* the arrow and amount are one unit and never split */
  color: var(--metric-delta-color);
}
/* ⚠ TWO LINES, THEN AN ELLIPSIS — CAPPED, NOT UNBOUNDED. A note that grew freely would push one tile
   taller than its siblings; .metric-row is a flex row with no height set, so the whole row grows to the
   tallest and the tiles stay aligned, but an unbounded note would drag the row down as far as its text
   went. Two lines holds the Sold SSTC foot's three segments at every width this page is used at.
   A THIRD LINE'S WORTH OF TEXT IS ELLIPSISED, and metric.js's title still carries the full string — the
   same fallback that was the ONLY route to the tail before, now the fallback for a much rarer case.
   ⚠ IT BREAKS AT SPACES, NOT SPECIFICALLY AT THE MIDDOTS. CSS cannot be told to prefer a separator it
   cannot see, so a long phrase can still split mid-phrase. Making the breaks land only on separators
   needs the segments to be non-breaking, which is a change to the string rather than to this file. */
/* ⚠⚠ CLAMPED WITH max-height, NOT WITH -webkit-line-clamp, AND THE REASON IS INTRINSIC SIZING.
   -webkit-line-clamp requires `display: -webkit-box`, and that display value is the legacy 2009
   flexbox: its MIN-CONTENT contribution is its content's MAX-content, i.e. the whole string on one
   line. The text still wrapped visually once a width was imposed, so the clamp looked correct — but
   .metric-row's track floor is `minmax(min-content, auto)`, and min-content is what the grid asks for.
   MEASURED ON THE DEPLOYED PAGE: this note reported a min-content of 444.8px of the Sold SSTC tile's
   448.8px, the full 102-character foot string as one unbreakable run, for a tile displaying "12".
   With a plain block box and normal wrapping, min-content is the longest WORD instead.

   ⚠ THE EARLIER nowrap WAS NO BETTER — this is not a regression from it. A nowrap inline also reports
   the whole string as min-content, so moving from `white-space: nowrap` to `display: -webkit-box`
   swapped one full-string minimum for another. The commit that did it changed the VISIBLE wrapping and
   left the intrinsic width exactly where it was.

   ⚠ NO VISIBLE ELLIPSIS ON THE CLIPPED LINE, deliberately. text-overflow only acts on single-line
   overflow, so it never fired here even under -webkit-box (that ellipsis came from -webkit-line-clamp
   itself). The full string stays reachable through the title metric.js sets, which detects this case
   because it tests scrollHeight as well as scrollWidth.

   The two max-height declarations are one fallback and one preference: 3em is two lines at the
   --type-body-sm line-height of 1.5, and `2lh` tracks the real line-height wherever it is supported, so
   a future change to that token cannot silently turn this into a three-line box. */
.metric__delta-note {
  flex: 0 1 auto;
  min-width: 0;
  margin-left: var(--space-1);
  white-space: normal;
  max-height: 3em;   /* 2 lines × 1.5 line-height (--type-body-sm) */
  max-height: 2lh;   /* preferred: tracks the real line-height */
  overflow: hidden;
  color: var(--text-secondary);
}

/* Small SVG triangle (currentColor), not a text arrow. Overrides base.css's
   `svg { display: block }` so it flows inline with the amount. */
.metric__arrow {
  display: inline-block;
  width: 0.72em;
  height: 0.72em;
  vertical-align: -0.05em;
  margin-right: var(--space-1);
}
/* Down = the same triangle rotated; flat = an en-dash instead of any arrow. */
.metric[data-direction="down"] .metric__arrow { transform: rotate(180deg); }
.metric[data-direction="flat"] .metric__arrow,
.metric[data-direction="flat"] .metric__amount { display: none; }
.metric__delta-figure::before { content: "\2013"; display: none; } /* en-dash */
.metric[data-direction="flat"] .metric__delta-figure::before { display: inline; }

/* --- Delta colour logic (polarity × direction) ---------------------------- */
/* Polarity defaults to up-good when the attribute is absent, hence the
   :not([data-polarity="up-bad"]) guards below. */
.metric[data-direction="up"]:not([data-polarity="up-bad"]),
.metric[data-polarity="up-bad"][data-direction="down"] {
  --metric-delta-color: var(--positive);
}
.metric[data-direction="down"]:not([data-polarity="up-bad"]),
.metric[data-polarity="up-bad"][data-direction="up"] {
  --metric-delta-color: var(--negative);
}
.metric[data-direction="flat"] {
  --metric-delta-color: var(--text-secondary);
}

/* --- Target comparison ----------------------------------------------------
   A metric measured against a fixed GOAL rather than against a previous period.
   Same delta slot, same --metric-delta-color hook, same render path — this adds a
   new way to DECIDE the colour, not a new way to draw it.

   OPT-IN AND ADDITIVE: a tile with no data-target-state is untouched, so every
   existing metric in the app renders exactly as before.

   MET IS GREEN, BELOW IS AMBER — deliberately not --negative. A period delta that
   went the wrong way is a fact about what happened; a daily target not yet met is a
   gap to close, and red overstates it on a figure that is short by one with hours
   of the day left. --warning is the system's "attention, not alarm" tone.

   MUTUALLY EXCLUSIVE WITH A TREND DELTA. One tile has one --metric-delta-color, so
   it can answer "how did this move?" or "is this on target?", not both. A target
   tile therefore carries NO data-direction — and note the polarity × direction
   rules above are (0,3,0) to these (0,2,0), so if both were set the direction
   would win. Setting both is a caller error, not a supported combination.

   The met/below decision is computed by the caller (HFMetric.targetState does the
   arithmetic) and written into the attribute, exactly as data-direction already is
   — so the colour is correct from the markup before any script runs. */
.metric[data-target-state="met"]   { --metric-delta-color: var(--positive); }
.metric[data-target-state="below"] { --metric-delta-color: var(--warning); }

/* --- No-data state -------------------------------------------------------- */
/* An em-dash value and a short phrase, both --text-tertiary. Deliberate, not
   broken: appears on new accounts and thin data. */
.metric--nodata .metric__value,
.metric--nodata .metric__delta {
  color: var(--text-tertiary);
}

/* --- TV mode: the value at display-1 ------------------------------------- */
.metric--tv .metric__value {
  font: var(--type-display-1);
  letter-spacing: var(--track-display-1);
}

/* --- Graceful value size step-down ---------------------------------------- */
/* metric.js sets data-value-length from the rendered value's character count
   (short ≤6, medium 7–9, long ≥10). Long financial values step down instead of
   overflowing — precision is kept, never abbreviated to a rounded "k". Short
   values stay at display-2. TV steps down from display-1 by the same ratio
   (display-1 / display-2 = 3.5 / 2.5 = 1.4), since TV has no horizontal scroll. */
.metric[data-value-length="medium"] .metric__value { font-size: var(--metric-value-md); }
.metric[data-value-length="long"] .metric__value { font-size: var(--metric-value-lg); }
.metric--tv[data-value-length="medium"] .metric__value { font-size: calc(var(--metric-value-md) * 1.4); }
.metric--tv[data-value-length="long"] .metric__value { font-size: calc(var(--metric-value-lg) * 1.4); }

/* --- Sparkline ------------------------------------------------------------ */
.metric__spark {
  /* Shrinks before anything else: the number keeps its intrinsic width (flex's
     default min-width: auto protects it), while min-width: 0 lets the sparkline
     give way. Overflow is hidden because the drawing is inset by the dot radius
     in metric.js, so nothing needs to spill. */
  flex: 0 1 var(--spark-w);
  min-width: 0;
  width: var(--spark-w);
  height: var(--spark-h);
  overflow: hidden;
}
.metric__spark-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.metric__spark-dot { fill: var(--accent); }

/* A sparkline squashed to nothing communicates nothing, so it disappears rather
   than compressing. The container is the value row, which is inset from the
   metric by its --space-6 padding, so ~140px here is a metric of ~200px. */
@container (max-width: 140px) {
  .metric__spark { display: none; }
}

/* =============================================================================
   METRIC ROW
   A row of metrics separated by hairline vertical rules — a 1px --border-subtle
   left border on every metric but the first, with --space-6 of padding either
   side of that border. No cards, no gaps beyond that padding.

   Alignment: the row is a grid of three shared rows (label / value / delta) and
   each metric is a subgrid spanning them, so every label, value and delta lines
   up across the row however many lines a single label wraps to. Browsers without
   subgrid keep the flex fallback below (self-contained metrics, no cross-metric
   alignment) rather than something broken.

   Wrapping: 2 columns below 900, 1 column below 640. The rules resolve on wrap
   with no orphaned border at the start of a wrapped line — the wrapped states are
   self-contained metrics in a known-column grid where :nth-child(odd) starts each
   wrapped row.
============================================================================= */
.metric-row {
  display: flex;
}
.metric-row > .metric {
  flex: 1 1 0;
  min-width: 0;
  padding-inline: var(--space-6);
  border-left: 1px solid var(--border-subtle);
}
.metric-row > .metric:first-child {
  padding-left: 0;
  border-left: none;
}

/* Subgrid alignment (progressive enhancement over the flex fallback above). */
@supports (grid-template-rows: subgrid) {
  .metric-row {
    display: grid;
    grid-auto-flow: column;
    /* Columns size to their content — a six-figure value takes the room it needs,
       a single digit gives it up — while auto-max tracks stretch to absorb any
       leftover, so the right edge is never ragged. Subgrid rows (below) are
       unaffected, so labels / values / deltas still align across the row. */
    grid-auto-columns: minmax(min-content, auto);
    justify-content: stretch;
    grid-template-rows: auto auto auto;
  }
  .metric-row > .metric {
    display: grid;
    grid-template-rows: subgrid;
    grid-row: span 3;
    align-items: start;
  }
}

@media (max-width: 900px) {
  /* Two self-contained columns; the vertical rule sits on column two (even), so
     column one (odd) starts each wrapped row with no orphaned border. Overrides
     the subgrid above at this width. */
  .metric-row {
    display: grid;
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
    row-gap: var(--space-5);
  }
  .metric-row > .metric {
    display: flex;
    grid-row: auto;
    grid-template-rows: none;
  }
  .metric-row > .metric:nth-child(odd) {
    padding-left: 0;
    border-left: none;
  }
}

@media (max-width: 640px) {
  .metric-row {
    grid-template-columns: 1fr;
    row-gap: 0;
  }
  /* Stacked: no vertical rules; a top hairline separates instead. */
  .metric-row > .metric {
    padding-inline: 0;
    border-left: none;
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-subtle);
  }
  .metric-row > .metric:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }
}

/* =============================================================================
   TABLE
   The shared data table — structure, sorting, density and responsive reflow.
   Deliberately spare: no zebra striping, no outer border, no vertical column
   rules, no shadow. Numbers line up because base.css sets tabular figures
   globally; right-alignment of numeric columns is the only extra needed.
============================================================================= */
.table {
  width: 100%;
  border-collapse: separate;   /* keeps the sticky header's border on the cell */
  border-spacing: 0;
  color: var(--text-primary);
}

/* Density → row height. data-density may sit on the table or any ancestor; the
   cells read --row-h with a comfortable fallback, so nothing needs it set. */
[data-density="compact"]     { --row-h: var(--row-h-compact); }
[data-density="comfortable"] { --row-h: var(--row-h-comfortable); }
[data-density="spacious"]    { --row-h: var(--row-h-spacious); }

/* --- Metric search (M229) -------------------------------------------------- */
/* A combobox over the figures a report declares. The input is the shipped .field; only the popup and
   the option rows are new.
   ⚠ THE POPUP SETS display, SO IT SHIPS ITS [hidden] GUARD BESIDE IT — the rule this stylesheet has
   now recorded seven times. Without it the list would render under the input at all times, because an
   author display beats the user agent's [hidden]{display:none}. */
.metric-search { position: relative; display: flex; flex-direction: column; gap: var(--space-1); }
.metric-search[hidden] { display: none; }

.metric-search__list {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  z-index: 20;
  margin: var(--space-1) 0 0;
  padding: var(--space-1);
  list-style: none;
  max-height: 20rem;
  overflow-y: auto;
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  display: block;
}
.metric-search__list[hidden] { display: none; }

/* ⚠ ONE LEFT-ALIGNED STACK, NOT A TWO-COLUMN GRID. The popup itself was never misplaced —
   left:0/right:0 inside the position:relative wrapper pins it to the input's left edge — but the
   OPTION was a grid whose second column held the location, auto-sized and right-aligned, so a long
   "Conversion — MA to Instructed" claimed most of the width and squeezed the name it described into
   a strip on the left. Every line now starts at the same left edge and the eye reads down it.
   ⚠ THE display RULES HERE OWE NO [hidden] GUARD: the element that carries the attribute is
   .metric-search__list, and these are its descendants — a display:none parent hides them whatever
   their own display. Checked, not assumed: nothing under public/ puts hidden on an option or on
   either of the two meta spans. */
.metric-search__option {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.metric-search__option[aria-selected="true"] { background: var(--surface-hover); }
.metric-search__label { display: block; font: var(--type-body-sm); color: var(--text-primary); }
/* The matched synonym, so a reader who typed "val" and got MAs can see why rather than guess. */
.metric-search__via { display: block; font: var(--type-micro); color: var(--text-tertiary); }
.metric-search__where { display: block; font: var(--type-micro); color: var(--text-secondary); }
.metric-search__empty { margin: var(--space-1) 0 0; font: var(--type-body-sm); color: var(--text-secondary); }

/* The reveal flash, for a figure that is not a table row — a tile, a note, the freshness chip.
   ⚠ NO `display` HERE, so no [hidden] guard is owed. It tints and outlines and nothing else. */
.is-found {
  outline: 2px solid var(--border-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
  transition: outline-color var(--motion-standard) var(--ease);
}

/* --- Export controls (M230) ------------------------------------------------ */
/* The section bar puts the export button on the same line as the heading, so the control that acts on
   a table sits with the table rather than floating above the page.
   ⚠ SETS display, SO IT SHIPS ITS [hidden] GUARD BESIDE IT — the eighth time this stylesheet has
   recorded the mechanism. */
.sales-section__bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  /* M231 — the bar owns the gap to what follows. The heading's own margin was sized for a heading
     sitting alone; with a button on the same line the block reads as crowded against the note under
     it, and the button is the part that needs the room. */
  margin-bottom: var(--space-4);
}
.sales-section__bar[hidden] { display: none; }
.sales-section__bar > .sales-section__head { margin: 0; }

/* ── Control row ───────────────────────────────────────────────────────────────────────────────────
   A row of controls that act on the thing directly below them — an Export button beside a
   show/hide toggle, say. Distinct from .sales-section__bar, which pairs ONE control with a HEADING
   and pushes them apart with space-between; this holds two or more peers together at the left.

   ⚠⚠ IT EXISTS BECAUSE base.css SETS `* { margin: 0 }` AND THAT IS EASY TO FORGET. A <p> wrapping a
   button therefore has NO margin of its own: two such paragraphs stacked are flush against each other
   with literally nothing between them. On the Property Managers page the Export button and the
   per-manager toggle collided exactly that way, and neither element was wrong — the space simply had
   nowhere to come from. Give the row the gap rather than giving each control a margin, so adding a
   third control needs no new rule.

   ⚠ SETS display, SO IT SHIPS ITS [hidden] GUARD BESIDE IT — an author declaration beats the user
   agent's [hidden] { display: none }, and a row left rendering while every reader of the code believes
   it hidden is the defect this stylesheet has now recorded nine times. */
.control-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.control-row[hidden] { display: none; }

/* The drill panel's export control used to live here, as an <a download> in the panel head. M285
   removed it: the panel's export is now HFExport in the TABLE TOOLBAR, beside the search field, where
   a control that acts on the table belongs and where it can describe what the reader has narrowed.
   ⚠ The `.btn[hidden]` guard at the foot of this file was what kept the old control from rendering on
   every panel. It is still needed by other hidden .btn elements — this was one of its callers, not its
   only one. */

/* --- Freshness chips (M237) ------------------------------------------------ */
/* One chip per cache a report reads, inside the drill-down panel the freshness button opens. Extracted
   from TWO hand-rolled copies — .sales-fresh* in the Sales page's inline <style> and .pm-fresh* in the
   Property Managers page's — which were byte-identical apart from the prefix and one dead rule.
   .hf-report-freshness above is a different thing: it lays out the WRAPPER the button sits in.

   ⚠ .hf-fresh-list SETS display, SO IT SHIPS ITS [hidden] GUARD BESIDE IT — the mechanism this
   stylesheet has now recorded nine times. .hf-fresh and .hf-fresh--stale set no display and owe no
   guard; they are not given inert ones. */
.hf-fresh { white-space: nowrap; }
.hf-fresh--stale { color: var(--color-warning-text, var(--text-primary)); font-weight: 600; }
.hf-fresh-lede { margin: 0 0 var(--space-4); color: var(--text-secondary); }
.hf-fresh-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
}
.hf-fresh-list[hidden] { display: none; }
.hf-fresh-list li { padding: var(--space-2) 0; border-bottom: 1px solid var(--border-subtle); }
.hf-fresh-list li:last-child { border-bottom: 0; }

/* --- Horizontal scroll wrapper -------------------------------------------- */
/* M226 — .table-scroll WAS A PHANTOM CLASS. It was used in styleguide.html twice and referenced by one
   margin rule at .hf-group__body-inner, but DEFINED IN NO STYLESHEET — so the styleguide's own wide
   tables did not scroll, they just overflowed. sales-daily-dashboard.html carried a comment saying as
   much and worked around it with a private .dd-table-scroll. Sixteen pages hold their own copy of this
   pattern under sixteen names; this is the shared one they can migrate to, page by page.

   ⚠⚠ A TABLE INSIDE THIS WRAPPER LOSES ITS VIEWPORT-STICKY HEADER, AND THAT IS A CSS CERTAINTY RATHER
   THAN A BUG TO FIX. `.table thead th` below is position: sticky; top: 0. Per spec, overflow-x: auto
   with overflow-y: visible makes the USED value of overflow-y auto too — so this wrapper is a scroll
   container on both axes, and a sticky header inside it sticks to the WRAPPER rather than to the
   viewport. The wrapper has no height, so it never scrolls vertically, so the header never sticks.
   Horizontal scrolling and a viewport-sticky header are mutually exclusive; wrap only tables where that
   trade is worth it, or give the wrapper a max-height so the header sticks within it instead.

   ⚠ OFF BELOW 640px, WHERE THE TABLE STACKS. The media query further down turns .table into display:
   block with one row per card, so it cannot overflow horizontally and there is nothing to scroll. Left
   on, the wrapper would create a scroll context for no reason. (The sticky header is moot there anyway
   — that block also sets .table thead { display: none }.)

   ⚠ SCROLLING WITH A MOUSE IS NOT ENOUGH. A scroll region that only a pointer can reach is unreachable
   by keyboard, so the wrapper MUST carry tabindex="0" and an accessible name in the markup:
       <div class="table-scroll" tabindex="0" role="region" aria-label="…, scrollable">
   CSS cannot grant focusability, which is why this is a rule about the markup and why the focus style
   below exists — a focusable element with no visible focus is worse than one that cannot be reached.
   The cost is a tab stop even when the table happens to fit; that is the accepted trade, and making it
   conditional needs JS measuring scrollWidth, which this pattern deliberately does not carry. */
.table-scroll { overflow-x: auto; }
.table-scroll:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--radius-sm); }

/* --- Header --------------------------------------------------------------- */
.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: var(--row-h, var(--row-h-comfortable));
  padding-inline: var(--space-3);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  font: var(--type-label);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--surface-page);   /* opaque when stuck so rows don't bleed through */
  border-bottom: 1px solid var(--border-default);
}

/* The sort trigger is a real <button>, so focus + keyboard come from base.css.
   It inherits the header's label type via base.css's `button { font: inherit }`. */
.table__sort {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}
.table__caret {
  width: 0.7em;
  height: 0.7em;
  flex: none;
  color: var(--accent);
  opacity: 0;                        /* inactive columns: hidden */
  transition: opacity var(--motion-micro) var(--ease),
              transform var(--motion-micro) var(--ease);
}
.table th[aria-sort] .table__caret { opacity: 1; }                    /* active column */
.table th[aria-sort="descending"] .table__caret { transform: rotate(180deg); }
/* Discoverable, not noisy: low opacity on hover/focus of an inactive header. */
.table th:not([aria-sort]) .table__sort:hover .table__caret,
.table th:not([aria-sort]) .table__sort:focus-visible .table__caret { opacity: 0.35; }

/* --- Body ----------------------------------------------------------------- */
.table tbody td {
  height: var(--row-h, var(--row-h-comfortable));
  padding-inline: var(--space-3);
  vertical-align: middle;
  font: var(--type-body);
  color: var(--text-primary);
}
/* Separators sit between rows only — none before the first or after the last. */
.table tbody tr + tr > td { border-top: 1px solid var(--border-subtle); }
.table tbody tr { transition: background-color var(--motion-micro) var(--ease); }
.table tbody tr:hover { background: var(--surface-hover); }

/* Numeric / currency columns right-align (JS tags them from the header type);
   text and date columns stay left-aligned by default. */
.table .is-numeric { text-align: right; }

/* --- Table section row (M231) ---------------------------------------------- */
/* A full-width break inside a table body, naming the group of rows beneath it and carrying the
   sentences that group needs — on the Sales report, the cohort basis and the suppression threshold
   that are the only place a reader learns why a rate is dashed or flagged as a floor.

   ⚠ .table__section-row WAS A PHANTOM CLASS UNTIL NOW, the same way .table-scroll was before M226:
   written in the markup since M228, referenced by no stylesheet, and therefore rendered with the
   BROWSER DEFAULT for a <th> — bold and CENTRED, with no padding and none of the design system's
   typography. That is why it read as one more row rather than as a break. It gets the heading token,
   the table's own left alignment, and room beneath it.

   ⚠ NO HOVER. Every other tbody row tints on hover to show it is a target; a heading that did the
   same would read as clickable, which it is not. */
.table tbody tr.table__section-row > th {
  padding: var(--space-5) var(--space-3) var(--space-4);
  text-align: left;
  vertical-align: bottom;
  font: var(--type-h3);
  color: var(--text-primary);
  border-top: 1px solid var(--border-default);
}
.table tbody tr.table__section-row:hover { background: transparent; }

/* The section's sentences, beneath its name rather than trailing off the end of it. .table__col-tag
   is tuned to sit INSIDE a column header at 0.85em of its parent; at heading size that lands close
   to body text and reads as part of the heading, so it is restated here at the body-small token.
   ⚠ SETS display AND OWES NO [hidden] GUARD, for the reason components.css records at its foot: the
   attribute is carried by the <tr>, this is a descendant, and a display:none parent hides it
   whatever its own display. Verified rather than assumed — no .table__col-tag anywhere under
   public/ carries hidden itself. */
.table tbody tr.table__section-row > th .table__col-tag {
  display: block;
  margin-top: var(--space-2);
  max-width: 72ch;
  font: var(--type-body-sm);
  color: var(--text-secondary);
}

/* --- Column tag ----------------------------------------------------------- */
/* A quiet, small marker inside a column header that qualifies what the column
   means — e.g. an ATTRIBUTION basis ("assigned", "contact") on a pivot whose
   column attributes differently from its neighbours, so the difference is on the
   exact column that would otherwise be misread, not only in a note. Lowercase,
   tertiary, smaller than the header. */
.table__col-tag { font-weight: 400; font-size: 0.85em; color: var(--text-tertiary); }

/* --- Totals row (tfoot) --------------------------------------------------- */
/* A pivot's totals row. It lives in a <tfoot>, which HFTable never sorts (it orders
   tBodies[0] only), so it stays pinned at the foot under any column sort. A stronger
   top rule and medium weight separate it from the data. It holds the SUM OF THE
   VISIBLE rows — which differs from a source's own grand total whenever records fall
   outside the breakdown; that difference is surfaced by the data-quality warning below.
   While a search or a column filter narrows the body, sortable-table.js sets [hidden] here
   and the row is removed rather than recomputed: its label is the page's ("All managers"),
   and a filtered total under it would be a correct figure making a false claim. Stated
   explicitly below rather than left to the user-agent cascade — an author `display` on a
   component silently defeats [hidden], which is a bug this stylesheet has had before.
   M480 — A PUBLISHED TOTAL (<tfoot data-total="published">) is the exception: its figures are not the sum of the rows
   (the office displays' calls drill shows the calls band's own there), so sortable-table.js keeps it shown while the
   rows are narrowed. Same styling; no rule here sets display for it. */
.table tfoot[hidden] { display: none; }
.table tfoot td {
  height: var(--row-h, var(--row-h-comfortable));
  padding-inline: var(--space-3);
  vertical-align: middle;
  font: var(--type-body);
  font-weight: 600;
  color: var(--text-primary);
  border-top: 2px solid var(--border-strong);
}

/* --- Data-quality warning ------------------------------------------------- */
/* A QUIET, actionable note beneath a table: records that fell OUTSIDE the shown
   breakdown, with a control to open them for review. Informational tone — a soft
   surface and an accent left rule — NEVER the red error alert: it is a gap to
   investigate, not a fault. The open control is a link-style button. */
/* ⚠ THE MARGIN OWNS THE BOTTOM, NOT THE TOP, AND THAT WAS A CORRECTION RATHER THAN A PREFERENCE.
   It read `margin: var(--space-3) 0 0` — 12px above, nothing below — while every other banner in the
   page stack does the opposite: .hf-report-freshness is `0 0 var(--space-4)`, .hf-report-stale and
   .hf-report-alert are both `0 0 var(--space-5)`. Three of three, so the convention is the stylesheet's
   and not a choice made here. (.hf-report-note is margin-top, and is not a counter-example: it is a
   trailing footnote that follows content rather than a banner leading it.)
   The consequence of disagreeing was visible on the Property Managers report, where this sits directly
   below .hf-report-freshness and directly above the date-range chips: 16px of the neighbour's bottom
   margin PLUS 12px of this one's top made a 28px gap above, and 0 + 0 left the banner touching the
   chips. --space-5 rather than --space-4 because the structural peers are the two PADDED banners with a
   border-left accent, which is what this is; --space-4 belongs to the unpadded freshness line. */
.hf-data-warning {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
  margin: 0 0 var(--space-5);
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--border-accent);
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.hf-data-warning__open {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}
.hf-data-warning__open:hover { text-decoration: none; }
.hf-data-warning__open:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--radius-sm); }
/* An author `display: flex` BEATS the user-agent's `[hidden] { display: none }` — author origin wins over UA
   origin regardless of specificity — so without this rule every one of these notes stayed visible when its JS
   set hidden, painting an empty tinted bar with an accent rule and nothing in it. There is no global [hidden]
   reset in this stylesheet (the shell menu and the drill-down overlay each carry their own), so any component
   that sets an explicit `display` must restate it. */
.hf-data-warning[hidden] { display: none; }

/* --- Empty state ---------------------------------------------------------- */
/* A designated row the component reveals when there are no body rows. The page
   supplies the sentence (never "No data") and an optional single action. */
.table__empty > td {
  padding: var(--space-7) var(--space-4);
  text-align: center;
}
.table__empty-message {
  margin: 0 auto var(--space-3);
  max-width: 48ch;
  font: var(--type-body);
  color: var(--text-secondary);
}
.table__empty-message:last-child { margin-bottom: 0; }

/* --- Search toolbar (injected above the table; strip leaves room for future
       filter / export controls without the search having to move) ----------- */
.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-4);
}
.table-search {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 40ch;                 /* caps its width so other controls can sit right */
}
.table-search .field {
  height: var(--control-h-sm);     /* the small control height */
  width: 100%;
  padding-left: var(--space-6);    /* room for the magnifier */
  padding-right: var(--space-6);   /* room for the clear control */
}
.table-search .field::-webkit-search-cancel-button,
.table-search .field::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;                /* use our own clear, not the native one */
}
.table-search__icon {
  position: absolute;
  left: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  width: 1em;
  height: 1em;
  color: var(--text-tertiary);
  pointer-events: none;
}
.table-search__clear {
  position: absolute;
  right: var(--space-1);
  top: 50%;
  transform: translateY(-50%);
  display: none;                   /* only shown while there is a query */
  align-items: center;
  justify-content: center;
  width: var(--space-5);
  height: var(--space-5);
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color var(--motion-micro) var(--ease),
              background-color var(--motion-micro) var(--ease);
}
.table-search__clear:hover { color: var(--text-primary); background: var(--surface-hover); }
.table-search__clear svg { width: 0.8em; height: 0.8em; }
.table-search.has-query .table-search__clear { display: inline-flex; }
.table-search-count {
  margin: 0;
  color: var(--text-secondary);    /* label type comes from the .label class */
}
.table-search-count:empty { display: none; }  /* collapse when no query is active */

/* Clear-all for the per-column filters. Link-styled rather than a button block: it is an undo, subordinate to
   the search field beside it. Shown only while at least one filter is applied — see updateFilterBar. */
.table-toolbar__clear-filters {
  margin-left: auto;                 /* pushed to the trailing edge, away from the search */
  border: 0;
  background: none;
  padding: 0;
  font: var(--type-body-sm);
  font-weight: 600;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}
.table-toolbar__clear-filters:hover { text-decoration: none; }
.table-toolbar__clear-filters:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--radius-sm); }
.table-toolbar__clear-filters[hidden] { display: none; }

/* ── The toolbar's actions slot (M284) ───────────────────────────────────────────────────────────
   Where a caller puts a control that acts on the table — an Export button, today. The slot is opt-in
   and empty unless something is mounted into it, so a toolbar that never asked for one is unchanged.

   ⚠ margin-left: auto IS THE WHOLE RULE, and it is doing real work: without it the button lands
   immediately after "Clear filters" and reads as a third piece of filter chrome rather than as an
   action on the table. Pushed right, the toolbar says search on the left, act on the right.

   ⚠ NO display DECLARATION, SO NO [hidden] GUARD IS OWED — which is worth stating rather than leaving
   a reader to check, given this stylesheet has recorded that mechanism ten times. */
.table-toolbar__actions {
  margin-left: auto;
}

/* A toolbar built for the slot ALONE, when search was suppressed — under eight rows, or opted out.
   Nothing to push away from, so the auto margin above would be the only thing positioning it; left is
   where every other control on these surfaces starts. */
.table-toolbar--actions-only > .table-toolbar__actions {
  margin-left: 0;
}

/* =============================================================================
   PAGER (M361)
   -----------------------------------------------------------------------------
   Below a table whose rows are paged in the browser: the count line, a "Show" page-size select and
   Previous / Next. The page owns the data — it sorts and filters the WHOLE set, then renders one slice —
   so this is markup and layout only; see the styleguide's Pagination section.
   ⚠ THREE RULES SET display, SO EACH SHIPS ITS [hidden] GUARD BESIDE IT. The count line is never hidden
   (it is what says how many there are); Previous / Next are, when everything fits on one page.
============================================================================= */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  margin-top: var(--space-3);
}
.pager[hidden] { display: none; }
.pager__count {
  margin: 0;
  color: var(--text-secondary);
}
.pager__size {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.pager__size[hidden] { display: none; }
.pager__size .field { width: auto; }
.pager__nav {
  display: inline-flex;
  gap: var(--space-2);
  margin-left: auto;                 /* trailing edge, away from the count */
}
.pager__nav[hidden] { display: none; }

/* =============================================================================
   PER-COLUMN FILTER
   -----------------------------------------------------------------------------
   A trigger in each column header, and a popover holding either a checkbox picker
   (few distinct values) or a text search (many). Which kind is chosen by the data,
   in sortable-table.js — the CSS styles both and knows about neither.

   THE POPOVER IS PORTALED TO <body> AND POSITIONED IN VIEWPORT COORDINATES, and it
   has to be. Inside the drill-down panel the obvious approach fails twice over:
   .drilldown__panel carries a transform, which makes it the containing block for
   position:fixed descendants (so "fixed" would mean the panel, not the viewport),
   and overflow:hidden, which clips them at the panel's edge. Anchoring inside the
   scrolling .drilldown__body is worse still — the popover would scroll away from a
   header that is itself sticky. Rendering in <body>, where no ancestor transforms,
   makes position:fixed mean the viewport and behave identically on a page-level
   table and inside the panel, which is the requirement.

   z-index sits above .drilldown (60) and below .skip-link (200).
============================================================================= */
.table__filter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4em; height: 1.4em;
  margin-left: var(--space-1);
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-tertiary);
  cursor: pointer;
  vertical-align: middle;
  transition: color var(--motion-micro) var(--ease), background-color var(--motion-micro) var(--ease);
}
.table__filter:hover { color: var(--text-primary); background: var(--surface-hover); }
.table__filter:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.table__filter-icon { width: 0.75em; height: 0.75em; }
/* An applied filter reads in the header WITHOUT opening anything: the glyph fills and takes the accent, and
   the header takes a tint. Never colour alone — the trigger's accessible name states what is applied. */
.table__filter.is-active { color: var(--accent); }
.table__filter.is-active .table__filter-icon { fill: currentColor; }
.table thead th.is-filtered { background: var(--surface-selected); }

.table-filter-pop {
  position: fixed;
  z-index: 90;
  min-width: 13rem;
  max-width: min(20rem, calc(100vw - 2 * var(--space-4)));
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
}
.table-filter-pop__head { margin: 0; color: var(--text-secondary); }
/* The list scrolls rather than growing past the viewport. The picker threshold keeps it short in practice, so
   this is the guard for a narrow window rather than the normal case. */
.table-filter-pop__body { max-height: min(18rem, 50vh); overflow-y: auto; }
.table-filter-pop__list { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; }
.table-filter-pop__opt {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-1);
  border-radius: var(--radius-sm);
  font: var(--type-body-sm);
  color: var(--text-primary);
  cursor: pointer;
  /* Values are shown exactly as the cell reads, so a long one wraps rather than being clipped to a stub the
     reader cannot tell apart from its neighbour. */
  overflow-wrap: anywhere;
}
.table-filter-pop__opt:hover { background: var(--surface-hover); }
.table-filter-pop__opt input { flex: none; }
.table-filter-pop__foot { display: flex; justify-content: flex-end; gap: var(--space-2); }

/* Match highlight — inherited colour, no extra weight; only ever a text wrapper. */
.table mark {
  background: var(--surface-selected);
  color: inherit;
  font-weight: inherit;
  border-radius: var(--radius-sm);
}

/* No-results state — distinct meaning from the empty state, shared layout. */
.table__noresults > td {
  padding: var(--space-7) var(--space-4);
  text-align: center;
}
.table__noresults-message {
  margin: 0 auto var(--space-3);
  max-width: 48ch;
  font: var(--type-body);
  color: var(--text-secondary);
}

/* --- Drill-down rows ------------------------------------------------------ */
/* A chevron button toggles the child; the whole parent row is clickable too
   (guarded in JS against interactive targets and text selection). */
.table__expand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--space-5);
  height: var(--space-5);
  margin-right: var(--space-2);
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  vertical-align: middle;
  transition: transform var(--motion-standard) var(--ease),
              color var(--motion-micro) var(--ease),
              background-color var(--motion-micro) var(--ease);
}
.table__expand:hover { color: var(--text-primary); background: var(--surface-hover); }
.table__expand svg { width: 0.7em; height: 0.7em; }
.table__expand[aria-expanded="true"] { transform: rotate(180deg); }
.table__has-drill { cursor: pointer; }

/* The child region sits on --surface-sunken, inset from the left. Its height is
   animated by transitioning a wrapper's grid rows 0fr -> 1fr — a <tr> can't be
   given a reliable height, so the row itself is never animated. Reduced motion is
   honoured by the global block in base.css. */
/* Closed: genuinely zero height — no background, no border, and no row-height
   floor. Only the chevron indicates the row can expand. Specific enough to beat
   the body-cell height/padding and the row-separator rules. A parent and its
   child are one unit, so there is never a separator between them; the row that
   follows the drill-down still draws its own separator via `tr + tr`. */
.table tbody tr.table__drilldown > td {
  height: auto;
  padding: 0;
  border-top: none;
}
/* Background only while open, so a closed row shows no tinted band. */
.table tbody tr.table__drilldown.is-open > td {
  background: var(--surface-sunken);
}
.table__drilldown-inner {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--motion-standard) var(--ease);
}
.table__drilldown.is-open .table__drilldown-inner { grid-template-rows: 1fr; }
.table__drilldown-content {
  overflow: hidden;
  min-height: 0;
}
/* The padding lives on the nested child table, not on the overflow-hidden wrapper,
   so the 0fr grid collapse clips it and the closed state is truly zero height. */
/* M222 — the REMAINDER row of a rollup: the amount belonging to no group, carried inside the child
   table so the children sum to the parent. A hairline above it separates the remainder from the real
   rows without making it look like a fault.
   ⚠ IT MUST NOT BE GIVEN data-row-error. That would tint it, sort it to the bottom and produce a footer
   declaring it EXCLUDED from every count — the opposite of why it is there. It is a true part of the
   total, not a record to fix.
   ⚠ NO `display` DECLARATION, so no [hidden] opt-out is owed. */
.table tbody tr.table__rollup-remainder > td {
  border-top: 1px solid var(--border-default);
}
.table tbody tr.table__rollup-remainder em { font-style: normal; color: var(--text-secondary); }

.table__drilldown-content > .table {
  padding: var(--space-4) var(--space-4) var(--space-4) var(--space-6);
}

/* --- Data-error rows ------------------------------------------------------ */
/* Shown as a fix-list but excluded from every aggregate. A subtle --negative tint
   mixed against the surface (so it adapts across themes) plus a dot; the reason
   rides on the row title and the dot's aria label, never as visible text. */
.table__error > td {
  background: color-mix(in srgb, var(--negative) 8%, var(--surface-page));
}
.table__error:hover > td {
  background: color-mix(in srgb, var(--negative) 14%, var(--surface-page));
}
.table__error-dot {
  display: inline-block;
  width: 0.5em;
  height: 0.5em;
  margin-right: var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--negative);
  vertical-align: middle;
}
.table__error-footer {
  margin-top: var(--space-3);
  color: var(--negative);
}

/* --- Reflow sort bar (built by JS; shown only in the stacked layout) ------- */
.table__sortbar { display: none; }
.table__sortbar-field { flex: 1 1 auto; }
.table__sortbar-dir .table__caret { opacity: 1; }
.table__sortbar-dir.is-desc .table__caret { transform: rotate(180deg); }

/* --- Responsive: stack each row into a block below 640 -------------------- */
@media (max-width: 640px) {
  /* Search stays visible, goes full width, and sits above the sort bar; the count
     drops onto its own line so it still reads clearly. */
  .table-search { max-width: none; flex: 1 1 100%; }
  .table-search-count { flex: 1 1 100%; }
  .table__sortbar {
    display: flex;
    align-items: flex-end;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
  }
  /* M226 — the wrapper is inert once the table stacks: a display:block table cannot overflow
     horizontally, so the scroll context would exist for nothing. Turned off here rather than left on,
     beside the rule that makes it unnecessary. */
  .table-scroll { overflow-x: visible; }
  .table thead { display: none; }               /* header row hidden when stacked */
  .table,
  .table tbody { display: block; width: 100%; }
  .table tbody tr { display: block; padding: var(--space-3) 0; }
  /* M223 — THE GUARD THIS RULE HAS ALWAYS OWED, AND ITS ABSENCE WAS A LIVE DEFECT RATHER THAN A LATENT
     ONE. The declaration above is an AUTHOR display, so it beats the user agent's [hidden]{display:none}
     and a <tr hidden> rendered anyway below 640px — hidden on desktop, visible on a phone, which is why
     nobody saw it.
     WHAT IT BROKE: sortable-table.js hides rows with the HIDDEN ATTRIBUTE, not with display — search and
     column filters at :906, the table__empty row at :719/:1003 and the table__noresults row at :1011. So
     on a narrow screen every search and every column filter in the app did nothing visible: the
     non-matching rows stayed on screen while the result count beside them said otherwise, because
     visibleDataCount already excluded them. The JS and the CSS disagreed about what "hidden" meant.
     ⚠ NOT REDUNDANT — DO NOT REMOVE IT AS DEAD. It looks like it duplicates a browser default, and it
     does, everywhere except inside this media query, which is the only place it is needed and the only
     place its absence could not be seen. `.table tfoot[hidden]` above exists for exactly this reason and
     says so; this is the same bug one element down. */
  .table tbody tr[hidden] { display: none; }
  .table tbody tr + tr { border-top: 1px solid var(--border-subtle); } /* row separator */
  .table tbody td {
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    height: auto;
    padding: var(--space-1) 0;
  }
  .table tbody tr + tr > td { border-top: none; } /* separator moved to the row */
  .table tbody td::before {
    content: attr(data-label);                    /* column name from the cell contract */
    flex: none;
    font: var(--type-label);
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    color: var(--text-secondary);
    text-align: left;
  }
  /* The empty / no-results rows keep a centred message, not a label / value pair. */
  .table tbody tr.table__empty { padding: 0; border-top: none; }
  .table tbody tr.table__empty > td { display: block; }
  .table tbody tr.table__empty > td::before { content: none; }

  /* Drill-down rows: the nested child table reflows itself; the wrapper cell just
     stays a block with no label. */
  .table tbody tr.table__drilldown { padding: 0; border-top: none; }
  .table tbody tr.table__drilldown > td { display: block; padding: 0; }
  .table tbody tr.table__drilldown > td::before { content: none; }
}

/* Visually-hidden helper for captions that carry accessible names only. */
.visually-hidden {
  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;
}

/* =============================================================================
   CHART
   The shared wrapper chrome and static SVG rendering for line, bar and donut.
   Charts are drawn in real pixel space by charts.js and redrawn on resize, so
   nothing is stretched. Colours come from the categorical --chart-* palette and
   the semantic tokens; no hex here. Draw-on animation is a later slice — the only
   motion is hover feedback and the loading shimmer.
============================================================================= */
.chart {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  /* A CONTAINER, so the head can respond to how wide THIS CHART is rather than how wide the window is.
     That distinction is the whole bug: in a small-multiples grid a chart is ~450px on a 1600px viewport,
     so a viewport media query never fires and the legend stays crammed beside the title. Same mechanism
     the metric component already uses. */
  container: chart / inline-size;
}

/* --- Head: title / subtitle + legend -------------------------------------- */
.chart__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}
.chart__title { margin: 0; color: var(--text-primary); }
.chart__subtitle { margin: var(--space-1) 0 0; color: var(--text-secondary); }
.chart__legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  color: var(--text-secondary);
  text-align: right;
}
/* The swatch aligns to the label's FIRST LINE, not to the middle of the whole label. With align-items:
   center a label that wraps to two lines pushed its swatch down to the block's centre — i.e. into the gap
   BETWEEN the two lines — which is the misalignment seen on charts with long series names. flex-start plus
   half the leading reproduces centred alignment exactly for the single-line case ((1.2em − 0.6em) / 2 is
   the offset centring already produced), so nothing changes until the label actually wraps. 1.2em is the
   --type-label line-height; the swatch is sized in the same em, so the two stay locked together. */
.chart__legend-item {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--space-1);
  color: var(--text-secondary);
}
.chart__swatch {
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  margin-top: calc((1.2em - 0.6em) / 2);
  border-radius: var(--radius-sm);
  flex: none;
}

/* --- Notice (caps / cropped-axis) ----------------------------------------- */
.chart__notice { margin: 0; color: var(--warning); }

/* --- Chart area ----------------------------------------------------------- */
.chart__area {
  position: relative;
  width: 100%;
  background: var(--surface-page);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.chart__area:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.chart__plot,
.chart__skeleton {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.chart__skeleton { display: none; }

/* SVG marks */
.chart__gridline { stroke: var(--border-subtle); stroke-width: 1; }
.chart__axis-label {
  fill: var(--text-secondary);
  font: var(--type-label);
  letter-spacing: var(--track-label);
}
.chart__line {
  fill: none;
  stroke-width: 2;                 /* fine, not heavy */
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart__dot { stroke: var(--surface-page); stroke-width: 1.5; }
.chart__bar { stroke: none; }
.chart__arc { stroke: none; }
.chart__axis-break { stroke: var(--text-tertiary); stroke-width: 1; fill: none; }
.chart__hoverband { fill: transparent; }
/* M337 — campaign lanes beneath a bar chart (HFChart.bar lanes): the fill is set per item, from a chart token. */
.chart__lane { stroke: var(--surface); stroke-width: 1; }
.chart__lane.is-selectable { cursor: pointer; }
.chart__lane.is-selectable:hover { opacity: 0.8; }
.chart__swatch--lane { border-radius: 2px; }
/* A SELECTABLE point (the chart was given an onSelect and this index has data). The pointer cursor and
   the faint band say "this opens something" before it is clicked, and — just as important — their
   ABSENCE on a gap month says the opposite without a word. Only selectable bands get the class, so an
   unselectable point cannot accidentally look interactive. */
.chart__hoverband.is-selectable { cursor: pointer; }
.chart__hoverband.is-selectable:hover { fill: var(--surface-hover); }

/* --- Draw-on entrance ------------------------------------------------------
   The keyframes for this live here, with the component, not in motion.css: they
   are transitions bound to the chart's own SVG marks (a line's dashoffset, a bar
   column's scaleY, a final dot's opacity), not a reusable page-level entrance
   pattern — nothing outside a chart would ever opt in. charts.js owns the timing:
   it decides WHEN to animate (once, on first data, on scroll-in), sets each mark's
   start and end values plus its stagger delay, and adds .is-drawing to arm the
   transition — so these rules stay inert on every resize redraw. The donut sweep
   and centre count-up are driven by requestAnimationFrame in charts.js instead, as
   a growing filled arc can't be expressed as a CSS transition without changing the
   geometry. Bar columns scale from the zero baseline (their group's bottom edge).
   The stroke and the column grow both run over --motion-draw on --ease-data — the
   long, gentle data-draw timing the donut shares in JS — so all four types complete
   together. The final-point dot is a supporting detail: a longer, gentler fade than
   feedback (--motion-data), delayed by charts.js until its own line has finished. */
.chart__bar-group { transform-box: fill-box; transform-origin: center bottom; }
/* M327 — a horizontal bar grows from the zero line on the LEFT. No `display` set, so no [hidden] guard owed. */
.chart__bar-group--h { transform-origin: left center; }
.chart__line.is-drawing { transition: stroke-dashoffset var(--motion-draw) var(--ease-data); }
.chart__dot.is-drawing { transition: opacity var(--motion-data) var(--ease); }
.chart__bar-group.is-drawing { transition: transform var(--motion-draw) var(--ease-data); }

/* Reduced motion: charts.js already skips the entrance entirely (it never adds
   .is-drawing and draws the final state, centre figure included), so this is
   belt-and-braces against any stray transition. */
@media (prefers-reduced-motion: reduce) {
  .chart__line.is-drawing,
  .chart__dot.is-drawing,
  .chart__bar-group.is-drawing { transition: none; }
}

/* Donut centre — Presti display-3, the metric value treatment. */
.chart__donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}
.chart__donut-value { color: var(--text-primary); line-height: 1; }
.chart__donut-label { color: var(--text-tertiary); margin-top: var(--space-1); }

/* --- Tooltip (raised surface, popover shadow, flips within bounds) -------- */
.chart__tooltip {
  position: absolute;
  z-index: 2;
  max-width: 60%;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.chart__tooltip-title { margin: 0 0 var(--space-1); color: var(--text-secondary); }
.chart__tooltip-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-1);
  margin: 0;
  color: var(--text-primary);
  white-space: nowrap;
}
.chart__tooltip-val { margin-left: auto; padding-left: var(--space-3); font-variant-numeric: tabular-nums; }

/* --- Foot: last-refreshed + optional status ------------------------------- */
.chart__foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}
.chart__refreshed { margin: 0; color: var(--text-tertiary); }
.chart__status { margin: 0; color: var(--text-secondary); }

/* --- Empty & error states ------------------------------------------------- */
.chart__empty,
.chart__error {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-5);
  text-align: center;
}
.chart__empty { color: var(--text-secondary); }
.chart__error-msg { margin: 0; color: var(--negative); }

/* --- Refresh hairline (indeterminate) ------------------------------------- */
.chart__refresh-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 2px;
  width: 30%;
  display: none;
  background: var(--accent);
  border-radius: var(--radius-pill);
}

/* --- Loading skeleton shapes + shimmer ------------------------------------ */
.chart__skel-grid { stroke: var(--surface-hover); stroke-width: 1; }
.chart__skel-shape { fill: var(--surface-hover); stroke: none; }
.chart__shimmer {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  background: linear-gradient(100deg,
    transparent 35%, var(--surface-raised) 50%, transparent 65%);
  background-size: 220% 100%;
  background-repeat: no-repeat;
  opacity: 0.6;
  /* One slow sweep, same direction and speed on every chart so several loading at
     once read as one system, on the dedicated ambient-loop token. */
  animation: hf-chart-shimmer var(--motion-ambient) linear infinite;
}
@keyframes hf-chart-shimmer {
  from { background-position: 180% 0; }
  to   { background-position: -80% 0; }
}

/* =============================================================================
   CHART STATES — driven by data-state on the figure
============================================================================= */
/* Loading (never had data): full skeleton on a sunken surface, chrome as blocks. */
.chart[data-state="loading"] .chart__area { background: var(--surface-sunken); }
.chart[data-state="loading"] .chart__plot { display: none; }
.chart[data-state="loading"] .chart__skeleton { display: block; }
.chart[data-state="loading"] .chart__shimmer { display: block; }
.chart[data-state="loading"] .chart__donut-center { display: none; }
.chart[data-state="loading"] .chart__title,
.chart[data-state="loading"] .chart__subtitle,
.chart[data-state="loading"] .chart__refreshed {
  color: transparent;
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
}
.chart[data-state="loading"] .chart__title { width: 45%; }
.chart[data-state="loading"] .chart__subtitle { width: 60%; }
.chart[data-state="loading"] .chart__refreshed { width: 30%; }
.chart[data-state="loading"] .chart__legend::before,
.chart[data-state="loading"] .chart__legend::after {
  content: "";
  display: inline-block;
  width: var(--space-8);
  height: 0.7em;
  background: var(--surface-hover);
  border-radius: var(--radius-pill);
}

/* Refreshing (has data): keep the chart, dim it, run a thin hairline. Never blank
   a chart the user is currently reading. */
.chart[data-state="refreshing"] .chart__plot { opacity: 0.5; }
.chart[data-state="refreshing"] .chart__refresh-bar {
  display: block;
  animation: hf-chart-refresh var(--motion-ambient) var(--ease) infinite;
}
@keyframes hf-chart-refresh {
  0%   { left: 0;    width: 15%; }
  50%  { left: 42%;  width: 30%; }
  100% { left: 100%; width: 15%; }
}

/* Empty & error replace the plot area. */
.chart[data-state="empty"] .chart__plot,
.chart[data-state="empty"] .chart__donut-center,
.chart[data-state="error"] .chart__plot,
.chart[data-state="error"] .chart__donut-center { display: none; }
.chart[data-state="empty"] .chart__empty { display: flex; }
.chart[data-state="error"] .chart__error { display: flex; }

/* --- Responsive: legend drops under the title on narrow figures -----------
   Keyed on the CHART's own width, not the viewport's. The old viewport media query only fired on a phone,
   so a chart sitting in a small-multiples grid column — narrow on a wide screen — kept a squeezed legend
   beside a title that had wrapped to two lines, and the two read as misaligned. Below 560px the title and
   legend stop competing for one row and the legend takes its own full-width line.
   This SUBSUMES the old max-width:640px viewport rule: a phone-width chart is itself narrow, so the
   container query fires there too. */
@container chart (max-width: 560px) {
  .chart__head { flex-direction: column; gap: var(--space-2); }
  .chart__legend { text-align: left; }
}

/* --- Reduced motion: static skeleton, no shimmer, no hairline animation --- */
@media (prefers-reduced-motion: reduce) {
  .chart__shimmer { animation: none; opacity: 0; }
  .chart[data-state="refreshing"] .chart__refresh-bar { animation: none; width: 100%; left: 0; opacity: 0.5; }
}

/* =============================================================================
   REPORT SCAFFOLD (hf-report.js) — the shared chrome of a Team Reports page:
   the freshness line, the staleness banner (page-level analogue of the table's
   per-row data-error), the row-count note, a flagged cell, an in-cell sub-line,
   quiet loading/empty text, and a wrapping table cell. Domain-free — a page picks
   these classes in its row/metric builders; the scaffold styles them once.
============================================================================= */
.hf-report-freshness { display: flex; align-items: baseline; gap: var(--space-2) var(--space-3); flex-wrap: wrap; margin: 0 0 var(--space-4); color: var(--text-secondary); font: var(--type-body-sm); }
.hf-report-stale { margin: 0 0 var(--space-5); padding: var(--space-3) var(--space-4); background: var(--surface-sunken); border-left: 3px solid var(--warning); border-radius: var(--radius-md); color: var(--text-primary); font: var(--type-body-sm); }
.hf-report-stale strong { font-weight: 600; }
.hf-report-note { margin-top: var(--space-3); color: var(--text-secondary); font: var(--type-body-sm); }
.hf-report-flag { color: var(--warning); font-weight: 700; }
/* Compliance alert banner (hf-report.js alert mechanism): louder than the stale banner — a NEGATIVE edge,
   because it means action is outstanding, not merely that the data is old. */
.hf-report-alert { display: flex; align-items: baseline; gap: var(--space-2) var(--space-3); flex-wrap: wrap; margin: 0 0 var(--space-5); padding: var(--space-3) var(--space-4); background: var(--surface-sunken); border-left: 3px solid var(--negative); border-radius: var(--radius-md); color: var(--text-primary); font: var(--type-body-sm); }
.hf-report-alert strong { font-weight: 600; }
.hf-report-alert-action { background: none; border: 0; padding: 0; color: var(--text-accent); font: inherit; cursor: pointer; text-decoration: underline; }
.hf-report-subline { display: block; color: var(--text-tertiary); font: var(--type-micro); }
.hf-report-muted { color: var(--text-secondary); }

/* --- Derived-data note (.report-derived-note) -------------------------------------------------------
   A standing statement that the figures on the page are INFERRED rather than read from the source
   system. Not a stale banner (the data is not old) and not an alert (nothing is outstanding) — it is a
   permanent property of the report, so it carries a NEUTRAL accent and never disappears.

   ⚠ IT IS NOT DISMISSIBLE AND NOT COLLAPSIBLE, ON PURPOSE. The reader who most needs it — somebody
   about to telephone a tenant about a payment they believe is late — is exactly the reader who would
   have dismissed it weeks ago. Anything that can be hidden will be, and the derivation is the one fact
   that changes what the number means. Placed ABOVE the controls and the table so it is read first. */
.report-derived-note {
  margin: 0 0 var(--space-5);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-sunken);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
}
.report-derived-note p { margin: 0; }
.report-derived-note p + p { margin-top: var(--space-2); }
.report-derived-note strong { font-weight: 600; }

/* --- Grouped-severity report (shared; rendered by hf-report.js `table.groups`; demonstrated in the styleguide) --
   A compliance report split into severity-ranked, collapsible groups instead of one flat list with a status
   column. The weight descends through the LEFT ACCENT RULE + the count treatment ONLY — headings are uniform and
   there are no filled blocks. A page maps each of its groups to one step of this severity vocabulary:
     negative-strong (gravest) → negative → warning-strong → warning → positive / neutral (reassurance). */
.hf-groups { display: flex; flex-direction: column; gap: var(--space-6); margin-top: var(--space-6); }

/* The accent spine runs the WHOLE group (header + its table); content clears it via padding-left. */
.hf-group { padding-left: var(--space-4); }
.hf-group--negative-strong { border-left: 3px solid var(--negative); }
.hf-group--negative        { border-left: 2px solid var(--negative); }
.hf-group--warning-strong  { border-left: 2px solid var(--warning); }
.hf-group--warning         { border-left: 1px solid color-mix(in srgb, var(--warning) 45%, var(--border-default)); }
.hf-group--positive        { border-left: 1px solid color-mix(in srgb, var(--positive) 55%, var(--border-default)); }
.hf-group--neutral         { border-left: 1px solid var(--border-default); }

/* The head is a flex ROW OF TWO SIBLING CONTROLS: the header button (chevron + name) expands the group, and
   the count opens its records in the drill-down panel. They were one button until the count became a drill
   target — a button inside a button is invalid, and browsers resolve it by hoisting the inner one out. */
.hf-group__head { display: flex; align-items: center; gap: var(--space-2); }
.hf-group__header {
  display: flex; align-items: center; gap: var(--space-2);
  flex: 1 1 auto; min-width: 0;                 /* takes the row, leaving the count its intrinsic width */
  padding: var(--space-2) 0; margin: 0;
  background: none; border: 0; cursor: pointer; text-align: left; color: var(--text-primary);
}
.hf-group__chevron {
  width: 0.7em; height: 0.7em; flex: none; color: var(--text-tertiary);
  transition: transform var(--motion-standard) var(--ease);
}
.hf-group__header[aria-expanded="true"] .hf-group__chevron { transform: rotate(90deg); }

/* Uniform heading type across every group — equal siblings; severity reads through the rule + count, not type. */
.hf-group__name { font: var(--type-body); font-weight: 600; }

/* Count. The GRAVEST group (negative-strong) shows a plain coloured number so it reads most plainly; every other
   group shows a small tinted pill in its own colour. */
/* Scoped to .hf-group (rather than the bare class) deliberately: the count now also carries .drill-value, whose
   `font: inherit` sits later in this file and would otherwise reset the weight below to the head's. The count
   only ever appears inside a group, so the extra specificity costs nothing and pins the typography. */
.hf-group .hf-group__count { margin-left: var(--space-1); font-weight: 600; }
.hf-group--negative-strong .hf-group__count { color: var(--negative); }
.hf-group:not(.hf-group--negative-strong) .hf-group__count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.6em; padding: 0 var(--space-2); border-radius: var(--radius-pill); font: var(--type-label); font-weight: 600;
}
.hf-group--negative .hf-group__count       { background: color-mix(in srgb, var(--negative) 14%, var(--surface-page)); color: var(--negative); }
.hf-group--warning-strong .hf-group__count { background: color-mix(in srgb, var(--warning) 15%, var(--surface-page)); color: var(--text-accent); }
.hf-group--warning .hf-group__count        { background: color-mix(in srgb, var(--warning) 8%, var(--surface-page));  color: var(--text-secondary); }
.hf-group--positive .hf-group__count       { background: color-mix(in srgb, var(--positive) 14%, var(--surface-page)); color: var(--positive); }
.hf-group--neutral .hf-group__count        { background: var(--surface-sunken); color: var(--text-secondary); }

/* Collapsible body — the system's accordion motion (grid rows 0fr → 1fr; reduced motion honoured globally).
   overflow:hidden lets the 0fr collapse clip the body, but it ALSO makes an open body an inner scroll/clip
   container: if the 1fr row is ever computed taller than its <table> child, the clip traps an empty band the page
   scrolls into (a second scroll context). So once a group has finished opening the clip is dropped (.is-settled,
   toggled by hf-report.js on the grid-rows transitionend — and immediately for reduced motion / groups open at
   first paint): the open group grows to fit its content and the PAGE is the only scroll context. The clip is
   re-applied the instant a close begins, so the collapse still animates cleanly. */
.hf-group__body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--motion-standard) var(--ease); }
.hf-group__body.is-open { grid-template-rows: 1fr; }
.hf-group__body-inner { overflow: hidden; min-height: 0; }
.hf-group__body.is-settled .hf-group__body-inner { overflow: visible; }
.hf-group__body-inner > .table-scroll,
.hf-group__body-inner > .table { margin-top: var(--space-2); }

/* Empty under a filter: a single quiet, unalarming line naming the group — not a heavy header over a zero, not
   gone (which reads as not-loaded). No accent spine. */
.hf-group--empty { padding-left: 0; border-left: 0; }
.hf-group__empty { margin: 0; padding: var(--space-2) 0; border-top: 1px solid var(--border-subtle); color: var(--text-secondary); font: var(--type-body-sm); }

/* Interactive headline metric — the scaffold renders .metric--action for a metric that jumps to its group;
   pointer + hover + keyboard focus, consistent with the system's controls. */
.metric--action { cursor: pointer; border-radius: var(--radius-sm); transition: background-color var(--motion-micro) var(--ease); }
.metric--action:hover { background: var(--surface-hover); }
.metric--action:focus-visible { outline: 2px solid var(--border-accent); outline-offset: -2px; }
/* M329 — .metric--links: a tile that is NOT a button, whose value and foot counts are .drill-value buttons of
   their own (see the styleguide "Links in a tile"). Nothing to restyle — .drill-value inherits the value's type —
   but the foot buttons must not inherit the note's ellipsis clipping mid-word, so they stay whole. No `display`
   set, so no [hidden] guard is owed. */
.metric--links .metric__delta-note .drill-value { white-space: nowrap; }
.table td.hf-report-wrap { white-space: normal; min-width: 200px; }

/* =============================================================================
   REPORT INDEX
   A way IN to a team's individual reports from its landing page — a responsive band of
   destination CARDS, each a report label plus a one-line description of what it holds,
   with a chevron marking it as a way out. Each card sits on --surface-raised with a
   --border-default edge so it reads as a destination, not a faint outline — both resolve
   per theme (raised = white on the off-white page in light, a lighter panel on the darker
   page in dark), and hover firms the edge to --border-strong. Sits directly under the page
   title, before the metrics; the reports it links are deliberately kept out of the sidebar
   (nav:false in lib/pages.js) and reached from here.

   Layout: auto-fit columns, min 260 / max 360px, so the band fills the row on wide
   content, collapses to fewer columns and stacks on narrow — with no media query, so it
   reflows to whatever content width the shell gives it (full width in drawer mode below
   900px, reduced beside the sidebar above it). The 360px CAP is load-bearing: a LONE
   card stays 360px rather than stretching the full content width. Cards in a row equalise
   to the tallest (grid stretch + the link filling its cell), so uneven description lengths
   give aligned card bottoms, not a ragged band. min(100%, 260px) keeps a card from
   overflowing a container narrower than 260px.

   The consuming page filters the links to what the viewer can open and hides the section
   when none remain — both are page decisions, not the component's.
============================================================================= */
.report-index {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 360px));
  gap: var(--space-4);
}
.report-index__item { display: flex; }   /* flex cell so its link stretches to the row height */

.report-index__link {
  flex: 1;
  display: flex;
  align-items: flex-start;               /* content to the top; short cards leave space below, not centred */
  gap: var(--space-3);
  padding: var(--space-4);
  text-decoration: none;
  color: var(--text-primary);
  background: var(--surface-raised);        /* lift the card off the page surface so it reads as a destination */
  border: 1px solid var(--border-default);  /* a definite edge, not the faint --border-subtle hairline */
  border-radius: var(--radius-md);
  transition: background-color var(--motion-micro) var(--ease), border-color var(--motion-micro) var(--ease), color var(--motion-micro) var(--ease);
}
.report-index__link:hover { border-color: var(--border-strong); }
.report-index__link:hover .report-index__label { color: var(--accent); }
.report-index__link:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }

/* Text column grows and wraps; min-width:0 lets a long description wrap rather than force the chevron out. */
.report-index__text { display: flex; flex-direction: column; gap: var(--space-1); flex: 1 1 auto; min-width: 0; }
.report-index__label { font: var(--type-body); font-weight: 500; color: var(--text-primary); transition: color var(--motion-micro) var(--ease); }
.report-index__desc { font: var(--type-body-sm); color: var(--text-secondary); }

.report-index__chevron {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;                        /* sits against the label's cap height */
  color: var(--text-tertiary);
  transition: color var(--motion-micro) var(--ease), transform var(--motion-micro) var(--ease);
}
.report-index__link:hover .report-index__chevron { color: var(--accent); transform: translateX(2px); }

/* LARGE (M398) — .report-index--large: fewer, bigger destinations, as on the Office Displays hub where each team's
   display is one tile. Wider columns (min 300 / max 440px, the cap load-bearing for a lone tile as above), more
   padding, a heading-size label and a minimum height so a row of tiles reads as a choice of screens.
   COMING SOON (M398) — .report-index__link--soon on a <div>, never an <a>: a destination that exists in the layout
   but cannot be opened yet. A sunken surface, a dashed edge, a muted label, no chevron and a neutral "Coming soon"
   badge; hover changes nothing, because there is nothing to go to. The page decides which tiles are coming soon. */
.report-index--large {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 440px));
  gap: var(--space-5);
}
.report-index--large .report-index__link { min-height: 9rem; padding: var(--space-6); gap: var(--space-4); }
.report-index--large .report-index__label { font: var(--type-h3); }
.report-index--large .report-index__desc { font: var(--type-body); color: var(--text-secondary); }
.report-index__link--soon {
  cursor: default;
  background: var(--surface-sunken);
  border-style: dashed;
}
.report-index__link--soon:hover { border-color: var(--border-default); }
.report-index__link--soon .report-index__label,
.report-index__link--soon:hover .report-index__label { color: var(--text-secondary); }
.report-index__soon { align-self: flex-start; flex: none; white-space: nowrap; }

/* =============================================================================
   DRILL-DOWN PANEL
   A modal-style panel that slides in from the right over the page, holding a title, a
   record count, and a table of the records behind whatever figure was clicked. It is the
   shared way to open the records behind any figure on the four team reports, so it lives
   here rather than being hand-rolled on one page. Driven by public/js/drilldown.js
   (window.HFDrilldown); see the styleguide "Drill-down panel" entry.

   Scroll architecture (the load-bearing part). The overlay is fixed and out of flow, so it
   never pushes the page or adds a page scrollbar. The panel is height:100% of the viewport
   with overflow:hidden — it never grows past the viewport. The ONLY scroll context is
   .drilldown__body; the head (title + count + close) is flex:none and stays put. The shared
   .table thead sticks at top:0 of .drilldown__body — it uses a LITERAL top:0 (not the page's
   --app-header-h), so inside this scroll container it needs no offset; only its opaque
   background is overridden to the panel surface. overscroll-behavior:contain stops scroll
   chaining to the page behind, which drilldown.js also makes inert ([inert] on .shell).
============================================================================= */
.drilldown { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: flex-end; }
.drilldown[hidden] { display: none; }

.drilldown__scrim {
  position: absolute; inset: 0;
  background: var(--surface-inverse);      /* the same scrim token the shell drawer overlay uses */
  opacity: 0;
  transition: opacity var(--motion-standard) var(--ease);
}
.drilldown.is-open .drilldown__scrim { opacity: 0.5; }

.drilldown__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  /* Wide enough for a four-column table with an address column to read without sideways scroll, while still
     leaving the page visible behind it on a desktop. Below the 900px drawer breakpoint it goes full width.
     M349: the two numbers are tokens, and a TABLE drill widens past this to fit its rows (--fit, below). */
  width: min(var(--drilldown-w), var(--drilldown-w-max));
  max-width: 100%;
  height: 100%;
  background: var(--surface-raised);
  border-left: 1px solid var(--border-default);
  box-shadow: var(--shadow-modal);
  transform: translateX(100%);
  transition: transform var(--motion-entrance) var(--ease);
  overflow: hidden;                        /* the panel itself never scrolls — only its body does */
}
@media (max-width: 900px) { .drilldown__panel { width: 100%; } }   /* drawer mode: effectively full width */
/* M349 — ONE LINE PER ROW, ON A DESKTOP. drilldown.js puts .drilldown__panel--fit on the panel when it renders a
   TABLE (never for a form, a loading or failed panel, or an empty set, which keep the width above). The panel is
   then as wide as the table's one-line width — max-content — from --drilldown-w up to --drilldown-w-max:
     · cells never wrap, so a row is one line; numbers stay right-aligned by .is-numeric as before;
     · a free-text cell's content sits in .drilldown__clip (drilldown.js wraps it), which stops at --drilldown-clip-w
       with an ellipsis, the full text in the cell's title — so one long address cannot widen every row;
     · only a table still wider than --drilldown-w-max scrolls, sideways, inside the body. Rows are never squashed.
   ⚠ THE HEAD IS contain: inline-size SO A LONG TITLE CANNOT WIDEN THE PANEL — it wraps inside whatever width the
     table sets. The note is already capped at 78ch, under --drilldown-w.
   ⚠ min-width: 901px, NOT A NEW PHONE BREAKPOINT: below it the panel is the full-width drawer it always was, and
     the shared table still turns into stacked cards under 640px. Nothing changes there.
   ⚠ THE CELL RULE OUTRANKS .table td.hf-report-wrap (white-space: normal), which the pages put on address cells
     for the page tables; inside the fitted panel the clip does that column's job. */
@media (min-width: 901px) {
  .drilldown__panel--fit {
    width: max-content;
    min-width: min(var(--drilldown-w), var(--drilldown-w-max));
    max-width: var(--drilldown-w-max);
  }
  .drilldown__panel--fit .drilldown__head { contain: inline-size; }
  .drilldown__panel--fit .drilldown__body { overflow-x: auto; }
  .drilldown__panel--fit .drilldown__body .table th,
  .drilldown__panel--fit .drilldown__body .table td { white-space: nowrap; }
  .drilldown__panel--fit .drilldown__clip {
    display: block;
    max-width: var(--drilldown-clip-w);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .drilldown__panel--fit .drilldown__clip[hidden] { display: none; }
}
.drilldown.is-open .drilldown__panel { transform: translateX(0); }

.drilldown__head {
  flex: none;
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  /* Horizontal padding matches the main content column (--space-6) so content is not tight against the edge. */
  padding: var(--space-5) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--border-default);
}
.drilldown__titles { flex: 1 1 auto; min-width: 0; }
.drilldown__title { margin: 0; }           /* .h3 supplied in markup — subordinate to the page title */
.drilldown__count { margin: var(--space-1) 0 0; font: var(--type-body-sm); color: var(--text-secondary); }

/* M220 — the note: one line above the table saying what the record set actually is, for a panel whose
   contents diverge from the figure that opened it.
   ⚠ NO `display` DECLARATION, DELIBERATELY, so this rule needs no [hidden] opt-out. The component omits
   the element entirely when there is no note rather than rendering an empty one and hiding it — which is
   the arrangement that cannot produce the bug this file records five separate discoveries of. */
.drilldown__note {
  margin: 0 0 var(--space-4);
  font: var(--type-body-sm);
  color: var(--text-secondary);
  max-width: 78ch;
}

.drilldown__close {
  flex: none;
  width: var(--control-h-md); height: var(--control-h-md);
  display: grid; place-items: center;
  background: none;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color var(--motion-micro) var(--ease), color var(--motion-micro) var(--ease);
}
.drilldown__close:hover { background: var(--surface-hover); color: var(--text-primary); }
.drilldown__close:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.drilldown__close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }

.drilldown__body {
  flex: 1 1 auto;
  min-height: 0;                           /* lets the flex child shrink so its own overflow engages */
  overflow-y: auto;                        /* THE single scroll context inside the panel */
  overscroll-behavior: contain;            /* no scroll chaining to the page behind */
  padding: 0 var(--space-6) var(--space-6); /* sides match the content column; top:0 keeps the sticky header flush */
}
/* Sticky header inside the panel: the shared rule sticks it at top:0 of THIS scroll box; only the opaque
   background needs to change from the page surface to the panel surface so rows don't bleed through. */
.drilldown__body .table thead th { top: 0; background: var(--surface-raised); }

.drilldown__empty {
  margin: 0;
  padding: var(--space-7) var(--space-4);
  text-align: center;
  font: var(--type-body-sm);
  color: var(--text-secondary);
}

/* Loading state — for records that have to be FETCHED (a chart-point drill re-runs the report for that
   month), so the panel is never a frozen empty dialog. Shimmer bars in the shape of the table that is
   coming, rather than a spinner: the reader sees the panel is working AND roughly what will arrive, and
   the body does not jump when the rows land. The record count is hidden while loading — a count we do
   not yet know must never render as a zero. */
.drilldown__loading {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4);
}
.drilldown__loading-bar {
  height: 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-sunken) 25%, var(--surface-hover) 37%, var(--surface-sunken) 63%);
  background-size: 400% 100%;
  animation: hf-drill-shimmer var(--motion-ambient) linear infinite;
}
/* Staggered widths so it reads as rows of text rather than a progress bar. */
.drilldown__loading-bar:nth-child(3n) { width: 78%; }
.drilldown__loading-bar:nth-child(3n + 1) { width: 92%; }
@keyframes hf-drill-shimmer {
  from { background-position: 100% 0; }
  to   { background-position: 0 0; }
}
/* Reduced motion: keep the placeholder, drop the movement — matching the chart skeleton's treatment. */
@media (prefers-reduced-motion: reduce) {
  .drilldown__loading-bar { animation: none; }
}

/* --- Export chooser (M271; rendered by /js/export-menu.js; demonstrated in the styleguide) ------- */
/* One "Export" button opens a small modal listing the formats. It is NOT the drill-down panel with a
   different body: this one is going to be mounted INSIDE that panel, so it has to be a separate
   overlay that can sit on top of it. See the note at the head of export-menu.js.

   ⚠ z-index 100 — above .drilldown (60) AND above the filter popover and toast (both 90), because
   this traps focus and nothing may float over a modal the reader cannot tab out of. Below
   .skip-link (200), which must never be covered. */
.export-menu {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}
/* ⚠ THE [hidden] GUARD SHIPS BESIDE THE display IT OPTS OUT OF. An author display declaration beats
   the user agent's [hidden] { display: none }, so without this the overlay renders while every reader
   of the code believes it is hidden — the mechanism this stylesheet has now recorded ten times. */
.export-menu[hidden] { display: none; }

.export-menu__scrim {
  position: absolute;
  inset: 0;
  background: var(--neutral-900);
  opacity: 0;
  transition: opacity var(--motion-entrance) var(--ease);
}
.export-menu.is-open .export-menu__scrim { opacity: 0.5; }

.export-menu__dialog {
  position: relative;
  width: min(26rem, 100%);
  max-height: calc(100vh - 2 * var(--space-4));
  overflow-y: auto;
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  padding: var(--space-5);
  opacity: 0;
  transform: translateY(var(--space-3));
  transition: opacity var(--motion-entrance) var(--ease), transform var(--motion-entrance) var(--ease);
}
.export-menu.is-open .export-menu__dialog { opacity: 1; transform: none; }
/* Reduced motion: the dialog still appears, it just does not travel — same treatment the drill panel
   and the chart skeleton take. */
@media (prefers-reduced-motion: reduce) {
  .export-menu__scrim,
  .export-menu__dialog { transition: none; }
  .export-menu__dialog { transform: none; }
}

.export-menu__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}
.export-menu__title { margin: 0; font: var(--type-h3); color: var(--text-primary); }

.export-menu__close {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0 var(--space-1);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.export-menu__close:hover { color: var(--text-primary); }

/* ⚠ THE SUMMARY IS THE OLD BUTTON LABEL. "Export team totals" / "Export the filtered row" said, in
   the control itself, that the file would be narrower than the report. A single "Export" cannot, so
   the sentence lives here and in the button's aria-label. It is never decoration and never optional. */
.export-menu__summary {
  margin: var(--space-3) 0 var(--space-4);
  font: var(--type-body-sm);
  color: var(--text-secondary);
}

/* No [hidden] guard: this is a DESCENDANT of .export-menu, which carries the attribute, and a
   display:none parent hides it whatever its own display. An inert guard here would read as a
   considered one. */
.export-menu__formats { display: flex; flex-direction: column; gap: var(--space-2); }

/* A format button is a stacked label + hint, so it reads as a choice rather than as a toolbar.
   ⚠⚠ IT CARRIES .btn, AND FOUR OF .btn's DECLARATIONS ARE WRONG FOR A TWO-LINE CHOICE. Every one is
   overridden below, and the reason is worth listing because the previous version of this rule
   overrode only two of them and the button rendered clipped at BOTH ends:

     height: var(--control-h-md)       a FIXED 36px — not a minimum. Two lines do not fit in it.
     padding: 0 var(--control-pad-x-md) ZERO vertical padding, so even one line touches the edges.
     justify-content: center            harmless in a ROW; in a COLUMN it centres on the VERTICAL
                                        axis, so content taller than the box overflows EQUALLY above
                                        and below. That is why the title was cut off at the top and
                                        the description at the bottom rather than simply spilling.
     white-space: nowrap                the description cannot wrap.

   The previous rule set flex-direction, align-items, text-align and white-space — so the text was
   already stacking and already allowed to wrap. It had nowhere to wrap TO. */
.export-menu__format {
  display: flex;
  flex-direction: column;
  /* stretch, not flex-start: both lines must fill the button's width or they shrink-to-fit and wrap
     early against an invisible edge. text-align does the alignment instead. */
  align-items: stretch;
  justify-content: flex-start;
  text-align: left;
  gap: var(--space-1);
  width: 100%;
  height: auto;                              /* ⚠ .btn sets a fixed height */
  min-height: var(--control-h-md);           /* ...kept as a FLOOR, so one-line formats still look right */
  padding: var(--space-3) var(--space-4);    /* ⚠ .btn sets 0 vertical */
  white-space: normal;                       /* ⚠ .btn sets nowrap */
}

/* ⚠⚠ NO opacity ON THE HINT, AND THAT IS A CONTRAST FIX RATHER THAN A TIDY-UP. It was opacity: 0.85,
   which thins --accent-contrast against --accent — and again against the DARKER --accent-hover, so the
   line got harder to read exactly when the pointer was on it. The two lines are told apart by SIZE and
   WEIGHT, which costs no contrast in either theme or any state. */
.export-menu__hint {
  font: var(--type-body-sm);
  font-weight: 400;
  color: inherit;
}

/* The focus ring is base.css's global :focus-visible, deliberately not overridden here — it is now
   drawn around a box that fits its text, which is the whole of what was wrong with it. */

/* ⚠ A FAILED EXPORT IS ANNOUNCED, NOT SWALLOWED. The modal stays open and says so; role="alert" on
   the element means a reader who triggered it from the keyboard hears it without hunting for it. */
.export-menu__error {
  margin: var(--space-4) 0 0;
  padding: var(--space-3);
  border-left: 3px solid var(--negative);
  background: var(--surface-hover);
  color: var(--text-primary);
  font: var(--type-body-sm);
}
.export-menu__error[hidden] { display: none; }

/* Drill target — a figure that OPENS the panel. Visibly interactive at rest (a dotted underline in the link
   idiom) so it never looks identical to a plain number, firming to the accent on hover. A real <button>, so it
   is Tab-reachable and activates on Enter/Space. Metric tiles reuse the existing .metric--action affordance. */
.drill-value {
  font: inherit; color: inherit;
  background: none; border: 0; padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--text-tertiary);
  text-underline-offset: 0.2em;
  transition: color var(--motion-micro) var(--ease), text-decoration-color var(--motion-micro) var(--ease);
}
.drill-value:hover { color: var(--accent); text-decoration-color: var(--accent); text-decoration-style: solid; }
.drill-value:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: var(--radius-sm); }

/* =============================================================================
   DATE RANGE PICKER
   A from/to pair (native <input type="date">, matching the filter bar's range) plus quick
   presets. Driven by public/js/date-range.js (window.HFDateRange); see the styleguide
   "Date range picker" entry. Presets are a wrapping row of pill toggles (the active one
   marked with .is-active + aria-pressed); the inputs wrap below the 900px drawer breakpoint
   where the control has less width. Layout only — all behaviour (default month-to-date,
   presets, the inverted-range guard, state + URL) lives in the JS.
============================================================================= */
.date-range { display: flex; flex-direction: column; gap: var(--space-4); }
.date-range[hidden] { display: none; }   /* M373 — the opt-out every display rule ships with (CLAUDE.md); it had none */

.date-range__presets { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.date-range__preset {
  height: var(--control-h-sm);
  padding: 0 var(--control-pad-x-sm);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  background: none;
  color: var(--text-secondary);
  font: var(--type-body-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--motion-micro) var(--ease), border-color var(--motion-micro) var(--ease), color var(--motion-micro) var(--ease);
}
.date-range__preset:hover { border-color: var(--border-strong); color: var(--text-primary); }
.date-range__preset:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.date-range__preset.is-active { border-color: var(--border-accent); background: var(--surface-selected); color: var(--text-primary); }

/* From / To inputs. flex-wrap stacks them when the width is tight (drawer mode below 900px). The native
   date input is full-width by default (.field width:100%); here it sizes to its own intrinsic width. */
.date-range__inputs { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.date-range__field { display: flex; flex-direction: column; }
.date-range__field .field { width: auto; min-width: 9rem; }

/* M373 — INLINE, VALIDATED: the compact form for a page header's top-right corner (the Daily Dashboards). From and
   To side by side with no presets, and the message beside them, on one line that wraps when narrow. The control
   validates rather than corrects (data-max-days — see date-range.js): an inverted or over-long range is left as
   typed and the message says why, in --negative; empty, the message takes no space. */
.date-range--inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
.date-range--inline .date-range__inputs { gap: var(--space-3); }
.date-range__message { margin: 0; color: var(--negative); font: var(--type-body-sm); align-self: center; }
.date-range__message:empty { display: none; }

/* =============================================================================
   PERSON SELECTOR
   -----------------------------------------------------------------------------
   A single "who" control — All + each team member — the sibling of the date range
   picker in a report's control area, used to narrow a page to one person. A labelled
   native <select> (the people are authored per page, so the component stays generic).
   Driven by public/js/pm-select.js (window.HFPmSelect); see the styleguide "Person
   selector" entry. Layout only — behaviour (event, URL sync) lives in the JS.
============================================================================= */
.pm-select__field { display: flex; flex-direction: column; gap: var(--space-1); }
.pm-select__field .field { width: auto; min-width: 12rem; }

/* =============================================================================
   SEARCH FILTER BAR
   -----------------------------------------------------------------------------
   A search box over a vertical column of selects, with a clear control. Built and
   driven by public/js/search-filter.js (window.HFSearchFilter); see the styleguide
   "Search filter bar" entry. Layout ONLY — the controls themselves are the shipped
   .field and .btn, so nothing here restates their appearance.

   ⚠ NOT .filter-bar, AND NOT A VARIANT OF IT. .filter-bar (layout.css) is the shell's
   control strip spanning the content column between the page header and the body —
   segmented office control, period range, people multi-select, pills, URL sync. This
   is the small one that sits INSIDE page content. No class name is shared and the two
   must not be merged: one is shell furniture, the other is a component.

   ⚠ IT LIVES HERE RATHER THAN BESIDE .filter-bar IN layout.css, and that is a
   deliberate departure from its sibling. layout.css's own header reads "Shell, grid
   and responsive rules ONLY. Reusable UI components live in components.css", and that
   file already records moving the segmented control out for exactly this reason
   ("It is a form input, not shell furniture"). This bar is embeddable anywhere a page
   wants it, so it is a component. Filing it next to .filter-bar would have put a
   component in the shell file on the strength of a resemblance.

   ⚠ STACKED AT EVERY WIDTH, WITH NO MEDIA QUERY. The pattern this generalises
   (.sp-mkt-filter) is a wrapping flex row, which is right for a bar spanning a full
   content column and wrong here: this one is built for a narrow column, where a
   wrapping row produces a ragged two-then-one-then-three arrangement that changes
   shape as options load. One column is predictable at every width, so there is
   nothing to reflow and no breakpoint to keep in step.
============================================================================= */
.sf-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
/* Any rule that sets display ships its [hidden] opt-out in the same breath — an author
   declaration beats the user agent's [hidden] { display: none }, so a bar carrying the
   attribute would render anyway while every reader of the code believed it hidden. */
.sf-bar[hidden] { display: none; }

/* NO width HERE, ON PURPOSE. .field is already width: 100%, so the search box and every
   select fill the bar by inheritance from the shipped component. Restating it would be a
   second copy of a value owned elsewhere, and the copy is what goes stale. These two
   classes are hooks — for a page that needs to reach one control, and so the markup names
   what each element is. They deliberately declare nothing today. */
.sf-bar__search,
.sf-bar__select { /* intentionally empty — see the note above */ }

/* Left-aligned rather than stretched: a full-width ghost button reads as a primary action
   at the foot of a form, which is exactly what this is not. align-self keeps it to its own
   text width inside the column. */
.sf-bar__clear { align-self: flex-start; }

/* =============================================================================
   VIEW TOGGLE
   -----------------------------------------------------------------------------
   A segmented control switching the SAME data between presentations — Visual
   (charts) vs Data (tables) on a team landing page. The third member of the
   report control set, alongside the date range picker and the person selector:
   those two choose WHICH figures, this one chooses HOW they are drawn.

   A track (the bordered pill) holding real <button>s, the active one raised onto
   a surface rather than merely recoloured — so the selected view reads as a
   physical position in the group, which is what makes a segmented control legible
   at a glance. Driven by public/js/view-toggle.js (window.HFViewToggle); see the
   styleguide "View toggle" entry. Layout only — behaviour (event, URL sync) lives
   in the JS.

   aria-pressed is the accessible state and .is-active its visual counterpart, the
   same split the date range picker's presets use. Both are set by the JS; the CSS
   keys off aria-pressed so the visual can never drift from what is announced.
============================================================================= */
.view-toggle {
  display: inline-flex;
  gap: var(--space-1);
  padding: 3px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
}
.view-toggle__btn {
  height: var(--control-h-sm);
  padding: 0 var(--control-pad-x-sm);
  border: 0;
  border-radius: var(--radius-pill);
  background: none;
  color: var(--text-secondary);
  font: var(--type-body-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--motion-micro) var(--ease), color var(--motion-micro) var(--ease);
}
.view-toggle__btn:hover { color: var(--text-primary); }
.view-toggle__btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
/* Keyed off aria-pressed, not .is-active, so the appearance cannot drift from the announced state. */
.view-toggle__btn[aria-pressed="true"] {
  background: var(--surface-raised);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* =============================================================================
   PINNED BAND — a section whose figures IGNORE the page's date control
   -----------------------------------------------------------------------------
   Most bands on a report answer "what does the selected range say". A pinned band
   does not: its figures are fixed to a window of their own — next month from today
   on the forward-looking metrics — and change when the calendar changes, never when
   the reader changes the date control above.

   That is a genuine misreading hazard, and a quiet one. Someone selects last month,
   reads down the page, and takes every figure as belonging to that month; the pinned
   band silently is not. So it is marked THREE ways, deliberately redundant: this
   visual treatment (an accent edge and a lifted surface, so it reads as a different
   kind of thing before it is read at all), a __flag chip INSIDE the heading — inside,
   so a screen reader announces the caveat as part of the heading rather than as a
   detached note it might never reach — and prose in the band itself.

   Do not use this merely to emphasise a section. It means one specific thing: the
   date control does not reach these figures.
============================================================================= */
.band-pinned {
  padding: var(--space-5);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--border-accent);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}
.band-pinned__flag {
  display: inline-block;
  margin-left: var(--space-2);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  font: var(--type-label);
  vertical-align: middle;
  white-space: nowrap;
}

/* =============================================================================
   CHART GRID (small multiples)
   -----------------------------------------------------------------------------
   One chart per metric, laid out so a band of related metrics can be compared by
   eye. auto-fit + minmax means the column count follows the available width with
   no breakpoints.

   440px floor, not 320: eighteen monthly points in a 320px column left roughly
   15px per point, which is not enough room for a line to show its shape — the
   chart reads as a squiggle rather than a trend. 440px is the width at which the
   plot area (column minus the 52px of axis gutter) gives a monthly series about a
   year and a half of legible spacing.

   max-width caps the grid at THREE columns however wide the screen. That is a
   readability bound and a tidiness one: a six-chart band divides exactly by 1, 2
   and 3, so the last row is never ragged at any width, whereas a fourth column
   would leave four-then-two. A band whose count does not divide by three will
   still leave a short last row — set an explicit column count on that grid rather
   than widening this one.

   Do NOT pair this with a shared axis.max unless every chart in the band measures
   THE SAME THING (e.g. one metric across four managers). Six different metrics on
   one scale is what the axis.max option must not be used for: the largest metric
   sets a ceiling that flattens all the others into the baseline. See charts.js.
============================================================================= */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
  gap: var(--space-5);
  max-width: 1500px;   /* three 440px+ columns plus gaps — never a fourth */
}

/* =============================================================================
   INSUFFICIENT HISTORY
   -----------------------------------------------------------------------------
   What a metric shows INSTEAD of a chart when it has too few months to plot. Three
   points is not a trend, and drawing one anyway invites a reader to see direction
   in noise — so below the promotion threshold the metric shows its current value
   and states plainly how much history exists.

   It is deliberately NOT the chart component's empty state: that reads as "this
   chart failed", where this is the opposite — the figure is fine, there is simply
   not yet enough of it to draw. Same footprint as a chart figure so a grid of small
   multiples does not jump as metrics graduate into charts one by one.

   The threshold belongs to the PAGE (one shared rule across every metric in the
   band, so metrics graduate on their own as data accumulates) — never per-metric,
   and never hardcoded here.
============================================================================= */
.chart-insufficient {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}
.chart-insufficient__title { margin: 0; }
.chart-insufficient__value { margin: var(--space-2) 0 0; }
.chart-insufficient__label { margin: 0; color: var(--text-secondary); }
/* The history statement is the point of the component — it is what makes the absent chart honest
   rather than merely missing, so it sits apart from the figure with a rule above it. */
.chart-insufficient__note {
  margin: var(--space-4) 0 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

/* =============================================================================
   Chart span note (M416) — public/js/chart-span.js
   -----------------------------------------------------------------------------
   One line above a band of team-report charts, saying what the charts show when
   it is NOT simply the date range above. Two cases, nothing else:

     · widened — the range is under 3 months, so the charts show the 3 months
       ending at its end (a one- or two-point line says nothing);
     · --refusal — the range is over 25 months, so no chart is drawn and the
       sentence from the series endpoint stands in their place. The tables still
       cover the full range; the range is never silently cut to fit.

   Hidden in every other case: a note that is always there stops being read.
============================================================================= */
.chart-span-note {
  display: block;
  margin: 0 0 var(--space-4);
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--border-accent);
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  color: var(--text-secondary);
}
.chart-span-note[hidden] { display: none; }
.chart-span-note--refusal {
  border-left-color: var(--border-warning);
  background: var(--surface-warning);
  color: var(--text-primary);
}

/* ── Toast: the ONE transient, floating notification ─────────────────────────
   ⚠ A DELIBERATE DEPARTURE, and the only one of its kind. Every other notice in
   this system — .hf-report-alert, .hf-report-stale, .hf-data-warning,
   .field-error, .table__empty-message — is an IN-FLOW BANNER that occupies
   layout and stays until something re-renders it. Those are right for a
   condition that persists: a stale cache, a validation failure, a data gap.

   This is for something that is true only at a moment and has no place in the
   page once read — "you were refused the page you asked for". An in-flow banner
   would push the dashboard down on arrival and then need dismissing to give the
   space back, which is worse than the thing it explains.

   The exception is licensed by the same principle that permits a shadow on a
   popover or a modal: an element that genuinely floats above the page may cast
   one. It uses --shadow-popover, NOT --shadow-modal — this is incidental, not a
   thing demanding attention, and it does not trap focus or block the page.

   FOUR PAGE-LOCAL TOASTS ALREADY EXIST (dashboard.html has two, plus
   lettings-offers.html and photo-editor.html), all on the old palette, none
   tokenised or accessible. This is the shared one they should collapse into;
   none of them is touched here.

   The region is fixed and pointer-events:none, so it never blocks a click it is
   sitting over; the toast itself re-enables pointer events for its dismiss
   control. Nothing here shifts layout. */
.toast-region {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  /* Above .drilldown (60) and the shell, below .skip-link (200) — a toast may
     appear over a panel, but must never cover the skip link. */
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(380px, calc(100vw - var(--space-7)));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  /* Accent as a rule only, never as body text — the same device as .hf-data-warning. */
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  color: var(--text-primary);
  font: var(--type-body-sm);
  opacity: 0;
  transform: translateY(var(--space-3));
  transition: opacity var(--motion-standard) var(--ease),
              transform var(--motion-standard) var(--ease);
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
/* Stated explicitly: .toast sets display:flex, and an author display silently
   defeats the user-agent's [hidden] — the bug this stylesheet has had three
   times. */
.toast[hidden] { display: none; }
.toast__message { margin: 0; flex: 1 1 auto; }
.toast__dismiss {
  flex: none;
  margin: calc(var(--space-1) * -1) calc(var(--space-2) * -1) 0 0;
  padding: var(--space-1) var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-secondary);
  font: var(--type-body-sm);
  line-height: 1;
  cursor: pointer;
}
.toast__dismiss:hover { color: var(--text-primary); }
.toast__dismiss:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; transform: none; }
}

/* ── [hidden] opt-outs — KEEP THIS BLOCK LAST IN THE FILE ─────────────────────
   THE MECHANISM. The user agent supplies [hidden] { display: none }, but that is
   a UA rule: any AUTHOR declaration of display beats it, whatever the selector.
   So every component that sets its own display silently defeats the hidden
   attribute, and an element marked hidden renders anyway — empty, but occupying
   layout and drawing its own border and background.

   PLACEMENT IS LOAD-BEARING, not tidiness. `.metric[hidden]` is (0,2,0) and so
   is `.metric-row > .metric`; on equal specificity the later rule wins, so these
   guards only take effect because they are the last thing in the file. Moving
   this block higher would silently re-break the ones it collides with.

   ⚠ FIFTH TIME. This has now been fixed for .hf-data-warning, .table tfoot,
   .table-toolbar__clear-filters, these six, and — found by an audit rather than
   by anyone noticing — three page-local rules that were LIVE DEFECTS at the time
   they were found:
     .doc-toolbar     (rent-report-document.html) a Print button rendering on the
                      client-facing document from first paint, and on the error
                      page a landlord reaches with a dead token
     .rr-nar-actions  (rent-report.html) the Generate-draft control showing for a
                      viewer and for a finalised report — the two states
                      isEditable() exists to refuse
     .sm-actions      (stock-management.html) the Sync-from-Reapit button showing
                      before /auth/me answers, and to users who never hold the key
   Fourteen guards existed before that audit and seventeen exist now.

   Five separate discoveries of one mechanism is the argument for fixing the
   CLASS of bug — a lint rule, or a convention that any display declaration ships
   with its opt-out — rather than each instance as somebody happens to notice it
   rendering an empty bar. The fifth strengthens that case rather than changing
   it: none of the three was visible without resolving the cascade by hand, and a
   further 640 rules in this repo set display where nothing currently applies
   hidden — not defects, but each one the day somebody adds the attribute.

   ⚠ THE CONVENTION IS NOW WRITTEN DOWN, in CLAUDE.md under "Design system" —
   "Any rule that sets display ships with its [hidden] opt-out", including the
   descendant exception below. Keep the two in step: this block is the mechanism
   and the running count, that one is the rule somebody reads before writing new
   CSS, and a count that stops being updated is how this comment came to say
   FOURTH while a fifth had already happened.

   FOUR MORE WERE CHECKED AND DELIBERATELY REJECTED. Do not re-add them from the
   same audit output: an audit that reports "class sets display, no [hidden]
   guard" cannot tell which ELEMENT carries the attribute, and these four set
   display on a DESCENDANT of it —
     .metric[data-direction="flat"] .metric__delta   (hidden sits on .metric)
     .metric-row > .metric                           (hidden sits on .metric-row)
     .hf-group:not(...) .hf-group__count             (hidden sits on .hf-group)
     .shell__breadcrumb--back a                      (hidden sits on the <nav>)
   A display:none parent hides its descendants regardless of their own display,
   so a guard on the child would be inert. Verified: none of those four
   descendants ever carries hidden itself anywhere under public/. */
.btn[hidden],
.badge[hidden],
.metric[hidden],
.metric-row[hidden],
.hf-report-alert[hidden],
.hf-groups[hidden] { display: none; }

/* --- Password form (shared; rendered by /js/password-form.js; demonstrated in the styleguide) ------
   Promoted out of change-password.html, where these rules lived as page-local `.cp*` styles. They move
   here with the component rather than staying on the page for the reason M124 records: a component whose
   styles live on one of its callers is styled correctly on that caller and unstyled everywhere else, and
   the second caller is where anyone finds out.

   NOT a stylesheet of its own. No component in public/js has one — every shared component's rules are in
   this file or in layout.css — and a new file would need its own entry in RESTRICTED_ALLOW_EXACT, adding
   a second way for a lettings-pm's password page to arrive unstyled. This file is already allowed there.

   The page's `body { display:flex; … }` centring rule did NOT come with them: that is where the page puts
   the form, not what the form looks like, and the styleguide and a settings page place it differently. */
.pw-form {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
}
.pw-form[hidden] { display: none; }   /* the author display above beats the UA's [hidden] rule */
.pw-form__heading { margin: 0 0 var(--space-2); }
.pw-form__lead { margin: 0 0 var(--space-5); color: var(--text-secondary); }
.pw-form__field { margin-bottom: var(--space-4); }
.pw-form__field .field { width: 100%; }
.pw-form__submit { width: 100%; margin-top: var(--space-2); }
/* Sits ABOVE the fields, so it needs bottom margin rather than the .field-error top margin it inherits. */
.pw-form__error { margin-bottom: var(--space-4); }
.pw-form__done { color: var(--positive); }

/* ── Job progress (.hf-job) ────────────────────────────────────────────────────────────────────────────
   A named sequence of steps that outlives the request that started it: start it, poll it, watch each step
   move. Built for the Property Managers report's manual refresh — five cache syncs, roughly two and a half
   minutes — and shared because the other report pages read the same kind of caches and will want the same
   control. It renders STATE ONLY; the polling, the job and the durable blob live with the caller.

   ⚠ EVERY STEP CARRIES ITS OWN STATE, INCLUDING THE TWO THAT ARE NEITHER SUCCESS NOR FAILURE. A step can
   be pending, running, done, SKIPPED (another run already held the sync's guard) or errored, and skipped
   is the one worth insisting on: rendering it as done would claim a refresh that did not happen, and
   rendering it as an error would raise an alarm about a guard working exactly as designed.

   ⚠ NO SPINNER AND NO PERCENTAGE. Step durations here differ by a factor of five and one of them varies
   with how much changed that day, so a bar would be a fiction with a number on it. The running step is
   marked and the rest are listed; that is all the honest information there is. */
.hf-job {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.hf-job[hidden] { display: none; }   /* the author display above beats the UA's [hidden] rule */
.hf-job__status { margin: 0; color: var(--text-secondary); }
.hf-job__status--error { color: var(--negative); }
.hf-job__steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}
.hf-job__steps[hidden] { display: none; }
.hf-job__step {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-1) 0;
  color: var(--text-secondary);
}
.hf-job__step[hidden] { display: none; }
/* The marker column is fixed-width so the labels line up whatever glyph a state uses. */
.hf-job__marker {
  flex: 0 0 1.25rem;
  text-align: center;
  color: var(--text-tertiary);
}
.hf-job__label { flex: 1 1 auto; }
.hf-job__detail { color: var(--text-tertiary); }
.hf-job__step--running { color: var(--text-primary); font-weight: 600; }
.hf-job__step--running .hf-job__marker { color: var(--info); }
.hf-job__step--done .hf-job__marker { color: var(--positive); }
.hf-job__step--skipped .hf-job__marker { color: var(--text-tertiary); }
.hf-job__step--error { color: var(--negative); }
.hf-job__step--error .hf-job__marker { color: var(--negative); }

/* --- Progress ring (M397) ---------------------------------------------------
   A count against a target as a ring: the fill is count ÷ target, capped at a full circle, with the count large in
   the centre and "of N" under it. First used by the Sales Office Display (/sales-office), where each KPI card has a
   main ring for today and two sub-rings for the week and the month; demonstrated in the styleguide under "Progress
   ring and freshness dot". Replaces the M396 pace bar, which nothing else used.
     <div class="progress-ring is-on-pace" style="--ring-fill: 0.778" role="img" aria-label="7 of 9 — on pace">
       <span class="progress-ring__body">
         <span class="progress-ring__count">7</span>
         <span class="progress-ring__of">of 9</span>
       </span>
     </div>
   · --ring-fill is a number from 0 to 1, set inline by the caller, already capped (min(count ÷ target, 1)).
   · .progress-ring--sub is the smaller size; any page may resize either through --ring-size and --ring-thickness
     (the type scales with --ring-size), as the display's TV mode does.
   · The colour is the caller's PACE judgement, not the fill: .is-on-pace (--positive) when the count is at or above
     what was expected by now, .is-behind (--negative) when below. A ring can be nearly full and behind, or a sliver
     and on pace (before opening nothing is expected yet, so it is on pace).
     .is-behind also tints the track, so a ring that is behind on a count of 0 — no fill at all — still reads red.
   · .is-no-target: a plain neutral ring with the count alone — no "of", no fill, whatever --ring-fill says.
   · .is-closed: the same neutral ring with a word ("Closed") in place of the count. */
.progress-ring {
  --ring-size: 160px;
  --ring-thickness: 14px;
  --ring-fill: 0;
  --ring-color: var(--border-strong);
  --ring-track: var(--surface-sunken);
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--ring-size);
  height: var(--ring-size);
  border-radius: 50%;
  background: conic-gradient(var(--ring-color) calc(var(--ring-fill) * 1turn), var(--ring-track) 0);
}
.progress-ring[hidden] { display: none; }
/* The hole: the raised surface the ring sits on, so the band is --ring-thickness wide in either theme. */
.progress-ring::before {
  content: '';
  position: absolute;
  inset: var(--ring-thickness);
  border-radius: 50%;
  background: var(--surface-raised);
}
.progress-ring__body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  line-height: 1.05;
}
.progress-ring__body[hidden] { display: none; }
.progress-ring__count {
  font-size: calc(var(--ring-size) * 0.27);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.progress-ring__of {
  margin-top: 2px;
  font-size: calc(var(--ring-size) * 0.1);
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}
.progress-ring--sub {
  --ring-size: 92px;
  --ring-thickness: 8px;
}
/* The sub size keeps "of N" legible: a tenth of a small ring is too small to read across a room. */
.progress-ring--sub .progress-ring__of { margin-top: 0; font-size: calc(var(--ring-size) * 0.14); }
.progress-ring.is-on-pace { --ring-color: var(--positive); }
.progress-ring.is-behind  { --ring-color: var(--negative); --ring-track: color-mix(in srgb, var(--negative) 22%, var(--surface-sunken)); }
.progress-ring.is-no-target,
.progress-ring.is-closed,
.progress-ring.is-withheld { background: var(--border-default); }
/* WITHHELD (M485). The figure's source cannot be trusted — never synced, its last sync failed, or it is too old — so
   the ring shows no count at all: a neutral ring, "—", and a .progress-ring__note saying "Not available" in the
   negative colour. Never a 0, which would read as a real, quiet period. The page says why beside the ring. */
.progress-ring.is-withheld .progress-ring__count { color: var(--text-secondary); }
.progress-ring.is-withheld .progress-ring__note { color: var(--negative); }
/* NO TARGET SET (M398). A grey ring with only a count looked broken, so .is-no-target carries a note under the
   count — .progress-ring__note, "No target set". Where the viewer can set targets the page makes the note a button,
   .progress-ring__note-link, that opens wherever targets are set; elsewhere (and on a wall screen) it stays text.
   A ring holding a button is not role="img" — the page gives it role="group" and its label instead. */
.progress-ring__note {
  max-width: calc(var(--ring-size) * 0.68);
  margin-top: 3px;
  font-size: max(10px, calc(var(--ring-size) * 0.075));
  font-weight: 500;
  line-height: 1.15;
  color: var(--text-secondary);
}
.progress-ring--sub .progress-ring__note { max-width: none; margin-top: 1px; font-size: max(9px, calc(var(--ring-size) * 0.1)); white-space: nowrap; }
.progress-ring__note-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--text-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.progress-ring__note-link:hover { color: var(--accent); }
.progress-ring__note-link:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 2px; }
.progress-ring.is-closed .progress-ring__count {
  font-size: calc(var(--ring-size) * 0.14);
  font-weight: 600;
  color: var(--text-secondary);
}

/* --- Freshness dot (M396) --------------------------------------------------
   How current a figure's source is, as a small dot beside its label: .fresh-dot--ok (positive), --amber (warning:
   stale during opening hours, or never synced), --red (negative: the last sync failed after the last success).
   The words go in the title ("updated 10:30") and in a visually-hidden label, never in the colour alone. Shown in the
   styleguide beside the progress ring (M397). */
.fresh-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
  vertical-align: middle;
  flex: none;
}
.fresh-dot[hidden] { display: none; }
.fresh-dot--ok    { background: var(--positive); }
.fresh-dot--amber { background: var(--warning); }
.fresh-dot--red   { background: var(--negative); }

/* ── M478 — A FIGURE AGAINST ITS REFERENCE: .value-diff ───────────────────────────────────────────────────────────
   The line under a figure that says how it differs from the figure it is measured against, in words — first the rent
   an applicant OFFERS against the ADVERTISED rent ("£50 below advertised (4%)"), on the Lettings Offers staff page,
   both landlord pages and the Lettings Daily Dashboard's Offers panel. The wording is public/lib/offer-rent.js
   difference(), so every surface says it the same way; nothing is shown when the two are equal.
   ⚠ WORDS, NOT COLOUR. A lower offer is not an error and a higher one is not a success: the line is secondary text,
     never a positive / negative tint. It also carries an absence ("Not given — …") in the same quiet voice.
   ⚠ THE SECOND SELECTOR beats .table--figures' `td *` font reset, so inside a figures table the line stays micro.
   ⚠ ABOVE THE DAILY DASHBOARD BLOCK, NOT AFTER IT: that block must stay the last thing in this file (M382,
     verify-daily-dashboard-css.js). */
.value-diff, .table--figures tbody td .value-diff {
  display: block; margin-top: 2px; font: var(--type-micro); font-weight: 400; color: var(--text-secondary); white-space: normal;
}
.value-diff[hidden], .table--figures tbody td .value-diff[hidden] { display: none; }

/* --- Daily Dashboard (M382) ------------------------------------------------
   The Sales and Lettings Daily Dashboards: the long date under the heading, the headline tiles, the two-column
   grid of collapsible panels, and the cells those panels' tables are built from. Rendered by
   public/js/daily-dashboard.js (HFDailyDashboard); demonstrated in the styleguide under "Daily Dashboard panel".
   Moved here from sales-daily-dashboard.html's inline <style> when the Lettings page became the second user —
   the rules are the page's, unchanged.

   ⚠ THIS BLOCK IS LAST IN THE FILE ON PURPOSE. It used to be the page's inline <style>, which came after every
   stylesheet, and three of its rules win only on ORDER: .dd-grid .hf-group .hf-group__count ties on specificity
   with .hf-group:not(.hf-group--negative-strong) .hf-group__count (both 0,3,0), and .dd-grid .hf-data-warning and
   .table td.dd-nowrap each restate a property a component rule above sets. At the end of components.css they still
   follow every rule they override (layout.css, which loads after, touches none of these selectors). Anything added
   below this block must not be something it overrides.

   Every selector here is a .dd-* class or descends from .dd-grid, which only a Daily Dashboard carries, so no
   other page is styled by any of it. */

/* M373 — the date range sits alone in the header's top-right corner (.shell__header-actions,
   right-aligned): the shared date range picker in its inline, validated form (.date-range--inline,
   data-max-days — components.css and date-range.js), From and To side by side. The shared sync
   control (.hf-sync-control) sits beside the heading on the left. */

/* Long-form date beneath the page title, naming the day (or days) the figures below describe.
   It reads the SELECTED range, not today, so changing the From/To fields restates it rather
   than leaving a stale one over changed figures. (M377: restored after M375 removed it.) */
.dd-date-subtitle { margin: var(--space-1) 0 0; color: var(--text-secondary); }

/* Eight tiles is more than .metric-row's single flex line handles on a narrow
   viewport, so this wraps. row-gap separates wrapped lines; the component's own
   hairline dividers still separate tiles within a line.

   margin-top clears the full-bleed sunken filter strip above. The strip reads as a
   band, so the headline figures need real air beneath it or they look attached to the
   control rather than to the report — the same generous step the PM report puts between
   its control area and its first section. */
.dd-tiles { flex-wrap: wrap; row-gap: var(--space-5); margin-top: var(--space-7); margin-bottom: var(--space-6); }
/* padding-top lifts the label off the tile's top edge; .metric-row only pads inline. */
.dd-tiles > .metric { flex: 1 1 8rem; padding-top: var(--space-4); }

/* Two-column panel grid, collapsing to one on narrow screens — the legacy layout.
   The calls panel spans both. */
.dd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-6); }
.dd-grid[hidden] { display: none; }
.dd-panel--wide { grid-column: 1 / -1; }
@media (max-width: 1100px) { .dd-grid { grid-template-columns: 1fr; } }

/* Panel head: the shared .hf-group__header is a flex row, so the title+subtitle pair
   stacks inside it as its own column. */
.dd-panel__titles { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; }
.dd-panel__titles[hidden] { display: none; }
.dd-panel__subtitle { color: var(--text-secondary); font: var(--type-body-sm); }
/* M380 — the calls panel's "may be incomplete" note sits between the head and the collapsible body, so it is
   read with the panel closed. The component's margin is a banner's (below, --space-5); under a panel head it
   only needs to clear the body. */
.dd-grid .hf-data-warning { margin: 0 0 var(--space-2); }

/* ── Count badge, made prominent ─────────────────────────────────────────────────
   .hf-group__count is a SHARED component (above), also worn by the grouped-severity
   reports (Sanctions, Right to Rent), where it is deliberately a small quiet pill sitting
   beside a severity-ranked heading. On a Daily Dashboard the count IS the headline of its
   panel, so it is sized and weighted up.

   Every selector here descends from .dd-grid, which exists only as a Daily Dashboard's
   panel grid, so the shared component and the two report pages that use it are untouched.

   Shape and colour tokens are kept: still the pill radius, still the component's own
   surface/positive/warning treatment. Only the type size, weight and padding change.
   Specificity note: the shared rule is .hf-group:not(...) .hf-group__count (0,3,0);
   this is (0,3,0) too and wins on order, being later in the cascade. */
.dd-grid .hf-group .hf-group__count {
  font: var(--type-body);
  font-weight: 700;
  min-width: 2.2em;
  padding: 2px var(--space-3);
}
/* Target state on the badge. Mirrors the tint-and-ink pattern the component already
   uses for its severity counts, so these read as the same family. The tile above each
   panel carries the same verdict IN WORDS ("Met" / "2 short"), so colour is never the
   only carrier of the information. */
.dd-grid .hf-group .hf-group__count.is-met {
  background: color-mix(in srgb, var(--positive) 14%, var(--surface-page));
  color: var(--positive);
}
.dd-grid .hf-group .hf-group__count.is-below {
  background: color-mix(in srgb, var(--warning) 15%, var(--surface-page));
  color: var(--text-accent);
}

/* Tile target colouring is not here: it is the metric component's own
   (.metric[data-target-state], met → --positive, below → --warning), which the tiles opt
   into through the shared contract. The count-badge rules ABOVE are a separate concern
   (badge prominence). */

/* Office pill — the "which office is this row from" tag, shown only in a combined view.
   Deliberately quieter and smaller than a .badge: it repeats on every row, so at badge
   weight it would out-shout the data it annotates. */
.dd-pill {
  display: inline-block; margin-left: var(--space-2); padding: 0 var(--space-1);
  border-radius: var(--radius-sm); background: var(--surface-sunken);
  color: var(--text-secondary); font: var(--type-micro); letter-spacing: var(--track-micro);
  vertical-align: middle;
}
.dd-pill[hidden] { display: none; }

/* Panel states — loading / empty / error. One quiet line each, never a zero pretending
   to be a count. */
.dd-state { margin: 0; padding: var(--space-3) 0; color: var(--text-secondary); font: var(--type-body-sm); }
.dd-state--error { color: var(--negative); }

/* A field the data-quality check flagged — the legacy page's red field, on the token. */
.dd-issue { color: var(--negative); font-weight: 700; }
/* Secondary lines under a name (email, phone). */
.dd-sub { display: block; color: var(--text-tertiary); font: var(--type-micro); }
.dd-sub[hidden] { display: none; }
/* Follow-up note, truncated to one line with the full text on hover. */
.dd-followup { display: block; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.dd-followup[hidden] { display: none; }
/* Connection-rate sub-line under the Connected figure. */
.dd-subrate { display: block; color: var(--text-tertiary); font: var(--type-micro); }
.dd-subrate[hidden] { display: none; }
/* Team-total footer row of the calls table. HFTable sorts tBodies[0] only, so a tfoot
   row is never reordered into the data. */
.dd-total-row td { font-weight: 700; border-top: 1px solid var(--border-strong); }

/* Cells that must not break across lines (times, dates, money). Table cells default to
   wrapping above, so this is the opt-out. */
.table td.dd-nowrap { white-space: nowrap; }

/* M226 — the page-local .dd-table-scroll was retired once .table-scroll existed above. The page kept only the margin,
   as a bare `.table-scroll { margin-top }` in its inline <style>; here it is scoped to the panel grid, because a bare
   rule in this file would move every .table-scroll in the app. On a Daily Dashboard every .table-scroll is inside the
   grid, so nothing on the page changes. */
.dd-grid .table-scroll { margin-top: var(--space-2); }

/* ── Info bubble (M465) — public/js/info-tip.js ───────────────────────────────────────────────────────────────────
   A small "i" beside a heading, a column title or a figure; pressing it opens .info-tip__pop, one shared popover per
   page placed by the script (position: fixed, kept on screen). Inside a table heading it keeps the heading's case-free
   look: the "i" is never uppercased or letter-spaced. */
.info-tip {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; margin-left: 3px; padding: 0;
  border: 1px solid var(--border-default); border-radius: 50%;
  background: transparent; color: var(--text-tertiary);
  font: italic 600 9px/1 Georgia, serif; text-transform: none; letter-spacing: 0;
  vertical-align: 1px; cursor: pointer; flex: none;
}
/* M466: small to look at, 24px to tap — an invisible ring round the 13px circle takes the touch */
.info-tip::before { content: ''; position: absolute; inset: -6px; }
.info-tip[hidden] { display: none; }
.info-tip:hover, .info-tip[aria-expanded="true"] { color: var(--text-primary); border-color: var(--text-secondary); }
.info-tip__pop {
  position: fixed; z-index: 1000; max-width: 320px; padding: var(--space-3);
  background: var(--surface-raised); color: var(--text-primary); border: 1px solid var(--border-default);
  border-radius: var(--radius-md); box-shadow: var(--shadow-popover);
  font: var(--type-body-sm); text-transform: none; letter-spacing: 0; white-space: normal; text-align: left;
}

/* ── Figures table (M465) — the Website pages' tables ───────────────────────────────────────────────────────────────
   .table plus .table--figures: at most 1100px wide; figure and status columns (.is-numeric) CENTRED, headings included,
   and shrunk to their content so the numbers sit together instead of across the screen; text columns stay left. One
   font in every cell — a name from outside data is shown as plain text in the table's own type, never bold or serif;
   only our own row (tr.is-us) is bold, on purpose. The global .is-numeric right-alignment elsewhere is unchanged. */
.table--figures { max-width: 1100px; }
.table--figures th.is-numeric, .table--figures td.is-numeric { text-align: center; width: 1%; }
.table--figures td.is-numeric { white-space: nowrap; }
/* a figure column's heading may wrap (two short lines beat a table wider than the page); the first text column keeps room
   for a business name and its address on one line each */
.table--figures thead th.is-numeric { white-space: normal; min-width: 4.5rem; line-height: 1.3; vertical-align: bottom; padding-block: var(--space-2); }
.table--figures tbody td:not(.is-numeric):first-of-type, .table--figures tbody td.is-numeric + td:not(.is-numeric) { min-width: 12rem; }
.table--figures tbody td, .table--figures tbody td * { font-family: inherit; font-size: inherit; font-style: normal; }
.table--figures tbody td { font: var(--type-body-sm); font-weight: 400; }
.table--figures tbody td strong, .table--figures tbody td b { font-weight: 400; }
.table--figures tbody tr.is-us > td, .table--figures tbody tr.is-us > td * { font-weight: 700; }

