/* Dialogs: one treatment, one backdrop, one stacking answer.
   ==========================================================================

   This file used to be three things. The COSMETIC half — a light-blue
   `#e3f2fd -> #90caf9` body gradient with `rgba(255,255,255,.95)` panels
   floating on it — was the 2014 look and came out on 2026-11-27. The
   FUNCTIONAL half was modal opacity and z-index, because a dimmed
   visitor-detail dialog (fc182b94) is what happens when they are wrong.

   On 2026-11-28 it became the third thing too: the dialog kit. 394 colour
   declarations sat in `style=""` attributes on dialog markup across 12
   templates — the highest-specificity declaration in CSS short of
   `!important`, so no stylesheet and no theme could reach them, which was
   true even of the 292 that already spelled a `var(--eq-*)` token. They are
   here now as classes. docs/modal-audit-2026-11-28.md is the measurement
   that justified each decision: every dialog in the product driven OPEN
   under all three themes at two widths, which is the thing the theme
   coverage run of the same morning could not do.

   WHY HERE AND NOT A NEW STYLESHEET. A new sheet has to be linked, and there
   are only two places to link one. `layouts/base.html`'s head order is
   pinned from both directions by tests/csslayers/test_cascade_order.py and
   tests/cssguard/test_body_stylesheets.py, and it is owned by another pass.
   Inside `<body>` is the Phase-3 regression that
   tests/cssguard/test_body_stylesheets.py exists to prevent — a sheet linked
   there is the last word in the whole application on every page. This file
   is already linked from the head in the pinned position, already declares
   itself the owner of dialog stacking, and is already the reason
   app-shell.css touches no `.modal*` selector at all. The kit belongs with
   the thing it is a kit for.

   THREE RULES FOR EDITING THE KIT BELOW.

   1. NO FILL ON `.modal-header` OR `.modal-footer`. theme-surfaces.css is
      the last sheet in the cascade and it paints
      `body.theme-dark .modal-header:not([class*="bg-"]):not(.eq-keep-light)`
      — and `.modal-footer`, `.modal-body`, `.modern-modal-*` — with
      `var(--eq-surface) !important`. A header fill declared here is
      therefore correct in Light and flattened in Dark, which is exactly
      where the rhythm is needed most. Separation comes from a hairline and
      the type scale. Where a tinted band is genuinely wanted it goes on
      `.eq-dlg__band`, an inner element those selectors do not reach.
   2. NO `.btn` SELECTORS. components.css loads after this file and owns
      `.btn`/`.btn-primary`/`.form-control`
      (tests/csslayers/test_cascade_order.py enforces it). Dialog buttons are
      `.eq-dlg-btn` and carry no `.btn` class.
   3. TOKENS ONLY, with one stated exception: the backdrop scrim is
      `rgba(0, 0, 0, …)`. A scrim has to stay dark under every theme and
      every ink token inverts, so there is no token for it. `--eq-scrim`
      would be the right fix and does not exist — see the audit.
   ========================================================================== */

/* ── the dialog surface ─────────────────────────────────────────────────── */
.eq-dlg {
  display: flex;
  flex-direction: column;
  /* 3.5rem is Bootstrap's own `1.75rem auto` margin at both ends. */
  max-height: calc(100vh - 3.5rem);
  border: none;
  border-radius: var(--eq-radius);
  overflow: hidden;
  background-color: var(--eq-surface);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .25);
}
.eq-dlg__head,
.eq-dlg__foot { flex: 0 0 auto; }
/* Measured radii before this: 4.8px on 21 dialogs, 12px on two, 16px on one.
   High contrast draws edges instead of shadows, which is the point of the
   theme — a soft shadow disappears entirely on a glare-prone screen. */
body.theme-contrast .eq-dlg {
  box-shadow: none;
  border: 2px solid var(--eq-ink);
}
body.theme-dark .eq-dlg { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .7); }

.eq-dlg__head {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--eq-line);
}
.eq-dlg__head--plain { border-bottom: none; padding-bottom: 0; }

.eq-dlg__band {
  /* The one element in a dialog that may carry a fill — see rule 1. */
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 1.25rem 1.5rem;
  background-color: var(--eq-surface-2);
  border-radius: var(--eq-radius-sm);
  color: var(--eq-text);
}
.eq-dlg__band--accent { background-color: var(--eq-accent-soft); color: var(--eq-accent-ink); }
.eq-dlg__band--bad    { background-color: var(--eq-bad-soft);    color: var(--eq-bad); }
.eq-dlg__band--good   { background-color: var(--eq-good-soft);   color: var(--eq-good); }
.eq-dlg__band--warn   { background-color: var(--eq-warn-soft);   color: var(--eq-warn); }
.eq-dlg__band--square { border-radius: 0; }

.eq-dlg__title {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.02em;
  color: var(--eq-ink);
}
.eq-dlg__title--sm { font-size: 1.125rem; }
.eq-dlg__band .eq-dlg__title { color: inherit; }

.eq-dlg__sub {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: .375rem 0 0;
  font-size: .9375rem;
  color: var(--eq-muted);
}
.eq-dlg__band .eq-dlg__sub { color: inherit; }
.eq-dlg__sub i { font-size: .875rem; }

.eq-dlg__body {
  padding: 1.5rem;
  /* A dialog taller than the window has to scroll inside itself: six of
     them pushed their own footer off the bottom of a 900px screen, and
     #checkoutConfirmationModal measured 956px tall.

     The cap is on the SURFACE and the body flexes, rather than a magic
     `calc(100vh - Nrem)` on the body alone. Two guesses at that number were
     both wrong, for the reason a guess there is always wrong: it has to
     know the height of a header it cannot see, and this dialog's header is
     a tinted band with a 64px glyph, a title and a subtitle in it. Flex
     measures instead of guessing. `min-height: 0` is the part that is easy
     to leave out — a flex item will not shrink below its content without
     it, and the overflow goes back to the page. */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.eq-dlg__body--flush { padding: 0; }
.eq-dlg__body--tight { padding: 1.25rem 1.5rem; }

.eq-dlg__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: .75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--eq-line);
}
.eq-dlg__foot--split { justify-content: space-between; }

/* ── the close affordance ────────────────────────────────────────────────
   One shape everywhere, at the 40px control height the kit already declares,
   with a real focus ring. 10 of the 25 dialogs had no close affordance a
   screen reader or a keyboard could find; on five of them it was the only
   control there was. */
.eq-dlg__close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--eq-control-min);
  height: var(--eq-control-min);
  padding: 0;
  margin: 0;
  border: none;
  border-radius: var(--eq-radius-control);
  background: transparent;
  color: var(--eq-muted);
  font-size: 1.125rem;
  line-height: 1;
  opacity: 1;
  cursor: pointer;
}
.eq-dlg__close:hover,
.eq-dlg__close:focus {
  background-color: var(--eq-surface-2);
  color: var(--eq-ink);
  opacity: 1;
}
.eq-dlg__close:focus-visible {
  outline: 3px solid var(--eq-accent);
  outline-offset: 2px;
}
.eq-dlg__band .eq-dlg__close { color: inherit; }
.eq-dlg__band .eq-dlg__close:hover,
.eq-dlg__band .eq-dlg__close:focus { background-color: var(--eq-accent-tint); color: inherit; }

/* ── the information card ────────────────────────────────────────────────
   The repeated `background: var(--dq-surface); border-radius: .75rem;
   padding: 1.5rem; box-shadow: 0 1px 3px …`, which appeared 14 times across
   three dialogs. A card inside a dialog sits on the dialog's own surface, so
   it needs a border rather than a second shadow — under Dark a shadow on a
   dark panel is invisible and the card had no edge at all. */
.eq-dlg-card {
  height: 100%;
  padding: 1.25rem;
  background-color: var(--eq-surface);
  border: 1px solid var(--eq-line);
  border-radius: var(--eq-radius-sm);
}
.eq-dlg-card--tight  { padding: 1rem; }
.eq-dlg-card--center { text-align: center; }

.eq-dlg-card__title {
  display: flex;
  align-items: center;
  margin: 0 0 1.125rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--eq-ink);
}
/* Was a 6x20px empty <div> in the markup, four times. A rule is decoration,
   so it is drawn rather than described. */
.eq-dlg-card__title::before {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 20px;
  margin-right: .5rem;
  border-radius: 2px;
  background-color: var(--eq-accent);
}
.eq-dlg-card__title--plain::before { display: none; }

/* ── the label / value row ──────────────────────────────────────────────── */
.eq-dlg-fields {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.eq-dlg-field { display: flex; align-items: flex-start; }
.eq-dlg-field.is-hidden { display: none; }
.eq-dlg-field__icon {
  flex: 0 0 16px;
  width: 16px;
  margin: .125rem .75rem 0 0;
  color: var(--eq-muted);
  text-align: center;
}
.eq-dlg-field__main { flex: 1; min-width: 0; }
.eq-dlg-field__label {
  margin: 0;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--eq-muted);
}
.eq-dlg-field__value {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--eq-ink);
  overflow-wrap: anywhere;
}
.eq-dlg-field__value--sm { font-size: .875rem; line-height: 1.4; }
.eq-dlg-field__link {
  font-size: 1rem;
  font-weight: 500;
  color: var(--eq-accent-ink);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.eq-dlg-field__link:hover { color: var(--eq-accent-ink); text-decoration: underline; }

/* ── the stat tile ──────────────────────────────────────────────────────── */
.eq-dlg-stat__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-bottom: .5rem;
  border-radius: 50%;
  background-color: var(--eq-accent-soft);
  color: var(--eq-accent-ink);
  font-size: 1.125rem;
}
.eq-dlg-stat__icon--warn { background-color: var(--eq-warn-soft); color: var(--eq-warn); }
.eq-dlg-stat__icon--good { background-color: var(--eq-good-soft); color: var(--eq-good); }
.eq-dlg-stat__icon--bad  { background-color: var(--eq-bad-soft);  color: var(--eq-bad); }
.eq-dlg-stat__label {
  margin: 0;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--eq-muted);
}
.eq-dlg-stat__value {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--eq-ink);
}
.eq-dlg-stat__value--sm { font-size: 1rem; font-weight: 600; }

/* ── the status chip ────────────────────────────────────────────────────── */
.eq-dlg-chip {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .375rem .75rem;
  border-radius: 9999px;
  font-size: .875rem;
  font-weight: 600;
  white-space: nowrap;
  background-color: var(--eq-surface-2);
  color: var(--eq-text);
}
.eq-dlg-chip--good { background-color: var(--eq-good-soft); color: var(--eq-good); }
.eq-dlg-chip--warn { background-color: var(--eq-warn-soft); color: var(--eq-warn); }
.eq-dlg-chip--bad  { background-color: var(--eq-bad-soft);  color: var(--eq-bad); }
.eq-dlg-chip__dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
  animation: eqDlgPulse 2s infinite;
}

/* ── dialog buttons ─────────────────────────────────────────────────────── */
.eq-dlg-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
}
.eq-dlg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: var(--eq-control-min);
  padding: .5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--eq-radius-control);
  background-color: var(--eq-surface-2);
  color: var(--eq-text);
  font-size: var(--eq-control-font);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.eq-dlg-btn:hover {
  background-color: var(--eq-accent-soft);
  color: var(--eq-accent-ink);
  text-decoration: none;
}
.eq-dlg-btn:focus-visible {
  outline: 3px solid var(--eq-accent);
  outline-offset: 2px;
}
.eq-dlg-btn--quiet { background-color: transparent; color: var(--eq-muted); }
.eq-dlg-btn--quiet:hover { background-color: var(--eq-surface-2); color: var(--eq-ink); }
.eq-dlg-btn--primary {
  padding: .625rem 1.5rem;
  font-weight: 600;
  background-color: var(--eq-accent);
  color: var(--eq-on-accent);
}
.eq-dlg-btn--primary:hover { background-color: var(--eq-accent-deep); color: var(--eq-on-accent); }
.eq-dlg-btn--danger {
  padding: .625rem 1.5rem;
  font-weight: 600;
  background-color: var(--eq-bad);
  color: var(--eq-on-bad);
}
.eq-dlg-btn--danger:hover { background-color: var(--eq-bad); color: var(--eq-on-bad); filter: brightness(.94); }
.eq-dlg-btn--good {
  padding: .625rem 1.5rem;
  font-weight: 600;
  background-color: var(--eq-good);
  color: var(--eq-on-good);
}
.eq-dlg-btn--good:hover { background-color: var(--eq-good); color: var(--eq-on-good); filter: brightness(.94); }
.eq-dlg-btn[disabled],
.eq-dlg-btn.is-disabled {
  background-color: var(--eq-surface-2);
  color: var(--eq-muted);
  cursor: not-allowed;
}
.eq-dlg-btn[disabled]:hover,
.eq-dlg-btn.is-disabled:hover { background-color: var(--eq-surface-2); color: var(--eq-muted); }

/* ── photographs ────────────────────────────────────────────────────────── */
.eq-dlg-photo-wrap { position: relative; display: inline-block; }
.eq-dlg-photo {
  width: 260px;
  height: 260px;
  max-width: 100%;
  border-radius: var(--eq-radius);
  object-fit: cover;
  background-color: var(--eq-surface-2);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, .1);
}
.eq-dlg-photo--zoom { cursor: zoom-in; }
.eq-dlg-photo--sm { width: 180px; height: 180px; }
.eq-dlg-photo__badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid var(--eq-surface);
  background-color: var(--eq-emerald);
  color: var(--eq-on-emerald);
  font-size: 1.125rem;
}
.eq-dlg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--eq-line);
  background-color: var(--eq-surface-2);
}
.eq-dlg-avatar--lg { width: 64px; height: 64px; }

/* A photo shown full-bleed in a lightbox: the surface behind it is a dark
   stage under every theme, because the subject is a photograph.

   Two classes in the selector on purpose. `.eq-dlg--stage` alone is (0,1,0),
   the same as the `.modal-content` rule further down this file, which would
   then win on order and paint the stage `var(--eq-surface)` — measured as
   white-on-white, 1:1, on the first after run. */
.eq-dlg.eq-dlg--stage {
  background-color: rgba(0, 0, 0, .9);
  color: var(--eq-paper, #fff);
}
.eq-dlg.eq-dlg--stage .eq-dlg__head,
.eq-dlg.eq-dlg--stage .eq-dlg__foot { border-color: rgba(255, 255, 255, .18); }
.eq-dlg.eq-dlg--stage .eq-dlg__title,
.eq-dlg.eq-dlg--stage .eq-dlg__close { color: #fff; }
.eq-dlg.eq-dlg--stage .eq-dlg__close:hover { background-color: rgba(255, 255, 255, .15); }

.eq-dlg__note { margin: 0; font-size: .875rem; color: var(--eq-muted); }
.eq-dlg__note--lg { font-size: 1rem; }
.eq-dlg__lead { margin: 0 0 1rem; font-size: 1rem; color: var(--eq-text); }
.eq-dlg__em-bad  { color: var(--eq-bad); }
.eq-dlg__em-good { color: var(--eq-good); }

/* A square glyph tile inside a tinted band: the icon beside a dialog's
   title. Translucent white because it sits on the band's own fill, whatever
   that fill is, and has to read on all four tones. */
.eq-dlg__band-icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--eq-radius-control);
  background-color: rgba(255, 255, 255, .25);
}
.eq-dlg__head-main { flex: 1 1 auto; min-width: 0; }
.eq-dlg__body--centred { text-align: center; padding: 2rem; }
.eq-dlg-actions--centred { justify-content: center; }

/* The 80px confirmation glyph: a destructive confirm, a success, a warning.
   Four copies of it existed across the check-in dialogs, each with its own
   diameter and its own literal. */
.eq-dlg-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  font-size: 2rem;
  background-color: var(--eq-accent-soft);
  color: var(--eq-accent-ink);
}
.eq-dlg-mark--bad  { background-color: var(--eq-bad-soft);  color: var(--eq-bad); }
.eq-dlg-mark--good { background-color: var(--eq-good-soft); color: var(--eq-good); }
.eq-dlg-mark--warn { background-color: var(--eq-warn-soft); color: var(--eq-warn); }

@keyframes eqDlgPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}

/* Two tones the shared button set did not have and two dialogs needed: the
   scheduled-visit quick look offers "Check In" and "Check In & Print Badge"
   side by side, and they have to be distinguishable at a glance by a guard
   who is not reading the labels. The outline one carried `#15803d` and
   `#16a34a` in a style attribute; both are gone. */
.eq-dlg-btn--outline-good {
  padding: .625rem 1.5rem;
  font-weight: 600;
  background-color: var(--eq-surface);
  border: 1.5px solid var(--eq-good);
  color: var(--eq-good);
}
.eq-dlg-btn--outline-good:hover {
  background-color: var(--eq-good-soft);
  color: var(--eq-good);
}
.eq-dlg-btn--emerald {
  padding: .625rem 1.5rem;
  font-weight: 600;
  background-color: var(--eq-emerald);
  color: var(--eq-on-emerald);
}
.eq-dlg-btn--emerald:hover {
  background-color: var(--eq-emerald-dp);
  color: var(--eq-on-emerald);
}

/* A caption over the bottom of a photograph. Dark under every theme for the
   same reason `.eq-dlg--stage` is: it sits on an image, not on a surface. */
.eq-dlg-photo__caption {
  display: none;
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  padding: 6px 12px;
  border-radius: 8px;
  background-color: rgba(0, 0, 0, .7);
  color: #fff;
  font-size: .85rem;
  font-weight: 500;
  text-align: center;
}

/* ── parts belonging to one dialog each ──────────────────────────────────
   These live here rather than in a `<style>` block beside their markup for
   one reason: their markup is inside `eduqueue/page/index.html` and
   `eduqueue/page/lookup.html`, which are full PAGE templates, and a
   `<style>` there renders at cascade position 9 — after the whole kit — so a
   dialog part declared there quietly outranks the kit it is meant to extend.
   That asymmetry is most of why the dialogs drifted in the first place.
   Prefixed per dialog so the scoping is still readable. */

/* The scheduled-visit quick look. */
.eq-sql-notes { display: none; padding: 1.25rem 1.5rem; }
.eq-sql-notes__title::before { background-color: var(--eq-warn); }
.eq-sql-notes__body { margin: 0; font-size: .95rem; line-height: 1.5; }

/* The visitor lookup's image preview and detail dialogs. */
.eq-lk-preview-dialog { max-width: 500px; }
.eq-lk-close { position: absolute; top: -20px; right: -20px; z-index: 1; }
.eq-lk-preview {
  border-radius: 50%;
  object-fit: cover;
  background-color: var(--eq-surface);
  box-shadow: 0 20px 40px rgba(0, 0, 0, .3);
}
/* Was `color: white` with a text shadow, on a stage. The stage sets the
   foreground now, so this is only the type. */
.eq-lk-preview__name { font-size: 1.5rem; text-shadow: 0 2px 10px rgba(0, 0, 0, .5); }
.eq-lk-avatar { width: 240px; height: 240px; border-radius: 50%; }
.eq-lk-tile {
  padding: 1rem;
  border-radius: var(--eq-radius-control);
  background-color: var(--eq-accent-soft);
}
.eq-lk-tile--good { background-color: var(--eq-good-soft); }
.eq-lk-tile__icon { margin-bottom: .5rem; font-size: 1.5rem; color: var(--eq-accent-ink); }
.eq-lk-tile__icon--good { color: var(--eq-good); }
.eq-lk-tile__value { font-size: 1.5rem; }

/* ==========================================================================
   OPACITY AND SOLIDITY — the fc182b94 rules, kept and tokenised.

   These are why this file exists. The visitor-detail dialog is on the
   check-in path and it came out dimmed when they were absent. The only
   change is that the colour is now a token, so a dark theme does not need
   two later stylesheets to undo a hardcoded `#ffffff` — which is what
   dashboard-common.css and theme-surfaces.css were both doing.
   ========================================================================== */
.modal-content {
  background-color: var(--eq-surface);
  opacity: 1;
}

.visitor-detail-modal { isolation: isolate; }

.visitor-detail-modal .modal-content,
.visitor-detail-modal .modern-modal-content {
  position: relative;
  background-color: var(--eq-surface);
  opacity: 1;
  isolation: isolate;
}

.visitor-detail-modal .modal-header,
.visitor-detail-modal .modal-body,
.visitor-detail-modal .modern-modal-body {
  position: relative;
  opacity: 1;
}
.visitor-detail-modal .modal-body,
.visitor-detail-modal .modern-modal-body { background-color: var(--eq-surface); }
.visitor-detail-modal .modal-footer,
.visitor-detail-modal .modern-modal-footer {
  position: relative;
  background-color: var(--eq-surface-2);
  opacity: 1;
}

/* Every child opaque. Kept as `!important` because the thing it is beating
   is a page-level `opacity` on an ancestor, and dropping it is what dimmed
   the dialog. */
.visitor-detail-modal * { opacity: 1 !important; }

/* A `.container-fluid` nested in a dialog brought the page canvas with it. */
.modal-body .container-fluid,
.modal-content .container-fluid {
  background-color: transparent;
  margin: 0;
  padding: 0;
}

body.modal-open .visitor-detail-modal { background: transparent; }

/* ==========================================================================
   ONE BACKDROP, AND WHY IT IS THIS ONE.

   `.modal-backdrop` had six answers in eight files: `z-index: 1040
   !important` (main.css, admin/buildings/_form.html twice),
   `1050 !important` (campus/chkin/_lightbox.html, which also says 1040 nine
   lines earlier), `10040 !important` (this file, eduqueue/page/lookup.html)
   and `display: none !important` three times (admin/user/index.html,
   campus/page/event_details.html, and _lightbox.html's opacity pair). The
   earlier audit left the cluster alone and said why: picking a winner is a
   behavioural change to every dialog in the product.

   So it was measured. All 25 dialogs, driven open, `getComputedStyle` read
   off the live backdrop, three themes, two widths — 150 records in
   docs/modal-audit-2026-11-28.md. Three things that measurement settled and
   no amount of reading could:

     * **The browser was already using 1040.** Not 10040, and not the
       `z-index: 1040` that `static/scripts/main.js` writes inline on every
       `shown.bs.modal`. An `!important` author declaration beats a NORMAL
       inline one — the cascade compares the important-author tier above
       inline — so this file's `10040 !important` won the CSS argument, and
       then every measured backdrop still reported 1040, because
       `visitor-photo-modal-fix.js` stamps `10060 + n*10` on `show` and
       main.js overwrites it on `shown`. Four mechanisms, and the one that
       decided it was in a file called `main.js`.
     * **The 10040/10050 lift no longer bought anything.** It existed to
       clear the barcode-scanner overlays, which run at four figures.
       `css/legacy-page-fixes.css` now hides those overlays outright under
       `.modal-open`. The lift had a cost: at 10050 a dialog outranks
       Bootstrap's own popovers (1060) and tooltips (1070), which are meant
       to float over a dialog's own form — the report filter dialog contains
       a dual listbox that uses them — and it outranked the full-page loader
       (9999), which must cover everything.
     * **The three `display: none` answers leaked.** `/admin/users/` wanted
       no backdrop behind its two confirm dialogs, which the
       `data-backdrop="false"` attribute already on those two dialogs
       achieves by not creating the element at all. The stylesheet rule it
       added instead removed the backdrop from every other dialog on that
       page, including the Bulk Check-in dialog in the shared sidebar. The
       probe measured exactly that: `#visit-modal` reported no backdrop on
       `/admin/users/` and a rendered one everywhere else.

   What changed for the other four. `main.css`, `eduqueue/page/lookup.html`,
   `admin/user/index.html`, `admin/buildings/_form.html` and
   `campus/page/event_details.html` no longer declare backdrop stacking;
   `campus/chkin/_lightbox.html` is deleted (it was included by no template
   and rendered by no view). The per-dialog `data-backdrop` attributes are
   untouched, because they are per-dialog and they say what they mean. The
   measured outcome is in the audit's after table: same stacking, one
   definition, and `#visit-modal` gets its backdrop back on `/admin/users/`.
   ========================================================================== */
.modal-backdrop,
.modal-backdrop.show,
.modal-backdrop.fade.show {
  display: block !important;
  z-index: 1040 !important;
  /* The one colour here that is not a token: see rule 3 in the header. */
  background-color: rgba(0, 0, 0, .5) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
.modal-backdrop.show,
.modal-backdrop.fade.show { opacity: 1 !important; }

/* The dialog above it. `pointer-events: auto` on `.modal` is deliberate and
   is a fix: `main.js` set `pointer-events: none` there, and because
   Bootstrap listens for the dismissing click on `.modal` and not on the
   backdrop, that silently removed click-outside-to-close from every dialog
   in the product. It also made the stacking unmeasurable by the obvious
   instrument — `elementFromPoint` ignores `pointer-events: none`, so the hit
   test said "dialog on top" for a dialog painted underneath. */
.modal {
  z-index: 1050 !important;
  pointer-events: auto !important;
}
.modal .modal-dialog,
.modal .modal-content { z-index: auto; pointer-events: auto; }

/* NO PER-DIALOG LIFT. There was one here for about an hour — `#modernImageModal`
   at 10050 with `#modernImageModal ~ .modal-backdrop` at 10040, to clear the
   barcode-scanner overlays — and the after measurement caught it doing
   exactly the damage this whole section exists to stop. `~` is the general
   SIBLING combinator and Bootstrap appends every backdrop to `<body>`, where
   that dialog also lives once it is re-parented, so the rule matched the
   backdrop of EVERY dialog on the two pages that include the photo dialog.
   Backdrop 10040, dialog 1050: ten dialogs painted under their own backdrop,
   60 of 150 records, from one selector written to help one of them. The
   scanner overlays are hidden under `.modal-open` by
   css/legacy-page-fixes.css, which is the right instrument and needs no
   z-index at all. */

/* ── the mobile sheet ────────────────────────────────────────────────────
   At 390px a centred desktop dialog is a shrunken desktop dialog: 16px of
   margin each side, a rounded box on a scrim, and a footer below the fold.
   21 of the 150 measured records overflowed the viewport. A full-height
   sheet on the bottom edge puts the actions under the thumb and gives the
   body the rest of the screen.

   575.98px is Bootstrap 4.6.2's own `sm` edge; tests/cssguard/
   test_breakpoints.py permits only the four tier edges, and its inventory of
   which stylesheets may hold a width query now names this file. */
@media (max-width: 575.98px) {
  .modal.show .modal-dialog:not(.modal-dialog--keep-desktop) {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: none;
    min-height: 0;
    margin: 0;
  }
  .modal.show .modal-dialog:not(.modal-dialog--keep-desktop) > .modal-content {
    display: flex;
    flex-direction: column;
    max-height: 92vh;
    border-radius: var(--eq-radius) var(--eq-radius) 0 0;
  }
  .eq-dlg__head,
  .eq-dlg__foot { flex: 0 0 auto; }
  .eq-dlg__body {
    flex: 1 1 auto;
    max-height: none;
    padding: 1.25rem;
    -webkit-overflow-scrolling: touch;
  }
  /* A sheet's grab affordance, where a thumb expects one. */
  .eq-dlg__head { padding-top: 1.5rem; }
  .eq-dlg__head::before {
    content: "";
    position: absolute;
    top: .5rem;
    left: 50%;
    width: 36px;
    height: 4px;
    margin-left: -18px;
    border-radius: 2px;
    background-color: var(--eq-line);
  }
  /* Full-width actions, stacked, at the touch size the kit declares. */
  .eq-dlg__foot,
  .eq-dlg-actions { flex-direction: column; align-items: stretch; width: 100%; }
  .eq-dlg-btn {
    width: 100%;
    min-height: var(--eq-control-min-touch);
    font-size: var(--eq-control-font-touch);
  }
  .eq-dlg-photo { width: 180px; height: 180px; }
}

/* ── motion ──────────────────────────────────────────────────────────────
   The dialogs animated unconditionally: Bootstrap's own fade and slide plus
   four hand-written @keyframes. A vestibular trigger is not a taste. */
@media (prefers-reduced-motion: reduce) {
  .modal.fade,
  .modal.fade .modal-dialog,
  .modal-backdrop.fade,
  .eq-dlg,
  .eq-dlg-btn,
  .eq-dlg__close {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }
  .eq-dlg-chip__dot { animation: none !important; }
}

/* ── print ───────────────────────────────────────────────────────────────
   dashboard-common.css already hides `.modal-backdrop` when printing,
   because a dialog open at Ctrl+P printed a sheet of grey. It does not hide
   the dialog, so what printed instead was a dialog floating over a page it
   had nothing to do with. Nothing modal prints — including the four overlays
   that are not Bootstrap modals at all. */
@media print {
  .modal,
  .modal-backdrop,
  .denial-modal-overlay,
  .verification-success-modal,
  .custom-modal,
  .upload-modal {
    display: none !important;
  }
  /* Bootstrap puts `overflow: hidden` on the body while a dialog is open,
     which truncates the printed page to one screen. */
  body.modal-open { overflow: visible !important; }
}
