/* ============================================================================
   components.css — the shared control layer: button, input, select, textarea,
   form row, table, card. Each defined ONCE, for the whole application.

   WHY THIS FILE EXISTS. The 2026-11-27 audits counted `.btn` defined 101 times
   across 31 files, six live primary-button treatments, five corner radii and
   two text cases inside a single four-click signup funnel. The cause was not
   carelessness: there was nowhere to put a button. `dashboard-common.css` owns
   the palette and the `dq-` dashboard parts, `app-shell.css` owns the shell
   chrome, and the one shared control vocabulary — the thing 293 templates
   actually use — lived nowhere, so every screen grew its own.

   WHAT IT TARGETS, AND WHY NOT A NEW NAMESPACE. These rules are written
   against BOOTSTRAP's class names (`.btn`, `.form-control`, `.card`, `.table`)
   rather than a fresh `eq-` set. A new namespace would help nobody until all
   293 templates were rewritten; retargeting the names the markup already
   carries means a template adopts this layer by DELETING its local copy, not
   by editing its HTML. `templates/macros/form.html` alone is imported by 78
   templates and emits `.form-control`.

   WHERE IT SITS. Last stylesheet in the head, immediately after
   `dashboard-common.css`, so it beats Bootstrap 4.6.2, `main.css`, the four
   2025 fix files and the shell's own inline block. The ONE thing that may
   still override it is a page's `{% block page_css %}`, which renders after
   it on purpose — see `docs/css-component-contract.md`.

   RULES FOR EDITING THIS FILE.
   - No hex literals. Every colour is a token from `dashboard-common.css`, or
     the three themes stop working. The only exception is a white/black alpha
     that must read correctly against any surface a theme picks.
   - No `!important`, except against an inline style attribute, with the
     reason named on the line.
   - Every interactive control carries hover, focus-visible, active and
     disabled. `:focus-visible` is used unguarded: 14 days of production
     nginx logs (72,370 real requests) put the oldest browser on the front
     desk at Chrome 153, and nothing anywhere below Chrome 103 — the feature
     landed in Chrome 86.
   - Contrast is not negotiable. Text on an accent fill uses
     `--eq-on-accent`, which `lib/theme.py` recomputes per tenant and
     guarantees at >=4.5:1. The legacy `#007bff` this replaces measured
     3.98:1 white-on-blue, i.e. it failed AA on every primary button in the
     product.
   ========================================================================== */

/* ============================================================================
   1. BUTTONS
   ========================================================================== */

/* The base. Bootstrap supplies display/line-height/border-width; everything
   below is the house style. `text-transform` is explicitly `none`: the shell
   set `uppercase` + 0.5px tracking on every button, which is one of the two
   text cases the funnel audit measured between the signup page and the app. */
.btn {
  border-radius: var(--eq-radius-control);
  padding: var(--eq-space-2) var(--eq-space-4);
  min-height: var(--eq-control-min);
  font-size: var(--eq-control-font);
  font-weight: var(--eq-weight-semibold);
  line-height: var(--eq-leading-normal);
  text-transform: none;
  letter-spacing: normal;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  /* Colour on --eq-dur-1, shape on --eq-dur-2: a fill should land before the
     lift finishes, or the button reads as lagging the pointer. The curve is
     decelerating, so a control arrives rather than bounces. These were
     `.15s/.2s ease` and the property list is unchanged — nothing newly
     animates, including on the five bulkmode screens, which take this layer
     the same as every other screen does. */
  transition: background-color var(--eq-dur-1) var(--eq-ease),
              border-color var(--eq-dur-1) var(--eq-ease),
              color var(--eq-dur-1) var(--eq-ease),
              box-shadow var(--eq-dur-2) var(--eq-ease),
              transform var(--eq-dur-2) var(--eq-ease);
}

/* Icon-and-label buttons. Replaces `.btn i { margin-right: 5px }` from
   button-overlap-fix.css, which also hit icon-only buttons and left a dangling
   5px gap inside them. A gap only applies when there is something to space. */
.btn > i,
.btn > .fa,
.btn > svg { vertical-align: middle; }
.btn > i:not(:only-child),
.btn > .fa:not(:only-child),
.btn > svg:not(:only-child) { margin-right: .4em; }   /* em: it tracks the label */

/* Sizes. `.btn-lg` has to actually be larger: the shell re-declared `.btn`
   padding AFTER Bootstrap at equal specificity, so `btn btn-primary btn-lg`
   rendered a 37px button while the plain `.btn` beside it rendered 38px —
   measured on the wizard, where the primary action carries `btn-lg`. These
   rules are more specific than the `.btn` base above, so the order holds. */
.btn.btn-sm { min-height: 2rem; padding: var(--eq-space-1) var(--eq-space-3);
  font-size: var(--eq-text-xs); border-radius: var(--eq-radius-xs); }
.btn.btn-lg { min-height: 48px; padding: var(--eq-space-3) var(--eq-space-6);
  font-size: var(--eq-text-body); }

/* Block buttons keep the touch floor on any width. */
.btn.btn-block { min-height: var(--eq-control-min-touch); }

/* ---- Focus: one ring, every control, visible on every theme --------------
   Bootstrap's own focus ring is a 0.2rem shadow in its hardcoded blue, which
   a tenant accent cannot reach and which `/signup/`'s override reduced to
   #e8effc on white — 1.12:1, i.e. invisible. This is an outline plus a soft
   halo: the outline survives a forced-colours mode and a dark canvas, the
   halo gives it the house look. `:focus-visible` only, so a mouse click does
   not paint a ring the keyboard user needs.

   THE HALO IS NEVER THE INDICATOR. --eq-ring is that same tint: 1.18-1.20:1
   in light, 1.30-1.49 in the dark palettes, 1.38 in high contrast. The
   paragraph above already said so when the front desk's own sheet shipped
   `:focus-visible { box-shadow: var(--eq-ring); outline: 0 }` on seven
   controls a day later, because a number in a comment stops nobody and the
   test beside it only checked that a :focus-visible selector EXISTED.
   tests/cssguard/test_focus_indicator.py now resolves what each focus rule
   in the kit actually draws and measures it against the surface behind it in
   every palette: `outline: 0` or `none` on a focus state needs a
   replacement of 2px and 3:1 in the same cascade, or it fails. */
.btn:focus { outline: none; box-shadow: none; }
.btn:focus-visible {
  outline: 2px solid var(--eq-accent-ink);
  outline-offset: 2px;
  box-shadow: var(--eq-ring);
}

/* ---- Pressed ------------------------------------------------------------- */
.btn:active,
.btn.active { transform: translateY(1px); }

/* ---- Disabled -----------------------------------------------------------
   `.disabled` on an <a> does not stop a click, so pointer-events has to. */
.btn:disabled,
.btn.disabled,
fieldset:disabled .btn {
  opacity: .55;
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}
a.btn.disabled { pointer-events: none; }

/* ---- Loading ------------------------------------------------------------
   A submit that takes a second with no feedback gets clicked again — the
   shell already carries a hand-rolled spinner for the PDF buttons for
   exactly this reason. One state class, with the label hidden rather than
   replaced so the button cannot change width mid-click. Pair it with
   `aria-busy="true"` so it is announced; CSS cannot do that part. */
.btn.is-loading {
  position: relative;
  color: transparent !important;   /* beats the variant's own `color` */
  pointer-events: none;
}
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 1em; height: 1em;
  margin: -.5em 0 0 -.5em;
  border: 2px solid currentColor;
  border-right-color: var(--eq-on-accent);
  border-radius: 50%;
  animation: eq-spin .6s linear infinite;
  color: var(--eq-accent);          /* currentColor for the ring, not the label */
}
.btn-secondary.is-loading::after,
.btn-light.is-loading::after,
.btn-outline-primary.is-loading::after { border-right-color: var(--eq-accent); color: var(--eq-line); }
@keyframes eq-spin { to { transform: rotate(360deg); } }

/* ---- Variants ------------------------------------------------------------
   Primary is a gradient between the two accent stops. Both come from the
   tenant's brand colour when it has one, and `--eq-on-accent` is computed
   against the fill, so a pale brand gets dark text instead of an unreadable
   white one. */
/* The gradient runs --eq-accent -> --eq-accent-deep, NOT --eq-accent-2 ->
   --eq-accent. `--eq-on-accent` is computed by lib/theme.py against
   `--eq-accent`, so only that stop carries a contrast guarantee: the lighter
   --eq-accent-2 (#3b82f6) under white measures 3.68:1, which fails AA for
   normal text and was therefore the left-hand half of the primary button on
   every authenticated screen. Both stops now clear it — 6.70:1 and 13.16:1
   on the stock palette — and the button is still a gradient. */
.btn-primary {
  background: linear-gradient(135deg, var(--eq-accent), var(--eq-accent-deep));
  border-color: var(--eq-accent);
  color: var(--eq-on-accent);
  box-shadow: 0 10px 22px -12px var(--eq-accent-shadow);
}
.btn-primary:hover {
  background: var(--eq-accent-deep);
  border-color: var(--eq-accent-deep);
  color: var(--eq-on-accent);
  box-shadow: 0 16px 30px -12px var(--eq-accent-shadow);
  /* No lift on hover. DESIGN.md: "the element does not move. A nav item
     that slides under the pointer is a nav item people misclick." The
     :active press below still moves, which is tactile feedback for a
     tap the user has already committed to, not a moving target. */
}
/* A keyboard user gets the hover fill as well as the ring: the ring alone,
   on a gradient, is easy to lose at a glance across a wide toolbar. */
.btn-primary:focus-visible { background: var(--eq-accent-deep); border-color: var(--eq-accent-deep); }
.btn-primary:active,
.btn-primary.active,
.btn-primary:not(:disabled):not(.disabled):active {
  background: var(--eq-accent-deep);
  border-color: var(--eq-accent-deep);
  color: var(--eq-on-accent);
  box-shadow: none;
  transform: translateY(1px);
}
.btn-primary:disabled,
.btn-primary.disabled { background: var(--eq-accent); border-color: var(--eq-accent); color: var(--eq-on-accent); }

.btn-secondary {
  background: var(--eq-surface-2);
  border-color: var(--eq-field-line);
  color: var(--eq-text);
  box-shadow: none;
}
.btn-secondary:hover {
  background: var(--eq-surface-2);
  border-color: var(--eq-muted);
  color: var(--eq-ink);
}
.btn-secondary:active,
.btn-secondary:not(:disabled):not(.disabled):active {
  background: var(--eq-surface-2); border-color: var(--eq-muted); color: var(--eq-ink); transform: translateY(1px);
}

.btn-outline-primary {
  background: transparent;
  color: var(--eq-accent-ink);
  border-color: var(--eq-accent-2);
}
.btn-outline-primary:hover,
.btn-outline-primary:not(:disabled):not(.disabled):active {
  background: var(--eq-accent);
  border-color: var(--eq-accent);
  color: var(--eq-on-accent);
}

/* Secondary/dark outlines: Bootstrap's own grey is a 2.4:1 ghost on a dark
   panel, and one of those buttons is the "follow the organization's default"
   control on the theme picker itself. */
.btn-outline-secondary,
.btn-outline-dark {
  background: transparent;
  color: var(--eq-text);
  border-color: var(--eq-field-line);
}
.btn-outline-secondary:hover,
.btn-outline-dark:hover,
.btn-outline-secondary:not(:disabled):not(.disabled):active,
.btn-outline-dark:not(:disabled):not(.disabled):active {
  background: var(--eq-surface-2);
  border-color: var(--eq-muted);
  color: var(--eq-ink);
}

/* Success is the check-in affirmative. `--eq-emerald` is the DECORATIVE
   green and the palette's own comment says it is never used for words — so
   the words that sit ON it take --eq-on-emerald, a foreground computed per
   theme exactly as --eq-on-accent is. White here measured 2.54:1 in light
   and 1.92:1 in dark; the emerald is a light green in both and a dark green
   in high contrast, so no single literal could have served all three. */
.btn-success {
  background: linear-gradient(135deg, var(--eq-emerald), var(--eq-emerald-dp));
  border-color: var(--eq-emerald-dp);
  color: var(--eq-on-emerald);
  box-shadow: var(--eq-shadow);
}
.btn-success:hover {
  background: var(--eq-emerald-dp); border-color: var(--eq-emerald-dp); color: var(--eq-on-emerald);
}
.btn-success:not(:disabled):not(.disabled):active {
  background: var(--eq-emerald-dp); border-color: var(--eq-emerald-dp); color: var(--eq-on-emerald); transform: translateY(1px);
}

/* Danger. The shell hardcoded #dc3545 here, which no theme could reach —
   under the dark palette it sat as a saturated Bootstrap red beside
   lightened everything else. */
.btn-danger {
  background: var(--eq-bad);
  border-color: var(--eq-bad);
  color: var(--eq-on-bad);
  box-shadow: none;
}
.btn-danger:hover,
.btn-danger:not(:disabled):not(.disabled):active { background: var(--eq-bad); border-color: var(--eq-bad); color: var(--eq-on-bad); filter: brightness(.92); }
.btn-outline-danger { background: transparent; color: var(--eq-bad); border-color: var(--eq-bad); }
.btn-outline-danger:hover,
.btn-outline-danger:not(:disabled):not(.disabled):active { background: var(--eq-bad); border-color: var(--eq-bad); color: var(--eq-on-bad); }

/* `#fff` stood here until 2026-11-28. The dark theme lightens --eq-warn to
   #f0b36b, so the label on a warning button measured 1.85:1 — and the
   outline variants are worse, because their FILL only appears on hover, so
   the control looks fine until a finger is on it. --eq-on-warn is the
   per-theme answer; the pairs are asserted in tests/csslayers. */
.btn-warning { background: var(--eq-warn); border-color: var(--eq-warn); color: var(--eq-on-warn); }
.btn-warning:hover { background: var(--eq-warn); border-color: var(--eq-warn); color: var(--eq-on-warn); filter: brightness(.92); }
.btn-outline-warning { background: transparent; color: var(--eq-warn); border-color: var(--eq-warn); }
.btn-outline-warning:hover,
.btn-outline-warning:not(:disabled):not(.disabled):active { background: var(--eq-warn); border-color: var(--eq-warn); color: var(--eq-on-warn); }

.btn-light { background: var(--eq-surface); border-color: var(--eq-line); color: var(--eq-text); box-shadow: none; }
.btn-light:hover { background: var(--eq-surface-2); border-color: var(--eq-field-line); color: var(--eq-ink); }

/* A text button. Bootstrap's `.btn-link` underlines on hover and inherits a
   blue no theme can reach. */
.btn-link {
  background: none;
  border-color: transparent;
  box-shadow: none;
  color: var(--eq-accent-ink);
  font-weight: var(--eq-weight-semibold);
}
.btn-link:hover { color: var(--eq-accent-2); text-decoration: underline; transform: none; }

/* A button that is only an icon. 2rem is below the 44px tap floor by design —
   these sit in dense card headers and table rows beside a real control — but
   it gets the floor back on a touch width with the rest of them. */
.btn-icon {
  width: var(--eq-control-min); height: var(--eq-control-min);
  min-height: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--eq-surface); border: 1px solid var(--eq-line); color: var(--eq-muted);
  border-radius: var(--eq-radius-control);
}
.btn-icon > i { margin-right: 0 !important; }   /* beats the `:not(:only-child)` gap when a label is sr-only */
.btn-icon:hover { color: var(--eq-accent-ink); border-color: var(--eq-accent); background: var(--eq-surface); }

/* ============================================================================
   2. FIELDS — input, select, textarea
   ========================================================================== */

/* The base control. This replaces, byte for byte of behaviour, the six
   border/radius systems the audit found: #ced4da/0.25rem (main.css),
   #e3e6f0/0.375rem (the shell), #d1d5db/0.375rem and /0.5rem (two bulkmode
   screens), 2px #e1e5e9/8px and 2px #e2e8f0/0.75rem (two login pages). */
.form-control,
.custom-select {
  min-height: var(--eq-control-min);
  height: auto;
  /* Longhands, deliberately, and NO padding-right.
     Bootstrap draws this control's chevron as a background image pinned
     `right .75rem center` at 8px wide, and reserves `padding-right: 1.75rem`
     for it. A symmetric `padding: x var(--eq-space-3)` here overrode that
     reservation while leaving the image — we set `background-color`, not the
     `background` shorthand — so the arrow sat on top of the value. Most
     visible on the DataTables length menu over every report table, where the
     chevron landed across the "25".
     The space scale has no 1.75rem step (it runs 24px then 32px), and
     inventing one to mirror a vendor asset's geometry would be the wrong
     reason to add a scale step. The dimension belongs to whoever draws the
     chevron, so Bootstrap's own 1.75rem stands here. Where the kit has to
     restate it at a higher specificity (the DataTables length menu below) it
     uses --eq-space-8, which is on the grid and leaves more room, not less. */
  padding-top: var(--eq-space-2);
  padding-bottom: var(--eq-space-2);
  padding-left: var(--eq-space-3);
  font-size: var(--eq-control-font);
  font-weight: var(--eq-weight-regular);
  line-height: var(--eq-leading-normal);
  color: var(--eq-text);
  background-color: var(--eq-field);
  border: 1px solid var(--eq-field-line);
  border-radius: var(--eq-radius-control);
  transition: border-color var(--eq-dur-1) var(--eq-ease),
              box-shadow var(--eq-dur-1) var(--eq-ease),
              background-color var(--eq-dur-1) var(--eq-ease);
}
/* --eq-muted, not --eq-faint. The palette lists placeholders under "faint"
   and faint is 2.56:1 on a white field — below AA, and a placeholder is the
   only label some of these fields have ("Visitor Lookup" on the search in
   templates/macros/form.html, imported by 78 templates). --eq-muted is the
   lightest value the palette allows for words: 5.46 / 6.88 / 9.44 across the
   three themes. The two rules this replaces were #6c757d (4.68:1, passed)
   and the shell's #a0aec0 (2.2:1, did not). */
.form-control::placeholder { color: var(--eq-muted); opacity: 1; }

.form-control:hover:not(:disabled):not([readonly]),
.custom-select:hover:not(:disabled) { border-color: var(--eq-muted); }

.form-control:focus,
.custom-select:focus {
  outline: none;
  border-color: var(--eq-accent);
  background-color: var(--eq-field);
  color: var(--eq-text);
  box-shadow: var(--eq-ring);
}
/* Keyboard focus additionally gets the outline, for the same reason buttons
   do: a 3px tinted halo is a look, an outline is a guarantee. */
.form-control:focus-visible,
.custom-select:focus-visible { outline: 2px solid var(--eq-accent-ink); outline-offset: 1px; }

.form-control:disabled,
.form-control[readonly],
.custom-select:disabled {
  background-color: var(--eq-surface-2);
  color: var(--eq-muted);
  opacity: 1;
  cursor: not-allowed;
}
/* A readonly field is still readable and still copyable — it is not disabled. */
.form-control[readonly] { color: var(--eq-text); cursor: text; }

/* ---- Native select -------------------------------------------------------
   Bootstrap 4's `.form-control` on a <select> does NOT suppress the browser's
   own caret, so a custom chevron drawn on top produces two. `appearance:none`
   plus one SVG chevron, which is what css/form-alignment-fix.css existed to
   do; it is folded in here so the control is defined once. The chevron is
   painted in currentColor-ish ink via a token-independent stroke, because a
   data: URI cannot read a custom property — so it is drawn in the one colour
   that reads on both a white and a dark field: the muted ink, at 60% through
   `opacity` on the element is not possible, hence two URIs under the themes
   below. */
select.form-control,
select.custom-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%235b6b7d' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right var(--eq-space-3) center;
  background-size: 16px 12px;
  text-align: left;
  text-indent: 0;
  cursor: pointer;
}
select.form-control option { padding: var(--eq-space-1) var(--eq-space-3); text-align: left; }
/* The chevron is a baked-in stroke colour, so the two dark-field themes get
   their own. This is the one place a hex appears in this file, and it is a
   data: URI the cascade cannot reach any other way. */
body.theme-dark select.form-control,
body.theme-dark select.custom-select,
body.theme-midnight select.form-control,
body.theme-midnight select.custom-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%239aa7b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}
/* Warm light keeps a light field, so it keeps the light chevron — but the
   stroke is the warm muted ink rather than the cool one, because a cool grey
   glyph on a cream field is the one place this palette shows a seam. */
body.theme-warm select.form-control,
body.theme-warm select.custom-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236a6052' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}
body.theme-contrast select.form-control,
body.theme-contrast select.custom-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2314181f' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.5' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

/* ---- Textarea ------------------------------------------------------------ */
textarea.form-control {
  min-height: calc(var(--eq-control-min) * 2);
  resize: vertical;
  line-height: var(--eq-leading-relaxed);
}

/* ---- Checkbox and radio --------------------------------------------------
   Enough to make the native control match the accent and clear the tap floor
   in a list; the markup stays native, which is what keeps the roles matrix on
   the wizard screen-reader-correct. */
.form-check-input,
input[type="checkbox"],
input[type="radio"] { accent-color: var(--eq-accent); }
.form-check-input:focus-visible,
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible { outline: 2px solid var(--eq-accent-ink); outline-offset: 2px; }

/* ---- Chrome autofill ----------------------------------------------------
   Autofill paints its own yellow-ish field and its own text colour, neither
   of which any theme can reach. The 1000px inset shadow is the standard way
   to repaint it; the 5000s transition stops Chrome re-applying on blur. */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--eq-text);
  -webkit-box-shadow: 0 0 0 1000px var(--eq-field) inset;
  transition: background-color 5000s ease-in-out 0s;
}

/* ---- Validation ---------------------------------------------------------- */
.form-control.is-invalid,
.was-validated .form-control:invalid {
  border-color: var(--eq-bad);
  background-image: none;      /* the icon moved to the field row's own marker */
  padding-right: var(--eq-space-3);
}
.form-control.is-invalid:focus,
.was-validated .form-control:invalid:focus { box-shadow: 0 0 0 3px var(--eq-bad-soft); }
.form-control.is-valid,
.was-validated .form-control:valid { border-color: var(--eq-good); background-image: none;
  padding-right: var(--eq-space-3); }

/* ---- Input groups -------------------------------------------------------- */
.input-group-text {
  background-color: var(--eq-surface-2);
  border: 1px solid var(--eq-field-line);
  color: var(--eq-muted);
  border-radius: var(--eq-radius-control);
}

/* ============================================================================
   3. FORM ROW — label, control, hint, error
   ========================================================================== */

/* Bootstrap's `.form-group` is the row 78 templates already emit through
   `templates/macros/form.html`; `.eq-field` is the same thing for new markup
   that wants the hint and error slots without the Bootstrap name. */
.form-group,
.eq-field { margin-bottom: var(--eq-space-4); }
.card .form-group:last-child,
.card .eq-field:last-child { margin-bottom: 0; }

/* Labels are sentence case. The shell set `uppercase` + 0.5px tracking on
   every form label in the app, against sentence case on the signup form and
   the wizard — the same one job, two typographies, measured in one session. */
.form-group > label,
.eq-field > label,
.eq-label {
  display: inline-block;
  margin-bottom: var(--eq-space-1);
  font-size: var(--eq-text-sm);
  font-weight: var(--eq-weight-semibold);
  line-height: var(--eq-leading-normal);
  letter-spacing: normal;
  text-transform: none;
  color: var(--eq-text);
  vertical-align: middle;
}
.form-group .required,
.eq-field .required,
.eq-label .required { color: var(--eq-bad); margin-left: var(--eq-space-1); }

/* The hint goes under the control, the error replaces it. Both are
   `--eq-muted`/`--eq-bad`, both >=4.5:1 on the surface. */
.eq-hint,
.form-text {
  display: block;
  margin-top: var(--eq-space-1);
  font-size: var(--eq-text-xs);
  line-height: var(--eq-leading-normal);
  color: var(--eq-muted);
}
.eq-error,
.invalid-feedback {
  display: block;
  margin-top: var(--eq-space-1);
  font-size: var(--eq-text-xs);
  font-weight: var(--eq-weight-semibold);
  line-height: var(--eq-leading-normal);
  color: var(--eq-bad);
}
.eq-error:empty, .invalid-feedback:empty { display: none; }

/* A row of fields that collapses to one column on a phone. */
.eq-field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 0 var(--eq-space-4);
}

.form-inline .form-control { display: inline-block; width: auto; vertical-align: middle; }

/* ============================================================================
   4. TABLES
   ========================================================================== */

/* Bootstrap's `.table` for the ~25 screens that use it. `.dq-table` in
   dashboard-common.css is the dashboard/report table and stays separate: it
   has sticky headers and a print contract this one does not need. */
.table {
  width: 100%;
  margin-bottom: var(--eq-space-4);
  background-color: var(--eq-surface);
  color: var(--eq-text);
  font-size: var(--eq-text-sm);
}
.table thead th {
  background: var(--eq-surface-2);
  color: var(--eq-muted);
  font-size: var(--eq-text-caption);
  font-weight: var(--eq-weight-semibold);
  letter-spacing: var(--eq-tracking-wide);
  text-transform: uppercase;   /* kept: small-caps headers are the kit's own
                                  convention, in .dq-table too */
  padding: var(--eq-space-3) var(--eq-space-4);
  border-bottom: 1px solid var(--eq-line);
  border-top: none;
  vertical-align: middle;
}
.table td {
  padding: var(--eq-space-3) var(--eq-space-4);
  vertical-align: middle;
  border-top: 1px solid var(--eq-line);
  color: var(--eq-text);
  line-height: var(--eq-leading-normal);
}
.table tbody tr { transition: background-color var(--eq-dur-1) var(--eq-ease); }
.table-hover tbody tr:hover,
.table tbody tr:hover { background-color: var(--eq-accent-wash); }
.table-striped tbody tr:nth-of-type(odd) { background-color: var(--eq-surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums lining-nums; }

/* A wide table scrolls inside its own box. `.container-fluid` is
   `overflow-x: clip` on purpose so sticky headers work, which means a table
   that overflows is CLIPPED, not scrolled — data unreachable with no
   scrollbar. This is the escape hatch, and `.dq-scroll` is its twin. */
.table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* DataTables chrome. Its generated controls carry no class of ours, so they
   fall back to browser defaults beside the kit's inputs unless dressed here
   — the same reason dashboard-common.css dresses the dual list box. */
.dataTables_wrapper .dataTables_filter input {
  min-height: var(--eq-control-min);
  padding: var(--eq-space-2) var(--eq-space-3);
  font-size: var(--eq-text-sm);
  color: var(--eq-text);
  background-color: var(--eq-field);
  border: 1px solid var(--eq-field-line);
  border-radius: var(--eq-radius-control);
}

/* The length menu's select, apart from the filter input, because it has a
   chevron and the input does not. Longhands and NO padding-right: the kit
   REPLACES Bootstrap's arrow with its own 16px one in `select.custom-select`
   and reserves 2.25rem for it there. A symmetric `padding: x var(--eq-space-3)`
   on the shared rule overrode that reservation at (0,2,1) and put the arrow
   across the value -- most visibly on "Show 25 entries" over every report
   table. Letting the rule that DRAWS the chevron own the space it needs is
   the fix; a number restated here is a second place to get it wrong, and the
   first number I tried (32px) was already 4px short of the kit's own 36. */
.dataTables_wrapper .dataTables_length select {
  min-height: var(--eq-control-min);
  padding-top: var(--eq-space-2);
  padding-bottom: var(--eq-space-2);
  padding-left: var(--eq-space-3);
}
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
  outline: none; border-color: var(--eq-accent); box-shadow: var(--eq-ring);
}
/* These two ARE .form-control in the markup DataTables generates, and still
   took no outline: the rule above is (0,3,1) and beats the field's
   `.form-control:focus-visible` at (0,2,0), so its `outline: none` stood and
   the search box over every report table showed focus as the halo alone —
   1.14:1 measured in light. Restated here at the specificity that wins.

   INSET, unlike the other fields. DataTables puts these flush in the corners
   of its wrapper, and both the wrapper and the .dq-scroll around it are
   scroll containers, which clip a descendant's outline: at `offset: 1px` the
   browser drew the ring and then cut two of its four sides off — 464 of the
   988 pixels a 2px perimeter needs. Drawn inside the field's own box there
   is nothing to clip it, and it is read against --eq-field.

   -4px AND NOT -2px, and that was measured too. At -2px the ring lies on
   top of the field's own border. In five palettes that is a 1px hairline
   and nobody would know; in high contrast the border is 2px of
   --eq-field-line, so the whole ring replaced a dark grey line with a dark
   blue one — 1.62:1 between the two states, in the theme people pick
   because they need the difference. At -4px it clears a 2px border in
   every palette and every pixel of it is new. */
.dataTables_wrapper .dataTables_filter input:focus-visible,
.dataTables_wrapper .dataTables_length select:focus-visible {
  outline: 2px solid var(--eq-accent-ink); outline-offset: -4px;
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter { color: var(--eq-muted); font-size: var(--eq-text-sm); }
.dataTables_wrapper .dataTables_paginate .paginate_button { border-radius: var(--eq-radius-xs); }

/* ============================================================================
   5. CARDS
   ========================================================================== */

.card {
  background-color: var(--eq-surface);
  border: 1px solid var(--eq-line);
  border-radius: var(--eq-radius);
  box-shadow: var(--eq-shadow);
  margin-bottom: var(--eq-space-6);
  transition: box-shadow var(--eq-dur-3) var(--eq-ease),
              transform var(--eq-dur-3) var(--eq-ease);
}
/* The card does not lift either. _form.html's own comment on this screen
   says it: "a card that lifts on hover moves the row being read". The
   deeper shadow is the whole hover state. */
.card:hover { box-shadow: var(--eq-shadow-hover); }

/* The header is a flex row: title on the left, controls pushed to the right
   edge. This is `button-overlap-fix.css` folded in — the file that was
   `<link>`ed at the bottom of <body> and therefore held the last word in the
   whole application for over a year, to deliver a `margin-left: auto`. Its
   60px `min-height` is kept: eight pages' headers were authored against it. */
.card-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--eq-space-2) var(--eq-space-3);
  min-height: 60px;        /* eight pages' headers were authored against it */
  padding: var(--eq-space-3) var(--eq-space-5);
  background: var(--eq-surface);
  border-bottom: 1px solid var(--eq-line);
  font-weight: var(--eq-weight-bold);
  color: var(--eq-ink);
  border-top-left-radius: var(--eq-radius);
  border-top-right-radius: var(--eq-radius);
}
.card-header > .btn-group,
.card-header > .btn,
.card-header > a.btn,
.card-header > .float-right,
.card-header > .card-header-actions { margin-left: auto; }
/* …but only the FIRST one claims the space, or two buttons end up at
   opposite ends of the header. */
.card-header > .btn-group ~ .btn-group,
.card-header > .btn ~ .btn,
.card-header > a.btn ~ a.btn,
.card-header > .btn-group ~ .btn,
.card-header > .btn ~ .btn-group { margin-left: 0; }
.card-header h1, .card-header h2, .card-header h3,
.card-header h4, .card-header h5, .card-header h6 { margin: 0; font-size: var(--eq-text-body);
  font-weight: var(--eq-weight-semibold); line-height: var(--eq-leading-snug); color: var(--eq-ink); }

.card-body { padding: var(--eq-space-5); }
.card-footer {
  padding: var(--eq-space-3) var(--eq-space-5);
  background: var(--eq-surface-2);
  border-top: 1px solid var(--eq-line);
  color: var(--eq-muted);
  border-bottom-left-radius: var(--eq-radius);
  border-bottom-right-radius: var(--eq-radius);
}

/* `.content-section` is the shell's own card. Same thing, same look. */
.content-section {
  background-color: var(--eq-surface);
  border: 1px solid var(--eq-line);
  border-radius: var(--eq-radius);
  box-shadow: var(--eq-shadow);
}

/* ============================================================================
   6. BADGES
   ========================================================================== */

.badge { border-radius: var(--eq-radius-pill); padding: .38em .75em;
  font-weight: var(--eq-weight-semibold); letter-spacing: .01em; }
.badge-primary { background: var(--eq-accent); color: var(--eq-on-accent); }
.badge-secondary { background: var(--eq-surface-2); color: var(--eq-text); }
.badge-success { background: var(--eq-emerald); color: var(--eq-on-emerald); }
/* --eq-accent, not --eq-accent-2: --eq-on-accent is only guaranteed
   against --eq-accent, and white on #3b82f6 is 3.68:1. */
.badge-info    { background: var(--eq-accent); color: var(--eq-on-accent); }
.badge-warning { background: var(--eq-warn); color: var(--eq-on-warn); }
.badge-danger  { background: var(--eq-bad); color: var(--eq-on-bad); }
.badge-light   { background: var(--eq-surface-2); color: var(--eq-muted); }

/* ============================================================================
   6b. ALERTS

   Bootstrap 4.6 paints these from its own palette — `.alert-warning` is
   `#fff3cd` with `#856404` on it — and no token in this application could
   reach any of them. `#flash-messages` is rendered by the shared layout, so
   every flash on every screen was a pale cream panel sitting on the dark
   canvas, with the dismiss `×` inheriting the theme's near-white ink at
   1.06:1. The three soft/strong token pairs are already guaranteed to clear
   AA in all three themes (tests/csslayers/test_control_contrast.py), so the
   alerts are simply built out of them.

   `.alert-primary` and `.alert-secondary` take the accent and surface pairs
   for the same reason. `.alert-link` has to be the strong colour rather than
   the accent, or a link inside a danger alert reads as a different message
   than the alert it is in.
   ========================================================================== */

.alert { border: 1px solid transparent; border-radius: var(--eq-radius-sm); }
.alert-success { background: var(--eq-good-soft); border-color: var(--eq-good); color: var(--eq-good); }
.alert-info    { background: var(--eq-accent-soft); border-color: var(--eq-accent-edge); color: var(--eq-accent-ink); }
.alert-primary { background: var(--eq-accent-soft); border-color: var(--eq-accent-edge); color: var(--eq-accent-ink); }
.alert-warning { background: var(--eq-warn-soft); border-color: var(--eq-warn); color: var(--eq-warn); }
.alert-danger  { background: var(--eq-bad-soft); border-color: var(--eq-bad); color: var(--eq-bad); }
.alert-secondary,
.alert-light,
.alert-dark    { background: var(--eq-surface-2); border-color: var(--eq-line); color: var(--eq-text); }
.alert .alert-link { color: inherit; text-decoration: underline;
  font-weight: var(--eq-weight-bold); }
/* The dismiss button inherits `color` from the document, not from the alert,
   so on a tinted panel it was the one glyph still painted in the theme ink.
   `currentColor` ties it to whichever alert it is sitting in. */
.alert .close,
.alert button.close {
  color: currentColor;
  text-shadow: none;
  opacity: .7;
}
.alert .close:hover,
.alert button.close:hover { color: currentColor; opacity: 1; }

/* ============================================================================
   7. TOUCH
   ========================================================================== */

/* Below 760px every control gets the 44px tap floor and 16px text.
   SIXTEEN PIXELS IS NOT A PREFERENCE: iOS Safari zooms the page when a field
   smaller than 16px takes focus, and it does not zoom back out. Measured on
   this app at 390x844: wizard inputs 14.72px, branding 13.6-14.4px, login
   15.2px — every one of them zooms. `/signup/` is the only screen that got
   this right, and it wrote down why; nothing downstream inherited it, because
   there was nothing to inherit from. There is now.

   The breakpoint is 767.98px: the max-width form of Bootstrap 4.6.2's `md`
   tier edge, which is the set tests/cssguard/test_breakpoints.py codifies
   and the whole app's grid already uses. It is wider than the 576px the old
   form-alignment-fix.css used, which is why that file never fixed anything
   above a phone. It still does not catch an iPad in portrait, which is
   exactly 768px — the `(hover: none) and (pointer: coarse)` block below is
   what catches that, and a pointer query is the right instrument for it
   anyway, because a 1024px landscape tablet is still a finger. */
@media (max-width: 767.98px) {
  .form-control,
  .custom-select,
  select.form-control,
  textarea.form-control,
  .dataTables_wrapper .dataTables_filter input,
  .dataTables_wrapper .dataTables_length select {
    /* THE ONE `!important` IN THIS FILE THAT IS NOT ABOUT AN INLINE STYLE,
       and it is deliberate. {% block page_css %} and {% block scripts %}
       render AFTER this file by design, so a page's own CSS wins — which is
       right for a colour or a width and wrong for this. Measured on
       /eduqueue/register/ with the rule unforced: min-height took (41px ->
       44px) but font-size did not, because the page sets a 14px
       `.form-control` of its own. The field is then still 14px, iOS Safari
       still zooms the page on focus, and still does not zoom back.

       16px is a platform behaviour, not a design choice, so the component
       layer asserts it. A page that genuinely needs smaller text on a phone
       can say so with its own media query and `!important`; it then owns the
       zoom. Scoped to <=760px, so no desktop rule is affected.
       tests/csslayers/test_cascade_order.py asserts this stays forced. */
    font-size: var(--eq-control-font-touch) !important;
    min-height: var(--eq-control-min-touch);
  }
  .btn { min-height: var(--eq-control-min-touch); }
  .btn.btn-sm { min-height: 2.25rem; }
  .btn-icon { width: var(--eq-control-min-touch); height: var(--eq-control-min-touch); }
  .card-body { padding: var(--eq-space-4); }
  .card-header { padding: var(--eq-space-3) var(--eq-space-4); }
  .table thead th, .table td { padding: var(--eq-space-2) var(--eq-space-3); }
}

/* A pointer that cannot hover is a finger, whatever the viewport says — a
   check-in tablet in landscape is 1024px wide and still gets tapped. */
@media (hover: none) and (pointer: coarse) {
  .btn { min-height: var(--eq-control-min-touch); }
  .form-control, .custom-select { min-height: var(--eq-control-min-touch); font-size: var(--eq-control-font-touch); }
  .card:hover { transform: none; box-shadow: var(--eq-shadow); }
  .btn:hover { transform: none; }
}

/* Every transition and every transform in this file, off in one place. The
   loading spinner is SLOWED rather than stopped: it is the only animation
   here that carries information ("the click registered, wait"), and a
   stationary ring says the opposite of what it means. */
@media (prefers-reduced-motion: reduce) {
  .btn, .card, .form-control, .custom-select, .table tbody tr { transition: none; }
  .btn:hover, .card:hover, .btn:active, .btn-primary:hover { transform: none; }
  .btn.is-loading::after { animation-duration: 2s; }
}

/* ============================================================================
   8. PRINT
   ========================================================================== */

/* dashboard-common.css reverts the palette to the light values for print, for
   every theme, and hides the chrome. What it cannot know about is these
   controls: a gradient button prints as a grey slab and a focus ring prints
   as a halo. Keep the outline so a form printed for a signature still reads
   as a form. */
@media print {
  .btn {
    background: none !important;
    color: #000 !important;
    border: 1px solid var(--eq-line) !important;
    box-shadow: none !important;
    transform: none !important;
  }
  .btn.is-loading { color: #000 !important; }
  .btn.is-loading::after { display: none; }
  .form-control, .custom-select {
    background: none !important;
    color: #000 !important;
    border: 1px solid var(--eq-line) !important;
    box-shadow: none !important;
  }
  select.form-control { background-image: none !important; }
  .card, .content-section { box-shadow: none !important; border-color: var(--eq-line) !important; break-inside: avoid; }
  .card:hover { transform: none !important; }
  .card-header { background: none !important; min-height: 0; }
  .badge { border: 1px solid var(--eq-line); color: #000 !important; background: none !important;
    border-radius: var(--eq-radius-xs); }
  .table thead th { background: none !important; color: #000 !important; }
}
