/* ===========================================================================
   Palette - the single source of truth for every color in the app. See
   AGENTS.md "Legibility and contrast": no page may hard-code a color literal
   that duplicates one of these; add a token here instead. Every pairing below
   is verified by tests/SafetyIQ.Tests/ContrastPaletteTests.cs, which fails the
   build if any pair in this file drops below its target ratio - that test is
   the standard, this comment is just the map of what it's checking.
   =========================================================================== */
:root {
  /* Explicitly opt OUT of forced/auto dark-mode recoloring on phones (Android
     Chrome, Samsung Internet, etc. all respect this). This is NOT dark mode -
     it's refusing one. Without it, a browser's heuristic re-coloring of an
     undeclared page is a plausible, invisible-in-source-review cause of
     exactly the "black text on an unexpectedly dark/blue background" defect
     this file exists to fix - see AGENTS.md for the full writeup. */
  color-scheme: light only;

  /* Brand anchors - large surfaces, borders, and brand-colored chrome only.
     NEVER use these two directly as small/body text color on a tinted
     background - use the derived, contrast-checked tokens below instead. */
  --brand-navy: #0b2c54;
  --brand-navy-dark: #082140;
  --brand-gold: #f2a900;
  --brand-gold-dark: #cf9000;

  /* Text-safe variant of brand gold - lightened just enough to clear 7:1 on
     navy (6.96:1 -> 7.53:1). Used only where gold is rendered AS TEXT (the
     active top-level nav link); use --brand-gold for fills/borders/outlines. */
  --brand-gold-text: #f4b31f;

  /* Body text - Bootstrap's own default, named here so it's a token like
     everything else. 15.4:1 on white. */
  --text-body: #212529;

  /* Secondary/muted TEXT. Overrides Bootstrap's own --bs-secondary-color
     (default rgba(33,37,41,.75), ~4.7:1 on white - fails the 7:1 floor this
     app requires for anything a user must read). 8.9:1 on white. Riding
     Bootstrap's own variable means every .text-muted, .form-text, and
     form-floating placeholder in the app is fixed by this one line - never
     override .text-muted's color directly in a page. */
  --bs-secondary-color: #4a4a4a;

  /* Solid-fill success/danger/secondary - what .badge/.btn/.text-* /.bg-* use
     for a plain colored fill with Bootstrap's default white text (--bs-badge-
     color/--bs-btn-color: #fff). Bootstrap's own defaults (#198754/#dc3545/
     #6c757d) measure 4.5-4.7:1 with white text - fails the 7:1 floor for
     status/active-inactive badges and buttons a user must read correctly.
     Darkened to the same shades Bootstrap itself already ships as its
     dark-theme "border-subtle" tokens (not arbitrary - these are colors
     Bootstrap's own design system considers accessible pairings), each
     >=7:1 with white text - verified in ContrastPaletteTests.cs.
     Deliberately NOT touching --bs-success-bg-subtle/--bs-success-text-
     emphasis (and the danger/secondary equivalents) - those back
     .alert-success/.bg-success-subtle/.text-success-emphasis, which are
     already light-tint-on-dark-text pairs that pass contrast as shipped;
     overriding them would make alert banners darker for no reason. */
  --bs-success: #0f5132;
  --bs-success-rgb: 15, 81, 50;
  --bs-danger: #842029;
  --bs-danger-rgb: 132, 32, 41;
  --bs-secondary: #495057;
  --bs-secondary-rgb: 73, 80, 87;

  /* Form validation text - overrides Bootstrap's --bs-form-valid-color /
     --bs-form-invalid-color (defaults #198754/#dc3545, 4.5:1 on white) with
     the same darkened colors above so a validation message a user must read
     also clears 7:1. (Border colors for valid/invalid inputs are untouched -
     those only need the lower 3:1 non-text boundary minimum, and already
     clear it at 4.5:1.) */
  --bs-form-valid-color: var(--bs-success);
  --bs-form-invalid-color: var(--bs-danger);

  /* Assistant chat drawer's assistant-side message bubble background - light enough
     that --text-body (already 7:1+ on pure white) stays comfortably above 7:1 on it
     too (verified in ContrastPaletteTests.AllPairs), distinct enough from the page's
     white background to read as its own bubble next to the navy user-side bubble. */
  --assistant-bubble-bg: #f1f3f5;

  /* Page guide callout (<page-help>, Bootstrap .alert-info) - named here so the R18
     "About this page" toggle can state its text colour explicitly. These are Bootstrap
     5.3's own --bs-info-text-emphasis / --bs-info-bg-subtle values (unmodified), i.e.
     exactly what the callout's text and fill already were; the pair is checked in
     ContrastPaletteTests.AllPairs. */
  --page-help-text: #055160;
  --page-help-bg: #cff4fc;
}

/* Badge text floor - Bootstrap's default 0.75em computes to 12px off a 16px
   base, below the 14px minimum for anything a user must read (a status badge
   always is). bg-warning/bg-info badges (Expiring/Due/InProgress) already
   pair text-dark at 7.9-9.5:1 and need no color change, only this. */
.badge {
  font-size: 14px;
}

/* 16px minimum on every viewport, phones included - sunlight on a phone eats
   contrast and size both. Do not reintroduce a smaller mobile size here. */
html {
  font-size: 16px;
}

/* Every interactive control gets a 44x44 CSS px minimum tap target, per
   AGENTS.md. .btn-sm keeps its tighter visual padding/font-size but is
   centered within the same 44px floor. */
.btn,
.btn-sm,
.btn-group-sm > .btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Checkboxes/radios: the glyph itself stays small, but the clickable row
   (glyph + label, already wired together by Bootstrap's for/id pairing) gets
   enough vertical padding to clear 44px. Padding, not min-height/flex - the
   checkbox glyph is positioned by Bootstrap via float+negative margin inside
   this block-level container, which a flex display would break. */
.form-check {
  padding-top: 0.6875rem;
  padding-bottom: 0.6875rem;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--brand-navy);
}

/* Brand overrides - deliberately global, not layout-scoped CSS, since every layout
   (_Layout, _PortalLayout, _AuthLayout, _PrintLayout) loads this file directly. See
   the navbar-color comment further down for why a scoped .cshtml.css is the wrong
   place for anything color-related in this app. */
a {
  color: var(--brand-navy);
}

.btn-primary {
  color: #fff;
  background-color: var(--brand-navy);
  border-color: var(--brand-navy);
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  color: #fff;
  background-color: var(--brand-navy-dark);
  border-color: var(--brand-navy-dark);
}

/* Navbar background AND text live under the SAME .bg-brand-prefixed selectors on
   purpose - every rule below that colors navbar text requires .bg-brand as an
   ancestor in its own selector, so it is structurally impossible for a
   navbar-text rule to apply anywhere the navy background isn't also present.
   A previous version of this file set background here and text color via a
   bare ".navbar-dark .navbar-nav .nav-link" selector with no dependency on
   .bg-brand at all - two rules that happened to agree, with nothing requiring
   them to. That produced a real regression (white text with no confirmed navy
   background - reported on _Layout.cshtml/Admin pages) for reasons that
   weren't fully pinned down even after direct live-server verification; rather
   than ship a fix whose correctness depends on correctly diagnosing exactly
   why the old version broke, this version makes the failure mode impossible
   regardless of the mechanism: delete .bg-brand from an element and every
   navbar-text rule below stops matching it too, instead of leaving white text
   stranded on whatever background happens to remain.
   .navbar-brand (the "SafetyIQ" wordmark) is included here too - it was never
   explicitly covered before (only .nav-link was), relying entirely on
   Bootstrap's own .navbar-dark cascade. */
.bg-brand {
  background-color: var(--brand-navy) !important;
  border-bottom: 3px solid var(--brand-gold);
}

.bg-brand .navbar-brand,
.bg-brand .navbar-nav .nav-link {
  color: rgba(255, 255, 255, 0.85);
}

.bg-brand .navbar-brand:hover,
.bg-brand .navbar-brand:focus,
.bg-brand .navbar-nav .nav-link:hover,
.bg-brand .navbar-nav .nav-link:focus {
  color: #fff;
}

.bg-brand .navbar-nav .nav-link.active,
.bg-brand .navbar-nav .show > .nav-link {
  color: var(--brand-gold-text);
}

.bg-brand .dropdown-menu .dropdown-item.active,
.bg-brand .dropdown-menu .dropdown-item:active {
  background-color: var(--brand-navy);
  color: #fff;
}

.navbar-brand img {
  height: 32px;
  width: 32px;
  margin-right: 0.5rem;
}

.brand-logo-lg {
  height: 72px;
  width: 72px;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  /* R9: room for the footer when its reference + build stamp wrap to two lines on a phone. */
  margin-bottom: 96px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* <help> tag helper trigger (SafetyIQ.Web.TagHelpers.HelpTagHelper) - a clearly visible
   circled "?" next to a label/column header/heading that shows a Bootstrap tooltip or
   popover. Deliberately NOT text-muted/tiny - a help affordance nobody notices might as
   well not exist. Visible circle is 24px (14px minimum text floor at an 18px/bold "?"),
   not 44px - a 44px dot inline in a label/column header would wreck every layout it
   appears in - but it's tabindex=0 and tap-activated, so the ::after pseudo-element
   below expands the actual tappable/clickable region to 44x44 without changing what's
   drawn. Clicks anywhere in the pseudo-element land on this element since generated
   content is part of its own box, not a separate overlapping one. */
.safetyiq-help {
  cursor: help;
  margin-left: 0.3rem;
  vertical-align: middle;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  border: 1px solid var(--brand-navy);
  border-radius: 50%;
  color: var(--brand-navy);
  background-color: #fff;
}

.safetyiq-help::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
}

.safetyiq-help:hover, .safetyiq-help:focus-visible {
  color: #fff;
  background-color: var(--brand-navy);
  outline: 2px solid var(--brand-gold);
  outline-offset: 1px;
}

/* AI assistant chat drawer (_AssistantDrawer.cshtml, AGENTS.md "AI assistant" section).
   --bs-offcanvas-width (not a raw width override) so it still composes with Bootstrap's
   own offcanvas transform/transition - Bootstrap already makes the offcanvas full
   viewport height by default, so no height override is needed for the "full-height on
   mobile" requirement. */
.safetyiq-assistant-drawer {
  --bs-offcanvas-width: 420px;
}

@media (max-width: 480px) {
  .safetyiq-assistant-drawer {
    --bs-offcanvas-width: 100vw;
  }
}

.safetyiq-assistant-message {
  max-width: 85%;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  overflow-wrap: break-word;
}

.safetyiq-assistant-message p {
  margin: 0 0 0.5rem;
}

.safetyiq-assistant-message p:last-child {
  margin-bottom: 0;
}

.safetyiq-assistant-message-user {
  margin-left: auto;
  background-color: var(--brand-navy);
  color: #fff;
}

.safetyiq-assistant-message-assistant {
  margin-right: auto;
  background-color: var(--assistant-bubble-bg);
  color: var(--text-body);
}

.safetyiq-assistant-message-assistant .safetyiq-assistant-tools {
  margin-top: 0.35rem;
  font-size: 14px;
  color: var(--bs-secondary-color);
}

/* A write tool's proposal card (AGENTS.md "AI assistant" section, phase 5) - a gold
   border and an explicit "not yet made" label are what keep this from reading as a
   normal answer bubble the user could mistake for something already done. White
   background + --text-body is the same already-verified "Body text on white" pair
   every other page uses (ContrastPaletteTests.AllPairs) - not a new combination, so no
   new pair entry needed there. */
.safetyiq-assistant-proposal {
  margin-right: auto;
  max-width: 85%;
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  border: 2px solid var(--brand-gold);
  border-radius: 0.5rem;
  background-color: #fff;
  color: var(--text-body);
}

.safetyiq-assistant-proposal-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand-navy);
  margin-bottom: 0.35rem;
}

.safetyiq-assistant-proposal-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
}

/* Drawer header: title grows to fill the left side (truncating with an ellipsis rather
   than wrapping into the controls at phone width); "New conversation" and the close X
   sit as a fixed-gap group on the right so they never crowd the title or each other.
   .offcanvas-header is already display:flex/align-items:center from Bootstrap - no
   justify-content there, which is why the title and the old text button used to sit
   flush against each other on the left while .btn-close floated off alone on the right
   via its own margin-left:auto. */
.safetyiq-assistant-drawer-header .offcanvas-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.safetyiq-assistant-drawer-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: 0.75rem;
}

/* Overrides Bootstrap's .offcanvas-header .btn-close margin-left: auto - that rule
   assumed .btn-close was the header's own last flex child; now it's nested one level
   deeper inside .safetyiq-assistant-drawer-controls, so the fixed gap above is the only
   spacing that should apply. */
.safetyiq-assistant-drawer-controls .btn-close {
  margin: 0;
}

/* Icon-only button, not a boxed text button competing with the title - 44x44 via the
   existing global .btn-sm min-height rule above plus an explicit matching width, so the
   icon sits centered in a square tap target. */
.safetyiq-assistant-icon-btn {
  width: 44px;
  padding: 0;
}

/* Sticky footer (_BuildFooter.cshtml) - the classic ASP.NET Core template pattern
   body { margin-bottom: 60px; } / html { position: relative; min-height: 100%; }
   above were already set up for, but no footer existed yet to go with them until this
   rule. No color properties here on purpose - the footer text relies entirely on the
   already-verified text-muted/--bs-secondary-color-on-white pair every other page uses
   (ContrastPaletteTests.AllPairs), so no new pair entry is needed for this rule. */
.footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  /* R9: min-height, not a fixed 60px - the reference + build stamp wrap on a 360px phone. */
  min-height: 60px;
  padding: 0.5rem 0;
  line-height: 1.4;
}

/* R9: the per-request reference a worker reads aloud (Pages/Error, _BuildFooter).
   Monospace + letter-spacing so 7F3A-2B91 is unambiguous; same --text-body on the page
   background as all body text (no new contrast pair). */
.safetyiq-error-reference {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-body);
}

.safetyiq-ref {
  font-family: SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-weight: 600;
}

/* Certificate Submissions detail page document viewer (AGENTS.md "Certificate
   intake", wwwroot/js/cert-document-viewer.js). White toolbar background needs its
   own explicit foreground per AGENTS.md "Legibility and contrast" - .btn-outline-
   secondary already supplies its own text color, so no new pair is introduced here
   (ContrastPaletteTests.AllPairs already covers that pairing via every other
   .btn-outline-secondary in the app). */
.safetyiq-document-viewer {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  overflow: hidden;
}

.safetyiq-document-viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem;
  background-color: #fff;
  color: var(--text-body);
  border-bottom: 1px solid var(--bs-border-color);
}

/* overflow: hidden is the clipping box the pan/zoom transform works inside;
   touch-action: none hands two-finger/drag gestures over this element to our own
   pointer-event handlers instead of the browser's default scroll/zoom. Height is
   viewport-relative (not a fixed px value) so the pane stays usable on short laptop
   screens and tall phone screens alike. */
.safetyiq-document-viewer-pane {
  position: relative;
  overflow: hidden;
  height: 70vh;
  min-height: 24rem;
  background-color: #e9ecef;
  color: var(--text-body);
  cursor: default;
  touch-action: none;
}

.safetyiq-document-viewer-pane-zoomed {
  cursor: grab;
}

.safetyiq-document-viewer-pane-zoomed:active {
  cursor: grabbing;
}

/* top/left 50% + the viewer script's own translate(-50%, -50%) is what centers the
   surface in the pane before any pan/rotate/zoom is applied - see apply() in
   cert-document-viewer.js for why the centering offset has to live in the inline
   transform the script sets, not here. */
.safetyiq-document-viewer-pane [data-viewer-surface] {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: none;
  max-height: none;
  transform-origin: center center;
}

.safetyiq-document-viewer-pane iframe[data-viewer-surface] {
  width: 100%;
  height: 100%;
  border: 0;
}

/* Top-bar "needs attention" badge (AGENTS.md "Certificate intake" phase 6c,
   CertIntakeBadgeViewComponent). Icon + count sit side by side rather than an
   overlapping dot, so the count's own text stays full-size and readable rather than
   shrunk to fit a corner - the whole point of a badge a supervisor must actually read
   in sunlight (AGENTS.md "Legibility and contrast"). No new color pair: the icon
   inherits .bg-brand .navbar-nav .nav-link's already-verified white-on-navy color via
   fill="currentColor", and the count uses .badge.text-bg-danger, the same
   already-verified white-on-bg-danger pair every Expired/Failed status badge uses. */
.safetyiq-certintake-badge-link {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.safetyiq-certintake-badge-count {
  position: relative;
  top: -1px;
}
/* ---------------------------------------------------------------------------
   R18 - phones (below Bootstrap's sm breakpoint, 576px). EVERY rule in this block
   is inside this one media query on purpose: at 576px and up nothing here applies,
   so a tablet or desktop renders exactly as it did before R18 (the run log
   byte-compares a 1280px screenshot before/after to prove it). PhoneLayoutTests
   holds the line: no sideways page scroll at 390/360px, a page heading never shares
   a row with its buttons, and every tap target on Customers > Edit is 44x44.
   --------------------------------------------------------------------------- */
@media (max-width: 575.98px) {
  /* Page title + action buttons (<page-header>, TagHelpers/PageHeaderTagHelper.cs):
     stacked - the heading block uses the whole width, the buttons drop beneath it
     full width, in source order. Bootstrap's utilities on the row are !important,
     so these have to be too. */
  .safetyiq-page-header {
    flex-direction: column;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 0.75rem !important;
  }

  .safetyiq-page-header > * {
    min-width: 0;
  }

  .safetyiq-page-header > :not(:first-child) {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    width: 100%;
  }

  .safetyiq-page-header > .btn,
  .safetyiq-page-header > :not(:first-child) .btn {
    width: 100%;
  }

  .safetyiq-page-header > :not(:first-child) .safetyiq-help {
    align-self: flex-start;
  }

  /* Inline forms (a select/input next to a button) wrap instead of widening the page -
     found on Employee > Required Training ("Add by hand") and Customers > Baseline
     Matrix ("Import from Excel"), both 430-500px wide at a 390px viewport. */
  main form.d-flex:not(.flex-nowrap) {
    flex-wrap: wrap;
  }

  /* Tap targets, 44x44 minimum (AGENTS.md "Legibility and contrast"). Inputs and
     selects also go to 16px text: iOS Safari zooms the whole page in on focus for any
     field under 16px, which is how a phone user loses the layout mid-form. */
  .form-control,
  .form-select,
  .form-control-sm,
  .form-select-sm {
    min-height: 44px;
    font-size: 1rem;
  }

  input[type="file"].form-control {
    line-height: 1.9;
  }

  .btn,
  .btn-sm {
    min-width: 44px;
  }

  .nav-tabs .nav-link,
  .nav-pills .nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .form-check {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .form-check .form-check-input {
    flex-shrink: 0;
  }

  .form-check-label {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  /* A matrix cell's checkbox: the label around it becomes the 44x44 tap area (see
     .safetyiq-tap-cell below for why that label has no box at all on a wider screen). */
  .safetyiq-tap-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin: 0 auto;
    cursor: pointer;
  }

  .safetyiq-tap-cell .form-check-input {
    margin: 0;
  }

  /* Page guide callout (<page-help>): collapsed to one "About this page" row on a
     phone - a whole paragraph in a blue box pushed the page's real content below the
     fold. Tapping the row expands it; the close (X) still dismisses it for good, kept
     in localStorage exactly as before (site.js initPageHelpWidgets). */
  .safetyiq-page-help:not(.is-expanded) .safetyiq-page-help-body {
    display: none;
  }

  .safetyiq-page-help {
    padding-top: 0;
    padding-bottom: 0;
  }

  .safetyiq-page-help.is-expanded {
    padding-bottom: 1rem;
  }

  .safetyiq-page-help .btn-close {
    padding-top: 0;
    padding-bottom: 0;
    height: 44px;
  }
}

/* Above the phone breakpoint the matrix checkbox's label generates no box at all, so the
   cell lays out exactly as it did when the checkbox stood alone (R18: nothing above sm
   changes). The label still works as a label on a phone, where it is the tap area. */
@media (min-width: 576px) {
  .safetyiq-tap-cell {
    display: contents;
  }
}

/* The page guide's "About this page" toggle - only ever shown on a phone (d-sm-none in
   the markup). It reads as part of the callout: no fill of its own (transparent, so the
   callout's own fill shows through) and the callout's own text colour, named. */
.safetyiq-page-help-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 44px;
  padding: 0 2rem 0 0;
  border: 0;
  background-color: transparent;
  color: var(--page-help-text);
  font-weight: 600;
  text-align: left;
}

.safetyiq-page-help-toggle::before {
  content: "\25B8";
  display: inline-block;
  transition: transform 0.15s ease-in-out;
}

.safetyiq-page-help.is-expanded .safetyiq-page-help-toggle::before {
  transform: rotate(90deg);
}

/* ---------------------------------------------------------------------------
   R18b - inline form rows (a text input or select beside a content-sized select
   or button, e.g. Customers > Jobs "Add job"). R18 already lets these rows wrap
   on a phone; this finishes the job:
   - each field carries a VISIBLE label on a phone. A placeholder vanishes the moment
     the user types, so a row labelled only by placeholders is unlabelled in use. The
     markup is <label class="safetyiq-inline-field"><span class="safetyiq-inline-field-caption">
     Job name</span><input ...></label>; any aria-label on the input stays.
   - every field takes the whole line, and the row's buttons go full width on their
     own line, in source order.
   At 576px and up the label generates no box (display: contents) and the caption is
   not rendered, so the input is laid out exactly as when it stood alone in the row -
   nothing changes on a tablet or desktop (byte-compared in the R18b run log).
   --------------------------------------------------------------------------- */
@media (min-width: 576px) {
  .safetyiq-inline-field {
    display: contents;
  }

  .safetyiq-inline-field-caption {
    display: none;
  }
}

@media (max-width: 575.98px) {
  .safetyiq-inline-field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 0.5rem;
    row-gap: 0.25rem;
    flex: 1 1 100%;
    min-width: 0;
    margin: 0;
  }

  .safetyiq-inline-field-caption {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-body);
  }

  .safetyiq-inline-field > .form-control,
  .safetyiq-inline-field > .form-select {
    flex: 1 1 100%;
    width: 100% !important;
    max-width: none !important;
  }

  /* A row that holds a field: its buttons (submit, Cancel) each take a full line. */
  main form.d-flex:has(.form-control, .form-select) > .btn {
    flex: 1 1 100%;
  }
}

/* ---------------------------------------------------------------------------
   R20 - Employee > Required Training: the row a Reports > Expiring link arrived
   for (?focus={TrainingRequirementId}#req-{id}). Scrolled clear of the sticky
   navbar, filled with the verified assistant-bubble pair, a navy left edge, and
   a "From the Expiring report" label - the label, not the colour, is what says
   which row it is (AGENTS.md "Legibility and contrast": never colour alone).
   --------------------------------------------------------------------------- */
tbody tr[id^="req-"] {
  scroll-margin-top: 6rem;
}

.table .safetyiq-row-focus > td {
  background-color: var(--assistant-bubble-bg);
  color: var(--text-body);
}

.table .safetyiq-row-focus > td:first-child {
  border-left: 4px solid var(--brand-navy);
}

.safetyiq-row-focus-label {
  background-color: var(--brand-navy);
  color: #fff;
  width: fit-content;
}

/* R20 - Reports > Expiring on a phone: the row's Action button stays in view at the
   right edge of the table's own scroll box while the other columns scroll under it.
   Phone-only; an opaque white cell (explicit body text colour) so scrolled text never
   shows through. Desktop is unchanged. */
@media (max-width: 575.98px) {
  .table .safetyiq-sticky-action {
    position: sticky;
    right: 0;
    z-index: 1;
    background-color: #fff;
    color: var(--text-body);
    box-shadow: -6px 0 6px -6px rgba(0, 0, 0, 0.35);
  }
}

/* R28 - a many-to-many pick list as visible checkboxes (cert type <-> course, training-event
   attendees) instead of <select multiple>: no modifier keys, and a stray click changes one row,
   never every other selection. Scrolls inside its own box. */
.safetyiq-checkbox-list {
  max-height: 16rem;
  overflow-y: auto;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  padding: 0.5rem 0.75rem;
}

/* R29 (S025) - collapsible sections (<collapsible-section>, TagHelpers/CollapsibleSectionTagHelper.cs). The header
   is a full-width button: a navy bar with white text, plainly NOT a table row or a form label. A group inside a
   section (h3) is lighter - a tinted bar. The count rides in the header so a collapsed section still says how much
   is in it. Focus ring always visible for keyboard users. */
.safetyiq-section { margin: 0 0 1.25rem 0; }
.safetyiq-section-heading { margin: 0; font-size: 1.05rem; }
.safetyiq-section-toggle {
  display: flex; align-items: center; gap: 0.6rem; width: 100%;
  min-height: 44px; /* a tap target on a phone (PhoneLayoutTests: 44px) */
  padding: 0.6rem 0.85rem; border: 0; border-radius: var(--bs-border-radius);
  background-color: var(--brand-navy); color: #fff;
  font-weight: 600; font-size: inherit; text-align: left; line-height: 1.3;
}
.safetyiq-section-toggle:hover { filter: brightness(1.12); }
.safetyiq-section-toggle:focus-visible { outline: 3px solid #f59e0b; outline-offset: 2px; }
.safetyiq-section-chevron {
  display: inline-block; width: 0.55rem; height: 0.55rem; flex: none;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); margin-top: -0.25rem; transition: transform 0.15s ease;
}
.safetyiq-section-toggle[aria-expanded="false"] .safetyiq-section-chevron { transform: rotate(-45deg); margin-top: 0; }
.safetyiq-section-count {
  margin-left: auto; font-weight: 500; font-size: 0.85rem; white-space: nowrap;
  background-color: #2b4c78; color: #fff; padding: 0.1rem 0.55rem; border-radius: 1rem;
}
.safetyiq-section-body { padding: 0.85rem 0.15rem 0 0.15rem; }
.safetyiq-section-heading-h3 { font-size: 0.95rem; }
.safetyiq-section-heading-h3 .safetyiq-section-toggle,
.safetyiq-section-heading-h4 .safetyiq-section-toggle {
  background-color: #e8edf5; color: var(--text-body); padding: 0.4rem 0.7rem;
}
.safetyiq-section-heading-h3 .safetyiq-section-count,
.safetyiq-section-heading-h4 .safetyiq-section-count { background-color: #d5dde9; color: var(--text-body); }
.safetyiq-section .safetyiq-section { margin-bottom: 0.6rem; }

/* R29 - a filterable pick list (cert types grouped by category, employees grouped by division). A hidden row is
   hidden by the filter only; a CHECKED row is never hidden (site.js) - nobody loses a selection by typing. */
.safetyiq-picklist-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.safetyiq-picklist-toolbar .form-control { max-width: 22rem; }
.safetyiq-picklist-group-title { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-body); border-bottom: 1px solid var(--bs-border-color); margin: 0.6rem 0 0.35rem 0; padding-bottom: 0.15rem; }
.safetyiq-picklist-group-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.15rem 1rem; }
.safetyiq-picklist-scroll { max-height: 22rem; overflow-y: auto; border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius); padding: 0.25rem 0.75rem 0.5rem 0.75rem; }
.safetyiq-filter-hidden { display: none !important; }
.safetyiq-requirement-group-row th { background-color: #e8edf5; color: var(--text-body); font-size: 0.85rem; }

/* R29 - Send Records: the recipient panel stays in view beside the list on a wide screen; on a phone the two
   stack and a bar at the bottom keeps the count and the Review button reachable. */
@media (min-width: 992px) {
  .safetyiq-sticky-panel { position: sticky; top: 1rem; }
}
.safetyiq-mobile-action-bar { position: sticky; bottom: 0; z-index: 5; background: #fff; color: var(--text-body);
  border-top: 1px solid var(--bs-border-color); padding: 0.5rem 0; margin-top: 0.5rem; }

/* ======================= R34 (S035): top bar + left menu =======================
   LaborIQ's shape (its site.css "left menu" and "phones" sections): a light 240px menu beside the page that scrolls on
   its own, sections with a small uppercase header, items = icon + label, a soft-blue active item with a 3px accent bar.
   Wide screens: the hamburger collapses it to a 64px icon rail (body.menu-collapsed - applied before paint by
   Pages/Shared/_MenuPrePaint.cshtml). Phones (< 768px): an off-canvas drawer over the page with a dark backdrop
   (body.menu-open). Behaviour: wwwroot/js/sidenav.js. Every rule that sets a background sets its text colour too. */
:root {
  --siq-topbar-h: 3.75rem;
}

.siq-topbar-row {
  flex-wrap: nowrap;
  gap: 0.5rem;
}

.bg-brand .siq-menu-toggle {
  color: #fff;
  background-color: transparent;
  border: 1px solid rgba(255, 255, 255, 0.45);
  min-width: 44px;
  min-height: 44px;
  font-size: 1.35rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bg-brand .siq-menu-toggle:hover,
.bg-brand .siq-menu-toggle:focus-visible {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.12);
  border-color: #fff;
}

.siq-brand {
  margin-right: 0.25rem;
}

.siq-topbar-tenant {
  flex: 0 1 auto;
  min-width: 0;
}

.siq-topbar-tenant form {
  margin: 0 !important;
}

.siq-topbar-tenant select {
  max-width: 22rem;
  min-height: 38px;
}

.bg-brand .siq-tenant-name {
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.siq-topbar-end {
  flex-direction: row;
  align-items: center;
  margin-left: auto;
  gap: 0.25rem;
}

.siq-topbar-end .nav-link {
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.siq-topbar-end .nav-link .bi {
  font-size: 1.2rem;
}

/* The top bar is a .navbar without navbar-expand, where Bootstrap makes a dropdown static - float it, as before. */
.siq-topbar .navbar-nav .dropdown-menu {
  position: absolute;
}

.siq-shell {
  display: flex;
  align-items: flex-start;
}

.siq-main {
  flex: 1 1 0;
  min-width: 0;
}

#sideNav {
  flex: 0 0 240px;
  width: 240px;
  max-width: 240px;
  background-color: #f8f9fa;
  color: #212529;
  border-right: 1px solid #e3e6ea;
  padding: 0.75rem 0.5rem 1rem;
  position: sticky;
  top: var(--siq-topbar-h);
  align-self: flex-start;
  min-height: calc(100vh - var(--siq-topbar-h));
  max-height: calc(100vh - var(--siq-topbar-h));
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}

#sideNav .siq-nav-section {
  margin-bottom: 0.35rem;
}

#sideNav .siq-nav-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  border: 0;
  border-radius: 8px;
  background-color: transparent;
  color: #5c636a;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: left;
}

#sideNav .siq-nav-section-toggle:hover {
  background-color: #e9ecef;
  color: #212529;
}

#sideNav .siq-nav-chev {
  font-size: 0.8rem;
  transition: transform 0.15s ease;
}

#sideNav .siq-nav-section-toggle[aria-expanded="false"] .siq-nav-chev {
  transform: rotate(-90deg);
}

#sideNav .siq-nav-list {
  list-style: none;
  margin: 0 0 0.25rem;
  padding: 0;
}

#sideNav .siq-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 40px;
  padding: 6px 0.75rem;
  margin: 1px 0;
  border-radius: 8px;
  color: #212529;
  font-size: 0.93rem;
  line-height: 1.3;
  text-decoration: none;
}

#sideNav .siq-nav-link .bi {
  flex: 0 0 1.25rem;
  width: 1.25rem;
  text-align: center;
  font-size: 1.05rem;
  color: #5f6770;
}

#sideNav .siq-nav-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#sideNav .siq-nav-link:hover {
  background-color: #e9ecef;
  color: #212529;
}

#sideNav .siq-nav-link.active {
  background-color: #e7f1ff;
  color: #0a4fb5;
  font-weight: 600;
}

#sideNav .siq-nav-link.active .bi {
  color: #0a4fb5;
}

#sideNav .siq-nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 3px;
  background-color: var(--brand-navy);
  color: #fff;
}

#sideNav .siq-nav-link:focus-visible,
#sideNav .siq-nav-section-toggle:focus-visible {
  outline: 2px solid var(--brand-navy);
  outline-offset: -2px;
}

.siq-nav-backdrop {
  display: none;
}

/* ---- wide screens: the hamburger collapses the menu to a 64px icon rail ---- */
@media (min-width: 768px) {
  body.menu-collapsed #sideNav {
    flex-basis: 64px;
    width: 64px;
    max-width: 64px;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
    scrollbar-width: none;
  }

  body.menu-collapsed #sideNav .siq-nav-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* the rail shows every item's icon; the section headers become thin dividers */
  body.menu-collapsed #sideNav .siq-nav-section-toggle {
    display: none;
  }

  body.menu-collapsed #sideNav .siq-nav-list[hidden] {
    display: block !important;
  }

  body.menu-collapsed #sideNav .siq-nav-section + .siq-nav-section {
    border-top: 1px solid #dee2e6;
    margin-top: 0.35rem;
    padding-top: 0.35rem;
  }

  body.menu-collapsed #sideNav .siq-nav-link {
    justify-content: center;
    padding: 8px 0;
  }

  body.menu-collapsed #sideNav .siq-nav-link .bi {
    flex-basis: auto;
    font-size: 1.15rem;
  }
}

@media (max-width: 991.98px) {
  .siq-topbar-label {
    display: none;
  }
}

/* ---- phones: the menu is a drawer, the top bar wraps the company switcher onto its own row, 16px gutters ---- */
@media (max-width: 767.98px) {
  #sideNav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100%;
    max-height: none;
    width: min(86vw, 20rem);
    max-width: 86vw;
    flex: none;
    z-index: 1050;
    transform: translateX(-105%);
    visibility: hidden;
    box-shadow: none;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
    overscroll-behavior: contain;
  }

  body.menu-open #sideNav {
    transform: none;
    visibility: visible;
    box-shadow: 4px 0 18px rgba(0, 0, 0, 0.28);
    transition: transform 0.2s ease;
  }

  .siq-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
    background-color: rgba(0, 0, 0, 0.45);
    color: #fff;
  }

  body.menu-open .siq-nav-backdrop {
    display: block;
  }

  body.menu-open {
    overflow: hidden;
  }

  #sideNav .siq-nav-link,
  #sideNav .siq-nav-section-toggle {
    min-height: 44px;
  }

  #sideNav .siq-nav-link {
    font-size: 1rem;
  }

  .siq-topbar-row {
    flex-wrap: wrap;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .siq-topbar-tenant {
    order: 3;
    flex: 1 0 100%;
  }

  .siq-topbar-tenant select {
    width: 100% !important;
    max-width: none;
    min-height: 44px;
  }

  .siq-user-name {
    display: none;
  }

  .siq-main {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
}

@media (max-width: 399.98px) {
  .siq-brand-text {
    display: none;
  }
}

/* R34 (S035): toggles. A switch (.form-check.form-switch + role="switch") is a state that takes effect - Active, May
   assign training, Receives alerts, As-required only, Show inactive; a plain checkbox is one of several things being
   picked (the cert-type / course / employee pickers, the matrix cells, the division list). A switch is a real checkbox
   underneath, so what a form posts is unchanged. A touch larger than Bootstrap's so it reads as a switch. */
.form-switch .form-check-input {
  width: 2.4em;
  height: 1.3em;
  margin-top: 0.1em;
  cursor: pointer;
}

.form-switch {
  padding-left: 3em;
}

.form-switch .form-check-input {
  margin-left: -3em;
}

/* ======================= R39 (S037): the employee picker, readable =======================
   Pages/Shared/_EmployeePicker.cshtml. One aligned row per person - checkbox, name, employee number, and a note only
   where it says something - instead of wrapping labels in auto-filled columns. Rows read top to bottom; a long group
   takes two columns on a wide screen, flowing DOWN the first column and then the second (CSS columns), with a rule
   between them. The group header holds its count and its own "Select all shown", styled like the global one. The
   count of who is selected is the largest text on the screen, in a bar that sticks to the bottom of the window. */
.siq-pick-toolbar .form-control { flex: 1 1 16rem; max-width: 24rem; }
.siq-pick-toolbar-actions { display: inline-flex; flex-wrap: wrap; gap: 0.5rem; }
.siq-pick-common {
  background-color: #f1f4f9;
  color: var(--text-body);
  border-left: 3px solid var(--brand-navy);
  padding: 0.4rem 0.75rem;
  border-radius: 0 4px 4px 0;
}
.siq-pick-group { margin-bottom: 0.9rem; }
.siq-pick-group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  background-color: #e8edf5;
  color: var(--text-body);
  border-radius: 6px;
  padding: 0.35rem 0.5rem 0.35rem 0.75rem;
  margin-bottom: 0.25rem;
}
.siq-pick-group-title { flex: 1 1 auto; font-size: 1rem; font-weight: 600; margin: 0; }
.siq-pick-group-count { margin-left: 0.4rem; font-size: 0.875rem; font-weight: 400; color: #3d4652; }
.siq-pick-list { list-style: none; margin: 0; padding: 0; }
.siq-pick-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 2.4rem;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid #eceff3;
  break-inside: avoid;
}
.siq-pick-row:hover { background-color: #f5f7fa; color: var(--text-body); }
.siq-pick-row:has(input:checked) { background-color: #e9f1ff; color: var(--text-body); }
.siq-pick-row .form-check-input { flex: 0 0 auto; margin: 0; width: 1.15em; height: 1.15em; }
.siq-pick-label {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6rem;
  column-gap: 0.75rem;
  align-items: baseline;
  margin: 0;
  cursor: pointer;
}
.siq-pick-has-notes .siq-pick-label { grid-template-columns: minmax(0, 1fr) 6rem minmax(0, 13rem); }
.siq-pick-name { overflow-wrap: anywhere; }
.siq-pick-number { font-size: 0.875rem; color: #3d4652; font-variant-numeric: tabular-nums; }
.siq-pick-note { font-size: 0.875rem; color: #7a4100; }

@media (min-width: 1200px) {
  .siq-pick-list-long { columns: 2; column-gap: 2rem; column-rule: 1px solid #dfe3e8; }
  /* two columns: a note goes under the name, so the name keeps its width */
  .siq-pick-list-long.siq-pick-has-notes .siq-pick-label { grid-template-columns: minmax(0, 1fr) 6rem; }
  .siq-pick-list-long .siq-pick-note { grid-column: 1 / -1; }
}

.siq-pick-actionbar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 0.75rem;
  padding: 0.6rem 0.25rem;
  background-color: #fff;
  color: var(--text-body);
  border-top: 2px solid var(--brand-navy);
  box-shadow: 0 -6px 12px -8px rgba(0, 0, 0, 0.25);
}
.siq-pick-count { font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.siq-pick-actionbar > .btn:first-of-type { margin-left: auto; }
.siq-pick-cost { font-size: 1.05rem; font-weight: 600; color: #3d4652; }

/* phones: one column, the number beside the name and any note under them, 44px rows */
@media (max-width: 575.98px) {
  .siq-pick-label,
  .siq-pick-has-notes .siq-pick-label { grid-template-columns: minmax(0, 1fr) auto; }
  .siq-pick-note { grid-column: 1 / -1; }
  .siq-pick-row { min-height: 44px; }
  .siq-pick-row .form-check-input { width: 1.35em; height: 1.35em; }
  .siq-pick-count { font-size: 1.2rem; }
  .siq-pick-toolbar .form-control { max-width: none; }
}

/* R39: a short (single-column) group is as wide as one column of a long group, so names and numbers line up from
   group to group instead of the number drifting to the far edge. */
.siq-pick-list:not(.siq-pick-list-long) { max-width: 36rem; }
@media (max-width: 1199.98px) { .siq-pick-list-long { max-width: 36rem; } }
