/*
 * app.css — small hand-written layer on top of vanilla Bootstrap 5.
 * Sidebar + topbar shell layout only; components are stock Bootstrap.
 */

/*
 * The deployment's branding (Settings > Branding, migration 151). The server
 * writes the accent tokens below into this stylesheet — tokens only, never a
 * rule — so a Council's own colour is on every page before first paint, with
 * no flash of the default blue. An unbranded deployment gets an empty file and
 * the defaults in :root stand. It must stay the first rule in this file (CSS
 * ignores an @import that follows any other rule); its `html:root` selector is
 * what lets it outrank the :root defaults that come after it. See
 * docs/ui-style-guide.md, "Branding".
 */
@import url("/branding/theme.css");


/*
 * Brand palette — ported from the legacy B-SAFE app (see docs/ui-style-guide.md):
 * shield orange #F05136 (logo + auth CTA), brand dark #241F33/#191E30 (the
 * login gradient and the logo's own ground), app blues #175DA6/#12457A
 * (legacy navbar / primary), report red #A12B1B (legacy .btn-danger).
 */
:root {
  --bsafe-sidebar-width: 250px;
  /* The legacy sidebar: AdminLTE skin-blue slate with the dark-sidebar pills. */
  --bsafe-sidebar-bg: #222d32;
  --bsafe-sidebar-fg: #c2c7d0;
  --bsafe-accent: #175da6;
  --bsafe-accent-deep: #12457a;
  /* The same two colours as rgb triplets, for translucent tints:
     rgba(var(--bsafe-accent-rgb), 0.1). Branding redeclares all four. */
  --bsafe-accent-rgb: 23, 93, 166;
  --bsafe-accent-deep-rgb: 18, 69, 122;
  --bsafe-orange: #f05136;
  --bsafe-orange-deep: #ea341c;
  --bsafe-brand-dark: #241f33;
  --bsafe-brand-dark-2: #191e30;
  --bsafe-ink: #241f33;
  /* Muted text clears WCAG AA (4.5:1) on BOTH grounds it sits on: 5.87:1 on
     white and 5.42:1 on the page grey #f4f6f9. The old #64748b managed only
     4.40:1 on the grey and was most of the app's axe colour-contrast nodes. */
  --bsafe-muted: #5b6578;
  --bsafe-line: #e3e6ea;
  /* The legacy danger red, reserved for the report document's headings. */
  --bsafe-report-red: #a12b1b;
  /* The attention line under a detail page's header: a warning tint that is
     legible next to the amber `text-bg-warning` chips without being one. */
  --bsafe-attention-bg: #fff8e6;
  --bsafe-attention-line: #f3d38a;
  --bsafe-attention-ink: #6b4b06;
  --bsafe-attention-mark: #b8860b;
  /* The same line once what it asked for is DONE. Green, because `closed` and
     `complete` are `success` everywhere else in this app (style guide, status
     vocabulary) — but a tint, not a badge: it is still the quietest thing in
     the head, and it must not out-shout the chips beside it. */
  --bsafe-attention-done-bg: #f1f8f3;
  --bsafe-attention-done-line: #bcdfcb;
  --bsafe-attention-done-ink: #0f5132;
  --bsafe-attention-done-mark: #198754;

  /* Map the brand onto Bootstrap's own tokens (links, badges, text-bg-*). */
  --bs-primary: var(--bsafe-accent);
  --bs-primary-rgb: var(--bsafe-accent-rgb);
  --bs-link-color: var(--bsafe-accent);
  --bs-link-color-rgb: var(--bsafe-accent-rgb);
  --bs-link-hover-color: var(--bsafe-accent-deep);
  --bs-link-hover-color-rgb: var(--bsafe-accent-deep-rgb);
}

/* Components that bake the stock blue into their own variables.
   Next-step colour: legacy markup (about 115 pages) still says btn-success for
   the single next step. It takes the same tokens as btn-primary in every
   state, so the next step is one colour, the organisation's. Status tones
   (btn-outline-success, text-bg-success, badges) are not touched. */
.btn-primary,
.btn-success {
  --bs-btn-bg: var(--bsafe-accent);
  --bs-btn-border-color: var(--bsafe-accent);
  --bs-btn-hover-bg: var(--bsafe-accent-deep);
  --bs-btn-hover-border-color: var(--bsafe-accent-deep);
  --bs-btn-active-bg: var(--bsafe-accent-deep);
  --bs-btn-active-border-color: var(--bsafe-accent-deep);
  --bs-btn-disabled-bg: var(--bsafe-accent);
  --bs-btn-disabled-border-color: var(--bsafe-accent);
  --bs-btn-focus-shadow-rgb: var(--bsafe-accent-rgb);
}

.btn-outline-primary {
  --bs-btn-color: var(--bsafe-accent);
  --bs-btn-border-color: var(--bsafe-accent);
  --bs-btn-hover-bg: var(--bsafe-accent);
  --bs-btn-hover-border-color: var(--bsafe-accent);
  --bs-btn-active-bg: var(--bsafe-accent);
  --bs-btn-active-border-color: var(--bsafe-accent);
  --bs-btn-focus-shadow-rgb: var(--bsafe-accent-rgb);
}

.pagination {
  --bs-pagination-color: var(--bsafe-accent);
  --bs-pagination-hover-color: var(--bsafe-accent-deep);
  --bs-pagination-active-bg: var(--bsafe-accent);
  --bs-pagination-active-border-color: var(--bsafe-accent);
}

.form-check-input:checked {
  background-color: var(--bsafe-accent);
  border-color: var(--bsafe-accent);
}

.form-control:focus,
.form-select:focus {
  border-color: rgba(var(--bsafe-accent-rgb), 0.6);
  box-shadow: 0 0 0 0.25rem rgba(var(--bsafe-accent-rgb), 0.2);
}

body {
  background-color: #f4f6f9;
}

/* ---------------------------------------------------------------- shell */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: var(--bsafe-sidebar-width);
  flex-shrink: 0;
  background-color: var(--bsafe-sidebar-bg);
  color: var(--bsafe-sidebar-fg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  /* AdminLTE's elevation-4, as on the legacy sidebar */
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
  z-index: 1030;
}

/* Brand row: the wordmark, and on a phone the slide-over's close control. */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-close { font-size: 0.7rem; }

/* The deployment's organisation (Settings > Branding) under the product
   name: B-SAFE stays, the customer's name and logo sit beside it. The logo
   gets a white tile because the sidebar is slate and a council crest is
   usually drawn for a light ground. */
.sidebar-brand { flex-wrap: wrap; row-gap: 0.55rem; }

.sidebar-brand-org {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.8);
}

.brand-org-logo {
  display: inline-flex;
  flex-shrink: 0;
  padding: 0.25rem 0.35rem;
  border-radius: 0.35rem;
  background: var(--bs-body-bg);
}

.brand-org-logo img {
  display: block;
  max-width: 5.5rem;
  max-height: 2rem;
}

/* The wordmark is a single colour, as in the legacy logo lockup. */
.sidebar-brand a { color: #fff; }

.brand-logo {
  height: 1.35rem;
  margin-right: 0.45rem;
  vertical-align: -0.25rem;
}

.sidebar-nav { padding: 0.5rem 0.6rem 1.5rem; }

/* Section labels. An h2 so the sections are real structure, drawn as the
   legacy nav-header: small caps, quiet — but 4.5:1 on the slate, which the
   old 0.55 tint was not. */
.sidebar-heading {
  margin: 0;
  padding: 1rem 0.75rem 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(194, 199, 208, 0.78);
}

/* AdminLTE dark-sidebar pills: rounded links, solid brand-blue active. */
.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--bsafe-sidebar-fg);
  padding: 0.45rem 0.75rem;
  margin-bottom: 0.15rem;
  border-radius: 0.3rem;
  font-size: 0.925rem;
}

.sidebar-nav .nav-link .bi {
  width: 1.25rem;
  flex-shrink: 0;
  text-align: center;
  font-size: 1rem;
  opacity: 0.85;
}

.sidebar-nav .nav-link:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-nav .nav-link.active {
  color: #fff;
  background-color: var(--bsafe-accent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.sidebar-nav .nav-link.active .bi { opacity: 1; }

/* Keyboard focus on the slate: Bootstrap's blue halo has no contrast on a
   dark ground, so the ring is white and inside the pill. */
.sidebar-nav .nav-link:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -2px;
  box-shadow: none;
}

.sidebar-nav .nav-link.disabled {
  color: rgba(194, 199, 208, 0.45);
}

/* Groups: the legacy treeview, one fold per family of registers. The toggle
   is a button drawn as a pill like the links around it; the caret turns when
   the fold is open; the pill goes white (not blue) when the fold holds the
   current page, so a collapsed group still says where you are. */
.sidebar-group-toggle {
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
}

/* A group label is one line: it is a heading for what is under it, and a
   heading that wraps reads as two entries. */
.sidebar-group-toggle span {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav .sidebar-group-toggle .sidebar-group-caret {
  width: auto;
  margin-left: auto;
  margin-right: -0.2rem;
  font-size: 0.75rem;
  opacity: 0.6;
  transition: transform 0.2s ease;
}

.sidebar-group-toggle[aria-expanded="true"] .sidebar-group-caret { transform: rotate(180deg); }

.sidebar-group-toggle.has-active,
.sidebar-group-toggle[aria-expanded="true"] { color: #fff; }

.sidebar-group-toggle.has-active .bi { opacity: 1; }

/* The fold. Children are indented under the group label and slightly
   smaller, with a hairline rail so the level reads as one block. */
.sidebar-subnav {
  margin: 0 0 0.25rem 0.85rem;
  padding-left: 0.35rem;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-subnav .nav-link {
  padding: 0.38rem 0.65rem;
  font-size: 0.875rem;
}

.sidebar-subnav .nav-link .bi { font-size: 0.9rem; }

.app-main {
  flex-grow: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* --- skip link (MOB-1, WCAG 2.2 SC 2.4.1) ---------------------------------
   Off-screen rather than display:none, because display:none takes it out of
   the tab order and a skip link nobody can tab to is decoration. It sits on
   top of the sticky topbar (z-index above .app-topbar's 1020) so the focused
   state is actually readable, and it is injected as the first child of <body>
   by shell.js. */
.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 1080;
  display: inline-block;
  padding: 0.55rem 1rem;
  background-color: var(--bsafe-accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 0.375rem 0.375rem;
  transition: top 0.15s ease-in-out;
}

.skip-link:focus,
.skip-link:focus-visible {
  top: 0;
  color: #fff;
  outline: 3px solid var(--bsafe-orange);
  outline-offset: 2px;
}

/* The shell gives <main> tabindex="-1" so the skip link can move focus, not
   just the viewport. Nobody should see a focus ring on the whole page for it. */
main.app-content:focus {
  outline: none;
}

/* --- topbar favourites (132 / SPEC-114) ---------------------------------- */
.topbar-star,
.topbar-favourites {
  flex: 0 0 auto;
  line-height: 1;
}

.topbar-star.is-favourite {
  color: #e0a800;
}

/* Phones. Measured at 390px: the hamburger, the counters, two icon buttons
   and the avatar leave the page title exactly nothing, and a topbar that has
   stopped saying which screen you are on is a worse trade than one control
   fewer. Below 576px the star moves INTO the favourites menu (see
   starItemHtml in js/components/favourites.js) and the caret and count come
   off the button, which gives the title its width back. */
@media (max-width: 575.98px) {
  .topbar-star,
  .topbar-favourites.dropdown-toggle::after { display: none; }

  /* Even one extra icon button leaves the title 21px at 390, so the bar wraps
     and the page name takes a row of its own UNDER the controls. Two short
     rows beat one row that has stopped naming the screen. */
  .app-topbar { flex-wrap: wrap; row-gap: 0.25rem; }

  #page-title { order: 10; flex: 1 0 100%; }
}

/* The title takes what it needs and truncates rather than collapsing: it is
   the only thing on the bar that names the page. */
#page-title {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-favourites::after {
  margin-left: 0.25rem;
}

.topbar-star-count:not(:empty) {
  display: inline-block;
  min-width: 1.25rem;
  margin-left: 0.25rem;
  padding: 0 0.3rem;
  border-radius: 0.75rem;
  background-color: var(--bsafe-accent);
  color: #fff;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.25rem;
  text-align: center;
}

.favourites-menu {
  min-width: 20rem;
  max-width: min(26rem, calc(100vw - 1.5rem));
  max-height: 70vh;
  overflow-y: auto;
}

/* The link takes the room; the controls keep a fixed gutter, so a long name
   truncates instead of pushing the buttons off the menu. */
.favourite-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.favourite-row .favourite-link {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.favourite-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding-right: 0.5rem;
}

.favourite-actions .btn-link {
  --bs-btn-color: var(--bsafe-muted);
  --bs-btn-hover-color: var(--bsafe-accent);
  padding: 0.15rem 0.3rem;
  text-decoration: none;
}

.favourite-actions .btn-link:disabled {
  opacity: 0.35;
}

.favourites-empty {
  white-space: normal;
}

.app-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background-color: #fff;
  border-bottom: 1px solid #e3e6ea;
  padding: 0.6rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.app-content {
  padding: 1.25rem;
  flex-grow: 1;
}

/* The topbar is sticky, so anything scrolled to the top edge of the page lands
   UNDER it: a deep link or anchor, a control focused with Tab, a script's
   scrollIntoView, and the "scroll to the start" step a browser-driven click
   falls back to. A row action in an open kebab menu was hidden behind the user
   button this way, and could not be clicked. The padding makes the scrollport
   start below the bar (WCAG 2.2 SC 2.4.11, focus not obscured). 7rem clears the
   two-row bar a phone gets, where the page name wraps under the controls. */
html { scroll-padding-top: 7rem; }

/* The name stays in the accessibility tree below 576px (it is the button's
   accessible name); only its box is taken out of the layout. */
@media (max-width: 575.98px) {
  .user-badge-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background-color: var(--bsafe-accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
}

/* --- topbar global search ------------------------------------------------
 * The one control in the chrome that goes to every module at once (116).
 *
 * It takes the growing space the page title used to take, and the title now
 * sizes to its content: the reader already knows which page they asked for,
 * and a search box narrow enough to hold four words is not one anybody types
 * into. Below 992px it goes away entirely rather than shrinking — the sidebar
 * toggle, the page name, the counters and the user menu already own that row,
 * and the results page carries a full-width search field of its own.
 */

.topbar-search {
  position: relative;
  min-width: 0;
  max-width: 32rem;
}

.topbar-search .form-control {
  padding-left: 2.1rem;
  background-color: #f5f6f8;
  border-color: #e3e6ea;
}

.topbar-search .form-control:focus {
  background-color: #fff;
}

.topbar-search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--bs-secondary-color);
  pointer-events: none;
  font-size: 0.9rem;
}

/* --- search results ------------------------------------------------------
 * One card per module, rows inside it. Grouping is the whole readability
 * argument: a flat list mixes an incident, a person and a policy document into
 * one undifferentiated column, and the reader's first question about any hit
 * is which register it lives in.
 */

.search-hit {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.6rem 0;
  border-top: 1px solid #eceef1;
  text-decoration: none;
  color: inherit;
}

.search-hit:first-child { border-top: 0; }

.search-hit:hover,
.search-hit:focus-visible {
  background-color: #f5f8fc;
}

.search-hit-title {
  flex-grow: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--bsafe-accent);
}

.search-hit-fields {
  flex: 0 0 auto;
  font-size: 0.8125rem;
  color: var(--bsafe-muted);
}

/* --- topbar counters -----------------------------------------------------
 * What is waiting for you, on every page: unread messages, your overdue
 * actions, the investigation questions somebody wants answered. Legacy carried
 * the same three in its navbar.
 *
 * They are quiet by construction. An icon in the muted text colour with a
 * small accent pill beside it — NOT a red disc, which in this palette means
 * "something has gone wrong" and would put a permanent alarm on the chrome of
 * every page. The count is the loud part, and only because it is a number in
 * the accent. A zero is never drawn (see shell.js), so the strip is empty for
 * a reader with nothing waiting and the topbar collapses back to title + user.
 */

.topbar-badges {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  /* Never squeezed. The counters and the user menu are controls; if the row
     runs out of room it is the TITLE that gives way (below), because the title
     names the page the reader just asked for and they can already infer it. */
  flex: 0 0 auto;
}

/* `flex-grow-1` alone does not let a flex item get SMALLER than its text: an
   item's automatic minimum size is its content, so a long page name pushed
   the user menu off a 390px topbar as soon as anything was added beside it.
   min-width: 0 restores the shrink, and the name then ellipsises. */
.app-topbar #page-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--bs-border-radius);
  color: var(--bsafe-muted);
  text-decoration: none;
  line-height: 1;
}

.topbar-badge:hover,
.topbar-badge:focus-visible {
  background-color: rgb(23 93 166 / 8%);
  color: var(--bsafe-accent);
}

.topbar-badge .bi { font-size: 1.05rem; }

.topbar-badge-count {
  display: inline-block;
  min-width: 1.35rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background-color: var(--bsafe-accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* A phone topbar holds a menu button, the page title and the user menu before
   these are asked for. Drop the padding so three counters still fit beside a
   title rather than pushing the user menu off the row. */
/* A phone topbar already holds a menu button, the page name and the user menu
   before the counters are asked for. Every measurement below buys the page
   NAME room to print in full rather than as "Dash…" — the counters shed their
   padding, the row sheds its gaps, and the bar sheds the horizontal inset the
   wider layout uses. */
@media (max-width: 575.98px) {
  .app-topbar {
    gap: 0.4rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  /* …and the name itself steps down one size. At 1.25rem "Dashboard" alone
     no longer fits beside three counters and a user menu, and a page name
     printed in full at 1.05rem beats "Dashbo…" printed larger. */
  .app-topbar #page-title { font-size: 1.05rem; }

  .topbar-badges { gap: 0.1rem; }

  /* The chrome search box is already gone below 992px; this keeps the rule
     with its neighbours if that breakpoint is ever widened. */
  .topbar-search { display: none; }

  .topbar-badge {
    gap: 0.2rem;
    padding: 0.2rem 0.15rem;
  }

  .topbar-badge .bi { font-size: 0.95rem; }

  .topbar-badge-count {
    min-width: 1.15rem;
    padding: 0.05rem 0.25rem;
  }
}

/* Small screens: sidebar slides over the content, toggled from the topbar. */
@media (max-width: 991.98px) {
  /* The topbar search box gives way to the toggle, the title, the counters
     and the user menu. /app/search.html still has its own field. */
  .topbar-search { display: none; }

  .app-sidebar {
    position: fixed;
    left: calc(-1 * var(--bsafe-sidebar-width));
    transition: left 0.2s ease;
    z-index: 1040;
  }
  .app-sidebar.open { left: 0; }
  /* Parked off-screen, the sidebar's shadow must not bleed onto the page edge. */
  .app-sidebar:not(.open) { box-shadow: none; }

  /* The scrim behind the open slide-over; a tap on it closes the menu. */
  body.sidebar-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.45);
    z-index: 1035;
  }
}

/* ----------------------------------------------------- policy documents */

/* Privacy and cookies notices. They are read signed-out, so they carry the
   report-document furniture without the app shell around it. */
.policy-page {
  min-height: 100vh;
  padding: 2rem 1rem 3rem;
  background: var(--bsafe-page, #f5f6f8);
}

.policy-doc {
  max-width: 52rem;
  margin: 0 auto;
}

.policy-doc .back-link { display: inline-block; margin-bottom: 0.75rem; }

.policy-title {
  margin: 0 0 1rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--bsafe-ink);
}

.policy-doc p { color: var(--bsafe-ink); }

/* A paragraph that follows a list needs its own space above it. */
.policy-doc .policy-after-list { margin-top: 1.25rem; }

/* The accessibility statement is the one policy page with a third level of
   heading (the GOV.UK model format uses them under "Technical information"
   and "Non-accessible content"). Smaller and quieter than the red section
   eyebrow above it, so the hierarchy reads at a glance. */
.policy-subtitle {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--bsafe-ink);
}

/* ---------------------------------------------------------------- login */

/* Single sign-on button, the divider above it and the legal notice below the
   card. SSO is the secondary way in: an outline under the form, so the one
   solid button on the card is the one that signs you in. It always links to
   /login/sso/start; when SSO is off, fails, or needs a tenant chosen, the
   server sends the browser back and login.js reveals the matching line. */
.login-card .btn-sso {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.sso-note {
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
  color: var(--bsafe-muted);
}

.sso-note.sso-failed {
  color: var(--bs-danger-text-emphasis);
}

.sso-choose .list-group-item {
  font-weight: 600;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.1rem 0;
  color: var(--bsafe-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--bsafe-line);
}

/* The Computer Misuse Act notice. Deliberately quiet — it is a legal
   statement, not a call to action — but legible against the dark ground. */
.login-disclaimer {
  max-width: 420px;
  margin: 0 auto;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.75rem;
  line-height: 1.5;
  text-align: left;
}


/* The legacy auth gradient: #191E30 → #241F33, orange CTA to match the logo.
   The card is centred by its own auto margins rather than align-items:center,
   because auto margins never push an item past the top edge: on a page taller
   than the window (1280×720 with the legal notice) align-items:center clipped
   the logo off the top. The padding is the side gutter on a phone. */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  background: linear-gradient(180deg, var(--bsafe-brand-dark-2) 0%, var(--bsafe-brand-dark) 60%);
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.4);
}

.login-card {
  width: 100%;
  max-width: 420px;
  margin-block: auto;
}

/* Links on the dark ground. The app's link colour is the brand accent, which
   is drawn for a white ground and falls to about 3:1 on this one; these are
   near-white and underlined instead. A link alone on its line gets a 24 px
   target (WCAG 2.5.8): inside a sentence the inline exception covers it. */
.login-links a {
  color: rgba(255, 255, 255, 0.92);
  text-decoration: underline;
}

.login-links a:hover { color: #fff; }

.login-links-target {
  display: inline-block;
  padding-block: 0.15rem;
}

/* The deployment's organisation under the B-SAFE lockup (login.js, from the
   public GET /branding). A logo gets the same white tile as in the sidebar. */
.login-org {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin: -0.75rem 0 1.25rem;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: center;
}

.login-logo {
  display: block;
  width: 110px;
  margin: 0 auto 1.5rem;
}

/* The sign-in button is the product's orange on an unbranded deployment.
   A branded one (Settings > Branding) defines --bsafe-auth-cta* in
   /branding/theme.css, and the button takes the organisation's colour: the
   one action on the page is theirs. The orange stays in the shield. */
.login-card .btn-primary,
.login-card .btn-success {
  --bs-btn-bg: var(--bsafe-auth-cta, var(--bsafe-orange));
  --bs-btn-border-color: var(--bsafe-auth-cta, var(--bsafe-orange));
  --bs-btn-hover-bg: var(--bsafe-auth-cta-deep, var(--bsafe-orange-deep));
  --bs-btn-hover-border-color: var(--bsafe-auth-cta-deep, var(--bsafe-orange-deep));
  --bs-btn-active-bg: var(--bsafe-auth-cta-deep, var(--bsafe-orange-deep));
  --bs-btn-active-border-color: var(--bsafe-auth-cta-deep, var(--bsafe-orange-deep));
  --bs-btn-disabled-bg: var(--bsafe-auth-cta, var(--bsafe-orange));
  --bs-btn-disabled-border-color: var(--bsafe-auth-cta, var(--bsafe-orange));
  --bs-btn-focus-shadow-rgb: var(--bsafe-auth-cta-rgb, 240, 81, 54);
}

/* ---------------------------------------------------------------- login language switch */

/* RCT r11. "English | Cymraeg" above the logo (login.js). Quiet text buttons
   on the dark ground: the language in force is bold and not underlined, the
   other is an underlined choice, so the state never rests on colour alone.
   Each button has a 24 px target (WCAG 2.5.8). */
.login-lang {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.55);
}

.login-lang-btn {
  min-height: 24px;
  padding: 0.2rem 0.4rem;
  border: 0;
  border-radius: 0.25rem;
  background: none;
  color: rgba(255, 255, 255, 0.92);
  text-decoration: underline;
}

.login-lang-btn:hover { color: #fff; }

.login-lang-btn[aria-pressed="true"] {
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

.login-lang-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- misc */

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

/* DataTables row click affordance used on list screens */
table.dataTable tbody tr { cursor: default; }

/* Registers whose whole row opens a detail view (incidents). */
#incidents-table tbody tr { cursor: pointer; }

/* Detail-view definition lists: label above value, wraps on narrow screens. */
.detail-list dt {
  font-weight: 500;
  color: var(--bs-secondary-color, #6c757d);
  font-size: 0.875rem;
  margin-bottom: 0;
}

.detail-list dd {
  margin-bottom: 0.75rem;
  white-space: pre-wrap;
}

/* ---------------------------------------------------------------- cards */

/* Quiet, consistent card chrome across the app. */
.card {
  --bs-card-border-color: var(--bsafe-line);
  box-shadow: 0 1px 2px rgba(28, 36, 52, 0.04);
}

.card > .card-header {
  background-color: #fff;
  font-weight: 600;
  color: var(--bsafe-ink);
}

/* ------------------------------------------------------ page header band */

.back-link {
  font-size: 0.85rem;
  color: var(--bsafe-muted);
  text-decoration: none;
}

.back-link:hover { color: var(--bsafe-accent); }

.page-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--bsafe-ink);
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.page-subtitle {
  color: var(--bsafe-muted);
  font-size: 0.9rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem;
}

/* ------------------------------------------- detail page action bar (tiers)

   A detail page's actions are three tiers rendered by
   js/components/page-actions.js: one solid button (the record's next step),
   at most two outlines, and a "More" menu for the rest. The row used to be up
   to fourteen equal-weight buttons with no responsive rules at all, which on
   a phone was five rows of buttons before any content.

   The menu is `position: fixed` via Popper (bindFixedDropdown) so it escapes
   `.page-head`; it therefore needs no overflow rules here, only a width floor
   so the section headers are not squeezed onto two lines. */

.page-actions-more .dropdown-menu {
  min-width: 15rem;
  --bs-dropdown-header-color: var(--bsafe-muted);
}

.page-actions-more .dropdown-header {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.page-actions-more .dropdown-toggle::after { display: none; }

.page-actions-more .dropdown-toggle .bi-chevron-down {
  font-size: 0.7rem;
  vertical-align: baseline;
}

/* The one line under the header that asks the reader to DO something — an
   overdue statutory duty, a half-finished investigation. It is deliberately
   NOT a chip: the chip row carries identity (status, category, RIDDOR), and
   mixing an alert into it made the most important thing on the page look like
   a label. Warning tint, a triangle, and `role="status"` on the element. */

.page-attention {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: -0.5rem 0 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--bsafe-attention-line);
  border-left-width: 4px;
  border-radius: var(--bs-border-radius, 0.375rem);
  background: var(--bsafe-attention-bg);
  color: var(--bsafe-attention-ink);
  font-size: 0.875rem;
  font-weight: 500;
}

.page-attention .bi-exclamation-triangle-fill,
.page-attention .bi-check-circle-fill {
  color: var(--bsafe-attention-mark);
  flex: none;
}

/* Done: the same band, restated in green. Only the four tokens change — the
   geometry, the weight and the left border stay put, so the line does not
   move or reflow when an investigation reaches step 6 while you are reading
   it. An alert that can never stand down is one the reader learns to skip. */

.page-attention-done {
  --bsafe-attention-bg: var(--bsafe-attention-done-bg);
  --bsafe-attention-line: var(--bsafe-attention-done-line);
  --bsafe-attention-ink: var(--bsafe-attention-done-ink);
  --bsafe-attention-mark: var(--bsafe-attention-done-mark);
}

.page-attention-sep { color: var(--bsafe-attention-mark); opacity: 0.7; }

/* Mobile: the head stacks — title block, then the action row below it. Under
   576px the tier-1 and tier-2 buttons also drop their glyphs. Every action
   gained an icon (ACTION_KINDS in js/components/page-actions.js), each one
   about 18px of button, and that was enough to push More onto a second line:
   the incident bar (Close case · Edit · Investigation · More) measures 378px
   at 390 and 324px without the glyphs, so it is back on one line. At this
   width the glyph is what goes, never the caption — an icon-only button is an
   unlabelled control (style guide hard rule 6) — and the `title` stays on
   every control either way. A bar whose three captions are unusually wordy
   still wraps, and it should: that is the row saying it has too many words,
   not too little room. The appointment page used to be the example — "Check
   the employee in · Edit · Record a screening · More" measured 444px at 390 —
   and the answer was to shorten the captions ("Check in", "Screening"), not
   to widen the bar or take a label off. The verbs survive in each button's
   `title` and in the glyph that comes back at 576px.

   The More button keeps its chevron, because that is what says "this opens",
   and the menu items keep theirs: a dropdown is as wide as it needs to be. */

@media (max-width: 575.98px) {
  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  .page-actions { width: 100%; }

  /* Only the bar's own buttons: the More toggle sits inside
     `.page-actions-more`, so the child combinator already spares its chevron
     and the dropdown items below it — `:not(.dropdown-toggle)` says so out
     loud for the day someone flattens the wrapper. `iconHtml()` writes a
     space after the glyph, and it belongs to the caption's text node; with
     the icon out of the box tree that space leads the line box and collapses
     away, so no caption starts with a gap. */
  .page-actions > .btn:not(.dropdown-toggle) > .bi { display: none; }

  .page-attention { margin-top: 0; }
}

/* --------------------------------------------------------- lifecycle rail */

.lifecycle {
  display: flex;
  list-style: none;
  margin: 0 0 1rem;
  padding: 0.9rem 1.1rem;
  background: var(--bs-body-bg);
  border: 1px solid var(--bsafe-line);
  border-radius: var(--bs-border-radius, 0.375rem);
  box-shadow: 0 1px 2px rgba(28, 36, 52, 0.04);
  overflow-x: auto;
}

.lc-step {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
}

.lc-step:last-child { flex: 0 0 auto; }

.lc-step::after {
  content: "";
  flex: 1;
  height: 2px;
  background: var(--bsafe-line);
  margin: 0 0.9rem;
  min-width: 1.5rem;
}

.lc-step.done::after { background: var(--bsafe-accent); }
.lc-step:last-child::after { display: none; }

/* Station names are long ("Submitted for review", "File attached") and there
   can be six of them (controlled documents), so `flex: 1` divides the narrow
   viewport into slices far below the width of a label — the steps then overlap
   into unreadable mush rather than wrapping. Below the md breakpoint let each
   step keep its natural width so the rail scrolls sideways instead, which
   .lifecycle already affords with overflow-x: auto.

   This was first fixed for the SSWP rail alone, as `.lifecycle-sswp`. That
   scoping was too narrow: the defect is in the shared `flex: 1`, so every
   other rail — incident, permit, claim, audit, assessment, training course,
   OH visit and the new controlled-document rail — had it too. Fixing the
   primitive is what removes the whole class of defect; a per-page modifier
   only ever hides one instance of it. */
@media (max-width: 767.98px) {
  .lifecycle .lc-step { flex: 0 0 auto; }
  .lifecycle .lc-step::after { min-width: 1.25rem; }
}

.lc-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.lc-dot {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  margin-right: 0.6rem;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 600;
  background: #eef1f6;
  color: #8a93a6;
  border: 2px solid transparent;
}

.lc-step.done .lc-dot {
  background: var(--bsafe-accent);
  color: #fff;
}

.lc-step.current .lc-dot {
  background: var(--bs-body-bg);
  border-color: var(--bsafe-accent);
  color: var(--bsafe-accent);
}

.lc-text { min-width: 0; line-height: 1.25; }

.lc-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #8a93a6;
  white-space: nowrap;
}

.lc-step.done .lc-label,
.lc-step.current .lc-label { color: var(--bsafe-ink); }

.lc-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--bsafe-muted);
  white-space: nowrap;
}

.lc-step.current .lc-sub { color: var(--bsafe-accent); }

/* --------------------------------------------------------- report document */

.report-card { border-radius: 0.5rem; }

.report-letterhead {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-bottom: 2px solid var(--bsafe-ink);
}

.report-brand {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--bsafe-ink);
}

.letterhead-mark {
  height: 1.5rem;
  margin-right: 0.5rem;
  vertical-align: -0.3rem;
}

.report-title {
  font-weight: 600;
  color: var(--bsafe-report-red);
  font-variant-numeric: tabular-nums;
}

.report-body { padding: 1.5rem; }

.report-body section + section {
  margin-top: 1.9rem;
}

/* An occupational health report (093) renders its sections from the payload
   into two containers — the manager-facing half and the clinical half —
   rather than writing them into the markup, because HOW MANY there are and
   which side each sits on is the template's decision and not the page's.
   `display: contents` drops the containers' own boxes so the sections lay out
   as though they were written straight into the report body, and these two
   selectors restore the `section + section` rhythm across a container
   boundary, which a sibling combinator cannot reach through. */
.report-sections { display: contents; }

.report-body .report-sections section,
.report-body .report-sections ~ section {
  margin-top: 1.9rem;
}

.report-section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--bsafe-report-red);
}

.report-section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e9ecf1;
}

/* keep the hairline between the title and a trailing control (Add a person) */
.report-section-title .btn {
  text-transform: none;
  letter-spacing: normal;
  order: 1;
}

/* Two label/value pairs per row — the legacy report table, on CSS grid. */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 2.5rem;
  row-gap: 0.9rem;
  margin: 0;
}

.detail-item.wide { grid-column: 1 / -1; }

.detail-item dt {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--bsafe-muted);
  margin-bottom: 0.15rem;
}

.detail-item dd {
  margin: 0;
  white-space: pre-wrap;
  color: var(--bsafe-ink);
  overflow-wrap: break-word;
}

@media (max-width: 575.98px) {
  .detail-grid { grid-template-columns: 1fr; }
  .report-body { padding: 1rem; }
}

.report-table thead th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bsafe-muted);
  border-bottom-width: 1px;
}

/* A report table with enough columns that a phone would otherwise crush every
   cell into a five-line stack. `.table-responsive` already gives the wrapper
   overflow-x, but a table with no floor happily shrinks to fit it and never
   scrolls, so the columns wrap instead — legible in the sense that the text is
   all there, and unreadable in every other sense.
   The floor makes the scroll actually happen. Same shape as
   `.task-calendar` inside `.task-calendar-scroll`. Print resets it: paper is
   wide enough and a clipped column would simply be lost. */
.report-table-wide { min-width: 46rem; }

@media print {
  .report-table-wide { min-width: 0; }
}

/* ------------------------------------------------------------ case notes */

.notes-timeline { margin-left: 0.4rem; }

.note-item {
  position: relative;
  padding: 0 0 1rem 1.4rem;
  border-left: 2px solid #e9ecf1;
}

.note-item:last-child { padding-bottom: 0.25rem; }

.note-item::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 0.35rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bsafe-accent);
}

.note-item.empty::before { background: #c6cdd9; }

.note-author { font-weight: 600; color: var(--bsafe-ink); }

.note-text {
  margin-top: 0.15rem;
  white-space: pre-wrap;
}

/* ------------------------------------------------------------- stat tiles */

/* Dashboard summary tiles: semantic colour as a stripe, not a slab. */
.stat-tile {
  height: 100%;
  background: var(--bs-body-bg);
  border: 1px solid var(--bsafe-line);
  border-left: 4px solid var(--bsafe-accent);
  border-radius: var(--bs-border-radius, 0.375rem);
  padding: 0.85rem 1rem;
  box-shadow: 0 1px 2px rgba(28, 36, 52, 0.04);
}

.stat-danger { border-left-color: var(--bs-danger); }
.stat-warning { border-left-color: var(--bs-warning); }
.stat-success { border-left-color: var(--bs-success); }

/* A tile that is only a count — "Archived", "All notices". Without a tone of
   its own it inherited the accent-blue stripe every tile starts with, which
   reads as brightly as "Signed off"; the hairline says "here, not news". */
.stat-muted { border-left-color: var(--bsafe-line); }

.stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--bsafe-muted);
}

.stat-count {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--bsafe-ink);
  font-variant-numeric: tabular-nums;
}

.stat-hint {
  font-size: 0.78rem;
  color: var(--bsafe-muted);
}

/* ---------------------------------------------------------- filter toggle */

/* The whole register-filter header is the collapse control. */
.filter-toggle {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  border: 0;
  border-bottom: 1px solid transparent;
  cursor: pointer;
}

.filter-toggle:not(.collapsed) { border-bottom-color: var(--bsafe-line); }

.filter-toggle:hover { background-color: #f8f9fb; }

.filter-caret {
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--bsafe-muted);
  border-bottom: 2px solid var(--bsafe-muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.filter-toggle:not(.collapsed) .filter-caret { transform: rotate(-135deg); }

/* -------------------------------------------------------------- settings */

/* The settings screen's two tabs (custom fields / reference lists). Stock
   Bootstrap tabs read as an unfinished dialog on a full-width admin page, so
   the active tab is marked with the app accent rather than a floating box. */
.settings-tabs {
  border-bottom: 1px solid var(--bsafe-line);
  gap: 0.25rem;
}

.settings-tabs .nav-link {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.55rem 0.95rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--bsafe-muted);
}

.settings-tabs .nav-link:hover { color: var(--bsafe-accent); }

.settings-tabs .nav-link.active {
  color: var(--bsafe-accent);
  background: transparent;
  border-bottom-color: var(--bsafe-accent);
}

.settings-tab-content { padding-top: 1.25rem; }

/* One instructive sentence above each tab's controls. */
.settings-lede {
  max-width: 68ch;
  margin-bottom: 1rem;
  color: var(--bsafe-muted);
  font-size: 0.9rem;
}

/* A heading inside a settings tab, for the one panel that needs its rows
   split into groups (the module switchboard's locked four). Not
   `.report-section-title`: that red uppercase eyebrow belongs to the report
   document, and this is a form. */
.settings-group-title {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bsafe-muted);
}

.settings-group-note {
  max-width: 68ch;
  margin-bottom: 0;
  color: var(--bsafe-muted);
  font-size: 0.85rem;
}

/* One module on/off switch: the control and the label on one line, and the
   plain-words consequence beneath it. The sentence is the point — "Hidden
   everywhere" tells an operator what the switch DID, which a bare toggle
   never does. */
.module-switch {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  height: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.5rem;
  background: var(--bs-body-bg);
}

.module-switch .form-check-label {
  font-weight: 600;
  font-size: 0.925rem;
  cursor: pointer;
}

.module-switch-state {
  padding-left: 2.5em;   /* clears the switch, so the sentence lines up with the name */
  color: var(--bsafe-muted);
  font-size: 0.8rem;
}

/* A module that cannot be switched off at all. Muted rather than alarming:
   it is a property of the product, not an error the reader made. */
.module-switch-locked {
  border-style: dashed;
  background: var(--bs-tertiary-bg);
}

.module-switch-locked .form-check-label { cursor: default; }

/* ------------------------------------------- escalation ladder (Lampton, 170)
   Settings › Scheduled jobs. Four numbered rungs read top to bottom as a
   sentence each: who is told, then when. The day boxes are narrow because
   they hold two digits; on a phone the "when" wraps under the "who". */
.ladder-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  margin-bottom: 1rem;
}

.ladder-switch .form-check-label { font-weight: 600; cursor: pointer; }

.ladder-switch-state {
  color: var(--bsafe-muted);
  font-size: 0.85rem;
}

.ladder-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ladder-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.5rem;
  background: var(--bs-body-bg);
}

.ladder-steps.ladder-off .ladder-step { background: var(--bs-tertiary-bg); }

.ladder-step-num {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--bsafe-line);
  font-weight: 700;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.ladder-step-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  min-height: 1.75rem;
}

.ladder-step-who {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  font-weight: 600;
}

.ladder-step-who label { margin: 0; }

.ladder-step-rule {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  color: var(--bsafe-muted);
}

.ladder-days {
  width: 4.5rem;
  font-variant-numeric: tabular-nums;
}

.ladder-mailbox {
  width: 16rem;
  max-width: 100%;
  font-weight: 400;
}

.ladder-preview:empty { display: none; }

.ladder-preview {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--bsafe-line);
}

.ladder-preview .report-table td { vertical-align: top; }

.ladder-who-role {
  display: block;
  color: var(--bsafe-muted);
  font-size: 0.85rem;
}

/* --------------------------------------- finding response times (Lampton S2)
   Settings > Reference lists > Inspections. Three rows read as a sentence each:
   the severity, then "Due in N days", then the priority. The number box is
   narrow because it holds up to three digits; on a phone each field takes a
   line of its own under the severity, so nothing sits side by side at 390 px. */
.frt-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.frt-row {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.5rem;
  background: var(--bs-body-bg);
}

.frt-name {
  font-weight: 600;
  font-size: 1rem;
}

.frt-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.frt-field label {
  flex: 0 0 4.5rem;
  margin: 0;
  color: var(--bsafe-muted);
  font-size: 0.9rem;
}

.frt-days { width: 5.5rem; font-variant-numeric: tabular-nums; }
.frt-priority { width: 10rem; max-width: 100%; }
.frt-unit { color: var(--bsafe-muted); font-size: 0.9rem; }

.frt-observation { margin-top: 1.25rem; }
.frt-observation .form-check-label { font-weight: 600; cursor: pointer; }

.frt-view-only { color: var(--bsafe-muted); font-size: 0.85rem; }

@media (min-width: 768px) {
  .frt-row {
    flex-direction: row;
    align-items: center;
    gap: 1.5rem;
  }

  .frt-name { flex: 0 0 6rem; }
  .frt-field label { flex: 0 0 auto; }
}

/* Master list of reference sets: full-width pill rows with a row count, the
   legacy "Databases" accordion rebuilt as a real selector. */
.settings-lookup-nav .nav-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  border: 0;
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
  color: var(--bsafe-ink);
}

.settings-lookup-nav .nav-link:not(.active):hover { background-color: #f8f9fb; }

/* Explicit, so the :hover rule above can never win over the selected row. */
.settings-lookup-nav .nav-link.active,
.settings-lookup-nav .nav-link.active:hover {
  background-color: var(--bsafe-accent);
  color: #fff;
}

.lookup-count {
  flex: none;
  min-width: 2rem;
  text-align: center;
  padding: 0.05rem 0.4rem;
  border-radius: 0.75rem;
  background: #eef1f6;
  color: var(--bsafe-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.settings-lookup-nav .nav-link.active .lookup-count {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

/* Reference lists carry the odd long value (RIDDOR form URLs). Clip them so
   one column cannot squeeze the name out of the table — the full text stays
   available as the cell's title. */
.lookup-clip {
  display: inline-block;
  max-width: 15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

/* ------------------------------------------------------ permit signatures */

/*
 * The permit-to-work signature pad (permit.html) and the two signature shots
 * printed on the permit document. The legacy app pulled in
 * canvas-free-drawing.js and an unstyled bordered <canvas>; the pad here is a
 * plain canvas drawn on by pointer events, so all it needs is a surface that
 * reads as somewhere to sign.
 */

.signature-pad {
  display: block;
  width: 100%;
  max-width: 34rem;
  height: auto;
  aspect-ratio: 600 / 220;
  background: var(--bs-body-bg);
  border: 1px dashed var(--bs-border-color);
  border-radius: 0.375rem;
  touch-action: none; /* the pad handles pointer drags itself */
  cursor: crosshair;
}

.signature-block {
  height: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  background: var(--bs-body-bg);
}

.signature-block-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bsafe-muted);
}

.signature-shot {
  display: block;
  width: 100%;
  max-width: 16rem;
  height: auto;
  margin: 0.4rem 0;
}

.signature-block-time {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--bsafe-muted);
}

/* ----------------------------------------------------------------- print */

/* The report card prints as a stand-alone document, legacy-style. */
@media print {
  body { background: #fff; }
  .app-sidebar,
  .app-topbar,
  .skip-link,
  .no-print,
  .page-actions,
  .alert { display: none !important; }
  .app-content { padding: 0; }
  .card,
  .report-card { border: 0; box-shadow: none; }
  .report-letterhead { padding-inline: 0; }
  .report-body { padding: 1rem 0 0; }
  .person-edit-btn,
  .person-delete-btn { display: none !important; }

  /* Pagination. Without these a long people table or notes timeline is sliced
     mid-row and the header only appears on page one — the two things that make
     a printed report look broken. They live here, not in a PDF-only
     stylesheet, so the Print button gets the same treatment. */
  .report-table thead { display: table-header-group; }
  .report-table tr,
  .detail-item,
  .note-item { break-inside: avoid; }
  .report-section-title { break-after: avoid; }
  .report-body section { break-before: auto; }

  /* Keep the design's colour. Chromium (and the sidecar) drop every background
     otherwise, which costs the letterhead rule its weight and turns the status
     badges into empty grey boxes. */
  .report-letterhead,
  .report-section-title,
  .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* -------------------------------------------- confidentiality marking */

/*
 * The marking a clinical document carries ON THE PAPER.
 *
 * It lives INSIDE `.report-card`, not in the `no-print` page head, and that
 * placement is the whole point. A status chip in the page head is stripped by
 * the `@media print` rule above AND is outside the fragment report-pdf.js
 * posts to the renderer (which is `.report-card` and nothing else), so a
 * marking kept up there is on the screen and on no printed artefact at all —
 * exactly the gap this class closes. Anything that prints a medical record
 * emits one of these.
 *
 * Shown on screen too, deliberately: what you see is what you print, and a
 * `d-print-block`-only marking is a marking nobody proofreads.
 */
.report-confidentiality {
  margin: 1.5rem 0 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--bsafe-line);
  border-left: 3px solid var(--bsafe-report-red);
  border-radius: 0.25rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--bsafe-ink);
  /* A tint of --bsafe-report-red rather than a token: the palette has no
     surface variable, and the block needs to read as part of the report
     document's red rule, not as a generic grey callout. */
  background: #faf7f6;
  break-inside: avoid;
}

.report-confidentiality-title {
  display: block;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
  color: var(--bsafe-report-red);
}

.report-confidentiality p {
  margin: 0.25rem 0 0;
}

@media print {
  /* Keep the rule and the tint — the marking losing its box is the marking
     losing the thing that makes a reader notice it. */
  .report-confidentiality {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    break-inside: avoid;
  }
}

/* Footer line the server-rendered PDF stamps under a document or register.
   Screen never shows it — nothing on a page emits it. */
.pdf-generated {
  margin: 1.25rem 0 0;
  font-size: 0.7rem;
  color: var(--bsafe-muted);
}

/* ------------------------------- safe systems of work */

/* Register whose whole row opens the method statement. */
#sswps-table tbody tr { cursor: pointer; }

/* Free-text blocks inside the report document (training, equipment, disposal):
   the same typography as a .detail-item value, keeping the author's newlines. */
.report-prose {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  color: var(--bsafe-ink);
}

/* PPE / sequence / restriction lists — tighter than the Bootstrap default so
   they read as part of the document rather than as a stack of paragraphs. */
.report-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--bsafe-ink);
}

.report-list li { margin-bottom: 0.3rem; }
.report-list li:last-child { margin-bottom: 0; }

/* The "nothing recorded" line inside a report list is a sentence, not an item:
   no bullet, no number, flush with the surrounding prose. */
.report-list li.report-list-empty {
  list-style: none;
  margin-left: -1.25rem;
}

/* The SSWP rail's narrow-viewport rule moved to the shared .lifecycle block
   above, where it now covers every rail rather than this one page. */
/* ------------------------------------------------------------------ coshh */

/* COSHH registers open a detail view from anywhere in the row, like the
   incident register above. */
#coshh-table tbody tr,
#sds-table tbody tr { cursor: pointer; }

/* The exposure-episode notes sit under the episode name inside the report
   table, so they need the same wrapping the report's field values get. */
#episodes-table td { white-space: normal; }
/* ------------------------------------------------------------------ */
/* Claims module (069)                                                 */
/* Money columns in the claims register and the claim report line up on */
/* the decimal point; the register keeps them right-aligned via         */
/* .text-end, this only supplies the figure shapes.                     */
/* ------------------------------------------------------------------ */

.amount-cell,
#losses-section .detail-item dd {
  font-variant-numeric: tabular-nums;
}
/* ------------------------------------------------- tasks & calendar */

/*
 * The app's month-grid primitive. Hand-rolled on CSS grid: the CSP forbids CDN
 * assets and no calendar library is vendored, so the legacy FullCalendar month
 * view is re-expressed with the app's own primitives.
 *
 * SHARED, despite the names. These rules started life on the Tasks & calendar
 * page and kept their `task-` prefix when js/components/month-calendar.js was
 * lifted out of it; the occupational-health clinic calendar draws the same
 * grid from the same component. The prefix is history, not scope — renaming it
 * would only churn the e2e and demo selectors that already name these classes.
 */

.task-calendar-scroll {
  overflow-x: auto;
}

.task-calendar {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 46rem;
  background-color: var(--bsafe-line);
  border: 1px solid var(--bsafe-line);
  border-radius: var(--bs-border-radius, 0.375rem);
  overflow: hidden;
}

.task-cal-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(6.5rem, 1fr));
  gap: 1px;
}

.task-cal-head {
  background-color: #f8f9fb;
  padding: 0.4rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--bsafe-muted);
}

.task-cal-day {
  background-color: #fff;
  min-width: 0;
  min-height: 6.5rem;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.task-cal-day.is-outside { background-color: #fafbfc; }

.task-cal-day.is-today { box-shadow: inset 0 0 0 2px var(--bsafe-accent); }

/* The day number doubles as the "drill the register down to this day" control. */
.task-cal-date {
  align-self: flex-start;
  border: 0;
  background: none;
  padding: 0 0.2rem;
  border-radius: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--bsafe-ink);
  cursor: pointer;
}

.task-cal-date:hover { background-color: rgba(var(--bsafe-accent-rgb), 0.1); }

.task-cal-day.is-today .task-cal-date { color: var(--bsafe-accent); }

.task-cal-items {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.task-chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
  max-width: 100%;
  padding: 0.12rem 0.3rem;
  border-radius: 0.25rem;
  background-color: #f1f4f8;
  color: var(--bsafe-ink);
  font-size: 0.75rem;
  line-height: 1.3;
  text-decoration: none;
}

/* text-overflow needs a block-level child — a flex container never elides. */
.task-chip-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.task-chip:hover { background-color: #e4eaf2; color: var(--bsafe-accent-deep); }

.task-chip-dot {
  flex: 0 0 auto;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: var(--bs-secondary);
}

/* The status vocabulary includes `light` (a cancelled appointment), which is
   invisible on the chip's own near-white ground without an outline. */
.task-chip-dot.bg-light {
  box-shadow: 0 0 0 1px var(--bsafe-muted);
}

/*
 * The phone rendering of the same month. Seven columns inside 390px is a
 * horizontal-scroll trap, so under `sm` the grid gives way to an agenda: only
 * the days that hold something, each with ALL of its entries — no "+N more",
 * because down here there is room.
 */
.cal-agenda-day + .cal-agenda-day {
  margin-top: 0.85rem;
  border-top: 1px solid var(--bsafe-line);
  padding-top: 0.85rem;
}

.cal-agenda-date {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--bsafe-muted);
  font-variant-numeric: tabular-nums;
}

.cal-agenda-day.is-today .cal-agenda-date { color: var(--bsafe-accent); }

.cal-agenda-items {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* The agenda has the width the cells do not: chips breathe and wrap. */
.cal-agenda-items .task-chip {
  padding: 0.3rem 0.5rem;
  font-size: 0.82rem;
}

.cal-agenda-items .task-chip-label { white-space: normal; }

/* One clinic day, opened out of a cell that could not hold it. */
.cal-day-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cal-day-list li + li {
  margin-top: 0.5rem;
  border-top: 1px solid var(--bsafe-line);
  padding-top: 0.5rem;
}

.cal-day-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--bsafe-ink);
}

.task-cal-more {
  align-self: flex-start;
  border: 0;
  background: none;
  padding: 0;
  font-size: 0.72rem;
  color: var(--bsafe-accent);
  cursor: pointer;
}

/* Traffic-light key, shared by the chips and the legend swatches. */
.rag-red { background-color: var(--bs-danger); }
.rag-amber { background-color: var(--bs-warning); }
.rag-green { background-color: var(--bs-success); }

.task-cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
  font-size: 0.78rem;
  color: var(--bsafe-muted);
}

.task-cal-legend li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.task-cal-key {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
}

.cal-month {
  font-weight: 700;
  color: var(--bsafe-ink);
  font-variant-numeric: tabular-nums;
}

/* Register rows open the owning entity's detail view. */
#tasks-table tbody tr { cursor: pointer; }

.task-text {
  display: inline-block;
  max-width: 22rem;
  vertical-align: bottom;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Slim inline completion bar; the width is set per row from the payload. */
.task-progress {
  display: inline-block;
  width: 3.5rem;
  height: 0.4rem;
  vertical-align: middle;
  margin-right: 0.4rem;
  border-radius: 0.2rem;
  background-color: #e9edf2;
  overflow: hidden;
}

.task-progress-bar {
  display: block;
  width: 0;
  height: 100%;
  background-color: var(--bsafe-accent);
}

.task-progress-label {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--bsafe-muted);
}

/* --------------------------------------------------- Risk assessments (G13) */

/*
 * The risk-assessment module: register table cells, the matrix grid inside the
 * report document, the hazard register and the review history. Everything here
 * reuses the tokens declared at the top of this file and Bootstrap's semantic
 * colours — no new hexes.
 */

/* Registers whose whole row opens a detail view. */
#assessments-table tbody tr { cursor: pointer; }

/* The id cell carries the row's priority as a coloured rule. */
.assessment-id {
  display: inline-block;
  padding-left: 0.5rem;
  border-left: 3px solid var(--bsafe-line);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

.assessment-id.prio-high { border-left-color: var(--bs-danger); }
.assessment-id.prio-medium { border-left-color: var(--bs-warning); }
.assessment-id.prio-low { border-left-color: var(--bs-success); }

.assessment-title { font-weight: 600; color: var(--bsafe-ink); }

.assessment-sub {
  display: block;
  font-size: 0.78rem;
  color: var(--bsafe-muted);
}

.hazard-count {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--bsafe-ink);
}

.review-date { font-variant-numeric: tabular-nums; }
.review-date.is-overdue { font-weight: 600; color: var(--bs-danger); }

/* Implementation progress: the width is data-driven, so it lives here as a
   5%-step class ladder rather than an inline style. */
.assessment-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 8rem;
}

.assessment-progress .progress {
  flex: 1;
  height: 0.5rem;
  min-width: 4rem;
}

.assessment-progress-value {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--bsafe-muted);
}

.assessment-progress .progress-bar.pct-0 { width: 0%; }
.assessment-progress .progress-bar.pct-5 { width: 5%; }
.assessment-progress .progress-bar.pct-10 { width: 10%; }
.assessment-progress .progress-bar.pct-15 { width: 15%; }
.assessment-progress .progress-bar.pct-20 { width: 20%; }
.assessment-progress .progress-bar.pct-25 { width: 25%; }
.assessment-progress .progress-bar.pct-30 { width: 30%; }
.assessment-progress .progress-bar.pct-35 { width: 35%; }
.assessment-progress .progress-bar.pct-40 { width: 40%; }
.assessment-progress .progress-bar.pct-45 { width: 45%; }
.assessment-progress .progress-bar.pct-50 { width: 50%; }
.assessment-progress .progress-bar.pct-55 { width: 55%; }
.assessment-progress .progress-bar.pct-60 { width: 60%; }
.assessment-progress .progress-bar.pct-65 { width: 65%; }
.assessment-progress .progress-bar.pct-70 { width: 70%; }
.assessment-progress .progress-bar.pct-75 { width: 75%; }
.assessment-progress .progress-bar.pct-80 { width: 80%; }
.assessment-progress .progress-bar.pct-85 { width: 85%; }
.assessment-progress .progress-bar.pct-90 { width: 90%; }
.assessment-progress .progress-bar.pct-95 { width: 95%; }
.assessment-progress .progress-bar.pct-100 { width: 100%; }

/* ------------------------------------------- report document: shared bits */

.report-note {
  margin: -0.4rem 0 0.9rem;
  font-size: 0.85rem;
  color: var(--bsafe-muted);
}

.report-subsection-title {
  margin: 1.25rem 0 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--bsafe-muted);
}

/* ------------------------------------- subject access pack (142) record

   The letterheaded record inside a subject access ZIP
   (App\Services\SubjectAccess\SubjectAccessDocument), rendered by the PDF
   sidecar with this stylesheet - or opened from record.html with it inlined.
   One person's whole file runs to dozens of records under each section
   eyebrow, so each record gets a quiet heading and a hairline above it rather
   than a card of its own; the records hanging off one (a report under its
   appointment, the answers under a questionnaire) are indented on a rule. */

.sar-prepared { margin-bottom: 1rem; }

.sar-record {
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px solid var(--bsafe-line);
}

.report-body section > .sar-record:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: 0;
}

.sar-record-title {
  margin: 0 0 0.7rem;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--bsafe-ink);
  break-after: avoid;
}

.sar-subrecord {
  margin: 0.75rem 0 0;
  padding: 0 0 0 0.9rem;
  border-top: 0;
  border-left: 2px solid var(--bsafe-line);
}

.sar-subrecord .sar-record-title { font-size: 0.85rem; }

.sar-record-files {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: var(--bsafe-muted);
  overflow-wrap: anywhere;
}

/* The record dialog's footer (users.html) carries the actions on the PERSON
   - "Download full record" - on the left, Cancel and Save on the right.
   renderPageActions() draws its buttons small, for a page head; in a footer
   they take the footer's own size, so the row reads as one row. */
.modal-footer .user-record-actions > .btn {
  --bs-btn-padding-y: 0.375rem;
  --bs-btn-padding-x: 0.75rem;
  --bs-btn-font-size: 1rem;
  --bs-btn-border-radius: var(--bs-border-radius);
}

/* ---- RCT r49 - merging duplicate records (users.html) ----
   The Compare table: three columns of names and email addresses do not fit a
   phone, and the table-responsive wrapper made the dialog scroll sideways at
   390 px. Under 576 px the columns share the width and long values (email
   addresses) wrap anywhere instead. */
@media (max-width: 575.98px) {
  .merge-compare-table { table-layout: fixed; }

  .merge-compare-table th:first-child { width: 28%; }

  .merge-compare-table th,
  .merge-compare-table td { overflow-wrap: anywhere; }
}

/* "Find duplicates": one block per pair, the two records side by side from
   576 px and stacked under it, so nothing scrolls sideways on a phone. */
.dup-pair {
  padding: 0.875rem 0;
  border-top: 1px solid var(--bsafe-line);
}

.dup-pair:first-child { border-top: 0; padding-top: 0; }

.dup-pair-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.dup-reason {
  margin: 0.25rem 0 0.5rem 1.5em;
  font-size: 0.875rem;
  color: var(--bsafe-muted);
}

.dup-records {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-left: 1.5em;
}

@media (min-width: 576px) {
  .dup-records { grid-template-columns: 1fr 1fr; }
}

/* On a phone the swap button wraps under the tick-box line: indent it with
   the rest of the pair rather than under the box. */
@media (max-width: 575.98px) {
  .dup-pair-head > .btn { margin-left: 1.5em; }
}

.dup-record {
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--bsafe-line);
  border-radius: var(--bs-border-radius);
}

.dup-role {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bsafe-muted);
}

.dup-name { font-weight: 600; }

.dup-meta {
  display: flex;
  flex-direction: column;
  font-size: 0.875rem;
  color: var(--bsafe-muted);
  overflow-wrap: anywhere;
}

.dup-result {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.dup-result + .dup-result { border-top: 1px solid var(--bsafe-line); }

.dup-selected { margin-right: auto; font-size: 0.875rem; }

/* ------------------------------------------------------ risk matrix grid */

.risk-matrix { table-layout: fixed; }

.risk-matrix th,
.risk-matrix td {
  text-align: center;
  vertical-align: middle;
}

.risk-matrix tbody th[scope="row"] {
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--bsafe-ink);
  white-space: normal;
}

.risk-matrix .matrix-corner {
  text-align: left;
  line-height: 1.2;
}

.matrix-axis {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--bsafe-muted);
}

.risk-matrix .matrix-cell {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  --bs-table-bg: transparent;
}

.risk-matrix .matrix-cell.band-low {
  --bs-table-bg: var(--bs-success-bg-subtle);
  background-color: var(--bs-success-bg-subtle);
  color: var(--bs-success-text-emphasis);
}

.risk-matrix .matrix-cell.band-medium {
  --bs-table-bg: var(--bs-warning-bg-subtle);
  background-color: var(--bs-warning-bg-subtle);
  color: var(--bs-warning-text-emphasis);
}

.risk-matrix .matrix-cell.band-high {
  --bs-table-bg: var(--bs-danger-bg-subtle);
  background-color: var(--bs-danger-bg-subtle);
  color: var(--bs-danger-text-emphasis);
}

/* Palette override for an appetite band (108). `band` stays the tolerance
   semantic that everything reasoning about risk reads, and `colour` is how an
   OPPORTUNITIES matrix renders green at the top of its grid — a big score
   there is a big benefit. A cell paints from `colour-*` when the band declares
   one and falls back to `band-*` when it does not, which is why these rules
   sit after the three above and match on the same specificity. */

.risk-matrix .matrix-cell.colour-green,
.rating-chip.colour-green,
.appetite-swatch.colour-green { --swatch: #d1e7dd; --swatch-ink: #0a3622; }

.risk-matrix .matrix-cell.colour-lime,
.rating-chip.colour-lime,
.appetite-swatch.colour-lime { --swatch: #dcf0c8; --swatch-ink: #2b4310; }

.risk-matrix .matrix-cell.colour-yellow,
.rating-chip.colour-yellow,
.appetite-swatch.colour-yellow { --swatch: #fff3cd; --swatch-ink: #4d3800; }

.risk-matrix .matrix-cell.colour-orange,
.rating-chip.colour-orange,
.appetite-swatch.colour-orange { --swatch: #ffe1c7; --swatch-ink: #663000; }

.risk-matrix .matrix-cell.colour-red,
.rating-chip.colour-red,
.appetite-swatch.colour-red { --swatch: #f8d7da; --swatch-ink: #58151c; }

.risk-matrix .matrix-cell.colour-maroon,
.rating-chip.colour-maroon,
.appetite-swatch.colour-maroon { --swatch: #eccfd4; --swatch-ink: #4a1119; }

.risk-matrix .matrix-cell.colour-blue,
.rating-chip.colour-blue,
.appetite-swatch.colour-blue { --swatch: #cfe2ff; --swatch-ink: #052c65; }

.risk-matrix .matrix-cell.colour-teal,
.rating-chip.colour-teal,
.appetite-swatch.colour-teal { --swatch: #cff1e9; --swatch-ink: #0b3d33; }

.risk-matrix .matrix-cell.colour-purple,
.rating-chip.colour-purple,
.appetite-swatch.colour-purple { --swatch: #e2d9f3; --swatch-ink: #2f1a5c; }

.risk-matrix .matrix-cell.colour-grey,
.rating-chip.colour-grey,
.appetite-swatch.colour-grey { --swatch: #e2e5e9; --swatch-ink: #33383d; }

.risk-matrix .matrix-cell[class*="colour-"] {
  --bs-table-bg: var(--swatch);
  background-color: var(--swatch);
  color: var(--swatch-ink);
}

/* The colour chip beside a band's name in the appetite table and the editor. */
.appetite-swatch {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 0.2rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background-color: var(--swatch, #e2e5e9);
  vertical-align: -0.1rem;
  margin-right: 0.35rem;
}

/* ------------------------------------------------------ risk heat map (S5)
   risk-heat-map.html draws the SAME grid as the risk matrix page (it reuses
   .risk-matrix / .matrix-cell and their band and colour rules above) and adds
   a count and the band's name to each square. The band is printed, not only
   coloured. A square with something in it is a link to the register; an empty
   one is plain text. The grid scrolls inside its own box if a phone is too
   narrow for it, never the page. */

.heat-body { padding: 1.5rem; }

.heat-explain {
  margin: 0 0 0.35rem;
  color: var(--bsafe-ink);
}

.heat-summary {
  margin: 0 0 1.5rem;
  font-size: 0.9rem;
  color: var(--bsafe-muted);
}

.heat-map-scroll {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.heat-map-scroll:focus-visible {
  outline: 2px solid var(--bsafe-accent);
  outline-offset: 2px;
}

.risk-matrix.heat-map { min-width: 20rem; }

.risk-matrix.heat-map thead th {
  font-size: 0.8rem;
  vertical-align: bottom;
}

/* table-layout is fixed, so the FIRST row sets the column widths: the corner
   cell carries the outcome-name column's width, not the row headers below it. */
.risk-matrix.heat-map .matrix-corner { width: 8.5rem; }

.risk-matrix.heat-map .heat-cell { padding: 0; }

.heat-cell-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: 5rem;
  padding: 0.5rem 0.25rem;
  color: inherit;
  text-decoration: none;
}

.heat-count {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.heat-band {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

/* An empty square keeps its band colour, so the shape of the grid reads, but
   its figure steps back: the squares with something in them are the answer. */
.heat-cell.is-empty .heat-count {
  font-size: 1.15rem;
  font-weight: 400;
}

.heat-cell-link:hover,
.heat-cell-link:focus-visible {
  color: inherit;
  text-decoration: none;
  box-shadow: inset 0 0 0 3px currentColor;
}

.heat-cell-link:focus-visible {
  outline: 3px solid var(--bsafe-accent);
  outline-offset: -3px;
}

.heat-legend-title { margin-top: 1.75rem; }

.heat-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
}

@media (max-width: 575.98px) {
  .heat-body { padding: 1rem 0.75rem; }
  .risk-matrix.heat-map th,
  .risk-matrix.heat-map td { padding-inline: 0.15rem; }
  .risk-matrix.heat-map thead th {
    font-size: 0.6rem;
    overflow-wrap: normal;
    hyphens: none;
  }
  .risk-matrix.heat-map .matrix-corner { width: 5.2rem; }
  .risk-matrix.heat-map .matrix-axis { font-size: 0.58rem; }
  .risk-matrix.heat-map tbody th[scope="row"] {
    font-size: 0.66rem;
    padding-inline: 0.3rem;
    overflow-wrap: normal;
    hyphens: none;
  }
  .heat-cell-inner { min-height: 3.6rem; padding: 0.35rem 0.1rem; gap: 0.15rem; }
  .heat-count { font-size: 1.2rem; }
  .heat-cell.is-empty .heat-count { font-size: 1rem; }
  .heat-band { font-size: 0.62rem; }
}

/* The line a register wears while it is opened on ONE square of the heat map
   ("Showing 3 assessments rated Likely x Major, inherent") with the one way
   back. A plain bordered strip with an accent edge: it is information, not a
   warning, so it takes no tint. */
.filter-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--bsafe-line);
  border-left: 4px solid var(--bsafe-accent);
  border-radius: 0.375rem;
  background: #fff;
}

/* Column widths for the risk assessment register.
   DataTables sizes columns from their content, and with eleven columns the
   TITLE — the thing anybody is actually reading — lost to the assessor list
   and wrapped one word per line. These four rules give the title the room and
   cap the two that do not need it. */

#assessments-table td.assessment-title-cell,
#assessments-table th:nth-child(3) { min-width: 13rem; }

#assessments-table td.assessment-assessor-cell { max-width: 11rem; }

/* One assessor name to a line; the job titles are not drawn (hover for the full field). */
.assessor-name { display: block; white-space: nowrap; }

#assessments-table td.assessment-matrix-cell { white-space: nowrap; }

/* The tick column of the "Add from library" picker. Narrow enough that the
   hazard wording — the thing being chosen — keeps the width. */
.library-pick-cell { width: 2.5rem; }

/* ------------------------------------------- matrix editor (108) */

/* Each axis and the band list are edited as a compact table of live inputs
   rather than a modal per row: an administrator setting up a 5x5 makes eleven
   small edits in one sitting, and eleven modals is eleven round trips. */
.matrix-level-table td { vertical-align: middle; }

.matrix-level-table .level-value { max-width: 6rem; }

.matrix-level-table .level-range { max-width: 6.5rem; }

.matrix-coverage-warning { font-size: 0.85rem; }

/* --------------------------------------------------- hazards and controls */

.hazards-table tbody td {
  vertical-align: top;
  white-space: pre-wrap;
  font-size: 0.875rem;
}

.hazards-table tbody td .risk-stack,
.hazards-table tbody td .btn { white-space: normal; }

.hazard-text { font-weight: 600; color: var(--bsafe-ink); }

.hazard-effect {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.8rem;
  color: var(--bsafe-muted);
}

/* "Potential outcome x Likelihood = band (score)", stacked so it stays
   readable in a narrow column and in print. */
.risk-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  min-width: 9rem;
}

.risk-line {
  font-size: 0.82rem;
  color: var(--bsafe-ink);
}

.risk-key {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bsafe-muted);
}

.risk-op {
  font-size: 0.8rem;
  color: var(--bsafe-muted);
}

.risk-result {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  margin-top: 0.15rem;
}

.risk-score {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--bsafe-ink);
}

.hazard-preview {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  min-height: calc(1.5em + 0.75rem + 2px);
}

/* A hazard pulled in from the library before anybody has rated it. It is not
   an error state — it is the middle of a job — so it reads as an instruction
   rather than a warning, but the assessment cannot be submitted while one is
   left, which is why it is visually louder than a muted dash. */
.hazard-unscored {
  font-weight: 600;
  color: var(--bs-warning-text-emphasis);
}

/* ------------------------------------------- risk assessment page (lam2-calmb)
   A rating is one chip, "High (16)"; its factors are the chip's tooltip and
   visually hidden text. The chip keeps to one line so a narrow column never
   splits the score from its band. */
.hazard-rating .badge { white-space: nowrap; }

/* On a phone the three prose cells (who is at risk, the controls) put their
   label above the text and read left-aligned: a long sentence right-aligned
   beside a floating label is hard to follow. */
@media (max-width: 575.98px) {
  .table-stack td.hazard-prose[data-label] { text-align: left; }
  .table-stack td.hazard-prose[data-label]::before {
    float: none;
    display: block;
    margin: 0;
  }
}

/* The row kebab stays level with the hazard's first line, not the cell's foot. */
.hazards-table tbody td.row-menu-cell { vertical-align: top; padding-top: 0.15rem; }

/* The scoring matrix and the appetite levels sit in a closed disclosure. The
   summary is a plain link-coloured line with a chevron that turns when open. */
.scoring-matrix > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.25rem;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: var(--bsafe-accent);
}
.scoring-matrix > summary::-webkit-details-marker { display: none; }
.scoring-matrix > summary:hover { color: var(--bsafe-accent-deep); }
.scoring-matrix > summary:focus-visible {
  outline: 2px solid var(--bsafe-accent);
  outline-offset: 2px;
  border-radius: 0.25rem;
}
.scoring-matrix-caret { transition: transform 0.15s ease; }
.scoring-matrix[open] .scoring-matrix-caret { transform: rotate(90deg); }
.scoring-matrix-body { padding-top: 0.75rem; }
@media (prefers-reduced-motion: reduce) {
  .scoring-matrix-caret { transition: none; }
}

/* "3 of 8" read receipts, in the register and on the document. */
.ack-progress {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  font-variant-numeric: tabular-nums;
}

.ack-progress .ack-outstanding { color: var(--bs-danger-text-emphasis); font-weight: 600; }

/* ---------------------------------------------------------- review history */

.review-list { margin-left: 0.4rem; }

.review-entry {
  position: relative;
  padding: 0 0 1.25rem 1.4rem;
  border-left: 2px solid #e9ecf1;
}

.review-entry:last-child { padding-bottom: 0.25rem; }

.review-entry::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 0.35rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bsafe-accent);
}

.review-entry.empty::before { background: #c6cdd9; }

.review-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
}

.review-author { font-weight: 600; color: var(--bsafe-ink); }

.review-summary {
  margin-top: 0.15rem;
  white-space: pre-wrap;
}

.review-next {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.82rem;
  color: var(--bsafe-muted);
}

.review-hazards tbody td {
  vertical-align: top;
  white-space: pre-wrap;
  font-size: 0.82rem;
}

.review-hazard-form td { vertical-align: top; }

/* ------------------------------------------------------------------ print */

@media print {
  .hazard-edit-btn,
  .hazard-delete-btn { display: none !important; }
  .risk-matrix .matrix-cell { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* -------------------------------------------------------------- mailbox */

/* The four legacy folders (inbox / unread / sent / drafts) as a quiet
   segmented control rather than stock nav-pills: the mailbox is a register
   with four scopes, not four pages, so the control has to read as a filter. */
.mailbox-folders {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  background-color: #f1f3f7;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.5rem;
}

.mailbox-folders .folder-btn {
  --bs-btn-color: var(--bsafe-muted);
  --bs-btn-bg: transparent;
  --bs-btn-border-color: transparent;
  --bs-btn-hover-color: var(--bsafe-ink);
  --bs-btn-hover-bg: #fff;
  --bs-btn-hover-border-color: transparent;
  font-weight: 600;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

/* Bootstrap's `.btn.active` rule reads the --bs-btn-active-* trio, not the
   base ones, so the selected folder has to set both. */
.mailbox-folders .folder-btn.active {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--bsafe-accent);
  --bs-btn-border-color: var(--bsafe-accent);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--bsafe-accent-deep);
  --bs-btn-hover-border-color: var(--bsafe-accent-deep);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--bsafe-accent);
  --bs-btn-active-border-color: var(--bsafe-accent);
}

.mailbox-folders .folder-btn.active .badge { background-color: rgba(255, 255, 255, 0.25) !important; }

/* Unread mail is bold in the list, as it was in the legacy inbox table. */
#messages-table tbody tr { cursor: pointer; }
#messages-table tbody tr.msg-unread { font-weight: 600; }

/* The subject cell carries a muted one-line preview under the subject, the
   legacy inbox's "subject + stripped body" cell, minus the whole body. */
.msg-preview {
  display: block;
  font-weight: 400;
  font-size: 0.8125rem;
  color: var(--bsafe-muted);
  max-width: 46rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The message body inside the report document: plain text, line breaks kept,
   measured column so long correspondence stays readable. */
.mailbox-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-width: 62rem;
  margin-bottom: 0;
}

/* The quoted original under a reply. */
.mailbox-quote {
  border-left: 3px solid var(--bsafe-line);
  padding-left: 0.85rem;
  color: var(--bsafe-muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.875rem;
}

/* -------------------------------------------------------- sustainability */

/*
 * The sustainability module is one sidebar entry covering seven registers
 * (the legacy sidebar gave the group its own fly-out). This strip carries that
 * navigation inside the module instead: quiet pills, the current page solid,
 * sitting directly under the page head on every screen of the module.
 */
.module-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.module-subnav a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--bsafe-ink);
  text-decoration: none;
  background: var(--bs-body-bg);
}

.module-subnav a:hover { border-color: var(--bsafe-accent); color: var(--bsafe-accent); }

.module-subnav a[aria-current="page"] {
  background: var(--bsafe-accent);
  border-color: var(--bsafe-accent);
  color: #fff;
}

/*
 * Chart wells. Chart.js needs a sized parent to be responsive, and a bare
 * <canvas> in a card body collapses to nothing on first paint.
 */
.chart-well {
  position: relative;
  height: 320px;
}

.chart-well-sm {
  position: relative;
  height: 220px;
}

/* Figures that belong to a measurement: the unit is secondary to the number. */
.measure-unit {
  font-size: 0.8em;
  color: var(--bsafe-muted);
  margin-left: 0.2rem;
}

/* Goal due-date states, matching the register's badge vocabulary. */
.due-overdue { color: var(--bs-danger); font-weight: 600; }
.due-soon { color: var(--bs-warning-text-emphasis, #664d03); font-weight: 600; }

/* ---------------------------------------------------- training register */

/*
 * Training & competency (M15). Two additions:
 *
 *  - `#training-table tbody tr` — the course register's whole row opens the
 *    course document, same affordance as the incident register.
 *  - `.register-section-title` — a quiet section heading for a page that
 *    stacks more than one register (competencies.html). It is deliberately
 *    NOT `.report-section-title`: that red uppercase eyebrow belongs to the
 *    report document alone. This is an ink-coloured heading with an accent
 *    rule, borrowing the left-stripe idiom of `.stat-tile`, and it keeps the
 *    guide's "no bare unstyled card-header" rule without inventing a second
 *    card chrome.
 */

/* Registers whose whole row opens a detail view (training courses). */
#training-table tbody tr { cursor: pointer; }

.register-section-title {
  margin: 0 0 0.75rem;
  padding-left: 0.6rem;
  border-left: 3px solid var(--bsafe-accent);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--bsafe-ink);
}

/* === Occupational health (068) === */

/* The appointments register opens its detail view from anywhere in the row. */
#visits-table tbody tr { cursor: pointer; }

/*
 * The stand-in for clinical detail the caller may not read (and for the
 * lifecycle's cancelled/not-attended footnote). Muted and italic so it reads
 * as an explanation rather than as a recorded value.
 */
.clinical-note {
  color: var(--bsafe-muted);
  font-style: italic;
  font-size: 0.875rem;
}

/* ------------------------------------------- ICD-10 diagnosis codes (146) */
/*
 * The codes on an appointment, one chip per code: the code in semibold
 * tabular numerals, then its title. A chip and not a badge, because it is a
 * recorded value rather than a state, so it wears the app's hairline and ink
 * instead of a tone. The title wraps inside its chip on a phone rather than
 * pushing the page sideways. The same `.diagnosis-code` styling marks the code
 * inside the picker's chips and dropdown and in the catalogue's table.
 */
.diagnosis-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.diagnosis-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  max-width: 100%;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 999px;
  background: #f7f9fc;
  color: var(--bsafe-ink);
  font-size: 0.9rem;
  line-height: 1.35;
}

.diagnosis-code {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--bsafe-accent-deep);
  white-space: nowrap;
}

.diagnosis-title { overflow-wrap: anywhere; }

/* Tom Select lays a chosen chip out as a flex row, which swallows the space
   between the code and its title; the gap is put back as a margin. */
.ts-wrapper .item .diagnosis-code { margin-right: 0.35rem; }

/* In the catalogue table the chapter's WHO title sits under its numeral -
   from a laptop up. On a phone the numeral alone keeps the row to the code,
   its title and its status. */
.diagnosis-chapter-title {
  display: none;
  font-size: 0.8125rem;
  color: var(--bsafe-muted);
}

@media (min-width: 992px) {
  .diagnosis-chapter-title { display: block; }
}

/* ------------------------------------------------------- audits (065) */

/*
 * The audit questionnaire, inside the report document. Sections and criteria
 * are headings within the one letterheaded card — never a grid of cards — and
 * each question is a row of the report table with its answer and comment
 * beside it. `.audit-flag` marks a question whose answer equals the form's
 * action answer (the derived finding).
 */

.audit-section + .audit-section { margin-top: 1.75rem; }

.audit-section-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--bsafe-ink);
  margin: 0 0 0.15rem;
}

.audit-criteria + .audit-criteria { margin-top: 1.25rem; }

.audit-criteria-name {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--bsafe-ink);
  margin: 0 0 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #e9ecf1;
}

.audit-blurb {
  font-size: 0.85rem;
  color: var(--bsafe-muted);
  margin-bottom: 0.5rem;
}

/*
 * Every criterion renders its own table, so the columns must be pinned or the
 * question/compliance/comment columns wander from one criterion to the next.
 */
.audit-criteria .report-table { table-layout: fixed; }

.audit-criteria .report-table th:nth-child(1),
.audit-criteria .report-table td:nth-child(1) { width: 48%; }

.audit-criteria .report-table th:nth-child(2),
.audit-criteria .report-table td:nth-child(2) { width: 22%; }

/* The non-compliance marker: a red rail, not a red slab. */
.audit-flag > td:first-child { box-shadow: inset 3px 0 0 var(--bsafe-report-red); }

.audit-answer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* Answer buttons in fill-in mode: a check/radio styled as a compact pill. */
.audit-option {
  position: relative;
  display: inline-flex;
}

.audit-option input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.audit-option span {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 999px;
  font-size: 0.85rem;
  line-height: 1.4;
  background: var(--bs-body-bg);
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.audit-option input:checked + span {
  background: var(--bsafe-accent);
  border-color: var(--bsafe-accent);
  color: #fff;
}

.audit-option input:focus-visible + span {
  outline: 2px solid var(--bsafe-accent);
  outline-offset: 2px;
}

/* Answering the form's action answer is the non-compliant choice — say so. */
.audit-option input:checked.is-action + span {
  background: var(--bsafe-report-red);
  border-color: var(--bsafe-report-red);
}

/* Completion meter above the questionnaire, and per-section in fill-in mode. */
.audit-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--bsafe-muted);
  font-variant-numeric: tabular-nums;
}

.audit-progress .progress {
  flex: 1;
  height: 0.4rem;
  min-width: 6rem;
}

/* Findings list — the legacy "items identified for action" card. */
.audit-finding {
  padding: 0.6rem 0 0.6rem 0.9rem;
  border-left: 3px solid var(--bsafe-report-red);
}

.audit-finding + .audit-finding { margin-top: 0.6rem; }

.audit-finding-where {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bsafe-muted);
}

/* --------------------------------------------- audit form builder (065) */

/*
 * The questionnaire builder on audit-template.html. Nesting is shown with an
 * indent rail rather than nested cards, so a three-level form stays readable.
 */

.builder-node {
  border: 1px solid var(--bsafe-line);
  border-radius: 0.5rem;
  padding: 0.9rem;
  background: var(--bs-body-bg);
}

.builder-node + .builder-node { margin-top: 0.75rem; }

.builder-criteria,
.builder-question {
  margin-left: 1rem;
  border-left: 2px solid #e9ecf1;
  border-radius: 0 0.5rem 0.5rem 0;
  padding-left: 0.9rem;
}

.builder-node-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.builder-node-kind {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bsafe-muted);
}

.builder-node-head .btn { margin-left: auto; }

@media (max-width: 575.98px) {
  .builder-criteria,
  .builder-question { margin-left: 0.4rem; padding-left: 0.6rem; }
}

/* ------------------------------------------------- field help tooltips (078) */
/* The explanatory tooltips the legacy investigation form carried beside its
   causation prompts. The trigger is a real <button> (tab-reachable, its own
   aria-label) rendered as a bare info glyph; Bootstrap's Tooltip supplies the
   bubble, themed here off the brand tokens rather than left as stock black.
   The bubble is wide and left-aligned because this copy is a paragraph, not a
   label. */

.field-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--bsafe-accent);
  font-size: 0.95rem;
  line-height: 1;
}

.field-help:hover {
  background: rgba(var(--bsafe-accent-rgb), 0.1);
  color: var(--bsafe-accent-deep);
}

/* The marker js/field-overrides.js inserts after a .form-label (E7). Both are
   inline, so they share a line; the bottom margin matches .form-label's so
   the glyph sits on the label's baseline rather than under it. */
.field-override-help-marker {
  margin-left: 0.15rem;
  margin-bottom: 0.5rem;
  vertical-align: middle;
}

.field-help:focus-visible {
  outline: 2px solid var(--bsafe-accent);
  outline-offset: 2px;
  color: var(--bsafe-accent-deep);
}

.tooltip {
  --bs-tooltip-bg: var(--bsafe-brand-dark);
  --bs-tooltip-color: #fff;
  --bs-tooltip-opacity: 1;
  --bs-tooltip-max-width: 24rem;
  --bs-tooltip-padding-x: 0.75rem;
  --bs-tooltip-padding-y: 0.5rem;
  --bs-tooltip-border-radius: 0.375rem;
}

.tooltip .tooltip-inner {
  text-align: left;
  line-height: 1.4;
}

/* -------------------------------- incident people: picker + body map (G14) */
/*
 * Two controls inside the "add a person" modal:
 *  - .person-picker  — the search-as-you-type user directory lookup. It wraps
 *    a Tom Select single-select, which must not shrink next to the Clear
 *    button, hence the flex-grow on the widget rather than on the <select>
 *    (Tom Select replaces the element and inherits none of its layout).
 *  - .body-map       — the legacy body diagram, re-cut as inline SVG. Region
 *    fill/stroke are the app blues; the selected state is the deep blue so
 *    it reads at a glance without a second hue entering the modal.
 */
.person-picker .ts-wrapper {
  flex: 1 1 auto;
  min-width: 0;
}

.person-picker .ts-dropdown .bm-opt-meta,
.person-picker .ts-dropdown .option .bm-opt-meta {
  display: block;
  font-size: 0.8125rem;
  color: var(--bsafe-muted);
}

.body-map {
  max-width: 34rem;
  margin: 0.25rem 0 0.25rem;
}

.body-map-svg {
  width: 100%;
  height: auto;
  display: block;
  touch-action: manipulation;
}

.bm-region > ellipse,
.bm-region > path {
  fill: #eef2f7;
  stroke: #b7c3d0;
  stroke-width: 1;
  stroke-linejoin: round;
  transition: fill 0.12s ease-in-out;
}

.bm-region {
  cursor: pointer;
}

.bm-region:hover > ellipse,
.bm-region:hover > path {
  fill: #cfe0f2;
}

.bm-region.is-selected > ellipse,
.bm-region.is-selected > path {
  fill: var(--bsafe-accent);
  stroke: var(--bsafe-accent-deep);
}

.bm-region.is-selected:hover > ellipse,
.bm-region.is-selected:hover > path {
  fill: var(--bsafe-accent-deep);
}

/* The focus ring has to be drawn by us — an <outline> on an SVG child is not
   reliably rendered, and these regions are keyboard-operable controls. */
.bm-region:focus {
  outline: none;
}

.bm-region:focus-visible > ellipse,
.bm-region:focus-visible > path {
  stroke: var(--bsafe-orange);
  stroke-width: 2.5;
}

.bm-caption {
  fill: var(--bsafe-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-anchor: middle;
  text-transform: uppercase;
}

@media (prefers-reduced-motion: reduce) {
  .bm-region > ellipse,
  .bm-region > path {
    transition: none;
  }
}

/* Phones: the diagram is the whole width, and the region hit areas grow with
   it, so no separate touch-target rule is needed — but the caption would
   otherwise shrink below legibility with the viewBox. */
@media (max-width: 575.98px) {
  .body-map {
    max-width: 100%;
  }

  .bm-caption {
    font-size: 14px;
  }
}

/* ------------------------------------------------------------ register kit */

/* Shared furniture for every register (list) page — see js/register-kit.js:
   a page head with a breadcrumb, a row of count tiles, a right-aligned
   toolbar, a per-row kebab menu and an export bar under the table. Ported
   from the legacy AdminLTE register, rebuilt on plain Bootstrap. */

.register-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 1rem;
}

/* With the repeated page heading gone, the create action holds the left of
   the head row. Buttons sit on the text baseline the breadcrumb uses.

   It is deliberately NOT `:empty { display: none }`: an empty mount is a
   zero-width flex item that still holds `justify-content: space-between`
   open, so the breadcrumb closes the row on the right whether or not the
   caller may create anything — and does not jump sideways when GET /me
   answers and the button appears. Pages that carry several registers
   (settings, the occupational-health catalogues, competencies) leave the
   mount empty on purpose and read the same as the rest. */
.register-head-action {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* The trail sits quietly at the end of the head — it orients, it does not
   compete with the action at the other end of the row. */
.register-breadcrumb {
  --bs-breadcrumb-divider: '/';
  --bs-breadcrumb-item-padding-x: 0.4rem;
  font-size: 0.8rem;
}

.register-breadcrumb .breadcrumb-item,
.register-breadcrumb .breadcrumb-item.active { color: var(--bsafe-muted); }

.register-breadcrumb .breadcrumb-item + .breadcrumb-item::before { color: var(--bsafe-line); }

/* --- count tiles ---------------------------------------------------------
   Extends the dashboard's .stat-tile: registers put the delta beside the
   figure and make the whole tile a filter control. */

.stat-count-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* The week-on-week change. Red because a rising incident count is bad news —
   this is the one place the report red earns a spot outside the document. */
.stat-delta {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--bsafe-report-red);
  font-variant-numeric: tabular-nums;
}

/* A tile that filters the register is a button, so it must not look like one:
   reset the control chrome and keep the tile's own surface. */
.stat-tile-action {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.stat-tile-action:hover {
  border-color: var(--bsafe-accent);
  box-shadow: 0 2px 8px rgba(28, 36, 52, 0.1);
}

.stat-tile-action:focus-visible {
  outline: 2px solid var(--bsafe-accent);
  outline-offset: 2px;
}

.stat-tile-action:active { transform: translateY(1px); }

/* The tile currently driving the table. Some of its filters have no control on
   the filter card, so this mark is the only thing telling the reader why the
   register is narrower than the card claims. */
.stat-tile-action.active {
  border-color: var(--bsafe-accent);
  box-shadow: inset 0 0 0 1px var(--bsafe-accent);
  background: #f4f8fd;
}

/* Six tiles across a wide screen leave little room; keep the figure legible
   and let the label wrap rather than clipping it. */
.stat-tile .stat-label { white-space: normal; }

@media (max-width: 1199.98px) {
  .stat-tile { padding: 0.7rem 0.8rem; }
  .stat-count { font-size: 1.45rem; }
}

/* --- toolbar -------------------------------------------------------------
   Right-aligned above the filter card, as in legacy. One solid button (the
   register's create action) and outlines for the rest — style guide §3 beats
   legacy's row of identical grey buttons. */

.register-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

@media (max-width: 575.98px) {
  .register-toolbar { justify-content: stretch; }
  .register-toolbar .btn { flex: 1 1 auto; }
}

/* A dropdown dropped into the toolbar (the recall register's More menu)
   behaves as one more button: it keeps the chevron the page-actions More
   button wears (not Bootstrap's second caret), and on a phone it shares the
   row like its siblings instead of sitting at content width. */
.register-toolbar .dropdown-toggle::after { display: none; }

@media (max-width: 575.98px) {
  .register-toolbar > .dropdown { display: flex; flex: 1 1 auto; }
  .register-toolbar > .dropdown > .btn { flex: 1 1 auto; }
}

/* --- row action menu ----------------------------------------------------- */

.row-menu-btn {
  --bs-btn-color: var(--bsafe-muted);
  --bs-btn-hover-color: var(--bsafe-accent);
  padding: 0.1rem 0.4rem;
  line-height: 1;
  text-decoration: none;
}

.row-menu .dropdown-menu {
  --bs-dropdown-min-width: 11rem;
  --bs-dropdown-font-size: 0.875rem;
  --bs-dropdown-border-color: var(--bsafe-line);
  box-shadow: 0 6px 20px rgba(28, 36, 52, 0.14);
}

.row-menu .dropdown-item i { width: 1.1rem; }

/* The kebab column never navigates and never prints. */
.row-menu-cell { cursor: default; }

/* --- export bar ---------------------------------------------------------- */

.register-export-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--bsafe-line);
}

/* --- printing the whole register ----------------------------------------
   The table on screen holds one page, so Print renders the full fetched set
   into a container of its own and hides the app shell behind it. */

.register-print-area { display: none; }

.register-print-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

@media print {
  body.printing-register > .app-shell { display: none !important; }
  body.printing-register .register-print-area { display: block; }
  .register-print-area .report-table { font-size: 8pt; }
  /* Tighter than the screen table and top-aligned: a register column of free
     text wraps to many lines, and a centred short cell beside it wastes half a
     page. */
  .register-print-area .report-table th,
  .register-print-area .report-table td { padding: 0.2rem 0.35rem; vertical-align: top; }
  /* break-word, not break-all: only a word too long for its column breaks,
     so "Warehouse" is never split across two lines. */
  .register-print-area .report-table td { overflow-wrap: break-word; }
  /* A toast that happened to be on screen is chrome, not part of the report. */
  #toast-container { display: none !important; }
}

/* --- register kit: sustainability + tasks -------------------------------
   Two registers carry a one-line explanation under the head (the tasks scope
   subtitle, the sustainability overview's standfirst). The head already owns
   the gap, so the paragraph only needs the space before what follows it. */

.register-head + .page-subtitle {
  margin-top: -0.5rem;
  margin-bottom: 1rem;
}

/* ------------------------------------------------------------- dashboard */

/* The landing page (index.html + js/pages/dashboard.js). It reuses the
   register kit's `.stat-tile` wholesale — a dashboard figure IS a register
   figure, so it should not wear different clothes — and adds only the things a
   landing page needs that a register does not: an identity band, section
   headings over grouped tile rows, the action queue, and a sized box for the
   trend chart. */

.dash-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}

/* Who the numbers below belong to. Two lines, quiet: it orients the reader
   without competing with the first figure on the page. */
.dash-who {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--bsafe-ink);
  margin: 0;
  line-height: 1.3;
}

.dash-scope {
  font-size: 0.85rem;
  color: var(--bsafe-muted);
  margin: 0;
}

/* Sections stack down the page with the same rhythm; the heading is a small
   uppercase eyebrow rather than a slab, so the tiles stay the loudest thing. */
.dash-section { margin-bottom: 1.75rem; }

.dash-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 0.75rem;
}

.dash-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bsafe-muted);
  margin: 0;
}

.dash-section-link {
  font-size: 0.82rem;
  text-decoration: none;
}

.dash-section-link:hover { text-decoration: underline; }

.dash-section-note {
  font-size: 0.78rem;
  color: var(--bsafe-muted);
  font-variant-numeric: tabular-nums;
}

/* A dashboard tile is a link, not an in-page filter button, so it needs the
   anchor's underline and inherited colour reset off. Everything else — the
   surface, the stripe, the hover lift — comes from `.stat-tile` and
   `.stat-tile-action`, which is the point. */
.dash-tile {
  text-decoration: none;
  color: inherit;
}

.dash-tile:hover { color: inherit; }

/* Eleven tiles across a wide screen sit at col-xxl-2; the label has to wrap to
   two lines without the tile growing taller than its neighbours. */
.dash-tile .stat-label {
  min-height: 2.1em;
  line-height: 1.25;
}

/* --- the action queue ---------------------------------------------------
   The work behind the RAG counts: a traffic-light pip, the action, what it
   hangs off, and the deadline. Three columns so the dates align down the
   right and the eye can scan for the red ones. */

/* Pip | action + parent | deadline. A grid rather than a flex row because
   the phone layout only moves the DEADLINE under the action — flex-wrap would
   break between the pip and the text first and leave the pip stranded on a
   line of its own. */
.dash-queue-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.15rem 0.75rem;
}

.dash-queue-rag {
  flex: 0 0 auto;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--bsafe-line);
  transform: translateY(-0.05rem);
}

.dash-queue-rag.rag-red { background: var(--bs-danger); }
.dash-queue-rag.rag-amber { background: var(--bs-warning); }
.dash-queue-rag.rag-green { background: var(--bs-success); }

.dash-queue-text { min-width: 0; }

/* The parent record is a link, but a quiet one: it is context for the action,
   not the action itself. */
.dash-queue-parent {
  color: inherit;
  text-decoration: none;
}

.dash-queue-parent:hover {
  color: var(--bsafe-accent);
  text-decoration: underline;
}

.dash-queue-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-queue-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--bsafe-muted);
}

.dash-queue-due {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --- which dashboard you are looking at ---------------------------------
 * The persona badge sits under the scope line because it says the same KIND
 * of thing: not a preference, a consequence of what this account may see. It
 * is deliberately quiet — a reader should find it when they ask "why is my
 * page different?", not have it compete with the first figure. */

.dash-persona {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.6rem;
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
}

.dash-persona-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bsafe-muted);
  background: var(--bs-body-bg);
}

.dash-persona-lead { color: var(--bsafe-muted); }

/* A section that has been paired into a half-width column: the row owns the
   spacing beneath, and the card stretches so two lists of unequal length still
   end level with each other. The stretch is a flex one, not `height: 100%`:
   a card as tall as its whole section plus the heading above it overhung the
   next one by the heading's height, which on a phone — where the halves stack
   — hid the second widget's title under the first widget's card. */
.dash-section-half {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

.dash-section-half > .card { flex: 1 1 auto; }

/* The RAG tiles sit in a third of the row beside the queue, two across, and
   stretch so the pair of rows ends level with the list next to it. */
#my-actions-rag > [class^='col-'] { display: flex; }

#my-actions-rag .dash-tile { width: 100%; }

/* --- who is off work ------------------------------------------------------
 * Same row rhythm as the action queue and the change feed above it: subject
 * left, figure right, one quiet line of context beneath. The close button is
 * an outline — clearing an absence is routine, not the page's headline
 * action, and the style guide allows exactly one solid CTA per row. */

.dash-absence-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: 0.15rem 0.75rem;
}

.dash-absence-text { min-width: 0; }

.dash-absence-who {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-absence-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--bsafe-muted);
}

/* The incident is context for the person, not the subject of the row. */
.dash-absence-parent {
  color: inherit;
  text-decoration: none;
}

.dash-absence-parent:hover {
  color: var(--bsafe-accent);
  text-decoration: underline;
}

.dash-absence-since {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 575.98px) {
  .dash-absence-item { grid-template-columns: minmax(0, 1fr) auto; }

  .dash-absence-who { white-space: normal; }

  .dash-absence-since { grid-column: 1; }
}

/* --- the notice board ----------------------------------------------------
 * The narrow column, so every row is two short lines: what was posted, and
 * when plus your own sign-off state. No body text — the notices page has it,
 * and a truncated policy paragraph helps nobody. */

.dash-notices .list-group-item { padding: 0.6rem 0.85rem; }

.dash-notice-title {
  display: block;
  font-size: 0.85rem;
  line-height: 1.35;
}

.dash-notice-meta {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  color: var(--bsafe-muted);
}

.dash-notice-state { margin-left: 0.35rem; }

/* --- the training-video frame -------------------------------------------
 * 16:9 by padding rather than by a fixed height, so the card matches the
 * delegates card beside it at every width instead of letterboxing. */

/* The shield sits UNDER the frame, centred on the black, so a video that has
   not painted yet — or cannot, on a machine with no route to the host — reads
   as the app's own placeholder rather than as a broken black rectangle. Once
   the player loads it paints over this entirely. */
.dash-video {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: var(--bs-border-radius);
  overflow: hidden;
  background:
    url('/app/img/logo-mark.svg') center / 4rem no-repeat,
    #000;
}

.dash-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* --- recent changes feed -------------------------------------------------
 * The dashboard's window onto the audit trail. Same row rhythm as the action
 * queue above it, so the two lists read as one page rather than two widgets:
 * subject left, date right, one quiet line of detail beneath. It carries the
 * NUMBER of fields an edit touched and never their values — the recorder
 * redacts encrypted columns and this is not the place to work around that. */

.dash-changes-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.15rem 0.75rem;
}

.dash-changes-text { min-width: 0; }

.dash-changes-what {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-changes-subject {
  color: inherit;
  text-decoration: none;
}

.dash-changes-subject:hover {
  color: var(--bsafe-accent);
  text-decoration: underline;
}

.dash-changes-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--bsafe-muted);
}

.dash-changes-when {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 575.98px) {
  .dash-changes-item { grid-template-columns: minmax(0, 1fr); }

  .dash-changes-what { white-space: normal; }

  .dash-changes-when { grid-column: 1; }
}

/* --- Change log (R23) ----------------------------------------------------
 * Two surfaces share one vocabulary: the admin register
 * (change-log.html + js/pages/change-log.js) and the "History" card that sits
 * among the sub-resource components on a detail page
 * (js/components/change-log.js).
 *
 * The log is evidence, so the primitives here exist mainly to keep MARKERS
 * from reading as data: a value the recorder deliberately did not store
 * (encrypted PII) and a value it stored only the head of are set apart from
 * the real before/after text, never printed as though someone had typed them.
 */

/* Whole-row click opens the change; the row does not navigate. */
#change-log-table tbody tr { cursor: pointer; }

.change-when,
.change-record {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --- outstanding investigation questions ---------------------------------
 * The same row rhythm as the action queue, the absence card and the change
 * feed, for the same reason: four lists reading as one page. Subject left,
 * figure right, one quiet line of context beneath.
 *
 * The difference is the subject. An action is a title you scan; a question is
 * a SENTENCE somebody wrote, and truncating it to one ellipsised line would
 * leave a row nobody can act on. So this title wraps — to two lines, after
 * which the incident's own questions tab has the rest — and the age stays
 * pinned to the right where the other three lists put their figure. */

.dash-question-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.15rem 0.75rem;
}

.dash-question-text { min-width: 0; }

.dash-question-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
}

.dash-question-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--bsafe-muted);
}

/* The incident is context for the question, not the subject of the row —
   matching .dash-queue-parent and .dash-absence-parent above. */
.dash-question-parent {
  color: inherit;
  text-decoration: none;
}

.dash-question-parent:hover {
  color: var(--bsafe-accent);
  text-decoration: underline;
}

.dash-question-age {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 575.98px) {
  /* The age drops under the question rather than squeezing it: a phone row is
     narrow enough that "34 days" on the right would cost the question half
     its width. */
  .dash-question-item { grid-template-columns: minmax(0, 1fr); }

  .dash-question-age { grid-column: 1; }
}

/* --- the trend chart ----------------------------------------------------
   Chart.js runs with maintainAspectRatio off, so the canvas needs a sized,
   positioned parent — the box below dictates the height. (The statistics page
   carries the same rule in a page-level <style>; this one lives here, where
   the style guide says it belongs.) */

.dash-chart-canvas {
  position: relative;
  height: 260px;
  width: 100%;
}

.dash-chart-hint {
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--bsafe-muted);
}

@media (max-width: 575.98px) {
  /* Two tiles across on a phone, and the deadline drops beneath the action
     (column 2, row 2) so the title keeps the full width instead of being cut
     to an ellipsis to make room for a date. */
  .dash-tile .stat-label { min-height: 0; }

  .dash-queue-item { grid-template-columns: auto minmax(0, 1fr); }

  .dash-queue-title { white-space: normal; }

  .dash-queue-due {
    grid-column: 2;
    text-align: left;
  }
}
/* ------------------------------------------ dashboard layouts (140, C-dash) */

/* Customisable dashboards: whose layout this is, the customise bar, the
   per-widget tools, the placeholders for widgets with nothing to show, and the
   Settings → Dashboards list editor. Everything here is quiet on purpose — the
   widgets themselves stay the loudest thing on the page even while they are
   being arranged. */

/* "Your own layout" / "Layout for Line Manager", after the persona's lead. */
.dash-layout-source { color: var(--bsafe-muted); }

.dash-layout-source::before {
  content: '·';
  margin-right: 0.6rem;
}

/* The bar under the head while customising: one sentence, and Add widget. */
.dash-edit-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.6rem 0.85rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--bsafe-line);
  border-left: 3px solid var(--bsafe-accent);
  border-radius: var(--bs-border-radius);
  background: var(--bs-body-bg);
}

.dash-edit-bar-text {
  margin: 0;
  font-size: 0.88rem;
  color: var(--bsafe-ink);
}

.dash-edit-bar-text .bi {
  color: var(--bsafe-accent);
  margin-right: 0.3rem;
}

/* Every widget wears a dashed frame while it is being arranged, so the reader
   can see where one ends and the next begins. A `.row` widget (the trend
   grid, the delegates row) already reaches into its gutters, so its frame
   needs no offset. */
.dash-editing [data-section] {
  outline: 1px dashed rgba(var(--bs-primary-rgb), 0.45);
  outline-offset: 0.5rem;
  border-radius: 2px;
  margin-bottom: 2.25rem;
}

.dash-editing .row[data-section] { outline-offset: 0; }

/* While arranging, the tools bar names the widget, so the widget's own
   eyebrow title (and the link beside it, asleep anyway) would only say the
   same thing twice. */
.dash-editing [data-section] .dash-section-head { display: none; }

/* The widget's name and its Move up · Move down · Remove. */
.dash-widget-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  margin-bottom: 0.75rem;
}

.dash-widget-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--bsafe-ink);
}

.dash-widget-tool-buttons {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* A widget with nothing to show this reader today, standing in for it. */
.dash-widget-placeholder {
  padding: 0.25rem 0;
}

.dash-placeholder-text {
  margin: 0;
  font-size: 0.85rem;
  color: var(--bsafe-muted);
}

/* The muted sentence a statistics widget prints instead of a chart. */
.dash-stats-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--bsafe-muted);
}

/* The Add widget menu: a section already on the page stays listed, disabled,
   with a quiet note saying why. */
.dash-add-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.dash-add-note {
  font-size: 0.75rem;
  color: var(--bsafe-muted);
}

/* The saved-view picker: the view's name, whose it is beneath. */
.dash-view-option {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.dash-view-name { font-weight: 600; }

.dash-view-owner {
  font-size: 0.8rem;
  color: var(--bsafe-muted);
}

/* Settings → Dashboards: a role's layout as a list, one widget per row. */
.dash-layout-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 1rem;
}

.dash-layout-name { font-weight: 600; }

.dash-layout-kind {
  display: block;
  font-size: 0.78rem;
  color: var(--bsafe-muted);
}

@media (max-width: 575.98px) {
  /* The tools drop under the widget's name rather than squeezing it. */
  .dash-widget-tools,
  .dash-layout-row { align-items: flex-start; }

  /* Captions only on a phone, as the page-actions bar does: the glyph gives
     way, never the word, and Move up · Move down · Remove stay on one line. */
  .dash-widget-tool-buttons .bi { display: none; }

  /* The Add widget menu keeps a margin inside the screen and lets a long
     section name wrap rather than pushing the menu off the edge. */
  .dash-add-menu { max-width: calc(100vw - 2rem); }

  .dash-add-item { white-space: normal; }
}

/* ------------------------------------------- interactive dashboard (C-dash) */

/* The filter bar, the key figures, the legacy-shaped statistics cards and the
   drill-down panel (index.html + js/pages/dashboard.js and its three
   components). The bar is quiet chrome over the widgets it governs; the
   figures are register tiles whose stripe says better or worse; the panel is
   an offcanvas over the page, never a new window. */

/* --- the filter bar ------------------------------------------------------ */
.dash-filters { margin-bottom: 1.5rem; }

.dash-filters-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem 1.75rem;
  padding: 0.85rem 1rem;
}

.dash-filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

/* The small uppercase label every register filter and detail item uses. */
.dash-filter-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--bsafe-muted);
  margin: 0;
}

.dash-period-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
}

.dash-period { width: auto; flex-wrap: nowrap; }

.dash-period-label {
  min-width: 12.5rem;
  font-variant-numeric: tabular-nums;
  color: var(--bsafe-ink);
}

.dash-period-caption {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--bsafe-ink);
}

.dash-granularity { font-size: 0.85rem; }

.dash-granularity .form-check-inline { margin-right: 0.85rem; }

.dash-period-custom {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.75rem;
  margin-top: 0.25rem;
}

.dash-period-custom .form-label {
  font-size: 0.78rem;
  margin-bottom: 0.15rem;
  color: var(--bsafe-muted);
}

.dash-period-error {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.82rem;
}

.dash-filter-units {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
}

.dash-filter-units .form-select { min-width: 14rem; }

.dash-filter-units .form-check { font-size: 0.85rem; }

.dash-filter-actions {
  margin-left: auto;
  align-self: flex-end;
}

/* --- key figures ---------------------------------------------------------
   The register tile with a verdict: more incidents than the period before is
   worse (the report red, the legacy danger), fewer is better (success green),
   the same is the hairline. Stripe, arrow and the sentence under the label
   all say it, so it is never colour alone; the title spells out what was
   compared with what. */
.dash-figure { position: relative; }

.dash-figure-up,
.dash-figure-up.stat-tile-action:hover { border-left-color: var(--bsafe-report-red); }

.dash-figure-down,
.dash-figure-down.stat-tile-action:hover { border-left-color: var(--bs-success); }

.dash-figure-same,
.dash-figure-same.stat-tile-action:hover { border-left-color: var(--bsafe-line); }

.dash-figure .stat-count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.dash-figure-arrow {
  font-size: 1.6rem;
  line-height: 1;
}

.dash-figure-up .dash-figure-arrow,
.dash-figure-up .dash-figure-trend { color: var(--bsafe-report-red); }

.dash-figure-down .dash-figure-arrow,
.dash-figure-down .dash-figure-trend { color: var(--bs-success); }

.dash-figure-same .dash-figure-arrow,
.dash-figure-same .dash-figure-trend { color: var(--bsafe-muted); }

.dash-figure .stat-label { display: block; }

.dash-figure-trend {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* --- statistics cards ---------------------------------------------------- */
.dash-stats-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
}

.dash-stats-head-end {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* Collapse: a quiet control in the card's corner, as legacy's "−". */
.dash-widget-collapse {
  --bs-btn-padding-x: 0.35rem;
  --bs-btn-padding-y: 0;
  --bs-btn-color: var(--bsafe-muted);
  --bs-btn-hover-color: var(--bsafe-accent);
  --bs-btn-border-color: transparent;
  --bs-btn-hover-border-color: var(--bsafe-line);
  --bs-btn-active-border-color: var(--bsafe-line);
  line-height: 1.4;
}

.dash-widget-collapsed .dash-stats-body { display: none; }

.dash-widget-collapsed .dash-stats-card > .card-header { border-bottom: 0; }

/* The criterion's own sentence, the legacy card's subtitle. */
.dash-stats-subtitle {
  margin: 0 0 0.6rem;
  font-size: 0.82rem;
  color: var(--bsafe-muted);
}

/* A ranked chart is as tall as its bars need (set per chart from the count). */
.dash-chart-canvas.dash-chart-ranked { height: var(--dash-chart-height, 260px); }

/* A mark that opens a list. */
canvas.dash-chart-live { cursor: pointer; }

.dash-stats-foot { margin-top: 0.5rem; }

/* The keyboard's way in: the chart's figures as buttons, out of sight until
   one of them has the focus (Bootstrap's .visually-hidden-focusable). */
.dash-drill-values:focus-within {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--bsafe-line);
  border-radius: var(--bs-border-radius);
}

.dash-drill-values-title {
  margin: 0 0 0.25rem;
  font-size: 0.78rem;
  color: var(--bsafe-muted);
}

.dash-drill-values-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.5rem;
}

.dash-drill-values-list .btn { padding-left: 0; padding-right: 0.25rem; }

/* --- the drill-down panel ------------------------------------------------ */
.dash-drill.offcanvas-end { --bs-offcanvas-width: 460px; }

.dash-drill .offcanvas-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--bsafe-line);
}

.dash-drill-eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--bsafe-muted);
}

.dash-drill .offcanvas-title { line-height: 1.3; }

.dash-drill-summary {
  margin: 0.3rem 0 0;
  font-size: 0.88rem;
  color: var(--bsafe-muted);
  font-variant-numeric: tabular-nums;
}

.dash-drill-summary strong { color: var(--bsafe-ink); }

.dash-drill-sep { margin: 0 0.45rem; }

.dash-drill-note {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--bsafe-muted);
}

.dash-drill-row { padding: 0; }

/* Reference and date on one line, what it was and its status beneath. */
.dash-drill-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.1rem 0.75rem;
  padding: 0.6rem 0.85rem;
  color: inherit;
  text-decoration: none;
}

.dash-drill-link:hover { background: #f4f8fd; }

.dash-drill-link:focus-visible {
  outline: 2px solid var(--bsafe-accent);
  outline-offset: -2px;
}

.dash-drill-ref {
  font-weight: 700;
  color: var(--bsafe-accent);
  font-variant-numeric: tabular-nums;
}

.dash-drill-date {
  font-size: 0.85rem;
  color: var(--bsafe-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dash-drill-meta {
  min-width: 0;
  font-size: 0.82rem;
  color: var(--bsafe-ink);
}

.dash-drill-nature { color: var(--bsafe-muted); }

.dash-drill-status { align-self: start; justify-self: end; }

.dash-drill-foot { margin-top: 1rem; }

@media (max-width: 575.98px) {
  /* The bar stacks: period, then units, then Update across the width. */
  .dash-filters-form { gap: 0.85rem; }

  .dash-filter-group,
  .dash-filter-units,
  .dash-filter-units .dash-filter-group { width: 100%; }

  .dash-period { flex: 1 1 auto; }

  .dash-period-label { min-width: 0; flex: 1 1 auto; }

  .dash-filter-units .form-select { min-width: 0; }

  .dash-filter-actions { margin-left: 0; width: 100%; }

  .dash-filter-actions .btn { width: 100%; }

  .dash-figure-arrow { font-size: 1.25rem; }

  /* A monthly chart's legend wraps to several lines on a phone and would
     take its room out of the plot; give the card the height back. */
  .dash-stats-card .dash-chart-canvas:not(.dash-chart-ranked) { height: 320px; }
}

/* --------------------------------------------------- statistics views (S6) */

/* Chart.js needs a sized, positioned parent to be responsive
   (maintainAspectRatio is off, so this box dictates the height). Moved out of
   statistics.html's per-page <style> block, which the style guide forbids. */
.stats-canvas {
  position: relative;
  height: 320px;
  width: 100%;
}

.criteria-grid .form-check { margin-bottom: 0.35rem; }

/* Five chart types and three view modes do not fit a 390px row, and a
   btn-group that does not wrap pushes the whole page sideways. Below the sm
   breakpoint the group wraps and every button gets its own corners back —
   Bootstrap only rounds the first and last child of a single row. */
@media (max-width: 575.98px) {
  .stats-toggle-group { flex-wrap: wrap; row-gap: 0.35rem; }

  .stats-toggle-group > .btn {
    border-radius: var(--bs-border-radius) !important;
    margin-left: 0;
  }
}

/* A caption under a chart or table that says something true about the data
   rather than decorating it — "one month in range", "no incidents in this
   period". Never used for a purely cosmetic hint. */
.stats-note {
  font-size: 0.8rem;
  color: var(--bsafe-muted);
  margin: 0.35rem 0 0;
}

.stats-note-warn { color: var(--bsafe-report-red); }

/* --- the comparison period list ---------------------------------------- */

.compare-range {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.5rem;
}

.compare-range + .compare-range { margin-top: 0.5rem; }

/* The swatch ties a row of the period list to its colour in every chart and
   table below, so "period 2" never has to be counted out. */
.compare-swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 0.2rem;
  flex: 0 0 auto;
  margin-bottom: 0.55rem;
}

.compare-range .form-control { min-width: 9.5rem; }

/* Remove closes the row on the right whatever the row's width. */
.compare-range .compare-range-remove { margin-left: auto; }

.compare-range-label {
  flex: 0 0 5.5rem;
  font-size: 0.8rem;
  color: var(--bsafe-muted);
  margin-bottom: 0.55rem;
}

/* --- the table view ------------------------------------------------------
   A statistics table is series (rows) × periods (columns) and is read by
   scanning a row, so the series name stays put while the months scroll. */

.stats-table { font-variant-numeric: tabular-nums; }

.stats-table th,
.stats-table td { white-space: nowrap; }

.stats-table th:first-child,
.stats-table td:first-child {
  position: sticky;
  left: 0;
  background: var(--bs-body-bg);
  white-space: normal;
  min-width: 12rem;
}

.stats-table thead th:first-child { z-index: 1; }

.stats-table td:not(:first-child),
.stats-table th:not(:first-child) { text-align: right; }

/* The period sub-head above the bucket columns in a comparison table. */
.stats-table .stats-period-head {
  text-align: center;
  border-bottom: 2px solid currentcolor;
}

/* A zero is real data, but it should not shout as loudly as a count. */
.stats-zero { color: var(--bsafe-muted); }

.stats-total-row td,
.stats-total-col {
  font-weight: 700;
  background: #f8f9fb; /* the app's standard hover/rest tint */
}

/* The bar under the table's total row echoes the register export bar; sitting
   directly on the card foot it needs no second rule above it. */
.report-card > .register-export-bar { border-top: 1px solid var(--bsafe-line); }

@media print {
  /* Print what is on screen: the view switcher already hid the other half, so
     nothing here forces a view. Only the sticky first column has to go — it
     has nothing to stick to on paper and Chromium repeats it on every page. */
  .stats-table th:first-child,
  .stats-table td:first-child { position: static; }
  .stats-table th,
  .stats-table td { white-space: normal; }
}

/* One changed column name. The `subject.` prefix of a sub-record's field
   ("injured person.first_name") stays visible but recedes. */
.change-field {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.75rem;
  background: #f8f9fb;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--bsafe-ink);
}

.change-field-subject {
  color: var(--bsafe-muted);
}

.change-field-subject::after {
  content: " · ";
}

/* The register's chip cell does not wrap. Inside `.table-responsive` a
   squeezed column stacks its chips vertically, which on a phone left every
   row as tall as its longest field list with the visible columns empty
   beside it. The table already scrolls sideways there; let it. */
#change-log-table td.change-fields-cell,
#change-log-table th.change-fields-cell {
  white-space: nowrap;
}

/* A real logged value: long ones wrap rather than stretch the column. */
.change-value {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* The side of a change that does not exist — a create has no before, a
   remove has no after. */
.change-none {
  font-style: italic;
  color: var(--bsafe-muted);
}

/* The column holds encrypted personal data, so the log records THAT it
   changed and nothing else. Italic and muted, so it can never be mistaken for
   somebody having typed the words. */
.change-redacted {
  font-style: italic;
  color: var(--bsafe-muted);
}

/* The stored value is only the head of the real one. */
.change-truncated {
  display: inline-block;
  padding: 0 0.35rem;
  border-radius: 0.75rem;
  background: #f1f3f6;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bsafe-muted);
  vertical-align: middle;
}

/* Before/after table, in the register's modal and inside a history entry. */
.change-diff td,
.change-diff th {
  vertical-align: top;
  font-size: 0.85rem;
}

.change-diff th[scope="row"] {
  width: 30%;
  font-weight: 400;
}

/* --- history card ------------------------------------------------------- */

.change-entry { padding: 0; }

/* The whole entry header is the collapse control, the same idiom the register
   filter card uses — never a bare header with a toggle button beside it. */
.change-entry-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.change-entry-toggle:hover { background-color: #f8f9fb; }

.change-entry-toggle:not(.collapsed) .filter-caret { transform: rotate(-135deg); }

.change-entry-body {
  flex: 1 1 auto;
  min-width: 0;
}

.change-entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
}

.change-entry-actor {
  font-weight: 600;
  color: var(--bsafe-ink);
}

.change-entry-when {
  font-size: 0.8rem;
  color: var(--bsafe-muted);
}

.change-entry-fields {
  display: block;
  margin-top: 0.3rem;
}

/* 142. An event row - "Subject access pack downloaded by … on …" - is one
   sentence, so its date reads at the sentence's own size and colour rather
   than as the muted "2 hours ago" beside an ordinary change. */
.change-entry-event { color: var(--bsafe-ink); }

.change-entry-event .change-entry-when {
  font-size: inherit;
  color: inherit;
}

.change-entry-detail {
  padding: 0 1rem 0.75rem;
}

/* The register's "Changed by" picker reuses the person picker's two-line
   option; that rule is scoped to the incident modal, so name this mount too. */
#filter-user-block .ts-dropdown .bm-opt-meta,
#filter-user-block .ts-dropdown .option .bm-opt-meta {
  display: block;
  font-size: 0.8125rem;
  color: var(--bsafe-muted);
}

/* ------------------------------------------------------------ saved views */
/* The named-query control that sits on a filter card beside Search / Clear.
   Both buttons are outlines: the card's one solid button is its search
   action, and the style guide allows exactly one per row. */

.saved-views {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.saved-views .dropdown-menu {
  --bs-dropdown-min-width: 16rem;
  --bs-dropdown-font-size: 0.875rem;
  --bs-dropdown-border-color: var(--bsafe-line);
  box-shadow: 0 6px 20px rgba(28, 36, 52, 0.14);
  max-height: 20rem;
  overflow-y: auto;
}

/* A menu row is the view (a full-width apply control) plus, on the caller's
   own views, a delete button that must not swallow the click that applies. */
.saved-view-row {
  display: flex;
  align-items: center;
}

.saved-view-row .dropdown-item {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.saved-view-row .saved-view-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-view-flag {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.saved-view-row-active .dropdown-item {
  font-weight: 600;
  color: var(--bsafe-accent);
}

.saved-view-delete {
  --bs-btn-color: var(--bsafe-muted);
  --bs-btn-hover-color: var(--bs-danger);
  flex: 0 0 auto;
  padding: 0.1rem 0.6rem;
  line-height: 1;
  text-decoration: none;
}

@media (max-width: 575.98px) {
  .saved-views { width: 100%; }
  .saved-views .btn-group,
  .saved-views > .btn { flex: 1 1 auto; }
}

/*
 * === User → Clinical tab (Stage 3 Phase 1 item 4) ===
 *
 * The occupational health record inside the user dialog. It borrows the report
 * document's vocabulary — `.report-table` for the four tables, `.detail-grid`
 * for the compliance roll-up — but NOT `.report-section-title`: that red
 * uppercase eyebrow belongs to a full-page letterheaded document, and this is a
 * panel inside a dialog. It uses `.register-section-title`, the same quiet
 * heading competencies.html uses to stack several tables on one surface.
 *
 * Everything else here is spacing. There is no colour of its own: a clinical
 * screen that invented its own palette would be one more thing to keep in step
 * with the badge vocabulary the rest of the app asserts in e2e.
 */

.clinical-record section + section { margin-top: 1.75rem; }

.clinical-record .report-table { margin-bottom: 0; }

.clinical-record .report-table td,
.clinical-record .report-table th { vertical-align: top; }

/* A real recorded clinical value (notes, a recommendation report, a diagnosis).
   Deliberately NOT `.clinical-note`, which is this module's muted-italic
   stand-in for a value the caller may NOT read: the two must never look alike,
   or a withheld field reads as a recorded one. This keeps the line breaks the
   clinician typed and wraps rather than stretching the table. */
.clinical-text {
  display: inline-block;
  max-width: 32rem;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/*
 * === Slot picker (103) ===
 *
 * The week of bookable appointment times that replaced the two free-typed
 * `datetime-local` boxes in the booking and edit modals. Every visible control
 * is stock Bootstrap — `btn-check` radios wearing `btn-outline-primary btn-sm`
 * pills — so there is no colour, no border and no state of its own here: only
 * the layout Bootstrap has no utility for. The checked radio is the source of
 * truth and it keeps every default focus ring it was born with.
 */

.slot-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.slot-picker-head .slot-range {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* One day per row, always. On a phone the day name sits above its times; from
   md up it becomes a fixed-width label to the left, so a week of times reads as
   a diary page rather than a grid of cards. */
.slot-days {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.slot-day h3 { margin-bottom: 0.35rem; }

@media (min-width: 768px) {
  .slot-day {
    display: flex;
    align-items: baseline;
    gap: 1rem;
  }

  .slot-day h3 {
    flex: 0 0 7rem;
    margin-bottom: 0;
  }

  .slot-day-times { flex: 1 1 auto; }
}

.slot-day-times {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.slot-day-times .btn { font-variant-numeric: tabular-nums; }

/* The chosen slot must still read as chosen once focus moves on — a focus ring
   marks where the keyboard is, not what was picked. Bootstrap's own
   `.btn-check:checked + .btn` says exactly this; it is restated here, scoped to
   the picker, because the pill is the entire answer to "when is this
   appointment" and it may not be ambiguous. Same accent, no new colour. */
.slot-day-times .btn-check:checked + .btn {
  background-color: var(--bsafe-accent);
  border-color: var(--bsafe-accent);
  color: #fff;
}

/* Who the time belongs to, printed on the pill only when the window holds more
   than one clinician — with a single clinician it would be the same name
   repeated forty times. */
.slot-doctor {
  font-size: 0.8em;
  font-weight: 400;
}

.slot-pick-summary {
  margin-top: 0.75rem;
  margin-bottom: 0;
  font-weight: 600;
}

/* The "nothing chosen yet" and "currently booked for…" readings are muted, and
   muted text should not also shout. */
.slot-pick-summary.text-body-secondary { font-weight: 400; }

/*
 * === Clinician diaries (103) ===
 *
 * The seven-row working-hours table on the occupational health catalogues
 * page. A day that is not worked keeps its (disabled) inputs in place rather
 * than emptying the row, so ticking it back on is one click — but it has to
 * read as off, and Bootstrap's disabled styling alone does not carry to the
 * day name beside it.
 */

.diary-table th,
.diary-table td { vertical-align: middle; }

.diary-table .diary-day { font-weight: 600; white-space: nowrap; }

.diary-table input[type="time"] { min-width: 7rem; }

.diary-off .diary-day { color: var(--bs-secondary-color); font-weight: 400; }

.diary-list .list-group-item { padding-left: 0; padding-right: 0; }

/*
 * ====================================================================
 * Risk register (109)
 * ===========================================================================
 *
 * Three groups of primitives, all additive — nothing above is touched:
 *
 *  1. Band chips. The register's three rating columns and the detail page's
 *     rating strip both print "score + band", and the appetite bands the
 *     matrix defines are low / medium / high, so the semantic Bootstrap trio
 *     already used by `.matrix-cell.band-*` is reused rather than a fourth
 *     palette invented. `.rr-band` is the stand-alone chip form of it.
 *  2. The bow-tie. Causes → preventive barriers → the risk event → mitigative
 *     barriers → consequences, as ONE CSS grid. No library: the diagram is
 *     real lists in real reading order, so it degrades to a stack on a phone
 *     by changing nothing but the column count.
 *  3. Key risk indicators. The sparkline is an inline SVG the page builds from
 *     the readings; only its box is styled here.
 */

/* --- band chips ---------------------------------------------------------- */

.rr-band {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  padding: 0.12rem 0.45rem;
  border-radius: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  background: #eef1f6;
  color: #55607a;
  border: 1px solid transparent;
}

.rr-band .rr-score { font-variant-numeric: tabular-nums; }

.rr-band.band-low {
  background: var(--bs-success-bg-subtle);
  color: var(--bs-success-text-emphasis);
  border-color: var(--bs-success-border-subtle);
}

.rr-band.band-medium {
  background: var(--bs-warning-bg-subtle);
  color: var(--bs-warning-text-emphasis);
  border-color: var(--bs-warning-border-subtle);
}

.rr-band.band-high {
  background: var(--bs-danger-bg-subtle);
  color: var(--bs-danger-text-emphasis);
  border-color: var(--bs-danger-border-subtle);
}

/* The register's appetite column: a tick when the risk sits inside appetite,
   a spelled-out chip when it does not. A bare cross is not a sentence. */
.rr-within { color: var(--bs-success-text-emphasis); font-size: 1.05rem; }

.rr-trend { white-space: nowrap; font-size: 0.82rem; }
.rr-trend.trend-improving { color: var(--bs-success-text-emphasis); }
.rr-trend.trend-worsening { color: var(--bs-danger-text-emphasis); }
.rr-trend.trend-stable { color: var(--bsafe-muted); }

/* The reference cell: the register is read by reference, not by row number. */
.rr-reference { font-weight: 600; font-variant-numeric: tabular-nums; }

.rr-title { font-weight: 600; color: var(--bsafe-ink); }

.rr-sub {
  display: block;
  font-size: 0.8rem;
  color: var(--bsafe-muted);
}

/* --- the rating strip ---------------------------------------------------- */

/* Inherent → current → residual, the three ratings the whole module turns on,
   read left to right with the arrow that makes them a sequence. */
.rating-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}

.rating-chip {
  flex: 1 1 12rem;
  min-width: 0;
  padding: 0.6rem 0.8rem;
  border-radius: 0.4rem;
  border: 1px solid var(--bsafe-line);
  background: var(--bs-body-bg);
}

.rating-chip.band-low {
  background: var(--bs-success-bg-subtle);
  border-color: var(--bs-success-border-subtle);
}

.rating-chip.band-medium {
  background: var(--bs-warning-bg-subtle);
  border-color: var(--bs-warning-border-subtle);
}

.rating-chip.band-high {
  background: var(--bs-danger-bg-subtle);
  border-color: var(--bs-danger-border-subtle);
}

/* Palette override for an appetite band (108), exactly as `.matrix-cell` takes
   it: `--swatch` is declared by the shared `.colour-*` rules above, so a chip
   painted from `colour` and a grid cell painted from the same band are the
   same colour. This rule sits after the three `band-*` above and at the same
   specificity, so a band that declares a colour wins and one that does not
   falls back. */
.rating-chip[class*="colour-"] {
  background: var(--swatch);
  color: var(--swatch-ink);
}

.rating-stage {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--bsafe-muted);
}

.rating-sum {
  display: block;
  font-size: 0.82rem;
  color: var(--bsafe-ink);
  overflow-wrap: break-word;
}

.rating-figure {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-top: 0.15rem;
}

.rating-score {
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--bsafe-ink);
}

.rating-band {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bsafe-muted);
}

/* The arrow is decoration between two readings, so it never takes width from
   them and disappears when the chips wrap onto their own rows. */
.rating-arrow {
  align-self: center;
  flex: 0 0 auto;
  color: var(--bsafe-muted);
  font-size: 1.1rem;
}

.appetite-line {
  margin: 0;
  font-size: 0.9rem;
  color: var(--bsafe-ink);
}

.appetite-line.is-breach { color: var(--bs-danger-text-emphasis); font-weight: 600; }

/* The live preview inside the edit modal, same shape as one rating chip. */
.rating-preview {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  min-height: calc(1.5em + 0.75rem + 2px);
}

/* --- the bow-tie --------------------------------------------------------- */

/*
 * Causes | preventive barriers | the event | mitigative barriers |
 * consequences. Five columns on a desktop, two from the md breakpoint down
 * (the event spanning both) and ONE below it, which is what a 390px phone
 * gets: the same lists, stacked, in the order they are read aloud.
 */
.bowtie {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: start;
}

.bowtie-col { min-width: 0; }

.bowtie-head {
  margin: 0 0 0.5rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--bsafe-muted);
}

/* The knot: the event the barriers sit either side of. */
.bowtie-event {
  padding: 0.75rem 0.85rem;
  border-radius: 0.4rem;
  border: 2px solid var(--bsafe-report-red);
  background: var(--bs-body-bg);
}

.bowtie-event-title {
  font-weight: 700;
  color: var(--bsafe-ink);
}

.bowtie-event-text {
  margin: 0.3rem 0 0;
  font-size: 0.85rem;
  color: var(--bsafe-ink);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.bowtie-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.bowtie-item {
  padding: 0.45rem 0.55rem;
  border-radius: 0.35rem;
  border: 1px solid var(--bsafe-line);
  border-left: 3px solid #b9c2d0;
  background: var(--bs-body-bg);
  font-size: 0.84rem;
  color: var(--bsafe-ink);
  overflow-wrap: break-word;
}

.bowtie-item-text { display: block; white-space: pre-wrap; }

.bowtie-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.3rem;
}

.bowtie-meta .badge { font-weight: 600; }

/* A cause's contributing factor and a consequence's impact area are the two
   vocabularies the bow-tie is grouped by, so each gets a rule colour rather
   than only a chip — the eye groups the column before it reads it. */
.bowtie-item[data-factor="people"] { border-left-color: #7e57c2; }
.bowtie-item[data-factor="process"] { border-left-color: var(--bsafe-accent); }
.bowtie-item[data-factor="equipment"] { border-left-color: #00838f; }
.bowtie-item[data-factor="materials"] { border-left-color: #8d6e63; }
.bowtie-item[data-factor="environment"] { border-left-color: #2e7d32; }
.bowtie-item[data-factor="management"] { border-left-color: #a12b1b; }
.bowtie-item[data-factor="external"] { border-left-color: #ef6c00; }

.bowtie-item[data-impact-area="safety"] { border-left-color: #a12b1b; }
.bowtie-item[data-impact-area="financial"] { border-left-color: #2e7d32; }
.bowtie-item[data-impact-area="service"] { border-left-color: var(--bsafe-accent); }
.bowtie-item[data-impact-area="reputation"] { border-left-color: #7e57c2; }
.bowtie-item[data-impact-area="legal"] { border-left-color: #00838f; }
.bowtie-item[data-impact-area="environment"] { border-left-color: #558b2f; }
.bowtie-item[data-impact-area="people"] { border-left-color: #ef6c00; }

/* A barrier's effectiveness is the one thing that decides whether it counts,
   so it is the colour of the barrier card, not a chip on it. */
.bowtie-item[data-role="effectiveness"] { border-left-width: 4px; }
.bowtie-item[data-effectiveness="high"] { border-left-color: var(--bs-success); }
.bowtie-item[data-effectiveness="medium"] { border-left-color: var(--bs-warning); }
.bowtie-item[data-effectiveness="low"] { border-left-color: var(--bs-danger); }

/* A retired or ineffective barrier is still recorded, but it is not holding
   anything back — say so quietly rather than dropping it from the diagram. */
.bowtie-item.is-inactive { opacity: 0.65; }

/* The why-chain: each level of "why did that happen?" steps in one notch.
   Depth arrives from the server already computed, so the indent is a class
   ladder rather than an inline style (hard rule 7). */
.why-depth-1 { margin-left: 0.9rem; }
.why-depth-2 { margin-left: 1.8rem; }
.why-depth-3 { margin-left: 2.7rem; }
.why-depth-4 { margin-left: 3.6rem; }
.why-depth-5 { margin-left: 4.5rem; }

.cause-root-flag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bsafe-report-red);
}

/* The 5-whys card below the diagram: one <li> per level, the ladder read
   downwards rather than sideways. */
.why-chain {
  list-style: none;
  margin: 0;
  padding: 0;
}

.why-chain > li {
  position: relative;
  padding: 0 0 0.7rem 1.5rem;
  border-left: 2px solid #e9ecf1;
  font-size: 0.88rem;
  overflow-wrap: break-word;
}

.why-chain > li:last-child { border-left-color: transparent; padding-bottom: 0; }

.why-chain > li::before {
  content: "";
  position: absolute;
  left: -0.32rem;
  top: 0.35rem;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--bsafe-accent);
}

.why-chain > li.is-root::before { background: var(--bsafe-report-red); }

.why-step {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bsafe-muted);
}

@media (max-width: 991.98px) {
  .bowtie { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bowtie-event-col { grid-column: 1 / -1; }
}

@media (max-width: 575.98px) {
  .bowtie { grid-template-columns: 1fr; }
  .why-depth-1 { margin-left: 0.5rem; }
  .why-depth-2 { margin-left: 1rem; }
  .why-depth-3 { margin-left: 1.5rem; }
  .why-depth-4 { margin-left: 2rem; }
  .why-depth-5 { margin-left: 2.5rem; }
}

/* --- key risk indicators ------------------------------------------------- */

.kri-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.kri-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.4rem;
  background: var(--bs-body-bg);
}

.kri-body { flex: 1 1 14rem; min-width: 0; }

.kri-name { font-weight: 600; color: var(--bsafe-ink); }

.kri-value {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.kri-number {
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--bsafe-ink);
}

.kri-unit { font-size: 0.82rem; color: var(--bsafe-muted); }

.kri-targets {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--bsafe-muted);
  font-variant-numeric: tabular-nums;
}

/* The sparkline is an inline SVG the page draws from the readings — it is a
   reading of the trend, never the only place a number appears. */
.kri-sparkline {
  flex: 0 0 auto;
  width: 8.5rem;
  height: 2.4rem;
  overflow: visible;
}

.kri-sparkline .kri-spark-line {
  fill: none;
  stroke: var(--bsafe-accent);
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.kri-sparkline .kri-spark-target {
  stroke: var(--bsafe-muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.kri-sparkline .kri-spark-dot { fill: var(--bsafe-accent); }

.kri-actions { flex: 0 0 auto; }

/* --- linked risks, reviews, taxonomy ------------------------------------- */

.rr-link-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.rr-relation {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bsafe-muted);
}

.rr-review-scores {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  font-variant-numeric: tabular-nums;
}

/* The taxonomy table indents a child under its parent. Depth is a column of
   the payload, so it is a class ladder here for the same reason the why-chain
   is one. */
.cat-depth-1 { padding-left: 1.2rem; }
.cat-depth-2 { padding-left: 2.4rem; }
.cat-depth-3 { padding-left: 3.6rem; }
.cat-depth-4 { padding-left: 4.8rem; }
.cat-depth-5 { padding-left: 6rem; }

.cat-name { font-weight: 600; color: var(--bsafe-ink); }
.cat-depth-1 .cat-name,
.cat-depth-2 .cat-name,
.cat-depth-3 .cat-name,
.cat-depth-4 .cat-name,
.cat-depth-5 .cat-name { font-weight: 400; }

/* The owner pickers search the directory as you type (enhanceRemoteSelect), so
   each option carries the email under the name — two people share a name far
   more often than they share a mailbox. */
.ts-dropdown .option .rr-opt-meta {
  display: block;
  font-size: 0.8125rem;
  color: var(--bsafe-muted);
}

/* --- the register table --------------------------------------------------
 *
 * Thirteen columns — reference, title, level, category, owner, three ratings,
 * appetite, trend, review date, status and the kebab — do not fit a 1440px
 * window beside the sidebar, and letting them shrink turned the TITLE, the one
 * column anybody reads first, into a six-line ribbon. So the short columns keep
 * their content on one line and the table takes the width it needs;
 * `.table-responsive` around it scrolls, which is what the style guide asks of
 * a wide register.
 */
#risks-table { min-width: 56rem; font-size: 0.9rem; }

#risks-table td { white-space: nowrap; vertical-align: top; }

/* Thirteen columns of Bootstrap's default cell padding is 6.5rem of air before
   a single character is drawn; tightening it is what buys the title its width
   back without shrinking the type any further. */
#risks-table th,
#risks-table td { padding-left: 0.35rem; padding-right: 0.35rem; }

/* Title and category are the two prose columns: they wrap, and they get the
   room the others gave back. */
#risks-table td:nth-child(2),
#risks-table td:nth-child(4) { white-space: normal; }

/* No fixed width on either: with every other column pinned to one line, the
   auto table layout hands these two whatever is left, which is self-balancing
   as the viewport changes. The floor above stops the pair collapsing to a
   letter a line on a phone — below it `.table-responsive` scrolls. */
#risks-table td:nth-child(2) { min-width: 11rem; }
#risks-table td:nth-child(4) { min-width: 6rem; }

/* --- the taxonomy table --------------------------------------------------
 *
 * The name column carries the indent, the name AND the description, so it is
 * the one that must not be squeezed: on a phone the auto layout gave it a
 * fifth of 390px and every description became a column of single words. A
 * floor on the table (and on that cell) makes `.table-responsive` scroll
 * instead, which is the style guide's answer for a wide table.
 */
#risk-categories-table { min-width: 44rem; }

#risk-categories-table td:first-child { min-width: 18rem; }

#risk-categories-table td:not(:first-child) { white-space: nowrap; }

/* --- the risk document's own tables and headings -------------------------
 *
 * `.rr-report` marks the risk page's report body so these rules cannot reach
 * any other module's document.
 *
 * The bow-tie section header carries three "Add a …" buttons; on a phone the
 * flex row squeezed each one into a three-line stack. Let the header wrap
 * below the sm breakpoint, so the eyebrow keeps its hairline on the first line
 * and the buttons sit on the next as whole words.
 */
@media (max-width: 767.98px) {
  .rr-report .report-section-title { flex-wrap: wrap; }
  .rr-report .report-section-title .btn { flex: 0 0 auto; }
}

/* Both tables inside the document keep their prose column readable and let
   `.table-responsive` scroll under them, rather than breaking a control's name
   into one word a line. */
#controls-table { min-width: 48rem; }
#controls-table td:first-child { min-width: 15rem; }
#controls-table td:not(:first-child) { white-space: nowrap; }

#related-risks-card { min-width: 42rem; }
#related-risks-card td:nth-child(2) { min-width: 14rem; }
#related-risks-card td:nth-child(1),
#related-risks-card td:nth-child(3) { white-space: nowrap; }
/* --------------------------------- assessment forms (110) */

/*
 * Questionnaire risk assessments — the 110 additions on top of the 065 audit
 * questionnaire above. Three new jobs: a result chip that carries a band's
 * colour, the category tiles that make the forms library navigable, and the
 * per-type answer controls the fill-in page renders (a scale, a number, a date
 * and free text alongside the existing option pills).
 *
 * Everything here uses the existing tokens. The band colours deliberately reuse
 * Bootstrap's semantic trio rather than inventing three more hexes: a risk band
 * is a status, and the app already says danger/warning/success everywhere else.
 */

.result-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
}

.result-chip .result-chip-score { font-weight: 700; }

.result-chip-low { background: #e8f5ec; border-color: #b6dfc4; color: #14653a; }
.result-chip-medium { background: #fdf3e0; border-color: #f2d9a6; color: #8a5a00; }
.result-chip-high { background: #fdeceb; border-color: #f3c2bd; color: var(--bsafe-report-red); }
.result-chip-none { background: var(--bsafe-tint); border-color: var(--bsafe-line); color: var(--bsafe-muted); }

/*
 * DSE-3 — the action cell on My assessment forms, which can now hold two
 * buttons: Start (solid) and "Nothing has changed" (outline). Side by side
 * from 576px up; on a phone they stack, one caption per line and the same
 * width, rather than squeezing "Nothing has changed" onto three lines beside
 * a Start the width of one word. The room for that comes from the Status
 * column, which folds into the form's own cell under 576px (my-forms.js).
 */
.my-forms-actions {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.25rem;
}

.my-forms-actions .btn { white-space: nowrap; }

@media (max-width: 575.98px) {
  .my-forms-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

/*
 * DSE-3 — the provenance line of a carried-forward assessment, under the
 * "About this audit" grid: "Confirmed unchanged by … on …; answers carried
 * forward from …". A quiet ruled note rather than an alert — it is a fact
 * about the record, not something anybody has to act on — and it prints.
 */
.provenance-note {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  margin: 0.75rem 0 0;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--bsafe-accent);
  background: var(--bs-tertiary-bg);
  font-size: 0.875rem;
}

.provenance-note .bi { color: var(--bsafe-accent); }

/* The score line under the chip: "48 of 60 points — pass mark 70%". */
.result-note {
  font-size: 0.8rem;
  color: var(--bsafe-muted);
  font-variant-numeric: tabular-nums;
}

/*
 * Category tiles on the forms library. A filter control, not a stat tile, so
 * it is a compact pill row rather than a row of count cards — the library has a
 * dozen categories and twelve stat cards would bury the table.
 */
.category-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.category-tile {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 999px;
  background: var(--bs-body-bg);
  font-size: 0.85rem;
  color: var(--bsafe-ink);
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.category-tile:hover { border-color: var(--bsafe-accent); color: var(--bsafe-accent); }

.category-tile.active {
  background: var(--bsafe-accent);
  border-color: var(--bsafe-accent);
  color: #fff;
}

.category-tile .category-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  opacity: 0.75;
}

.category-tile.active .category-count { opacity: 0.9; }

/*
 * Fill-in controls for the typed questions. The scale is the option pill
 * treatment at a fixed width so 1..5 reads as a scale and not as five words;
 * number/date/text keep the ordinary form controls, capped so a date input does
 * not stretch to the full column on a desktop.
 */
.audit-scale { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.audit-scale .audit-option span {
  min-width: 2.4rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.audit-typed-input { max-width: 18rem; }

.audit-typed-input.audit-typed-text { max-width: none; }

/* A question the conditional logic is not asking right now. */
.audit-hidden { display: none; }

/* Required marker on a question, and the state after a failed submit. */
.audit-required-mark { color: var(--bsafe-report-red); margin-left: 0.15rem; }

.audit-missing > td:first-child { box-shadow: inset 3px 0 0 var(--bs-warning); }

/*
 * The builder's per-option editor: a dense table inside a question node. Kept
 * to .table-sm rather than a grid so the header names the columns once.
 */
.option-editor { margin-bottom: 0.5rem; }

.option-editor td { padding: 0.25rem 0.3rem; vertical-align: middle; }

.option-editor .form-control,
.option-editor .form-select { font-size: 0.85rem; }

.option-editor-score { max-width: 6rem; }

/* The builder's live preview panel. */
.form-preview {
  border: 1px solid var(--bsafe-line);
  border-radius: 0.5rem;
  padding: 1rem;
  background: var(--bsafe-tint);
}

.form-preview-question + .form-preview-question { margin-top: 0.85rem; }

.form-preview-text { font-size: 0.9rem; margin-bottom: 0.3rem; }

/*
 * Phone. An employee completes a DSE assessment on their own handset, so the
 * three-column question table collapses to stacked blocks below 576px rather
 * than scrolling sideways — a horizontally scrolling questionnaire is a
 * questionnaire nobody finishes.
 */
@media (max-width: 575.98px) {
  .audit-criteria .report-table,
  .audit-criteria .report-table tbody,
  .audit-criteria .report-table tr,
  .audit-criteria .report-table td { display: block; width: auto; }

  .audit-criteria .report-table thead { display: none; }

  /*
   * The 065 column pins above are `.audit-criteria .report-table td:nth-child(n)`
   * — specificity (0,3,1) — and they beat the (0,2,1) `width: auto` in the
   * block above, so `display: block` took effect and the width did not: every
   * answer control was squeezed into a 65px column and stacked vertically on a
   * phone. Restated here at matching specificity rather than reached for with
   * `!important`, which would have to be undone by the next person who touches
   * the table.
   */
  .audit-criteria .report-table th:nth-child(1),
  .audit-criteria .report-table td:nth-child(1),
  .audit-criteria .report-table th:nth-child(2),
  .audit-criteria .report-table td:nth-child(2),
  .audit-criteria .report-table th:nth-child(3),
  .audit-criteria .report-table td:nth-child(3) { width: auto; }

  /*
   * Tap targets. The pill is 26px at desktop density, which is below the 44px
   * a thumb needs — and an employee completes their DSE assessment on a phone.
   * The input is absolutely positioned to fill the label, so growing the pill's
   * padding grows the whole target.
   */
  .audit-option span { padding: 0.55rem 0.9rem; }

  .audit-scale .audit-option span { min-width: 3rem; }

  .audit-criteria .report-table tr {
    border: 1px solid var(--bsafe-line);
    border-radius: 0.4rem;
    padding: 0.6rem;
    margin-bottom: 0.6rem;
    background: #fff;
  }

  .audit-criteria .report-table td { border: 0; padding: 0.25rem 0; }

  .audit-flag > td:first-child,
  .audit-missing > td:first-child { box-shadow: none; }

  .audit-flag { border-left: 3px solid var(--bsafe-report-red); }

  .audit-missing { border-left: 3px solid var(--bs-warning); }

  .audit-typed-input { max-width: none; }
}

/* --------------------------------- COSHH products and GHS hazard marks (122)
 *
 * The hazard pictogram. A GHS/CLP diamond is a square standing on a corner
 * with a red border and a white ground, and that is exactly what it is here:
 * a rotated square, drawn in CSS, with a VENDORED Bootstrap Icons glyph
 * counter-rotated inside it. No image asset and no CDN — the CSP forbids one,
 * and an SVG sprite for nine marks would have been a second thing to keep in
 * step with the `danger_types` catalogue an administrator can edit.
 *
 * It is never the only way to read the classification: every mark sits inside
 * a chip that also prints the pictogram's NAME, and the picker on the product
 * form is a real multi-select. The diamond is recognition, not information.
 */

.ghs-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.ghs-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.15rem 0.5rem 0.15rem 0.2rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 999px;
  background: var(--bs-body-bg);
  font-size: 0.8rem;
  line-height: 1.2;
  color: var(--bsafe-ink);
  white-space: nowrap;
}

/* The diamond itself: a square rotated 45 degrees inside a square box, so the
 * chip's line box does not grow with the rotation. */
.ghs-mark {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border: 1.5px solid var(--bsafe-report-red);
  background: var(--bs-body-bg);
  transform: rotate(45deg);
  border-radius: 2px;
}

.ghs-mark > i {
  transform: rotate(-45deg);
  font-size: 0.72rem;
  line-height: 1;
  color: var(--bsafe-report-red);
}

/* Signal word "warning" is the lower of the two CLP tiers. It keeps the red
 * diamond — that is the standard and not ours to restyle — but the chip's
 * caption is muted so a row of nine marks still reads in order of severity. */
.ghs-chip[data-signal="warning"] .ghs-chip-label { color: var(--bsafe-muted); }

.ghs-chip[data-signal="none"] .ghs-mark {
  border-color: var(--bsafe-line);
}

.ghs-chip[data-signal="none"] .ghs-mark > i { color: var(--bsafe-muted); }

/* The register cell packs marks without their captions — a table column of
 * nine words is unreadable — and carries the names in the title attribute. */
.ghs-list-compact { gap: 0.2rem; }

.ghs-list-compact .ghs-chip {
  padding: 0;
  border: 0;
  background: none;
}

/* The picker on the product form: a checkbox grid, so the classification can
 * be read and set with a keyboard and a screen reader. The diamond decorates
 * the label; the checkbox is the control. */
.ghs-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.35rem;
}

.ghs-picker .form-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.375rem;
}

.ghs-picker .form-check-input { margin: 0; flex: 0 0 auto; }

.ghs-picker .form-check-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  cursor: pointer;
}

/* The product register's prose columns wrap; everything else stays on one
 * line, the same trade the risk register's table makes. */
#products-table td:nth-child(2),
#products-table td:nth-child(5) { white-space: normal; min-width: 10rem; }

/* A cohort row whose exposure has ended is history, not a live control. */
.cohort-ended { color: var(--bsafe-muted); }

/* Edit and Remove belong on one line: stacked, they make the cohort table
 * twice as tall as the fact it is carrying. */
.cohort-actions { white-space: nowrap; }

.cohort-actions .btn + .btn { margin-left: 0.25rem; }
/* --------------------------------------------- saved reports + league (123)

   Two small additions, both in service of screens that already exist:

   `.report-pre` is the stored filter of a saved report, shown as the JSON it
   is. It is not a code editor and not a `<code>` run inside prose — it is a
   short, wrapped, scrollable block that has to stay legible when the filter
   has fifteen keys in it, so it wraps rather than scrolls sideways and caps
   its own height.

   `.league-table` is the statistics league table. It is a `.report-table` with
   two differences that the numbers require: the figure columns are tabular and
   right-aligned so a column of rates lines up on the decimal point, and the
   rank column is fixed-width so the table does not reflow as the ranks pass
   from one digit to two.                                                    */

.report-pre {
  font-size: 0.8125rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 14rem;
  overflow-y: auto;
  padding: 0.75rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.4rem;
  background: var(--bs-tertiary-bg);
  color: var(--bs-body-color);
}

.league-table td.league-num,
.league-table th.league-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.league-table td.league-rank,
.league-table th.league-rank {
  width: 3rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--bs-secondary-color);
}

/* A denominator of nothing is not a low rate — it is no rate, and it reads
   that way rather than as a zero. */
.league-table .league-none { color: var(--bs-secondary-color); }
/* --- Offsite activities (111) ---------------------------------------------
 *
 * Two small additions for the visit document; everything else on both pages
 * is the shared report / register furniture.
 *
 *  - `.offsite-guidance` — the legacy check.php printed a sentence of guidance
 *    under each of the twenty-one coordinator criteria, and the criterion on
 *    its own ("Plan B", "Advice") does not say what is being asked. The same
 *    quiet second line carries the reviewer's name under a linked
 *    assessment's note.
 *  - `.offsite-checklist` — the criterion column is the reading matter and the
 *    answer is one word, so the table is given proportions rather than letting
 *    a twenty-one row grid share its width equally. The answer control is
 *    capped so it does not stretch to the column.
 */

.offsite-criterion { display: block; font-weight: 600; }

.offsite-guidance {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--bsafe-muted);
}

.offsite-checklist th:first-child,
.offsite-checklist td:first-child { width: 46%; }

.offsite-checklist th:nth-child(2),
.offsite-checklist td:nth-child(2) { width: 14%; }

.offsite-answer { max-width: 10rem; }

@media (max-width: 575.98px) {
  .offsite-checklist th:first-child,
  .offsite-checklist td:first-child,
  .offsite-checklist th:nth-child(2),
  .offsite-checklist td:nth-child(2) { width: auto; }
}

/* SEVEN stations — one more than any other rail in the app carries, and the
   labels are long ("Coordinator check", "Adviser approval", "LA
   notification"). The shared `.lc-step { flex: 1 }` therefore divides a
   desktop row into slices narrower than the words, and because the connector
   is the step's own `::after` the line rules straight through the overflowing
   text. The shared rail already solves this below the md breakpoint by
   letting each step keep its natural width and scrolling sideways instead;
   this rail needs the same treatment at every width. Scoped to the class
   rather than raising the shared breakpoint, because every other rail is
   correct as it stands and 14 branches are merging into this file. */
.lifecycle-offsite .lc-step { flex: 0 0 auto; }
.lifecycle-offsite .lc-step::after { min-width: 1.25rem; }

/* From md up, seven stations with "Out since 14/10/2026 18:00" under one of
   them are wider than the card at 1440 px, and the scroll hid "Closed" off the
   right-hand edge. Wrap onto a second row instead: each step may grow into
   the spare width, so its connector still runs to the next station. Phones
   keep the sideways scroll the shared rail gives them. */
@media (min-width: 768px) {
  .lifecycle-offsite {
    flex-wrap: wrap;
    row-gap: 0.75rem;
    overflow-x: visible;
  }
  .lifecycle-offsite .lc-step { flex: 1 1 auto; }
  .lifecycle-offsite .lc-step:last-child { flex: 0 0 auto; }
}

/*
 * On paper the coordinator checklist is a RECORD, not a form: the answer and
 * the comment are the same controls the coordinator typed into, so they are
 * stripped back to plain text rather than duplicated into a second print-only
 * copy that could fall out of step with them.
 */
@media print {
  .offsite-checklist .form-select,
  .offsite-checklist .form-control {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    background-image: none;
    font-size: inherit;
    appearance: none;
    -webkit-appearance: none;
  }
}
/* ------------------------------------------------ warning register (112) */

/*
 * The warning register (the legacy SWR) opens its marker document from
 * anywhere in the row, the same affordance the incident, risk, COSHH and
 * training registers already carry. That is the whole addition the module
 * needs: everything else on its three pages is built from primitives already
 * in this file — `.report-card` and `.detail-grid` for the document,
 * `.lifecycle` for the raised → approved → in review → closed rail,
 * `.report-table` for the decision history, and `.register-print-area` for
 * printing the letter that goes to the individual.
 */
#warnings-table tbody tr { cursor: pointer; }
/* =====================================================================
   Terms, policies and the admin console (migration 117)
   =====================================================================
   Three small additions, all of them typography or layout for content the
   rest of the design layer already dresses. Nothing here restyles a
   Bootstrap component or introduces a colour that is not already a token.

   Policy text is PROSE and is read, not scanned: it gets a measure (a line
   length the eye can track) and a little more leading than a dense register
   row wants. The page itself still runs full width - this caps the TEXT
   COLUMN inside the report document, which is what the style guide's
   "no max-width caps" rule is about the page wrapper, not a paragraph. */
.terms-text,
.terms-gate-body {
  max-width: 68ch;
  line-height: 1.65;
}

/* The console's health strip: one line per subsystem, its verdict as a dot
   rather than as a fourth badge colour competing with the register badges. */
.console-health-dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--bsafe-muted);
}

.console-health-ok       { background: var(--bs-success); }
.console-health-degraded { background: var(--bs-warning); }
.console-health-off      { background: var(--bsafe-muted); }

/* The console's count grid: a plain list of register sizes, tabular numerals
   so the figures line up down the column the way the stat tiles' do. */
.console-count-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
/* 114 — projects, workflows and action templates ---------------------------
 *
 * Four primitives the project module needs and the layer did not already
 * carry. Everything else on its five pages is stock Bootstrap plus the
 * register / report / lifecycle primitives above.
 */

/* Dates and counts that sit in a column and are read DOWN it — a start date
   against an end date, a step's offset against the next one's. Proportional
   digits make those columns ripple; the style guide asks for tabular figures
   wherever numbers align. Dates keep to one line: a wrapped "01/04/2026" reads
   as two different numbers. */
.pj-date-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }

.pj-num-cell { font-variant-numeric: tabular-nums; }

/* The workflow library is two panes: the row that is being described on the
   right has to be legible AS the chosen one, or the pane looks like it belongs
   to whatever was clicked last. A left rule in the accent, not a fill — the
   table already uses its hover tint, and two backgrounds fighting over one row
   is how a "selected" state stops reading as one. */
.wf-chosen > td:first-child { box-shadow: inset 3px 0 0 var(--bsafe-accent); }

.wf-chosen > td { background-color: rgba(var(--bsafe-accent-rgb), 0.06); }

/* The detail pane travels with the library on a wide screen: the table beside
   it can be long, and a pane that scrolls away is a pane nobody reads the
   steps in. Below xl the two stack and the sticky is meaningless, so it is
   scoped to the breakpoint the columns split at. */
@media (min-width: 1200px) {
  #workflow-detail { position: sticky; top: 1rem; }
}

/* One choosable action template in the apply modal: the name, the wording of
   the task it would raise, and when it would fall due, as one target. */
.apply-template-option {
  padding: 0.6rem 0.75rem 0.6rem 2.1rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.4rem;
  background: var(--bs-body-bg);
}

.apply-template-option .form-check-label { display: block; cursor: pointer; }

/* Already applied: still shown, because knowing it has been done is the
   answer to "why can I not pick this one?", but plainly not available. */
.apply-template-option.is-applied {
  background: #f8f9fa;
  border-style: dashed;
}

.apply-template-option.is-applied .form-check-label { cursor: default; }

.apply-template-option.is-applied .rr-title { color: var(--bsafe-muted); }

/* --- the module's three wide tables ---------------------------------------
 *
 * Same shape as the risk register's block above, for the same reason: ten
 * columns do not fit a 1440px window beside the sidebar, and letting them all
 * shrink turns the columns anybody actually reads — the project's name, the
 * task an action template raises — into ribbons of single words. So the short
 * columns keep their content on one line, the prose columns wrap and take the
 * room the others gave back, and `.table-responsive` scrolls when the total no
 * longer fits.
 */
#projects-table { min-width: 52rem; font-size: 0.9rem; }

#projects-table td { white-space: nowrap; vertical-align: top; }

#projects-table th,
#projects-table td { padding-left: 0.35rem; padding-right: 0.35rem; }

/* Project, type and business unit are the prose columns. */
#projects-table td:nth-child(2),
#projects-table td:nth-child(3),
#projects-table td:nth-child(4) { white-space: normal; }

#projects-table td:nth-child(2) { min-width: 13rem; }

#action-templates-table { min-width: 54rem; font-size: 0.9rem; }

#action-templates-table td { white-space: nowrap; vertical-align: top; }

#action-templates-table th,
#action-templates-table td { padding-left: 0.35rem; padding-right: 0.35rem; }

/* The task text and the recipient list are the two that must be readable. */
#action-templates-table td:nth-child(2),
#action-templates-table td:nth-child(5) { white-space: normal; }

#action-templates-table td:nth-child(2) { min-width: 14rem; }
#action-templates-table td:nth-child(5) { min-width: 10rem; }

/* The workflow library sits in the narrower of two panes, so its floor is
   lower and only its name column wraps. */
#workflows-table { min-width: 34rem; }

#workflows-table td { white-space: nowrap; vertical-align: top; }

#workflows-table td:first-child { white-space: normal; min-width: 13rem; }

#project-types-table { min-width: 44rem; }

#project-types-table td:first-child { min-width: 12rem; }

#project-types-table td:not(:first-child):not(:nth-child(2)) { white-space: nowrap; }

/* 114 (C4) — contractor completion page ------------------------------------
 *
 * `task-complete.html` is the one page in this tree with no app shell: its
 * visitor holds a single-use link, has no session and has nothing else here to
 * navigate to. So it needs a ground and a column of its own, and nothing else
 * — the card inside it is the ordinary report document (`.report-card`'s
 * letterhead, section eyebrows and `.detail-grid`), because a page that reads
 * as part of B-SAFE is exactly what a stranger being asked to type into it
 * should see.
 *
 * The ground is the brand dark pair, matching the login screen: those two are
 * the only pages a person reaches before they are inside the application, and
 * they should look like the same doorway.
 */
.tc-body {
  min-height: 100vh;
  padding: 2.5rem 1rem;
  /* The login screen's own ground, and deliberately the same one: these two
     are the only pages a person reaches before they are inside the
     application, and they should look like the same doorway. Not
     `background-attachment: fixed` — that paints one viewport and leaves a
     seam under a card taller than the window. */
  background: linear-gradient(180deg, var(--bsafe-brand-dark-2) 0%, var(--bsafe-brand-dark) 60%);
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.4);
}

.tc-shell {
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
}

.tc-card { border-radius: 0.5rem; }

/* The status line the page opens on, before the API has answered. Light,
   because it sits on the dark ground rather than inside the card. */
.tc-status {
  padding: 1rem 0;
  text-align: center;
  color: #ffffff;
  opacity: 0.75;
}

/* The one sentence that carries the page: the action being asked for, or the
   refusal, or the thank-you. Larger than body copy and never bold — this is a
   sentence to read, not a heading to scan past. */
.tc-lede {
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--bsafe-ink);
  white-space: pre-wrap;
}

@media (max-width: 575.98px) {
  .tc-body { padding: 1rem 0.5rem; }
}

/* The action register grew two columns in C4 — the classification and the
 * external assignee — and eleven columns do not fit a 1440px window beside the
 * sidebar. Same treatment as the risk and project registers above, for the
 * same reason: letting them all shrink turned "Risk assessment control" into a
 * three-line ribbon and squeezed the task text, which is the column anybody
 * actually reads. So the short columns keep their content on one line, the two
 * prose columns wrap and take the room the others gave back, and
 * `.table-responsive` scrolls when the total no longer fits. */
#tasks-table { min-width: 68rem; font-size: 0.9rem; }

#tasks-table td { white-space: nowrap; vertical-align: top; }

#tasks-table th,
#tasks-table td { padding-left: 0.35rem; padding-right: 0.35rem; }

/* The task text and the responsible people are the two that must be readable. */
#tasks-table td:nth-child(2),
#tasks-table td:nth-child(3) { white-space: normal; }

#tasks-table td:nth-child(2) { min-width: 16rem; }

/* ------------------------------------------------------------------------
 * Register references (129, Cafcass C13)
 *
 * `INC-2026-0042`, `PPM-0014`, `OV-2026-0004` — a fixed-shape handle that is
 * read down a telephone and compared down a column, so it aligns like a
 * number and never wraps mid-code. Used by the incident register's first
 * column and by the reference chip on the incident detail page.
 * ---------------------------------------------------------------------- */
.ref-code {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Settings › Retention (133)

   The three month boxes are a fixed, narrow width so the columns line up down
   the table and the row reads as "12 / 12 / 36" rather than as three inputs of
   whatever width their content happened to ask for. Sized here rather than
   inline because the style guide forbids inline styles, and a number that
   appears in three places in one row should be one declaration.
   --------------------------------------------------------------------------- */
.retention-months {
  width: 5.5rem;
  min-width: 5.5rem;
}

.retention-unit {
  font-weight: 400;
  color: var(--bsafe-muted);
  white-space: nowrap;
}

.retention-legend {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.retention-legend dt {
  font-weight: 600;
}

.retention-legend dd {
  margin: 0;
}

@media (max-width: 575.98px) {
  .retention-legend {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .retention-legend dd {
    margin-bottom: 0.5rem;
  }
}

/* ---------------------------------------------------------------------------
   Settings › Retention: incidents due for anonymisation (lam2-anon)

   One card under the incident rules: the rule in words, the count by type,
   what is held back and why, the free-text caveat, then the list. The lines
   are spaced apart so each reads as its own statement; numbers align.
   --------------------------------------------------------------------------- */
.retention-keep-note {
  margin: -0.25rem 0 0.75rem;
}

#anon-card .settings-group-note,
#anon-card .anon-summary {
  margin-bottom: 0.75rem;
}

.anon-summary {
  margin-top: 1rem;
  font-size: 0.95rem;
}

.anon-caveat .bi,
.anon-result .bi {
  margin-right: 0.25rem;
}

.anon-result {
  margin: 1rem 0 0;
}

.anon-num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The incident page's standing note that its personal details were removed. */
.anonymised-banner .bi {
  margin-right: 0.35rem;
}

/* ---- Maps and plans ----
 *
 * 137. The map picker modal, the read-only mini-maps on the detail pages, and
 * the floor/site plan a pin is dropped on.
 *
 * Leaflet brings its own stylesheet and positions everything it draws with
 * inline `style` attributes of its own; what is here is only the SIZE of the
 * boxes it draws into (a Leaflet map with no height renders as nothing at all)
 * and the first-party furniture around it. Nothing below re-styles a Leaflet
 * class.
 *
 * The plan pin is the one place the app sets a style from JS, and it sets two
 * properties: `left` and `top`, because a percentage position IS the datum
 * (plan_x / plan_y) and cannot be a class. Everything else about the pin —
 * shape, colour, the anchor point — is declared here, and the pin is never the
 * only way to place it: the two number inputs beside it are the real control.
 */

/* The picker's canvas. 60vh keeps the whole modal on a laptop screen and the
   floor is there for a short phone in landscape. */
.map-picker {
  height: 60vh;
  min-height: 320px;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.375rem;
}

/* On a phone 60vh plus a postcode row plus the readout plus a footer is taller
   than the screen, and the CTA ends up somewhere below the fold. The map gives
   up the height — it is the one part of the dialog that can be panned. */
@media (max-width: 575.98px) {
  .map-picker {
    height: 45vh;
    min-height: 240px;
  }
}

/* The read-only map on a detail page: a figure inside the report document, so
   it is fixed-height and never grows to swallow the page. */
.mini-map {
  height: 220px;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.375rem;
}

/* No OS key on this server, or /maps/status could not be reached. The map is
   still live and a point can still be picked — this is the ground it is picked
   on, a quiet grid rather than a blank white hole that reads as broken. */
.map-unavailable {
  background-color: #eef1f5;
  background-image:
    linear-gradient(to right, rgba(100, 116, 139, 0.16) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(100, 116, 139, 0.16) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* ---- the plan ---- */

/* The positioning context for the pin: the image sets the size, the pin is
   placed inside it in percentages of that box. */
.plan-canvas {
  position: relative;
  display: inline-block;
  max-width: 100%;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.375rem;
  background: var(--bs-body-bg);
  overflow: hidden;
}

.plan-canvas img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* The picker's canvas takes the click; the read-only one does not. */
.plan-canvas.pickable { cursor: crosshair; }

/* The read-only one is a FIGURE inside a report document, so it is capped:
   a 1600x1000 plan drawn at the full width of the card is two thirds of a
   screen (and most of a printed page) of white space with one pin in it. The
   canvas is inline-block and hugs the image, so the pin's percentages still
   land on the same spot at any size. */
.plan-figure img {
  max-height: 420px;
  width: auto;
}

/* The pin itself. `left` / `top` are set from JS (they are the datum); the
   transform hangs the point of the pin on that spot rather than its middle. */
.plan-pin {
  position: absolute;
  width: 22px;
  height: 30px;
  margin: 0;
  transform: translate(-50%, -100%);
  pointer-events: none;
  background: var(--bsafe-report-red);
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  box-shadow: 0 1px 3px rgba(28, 36, 52, 0.45);
}

/* The dot in the middle of the head, so the pin reads as a marker and not as a
   coloured blob at any size. */
.plan-pin::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 38%;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: var(--bs-body-bg);
}

/* The tail. Drawn as a triangle under the head so the anchor point is visibly
   the spot, not the body of the pin. */
.plan-pin::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 0;
  height: 0;
  margin-left: -5px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 8px solid var(--bsafe-report-red);
}

/* ---- the plan library on a site record ---- */

.plan-thumb {
  border: 1px solid var(--bsafe-line);
  border-radius: 0.375rem;
  background: var(--bs-body-bg);
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.plan-thumb img {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: contain;
  background: #f4f6f9;
  border-bottom: 1px solid var(--bsafe-line);
}

.plan-thumb-body {
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 auto;
}

.plan-thumb-label {
  font-weight: 600;
  color: var(--bsafe-ink);
  line-height: 1.3;
}

.plan-thumb-meta {
  font-size: 0.78rem;
  color: var(--bsafe-muted);
}

@media print {
  /* Both blocks are part of the report, not chrome: a printed incident report
     that shows where in the building it happened is the whole point of the
     pin. Keep the tiles and the plan image, and keep either off a page break. */
  .mini-map,
  .plan-canvas,
  .plan-pin {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .mini-map,
  .plan-canvas { break-inside: avoid; }
  /* Leaflet's zoom buttons and attribution flag are screen controls. */
  .mini-map .leaflet-control-zoom { display: none !important; }
}

/* ------------------------------------------- HSE online reporting (page C)

   The "Report to HSE" page draws HSE's own RIDDOR injury form from the
   structure the agent read minutes ago: six panes, about a hundred controls,
   a live drive view and a receipt. Everything here exists because that page
   asks for something the shared primitives do not already give:

   - a stepper whose stations are BUTTONS (the rail elsewhere is links or
     inert text, and this one navigates within the page);
   - an either/or group drawn as one control, because that is what it is on
     HSE's form even though HSE builds it out of checkboxes;
   - two kinds of marginalia — what HSE changed since we were built, and why
     an answer is blank — which must read as annotations and never as errors;
   - the drive list, which is a live list of six steps with a screenshot
     under each one.

   No HSE colour, glyph or type is copied: a screenshot of this page must be
   unmistakably B-SAFE, never something that could pass for HSE's own site. */

.hse-source-note {
  font-size: 0.85rem;
  color: var(--bsafe-muted);
  margin-bottom: 0.75rem;
}

.hse-source-warning { display: block; }

/* The same sentence as the source note above, about one list rather than the
   whole form: a reviewer choosing a council is entitled to know whether the
   list is HSE's or a demonstration's. It sits inside the field's own
   `.form-text`, so it inherits that size and only needs the icon spaced. */
.hse-runtime-note > .bi,
.hse-runtime-note > .spinner-border {
  margin-right: 0.25rem;
}

/* The stepper. `.lifecycle` gives the rail; these make the stations pressable
   without a button's chrome. */
.hse-stepper .hse-step-link {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
}

.hse-stepper .hse-step-link:focus-visible {
  outline: 2px solid var(--bsafe-accent);
  outline-offset: 3px;
  border-radius: 0.25rem;
}

/* Seven stations, and HSE's own labels are long ("About Injured Person",
   "Submission Receipt"). The shared rail divides the row evenly and lets the
   labels collide; here every station keeps its natural width and the rail
   scrolls sideways at EVERY viewport, not only below the md breakpoint. */
.hse-stepper {
  flex-wrap: wrap;
  row-gap: 0.4rem;
  overflow-x: visible;
}

.hse-stepper .lc-step { flex: 0 0 auto; }
.hse-stepper .lc-step::after { min-width: 1.25rem; }

/* A question HSE requires. The star is decoration; the `required` attribute
   and HSE's own message are what actually police the answer. */
.hse-req {
  color: var(--bsafe-report-red);
  font-weight: 700;
}

/* Marginalia: "New on HSE's form", "Matched by label". Not an error — an
   annotation on a field that is otherwise perfectly usable. */
.hse-flag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--bsafe-attention-ink);
  background: var(--bsafe-attention-bg);
  border: 1px solid var(--bsafe-attention-line);
  border-radius: 0.25rem;
  padding: 0.05rem 0.35rem;
  vertical-align: middle;
}

/* Personal data, marked once per field. The sentence lives in the tooltip and
   in the accessibility tree; printing it under forty boxes buried the
   questions it was meant to qualify. */
.hse-pii {
  font-size: 0.75rem;
  color: var(--bsafe-muted);
  vertical-align: middle;
}

/* HSE's own help text, where HSE wrote eighty words of it. Folded, never
   trimmed: the words are HSE's and a reader who wants them can open them. */
.hse-note > summary {
  font-size: 0.78rem;
  color: var(--bsafe-accent);
  cursor: pointer;
}

.hse-note > p {
  font-size: 0.78rem;
  color: var(--bsafe-muted);
  margin-top: 0.25rem;
}

/* One either/or question. HSE builds these out of checkboxes tied together by
   a behaviour key; here it is one control with one legend and one answer. */
.hse-choice {
  border: 1px solid var(--bsafe-line);
  border-radius: 0.375rem;
  padding: 0.65rem 0.85rem;
  margin: 0;
}

.hse-choice > legend {
  float: none;
  width: auto;
  padding: 0 0.25rem;
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
}

.hse-field .form-text { font-size: 0.78rem; }

.hse-pane-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 1rem 0 0;
}

/* What HSE has changed since B-SAFE was built. A warning band, listed rather
   than prosed, because a reader is checking items off. */
.hse-drift-list { margin: 0; }
.hse-drift-list dt {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.5rem;
}
.hse-drift-list dd { margin: 0.15rem 0 0; }
.hse-drift-field { font-weight: 600; }
.hse-drift-value {
  display: block;
  font-size: 0.8rem;
  font-family: var(--bs-font-monospace);
}

.hse-review-pane {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1.1rem 0 0.35rem;
}

/* A blank with its reason. Muted and italic so the review reads as answers
   with gaps explained, not as a list of failures. */
.hse-blank {
  color: var(--bsafe-muted);
  font-style: italic;
}

/* The drive: six steps, a state each, a screenshot under each. */
.hse-drive-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hse-drive-pane {
  border-top: 1px solid var(--bsafe-line);
  padding: 0.7rem 0;
}

.hse-drive-pane:first-child { border-top: 0; }

.hse-drive-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hse-drive-label { font-weight: 600; }

.hse-drive-state {
  margin-left: auto;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bsafe-muted);
}

.hse-drive-pane[data-state="done"] .hse-drive-head .bi { color: #198754; }
.hse-drive-pane[data-state="failed"] .hse-drive-head .bi { color: var(--bs-danger, #dc3545); }
.hse-drive-pane[data-state="filling"] .hse-drive-head .bi { color: var(--bsafe-accent); }
.hse-drive-pane[data-state="pending"] .hse-drive-head .bi { color: #c3c9d4; }

.hse-drive-errors {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.85rem;
  color: var(--bs-danger, #dc3545);
}

.hse-drive-field { font-weight: 600; }

.hse-drive-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

@keyframes hse-spin { to { transform: rotate(360deg); } }

.hse-spin {
  display: inline-block;
  animation: hse-spin 1.1s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .hse-spin { animation: none; }
}

/* The transcript. Shown INSIDE the app window — a demonstration is a shared
   window, and a screenshot that opens a viewer takes the room somewhere else. */
.hse-shot {
  display: block;
  width: 100%;
  max-width: 420px;
  margin-top: 0.5rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.375rem;
}

.hse-transcript {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hse-shot-figure {
  flex: 1 1 220px;
  max-width: 320px;
  margin: 0;
}

.hse-shot-figure figcaption {
  font-size: 0.78rem;
  color: var(--bsafe-muted);
  margin-top: 0.2rem;
}

/* The reference HSE issued. Large, tabular, with the mode chip welded to it:
   a demonstration reference must never be able to pass for a real one. */
.hse-reference-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.35rem;
}

/* HSE's own words, quoted rather than paraphrased. */
.hse-hse-words {
  border-left: 3px solid var(--bsafe-line);
  padding-left: 0.75rem;
  margin: 0.5rem 0;
  font-size: 0.9rem;
}

@media (max-width: 575.98px) {
  .hse-reference-line { font-size: 1.2rem; }
  .hse-shot { max-width: 100%; }
  .hse-shot-figure { max-width: 100%; }
  .hse-pane-nav .btn { flex: 1 1 0; }
}

/* ------------------------------------ C41 P2 (feat/ai-suggest): the report
   form's optional AI suggestion. Everything in this section is inert on a
   deployment without the AI module: the button it lays out is hidden and the
   card it styles is never filled. */

/* The type select with "Suggest a type" beside it — the inline-assistive-
   control shape of "Find on map". incident-form.js builds this row only for
   someone who can ask, so without AI the column is untouched. Should the AI
   go away mid-page the select is left as the row's only item and grows to the
   width it always had. Anything a shared helper appends to the select's
   parent (live validation's message) takes a line of its own below. */
.type-suggest-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem;
}

.type-suggest-row > .form-select {
  flex: 1 1 14rem;
  width: auto;
  min-width: 0;
}

.type-suggest-row > .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.type-suggest-row > :not(.form-select):not(.btn) {
  flex-basis: 100%;
}

/* The answer: a quiet panel under the field it is about, marked on its
   leading edge in the app blue so it reads as help offered, not as part of
   the report. */
.ai-suggestion {
  margin-top: 0.5rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--bsafe-line);
  border-left: 3px solid var(--bsafe-accent);
  border-radius: 0.375rem;
  background-color: #fff;
}

.ai-suggestion-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bsafe-muted);
  margin-bottom: 0.5rem;
}

.ai-suggestion-grid {
  row-gap: 0.5rem;
  column-gap: 1.5rem;
  margin-bottom: 0.6rem;
}

/* What was sent. The feature's honesty line: always shown with an answer,
   and with a refusal too, because the description left either way. */
.ai-suggestion-sent {
  font-size: 0.8rem;
  color: var(--bsafe-muted);
  margin-bottom: 0.6rem;
}

.ai-suggestion-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---------------------------------------------------------------------------
   P3 — the optional AI help assistant (C41, feat/ai-assist)
   ---------------------------------------------------------------------------
   A topbar control that exists only when GET /me reports `ai.assist`, and the
   Bootstrap offcanvas it opens, appended to <body> by
   js/components/ai-assistant.js. On a default deployment neither is ever in
   the page, so nothing here applies. The drawer is a column: the conversation
   scrolls, the question box and the disclosure line stay put beneath it. */
/* Shown from 1200px up by its d-xl-inline-flex utility; below that the control
   is an item in the user menu (js/components/ai-assistant.js menuItem()), so
   the narrower topbars keep exactly the room they had. */
.topbar-assistant {
  flex: 0 0 auto;
  line-height: 1;
  align-items: center;
  gap: 0.35rem;
}

.ai-assistant {
  --bs-offcanvas-width: min(28rem, 100vw);
}

.ai-assistant .offcanvas-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--bsafe-line);
}

.ai-assistant-subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--bsafe-muted);
}

.ai-assistant .offcanvas-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
}

.ai-assistant-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.ai-assistant-intro {
  font-size: 0.875rem;
  color: var(--bsafe-muted);
}

.ai-assistant-log {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ai-assistant-question {
  align-self: flex-end;
  max-width: 90%;
  padding: 0.5rem 0.75rem;
  border-radius: var(--bs-border-radius);
  background: rgba(var(--bs-primary-rgb), 0.08);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.ai-assistant-answer {
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--bsafe-line);
  border-radius: var(--bs-border-radius);
  background: var(--bs-body-bg);
}

/* Model output is plain text by construction; pre-line keeps its line breaks
   and numbered steps without ever interpreting a character of it. */
.ai-assistant-answer-text {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.ai-assistant-sources {
  margin-top: 0.5rem;
}

.ai-assistant-sources-title {
  margin: 0 0 0.15rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bsafe-muted);
}

.ai-assistant-source-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.875rem;
}

.ai-assistant-meta,
.ai-assistant-notice,
.ai-assistant-disclosure {
  margin: 0;
  font-size: 0.75rem;
  color: var(--bsafe-muted);
}

.ai-assistant-meta {
  margin-top: 0.5rem;
}

.ai-assistant-notice {
  font-size: 0.875rem;
  font-style: italic;
}

.ai-assistant-status:empty {
  display: none;
}

.ai-assistant-status {
  margin: 0;
  font-size: 0.875rem;
  color: var(--bsafe-muted);
}

.ai-assistant-offline {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--bsafe-attention-line);
  border-radius: var(--bs-border-radius);
  background: var(--bsafe-attention-bg);
  color: var(--bsafe-attention-ink);
  font-size: 0.875rem;
}

.ai-assistant-form textarea {
  resize: vertical;
}

.ai-assistant-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.ai-assistant-disclosure {
  padding-top: 0.5rem;
  border-top: 1px solid var(--bsafe-line);
}

/* ------------------------------------------ P4: AI settings and the AI usage log
   (C41, migration 139 — ai-settings.html, ai-usage.html). Append-only section
   for the C41 admin package; the pages otherwise wear the page head, the
   report document and the register kit unchanged. */

/* The disclosure: the paragraph an evaluator photographs. Full ink and a
   hairline in the accent on the left, so it reads as a statement the product
   makes rather than as a caption under something else. */
.ai-disclosure {
  max-width: 80ch;
  padding-left: 0.75rem;
  border-left: 3px solid var(--bsafe-accent);
  color: var(--bsafe-ink);
}

/* The provider's own note, above the per-feature list of what leaves. */
.ai-data-note-text {
  max-width: 80ch;
  margin-bottom: 0.75rem;
}

/* The two inline notes under the form: a model with no price row, and a cap
   at or below what has already been spent. Attention-toned words and not an
   alert box — they say what saving will do, they do not stop anybody. */
.ai-unpriced,
.ai-cap-warning {
  color: var(--bsafe-attention-ink);
  font-weight: 500;
}

/* Hashes: shortened and kept on one line in the register, whole and allowed
   to break anywhere in the detail view (sixty-four hex digits have no spaces
   for a browser to break at). */
.ai-hash {
  white-space: nowrap;
  font-size: 0.8rem;
}

.ai-hash-full {
  word-break: break-all;
  font-size: 0.8rem;
}

/* Tokens and money are read down the column; the time and the provider line
   are short tokens that read wrongly broken across lines ("2026-" / "09-23"),
   so those CELLS hold together while their headers may wrap — nine columns
   have to fit beside the sidebar at 1440 without pushing the row menu out of
   sight. The prose columns (purpose, outcome) wrap as usual. */
.ai-requests-table td.ai-num,
.ai-requests-table td.ai-when {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ai-requests-table td.ai-where > div:first-child {
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   "Fill in this form for me" — the AI form draft (C41, feat/ai-draft)
   ---------------------------------------------------------------------------
   The panel sits at the top of the assistant drawer on a new report; the
   markers and the summary line sit on the report form. None of it is ever in
   a page where GET /me does not report `ai.suggest`. */
.ai-draft {
  padding-bottom: 0.9rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--bsafe-line);
}

.ai-draft-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.ai-draft-intro {
  font-size: 0.875rem;
  color: var(--bsafe-muted);
  margin-bottom: 0.6rem;
}

.ai-draft textarea {
  resize: vertical;
}

.ai-draft .ai-suggestion {
  margin-top: 0.75rem;
}

.ai-draft .report-pre {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* The chip on the label of every field the draft filled, until the person
   changes the field. Accent-tinted rather than a status colour: it says where
   an answer came from, not what state anything is in. */
.ai-draft-marker {
  margin-left: 0.4rem;
  padding: 0.2em 0.5em;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: 0.1em;
  color: var(--bsafe-accent-deep);
  background-color: rgba(var(--bs-primary-rgb), 0.08);
  border: 1px solid rgba(var(--bs-primary-rgb), 0.35);
}

.form-control.ai-drafted,
.form-select.ai-drafted {
  border-color: rgba(var(--bs-primary-rgb), 0.55);
  box-shadow: inset 3px 0 0 var(--bsafe-accent);
}

/* The summary line: what the AI filled, and that nothing is saved until the
   person saves. The suggestion card's quiet panel, full width above the form. */
.ai-draft-summary {
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--bsafe-line);
  border-left: 3px solid var(--bsafe-accent);
  border-radius: 0.375rem;
  background-color: #fff;
}

.ai-draft-summary:focus {
  outline: 2px solid rgba(var(--bs-primary-rgb), 0.45);
  outline-offset: 2px;
}

.ai-draft-summary-text {
  margin-bottom: 0.35rem;
  font-weight: 500;
}

/* ---------------------------------------------------------------------------
   C41 — statistics in your own words (feat/ai-stats)
   ---------------------------------------------------------------------------
   The "Ask in your own words" card on statistics.html, filled by
   js/components/ai-statistics.js. The card ships `d-none` and stays so unless
   GET /me reports ai.assist; the preview and the answer reuse the report
   form's `.ai-suggestion` panel, so an AI answer looks the same wherever it
   appears. What is added here is the request, shown as chips — one per
   criterion and per filter the page applied — and the honesty line. */

.ai-stats-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  margin: 0 0 0.6rem;
  padding: 0;
}

.ai-stats-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 999px;
  background-color: var(--bs-tertiary-bg, #f8f9fa);
  font-size: 0.85rem;
  line-height: 1.4;
}

.ai-stats-chip-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bsafe-muted);
}

.ai-stats-chip-remove {
  width: 0.55rem;
  height: 0.55rem;
  padding: 0.2rem;
  background-size: 0.55rem;
}

.ai-stats-notes {
  font-size: 0.85rem;
  margin-bottom: 0.6rem;
}

.ai-stats-notes-title {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bsafe-muted);
}

/* The feature's honesty line: who computed the numbers, and what the model
   never saw. Always shown with a request, never smaller than body text. */
.ai-stats-honesty {
  margin-bottom: 0.4rem;
  color: var(--bsafe-accent-deep);
  font-weight: 500;
}

/* ====================================================================}

 * Occupational health referrals (144, RCT)
 * ===========================================================================
 *
 * The register and the referral document are built from primitives that
 * already exist (the register kit, the report document, the lifecycle rail,
 * the notes timeline). What is new is the FORM a manager sends one from: one
 * card read top to bottom in six numbered steps, each with a plain sentence
 * saying why it is asked. From 1200px the sentence sits in a column to the
 * left of the fields, so the fields keep a readable width without capping the
 * page; below that it sits above them. Generous padding between the steps is
 * the point, not a by-product: the form is filled in by somebody worried
 * about a member of their team, and it should look calm.
 */

#referrals-table tbody tr { cursor: pointer; }

/* Days waiting are read down the column. */
.referral-days {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The referral's rail says each station's state in words for a screen reader
   (a `.visually-hidden` span, which is absolutely positioned). Without a
   positioned rail those spans take the PAGE as their containing block, so on
   a phone — where the rail scrolls sideways — the stations scrolled out of
   view stretched the whole page to 800px wide. Positioned, the rail holds
   them inside its own scroll box. */
.referral-rail { position: relative; }

/* The rail is focusable (it scrolls on a phone, and a keyboard has to be able
   to scroll it); its focus ring is the app's accent. */
.referral-rail:focus-visible {
  outline: 2px solid var(--bsafe-accent);
  outline-offset: 2px;
}

/* Reason and "Referred by" give way on a phone, so the status is on screen
   without a sideways scroll. The referral itself carries both. */
@media (max-width: 767.98px) {
  #referrals-table .referral-col-wide { display: none; }
}

.referral-form > .card-body { padding: 0 1.5rem; }

.form-step {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem 3rem;
  padding: 1.75rem 0;
}

.form-step + .form-step { border-top: 1px solid var(--bsafe-line); }

@media (min-width: 1200px) {
  .form-step { grid-template-columns: minmax(15rem, 1fr) minmax(0, 3fr); }
}

/* `baseline`: a title that wraps ("Background and welfare notes" in a narrow
   column) keeps its number beside the FIRST line, where the eye starts. */
.form-step-title {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--bsafe-ink);
}

/* The step number wears the lifecycle rail's "current" dot, so a numbered
   process looks the same wherever the app draws one. */
.form-step-number {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border: 2px solid var(--bsafe-accent);
  border-radius: 50%;
  color: var(--bsafe-accent);
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.form-step-intro {
  margin: 0;
  color: var(--bsafe-muted);
  font-size: 0.9rem;
}

/* A legend is a field's label, not a heading: Bootstrap's reboot draws it at
   heading size and floats it. */
.referral-form legend.form-label,
#accept-modal legend.form-label {
  float: none;
  font-size: 1rem;
}

/* "(optional)" is a quieter part of the label it belongs to. */
.form-optional {
  font-weight: 400;
  color: var(--bsafe-muted);
}

/* A help sentence is read, so it keeps a reading measure on a wide screen.
   This is a typographic measure on one line of text, not a cap on the page. */
.referral-form .form-text { max-width: 48rem; }

/* Radio and checkbox lists: one column on a phone, the eight reasons in two
   from 768px. Each choice keeps its whole label on the hit area. */
.choice-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem 2rem;
}

@media (min-width: 768px) {
  .choice-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.choice-grid .form-check { margin: 0; }

/* The employee, once the referral exists: a value, not a box. */
.referral-fixed-value {
  padding: 0.375rem 0;
  font-weight: 600;
  color: var(--bsafe-ink);
}

.staged-files { max-width: 48rem; }

/* The agreement is the last thing read before the button, so it gets a
   quiet frame of its own rather than sitting loose under the background. */
.referral-consent {
  padding: 0.85rem 1rem 0.85rem 2.6rem;
  border: 1px solid var(--bsafe-line);
  border-radius: var(--bs-border-radius, 0.375rem);
  background: #f8fafc;
}

.referral-consent .form-check-label { font-weight: 600; }
/* "More questions" are the unit's own (Settings > Custom fields, "OH
   referral"). When the unit groups them into sections, each section wears the
   report's quiet subsection heading, on the form and on the referral; the
   first one sits level with the title beside it rather than below it. */
#ref-more-fields > .report-subsection-title:first-child,
#ref-section-more > .report-subsection-title:first-child { margin-top: 0; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* The summary of answers that need attention: a white panel with a red edge,
   not a red slab. It is a list of ways back to the fields, and the fields
   themselves carry the same words. */
.error-summary {
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--bs-danger-border-subtle, #f1aeb5);
  border-left: 4px solid var(--bs-form-invalid-border-color, #dc3545);
  border-radius: var(--bs-border-radius, 0.375rem);
  background: var(--bs-body-bg);
  color: var(--bsafe-ink);
}

.error-summary-title {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  font-weight: 600;
}

.error-summary-list {
  margin: 0;
  padding-left: 1.25rem;
}

.error-summary-list a {
  color: var(--bs-danger-text-emphasis, #842029);
  font-weight: 500;
}

/* A list of choices that needs an answer: one bar beside the whole group,
   and its message under it — not every option painted red. */
.referral-form fieldset.field-invalid {
  padding-left: 0.85rem;
  border-left: 3px solid var(--bs-form-invalid-border-color, #dc3545);
}

.referral-consent.field-invalid {
  border-color: var(--bs-form-invalid-border-color, #dc3545);
  border-left-width: 3px;
}

/* On the appointments register, the one-line way to the referral form for a
   reader who may both book and refer. Quiet: it orients, it does not compete
   with the button above it. */
.register-pointer {
  margin: -0.25rem 0 1rem;
  font-size: 0.875rem;
  color: var(--bsafe-muted);
}

/* One line of a referral's timeline: the event in the document's own ink and
   weight (the notes timeline's bold is for an author's name, and a sentence
   in bold shouts), with its time beneath. */
.referral-event { color: var(--bsafe-ink); }

/* The note a clinician left for whoever books, shown inside the booking dialog. */
.book-note {
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--bsafe-line);
  color: var(--bsafe-ink);
  white-space: pre-wrap;
}

@media (max-width: 575.98px) {
  .referral-form > .card-body { padding: 0 1rem; }
  .form-step { padding: 1.25rem 0; }
  .form-actions .btn { flex: 1 1 auto; }
}
/* ---------------------------------------------------------------------------
   145 — appointment messages: the Messages card, the text-message mode note,
   the outbox, the template editor and "My details"
   ---------------------------------------------------------------------------
   The mode note is the text-message gateway's permanent statement of what it
   is (style guide rule 8): in demo mode, that nothing reaches a phone. It
   wears the attention band's tokens so it reads as a standing caution, not
   as decoration, and it has no close button anywhere it appears. */

.sms-mode-note {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--bsafe-line);
  color: var(--bsafe-muted);
  font-size: 0.875rem;
}

.sms-mode-note.is-demo {
  border: 1px solid var(--bsafe-attention-line);
  border-left-width: 4px;
  background: var(--bsafe-attention-bg);
  color: var(--bsafe-attention-ink);
  font-weight: 500;
}

.sms-mode-note.is-demo .bi { color: var(--bsafe-attention-mark); }

/* Outside a card (the outbox, the template tab, My details) the band keeps its
   own rounded edge and some air below it. */
.sms-mode-note.is-standalone {
  border-radius: var(--bs-border-radius, 0.375rem);
  margin-bottom: 1rem;
}

.msg-row { padding-top: 0.6rem; padding-bottom: 0.6rem; }

.msg-row-head {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.msg-channel-icon {
  flex: none;
  margin-top: 0.15rem;
  color: var(--bsafe-muted);
}

.msg-row-what { flex: 1 1 auto; min-width: 0; }

.msg-row-title { font-weight: 500; }

.msg-status { flex: none; white-space: normal; text-align: right; }

.msg-row-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.35rem 0 0 1.6rem;
}

.msg-text { flex: 1 1 14rem; font-size: 0.875rem; }

.msg-text summary {
  color: var(--bsafe-accent);
  cursor: pointer;
}

.msg-text-body,
.sms-body {
  margin: 0.35rem 0 0;
  padding: 0.5rem 0.65rem;
  border-left: 3px solid var(--bsafe-line);
  background-color: var(--bs-tertiary-bg, #f8f9fa);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-resend { flex: none; }

.msg-more { background: transparent; }

/* The template editor's live preview and its honest length line. */
.tpl-preview {
  padding: 0.75rem;
  border: 1px solid var(--bsafe-line);
  border-radius: var(--bs-border-radius, 0.375rem);
  background-color: var(--bs-tertiary-bg, #f8f9fa);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.tpl-preview-subject { font-weight: 600; margin-bottom: 0.5rem; }

.tpl-length { font-size: 0.85rem; color: var(--bsafe-muted); }

.tpl-length.is-ucs2 { color: var(--bsafe-attention-ink); }

.tpl-placeholders {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tpl-placeholders .btn { font-family: var(--bs-font-monospace); }

.tpl-status { font-size: 0.85rem; }

/* The Resend button sits at the right of its row whether or not the row has a
   "Show the text" disclosure beside it. */
.msg-row-foot .msg-resend { margin-left: auto; }

/* The Messages tab's table on a phone: each message becomes a short stack -
   its name, then each column under its own small label - instead of five
   columns squeezed into 390px with the switches scrolled out of reach. */
@media (max-width: 575.98px) {
  .tpl-table thead,
  .tpl-table tfoot { display: none; }

  .tpl-table,
  .tpl-table tbody,
  .tpl-table tr,
  .tpl-table td {
    display: block;
    width: 100%;
  }

  .tpl-table tr {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--bsafe-line);
  }

  .tpl-table td {
    border: 0;
    padding: 0.15rem 0;
  }

  .tpl-table td[data-label]:not([data-label="Message"])::before {
    content: attr(data-label);
    display: block;
    color: var(--bsafe-muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
}

/* ------------------------------------------------- clinic diary (147) */

/*
 * The occupational health clinic diary (occupational-health-diary.html):
 * clinicians as columns on a time axis, a week as a table, an agenda on a
 * phone. Calm on purpose: working hours are plain white, everything else a
 * quiet grey, and the only colour on the page is the status rule on an
 * appointment and the accent on the control under the pointer. Free time
 * shows "Book" only on hover or focus, so a clinic day reads as a day and not
 * as a wall of buttons.
 *
 * Positions come from two custom properties set from the CSSOM per block -
 * `--d-start` (minutes from the top of the axis) and `--d-len` (minutes long)
 * - against `--diary-minute`, so the markup carries no style attribute.
 */

.diary-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.diary-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.diary-title {
  margin: 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--bsafe-ink);
  font-variant-numeric: tabular-nums;
}

.diary-date { width: auto; }

.diary-views .btn.active,
.diary-views .btn[aria-pressed="true"] {
  background-color: var(--bsafe-accent);
  border-color: var(--bsafe-accent);
  color: #fff;
}

.diary-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.diary-clinician-picker { flex: 1 1 22rem; }

.diary-clinician-picker .form-label { margin-bottom: 0.25rem; }

.diary-filters .register-toolbar { margin-bottom: 0; }

/* --- the day: clinicians side by side ------------------------------------ */

.diary-scroll { overflow-x: auto; }

.diary-grid {
  --diary-hour: 4.75rem;
  --diary-minute: calc(var(--diary-hour) / 60);
  min-width: min-content;
}

.diary-row {
  display: grid;
  grid-template-columns: 3.5rem repeat(var(--diary-cols, 1), minmax(13rem, 1fr));
}

.diary-row-head {
  position: sticky;
  top: 0;
  z-index: 4;
  background-color: #fff;
  border-bottom: 1px solid var(--bsafe-line);
}

.diary-col-head {
  position: relative;
  padding: 0.5rem 2.5rem 0.6rem 0.75rem;
  border-left: 1px solid var(--bsafe-line);
}

.diary-col-name {
  font-weight: 700;
  color: var(--bsafe-ink);
}

.diary-col-hours {
  font-size: 0.8rem;
  color: var(--bsafe-muted);
  font-variant-numeric: tabular-nums;
}

.diary-col-menu {
  position: absolute;
  top: 0.35rem;
  right: 0.25rem;
}

.diary-col-menu .btn { color: var(--bsafe-muted); }

.diary-col-menu .btn:hover,
.diary-col-menu .btn:focus-visible { color: var(--bsafe-ink); }

.diary-gutter,
.diary-col {
  position: relative;
  height: calc(var(--diary-span, 600) * var(--diary-minute));
}

.diary-hour {
  position: absolute;
  top: calc(var(--d-start, 0) * var(--diary-minute));
  right: 0.5rem;
  padding-top: 0.1rem;
  font-size: 0.72rem;
  color: var(--bsafe-muted);
  font-variant-numeric: tabular-nums;
}

/* Outside working hours: quiet grey, with an hour rule every hour. */
.diary-col {
  border-left: 1px solid var(--bsafe-line);
  background-color: #f4f6f9;
  background-image: repeating-linear-gradient(
    to bottom,
    var(--bsafe-line) 0,
    var(--bsafe-line) 1px,
    transparent 1px,
    transparent var(--diary-hour)
  );
}

.diary-col.is-off { background-color: #eef1f5; }

.diary-off-note {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  padding-top: 1rem;
  font-size: 0.85rem;
  color: var(--bsafe-muted);
}

.diary-work,
.diary-break,
.diary-blocked,
.diary-free,
.diary-appt,
.diary-booked {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--d-start, 0) * var(--diary-minute));
  height: calc(var(--d-len, 0) * var(--diary-minute));
}

/* Working hours: white, the same hour rules, aligned to the column's own. */
.diary-work {
  background-color: #fff;
  background-image: repeating-linear-gradient(
    to bottom,
    var(--bsafe-line) 0,
    var(--bsafe-line) 1px,
    transparent 1px,
    transparent var(--diary-hour)
  );
  background-position: 0 calc(var(--d-start, 0) * var(--diary-minute) * -1);
}

.diary-break {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--bsafe-muted);
}

/* Not available: hatched, so it reads as "not this time" without a colour. */
.diary-blocked {
  z-index: 1;
  padding: 0.3rem 2rem 0.3rem 0.5rem;
  border-top: 2px solid #c9d1db;
  background-color: #eceff3;
  background-image: repeating-linear-gradient(
    135deg,
    transparent 0,
    transparent 6px,
    rgba(100, 116, 139, 0.12) 6px,
    rgba(100, 116, 139, 0.12) 12px
  );
  font-size: 0.78rem;
  color: #475569;
  overflow: hidden;
}

.diary-blocked-label { font-weight: 600; }

.diary-blocked-remove {
  position: absolute;
  top: 0.2rem;
  right: 0.25rem;
  padding: 0.05rem 0.35rem;
  border: 0;
  border-radius: 0.25rem;
  background: none;
  color: var(--bsafe-muted);
}

.diary-blocked-remove:hover,
.diary-blocked-remove:focus-visible {
  background-color: rgba(15, 23, 42, 0.07);
  color: var(--bsafe-ink);
}

/* Free time: invisible until the pointer or the keyboard is on it. */
.diary-free {
  z-index: 1;
  padding: 0 0.6rem;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.diary-free-label {
  display: none;
  height: 100%;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--bsafe-accent);
}

.diary-free:hover,
.diary-free:focus-visible {
  background-color: rgba(23, 93, 166, 0.07);
  box-shadow: inset 0 0 0 1px rgba(23, 93, 166, 0.35);
}

.diary-free:focus-visible { outline: 2px solid var(--bsafe-accent); outline-offset: -2px; }

.diary-free:hover .diary-free-label,
.diary-free:focus-visible .diary-free-label { display: inline-flex; }

/* An appointment: white card, status as a coloured rule AND as a word. */
.diary-appt {
  z-index: 2;
  left: 0.3rem;
  right: 0.3rem;
  height: calc(var(--d-len, 0) * var(--diary-minute) - 2px);
  margin-top: 1px;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.15rem 0.45rem;
  overflow: hidden;
  border: 1px solid #d4dce6;
  border-left: 4px solid var(--bs-secondary);
  border-radius: 0.375rem;
  background-color: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  text-align: left;
  font-size: 0.78rem;
  line-height: 1.2;
  color: var(--bsafe-ink);
}

/* Overlapping appointments share the column side by side: lane and lane count
   come from the page's column packing (--d-lane, --d-lanes). */
.diary-appt.is-laned {
  --d-slice: calc((100% - 0.6rem) / var(--d-lanes, 1));
  left: calc(0.3rem + var(--d-slice) * var(--d-lane, 0));
  right: auto;
  width: calc(var(--d-slice) - 2px);
  padding-left: 0.35rem;
  padding-right: 0.3rem;
}

.diary-appt.is-laned .diary-appt-line { flex-wrap: wrap; row-gap: 0; }

/* Under half an hour: one line - time, name and the status in words. */
.diary-appt.is-short {
  justify-content: center;
  padding-top: 0;
  padding-bottom: 0;
}

.diary-appt:hover {
  border-color: #b9c6d6;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

.diary-appt:focus-visible { outline: 2px solid var(--bsafe-accent); outline-offset: 1px; }

.diary-appt-line {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.diary-appt-time {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.diary-appt-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.diary-appt-meta { color: var(--bsafe-muted); }

.diary-appt-type {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diary-appt .badge,
.diary-week-appt .badge,
.diary-agenda-appt .badge {
  flex: 0 0 auto;
  font-size: 0.66rem;
}

.diary-appt-planned { border-left-color: var(--bs-secondary); }
.diary-appt-attended { border-left-color: var(--bs-info); }
.diary-appt-unattended { border-left-color: var(--bs-warning); }
.diary-appt-report_agreed { border-left-color: var(--bs-success); }
.diary-appt-report_sent { border-left-color: var(--bs-dark); }

/* Somebody else's appointment this caller may not see: busy, nameless. */
.diary-booked {
  z-index: 2;
  left: 0.3rem;
  right: 0.3rem;
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  border-radius: 0.375rem;
  background-color: #e9edf2;
  font-size: 0.75rem;
  color: var(--bsafe-muted);
}

.diary-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.78rem;
  color: var(--bsafe-muted);
}

.diary-legend li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.diary-key {
  width: 1rem;
  height: 0.75rem;
  border: 1px solid #cfd6df;
  border-radius: 0.2rem;
}

.diary-key-free { background-color: #fff; }
.diary-key-off { background-color: #f4f6f9; }

.diary-key-blocked,
.diary-week-blocked,
.diary-agenda-blocked {
  background-color: #eceff3;
  background-image: repeating-linear-gradient(
    135deg,
    transparent 0,
    transparent 4px,
    rgba(100, 116, 139, 0.14) 4px,
    rgba(100, 116, 139, 0.14) 8px
  );
}

/* --- the week: one row per clinician -------------------------------------- */

.diary-week {
  min-width: 52rem;
  margin: 0;
  table-layout: fixed;
}

.diary-week th,
.diary-week td {
  vertical-align: top;
  border-color: var(--bsafe-line);
}

.diary-week thead th {
  font-size: 0.8rem;
  font-weight: 700;
}

.diary-week thead th:first-child,
.diary-week-name { width: 11rem; }

.diary-week-name { font-weight: 700; }

.diary-week-day {
  padding: 0;
  font-weight: 700;
  text-decoration: none;
}

.diary-week .is-today { background-color: rgba(23, 93, 166, 0.04); }

.diary-week-cell.is-off { background-color: #f8f9fb; }

.diary-week-off,
.diary-week-full,
.diary-week-booked {
  font-size: 0.75rem;
  color: var(--bsafe-muted);
}

.diary-week-hours {
  margin-bottom: 0.4rem;
  font-size: 0.75rem;
  color: var(--bsafe-muted);
  font-variant-numeric: tabular-nums;
}

.diary-week-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0 0 0.35rem;
  padding: 0;
  list-style: none;
}

.diary-week-appt {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  padding: 0.15rem 0.35rem;
  border: 1px solid #d4dce6;
  border-left-width: 3px;
  border-radius: 0.3rem;
  background-color: #fff;
  text-align: left;
  font-size: 0.75rem;
}

.diary-week-appt .diary-appt-name { flex: 1 1 auto; }

.diary-week-blocked {
  padding: 0.15rem 0.4rem;
  border-radius: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
}

.diary-week-free {
  padding: 0;
  font-size: 0.78rem;
  font-weight: 600;
}

/* --- phones: the agenda ----------------------------------------------------- */

.diary-agenda-date {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--bsafe-muted);
}

.diary-agenda-day + .diary-agenda-day {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--bsafe-line);
}

.diary-agenda-person + .diary-agenda-person {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--bsafe-line);
}

.diary-agenda-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.diary-agenda-head .diary-col-menu { position: static; }

.diary-agenda-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.diary-agenda-hours {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--bsafe-muted);
}

.diary-agenda-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0 0 0.6rem;
  padding: 0;
  list-style: none;
}

.diary-agenda-appt {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid #d4dce6;
  border-left: 4px solid var(--bs-secondary);
  border-radius: 0.375rem;
  background-color: #fff;
  text-align: left;
}

.diary-agenda-when {
  min-width: 3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.diary-agenda-who {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  font-weight: 600;
}

.diary-agenda-type {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--bsafe-muted);
}

.diary-agenda-blocked,
.diary-agenda-booked {
  padding: 0.45rem 0.6rem;
  border-radius: 0.375rem;
  font-size: 0.85rem;
  color: #475569;
}

.diary-agenda-blocked { font-weight: 600; }

.diary-agenda-booked { background-color: #e9edf2; }

.diary-agenda-none {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--bsafe-muted);
}

.diary-agenda-free {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.diary-agenda-free-label {
  margin-right: 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--bsafe-muted);
}

.diary-agenda-free .btn { font-variant-numeric: tabular-nums; }

/* --- after "Cancel this clinic": the rebooking list ------------------------- */

.diary-followup {
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--bsafe-line);
  border-left: 4px solid var(--bsafe-accent);
  border-radius: 0.5rem;
  background-color: #fff;
}

.diary-followup-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.diary-followup-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.diary-followup-note {
  margin: 0.25rem 0 0.75rem;
  font-size: 0.88rem;
  color: var(--bsafe-muted);
}

.diary-followup-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.diary-followup-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0;
}

.diary-followup-list li + li { border-top: 1px solid var(--bsafe-line); }

.diary-followup-what {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}

.diary-followup-type,
.diary-followup-done {
  font-size: 0.85rem;
  color: var(--bsafe-muted);
}

.diary-followup-done .bi { color: var(--bs-success); }

/* --- the appointment panel ---------------------------------------------------- */

.diary-panel.offcanvas-end { --bs-offcanvas-width: min(26rem, 100vw); }

.diary-panel .offcanvas-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--bsafe-line);
}

.diary-panel-eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--bsafe-muted);
}

.diary-panel-details { margin: 0 0 1.25rem; }

.diary-panel-row {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--bsafe-line);
}

.diary-panel-row dt {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bsafe-muted);
}

.diary-panel-row dd {
  margin: 0.15rem 0 0;
  white-space: pre-line;
  color: var(--bsafe-ink);
}

.diary-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.diary-panel-confirm p {
  margin-bottom: 0.6rem;
  font-weight: 600;
}

/* --- "Cancel this clinic" ------------------------------------------------------- */

.cancel-clinic-intro { margin-bottom: 0.5rem; }

.cancel-clinic-list {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.375rem;
}

.cancel-clinic-list li { padding: 0.4rem 0.65rem; }

.cancel-clinic-list li + li { border-top: 1px solid var(--bsafe-line); }

.cancel-clinic-type { color: var(--bsafe-muted); }

/* --- W-diary: cancelled bookings, dragging a booking, changing a block ---------- */

/* Cancelled: muted, struck through, AND the "Cancelled" chip in words. */
.diary-appt-cancelled {
  border-left-color: #cbd5e1;
  background-color: #f8fafc;
  box-shadow: none;
}

.diary-appt-cancelled .diary-appt-time,
.diary-appt-cancelled .diary-appt-name,
.diary-appt-cancelled .diary-appt-type,
.diary-agenda-appt.diary-appt-cancelled .diary-agenda-when,
.diary-agenda-appt.diary-appt-cancelled .diary-agenda-who {
  text-decoration: line-through;
  color: var(--bsafe-muted);
}

.diary-appt-cancelled .badge { border: 1px solid #cbd5e1; }

.diary-key-cancelled {
  background-color: #f8fafc;
  background-image: linear-gradient(transparent 44%, #64748b 44%, #64748b 56%, transparent 56%);
}

/* A free cell sharing time with a cancelled booking takes its own lane. */
.diary-free.is-laned {
  --d-slice: calc((100% - 0.6rem) / var(--d-lanes, 1));
  left: calc(0.3rem + var(--d-slice) * var(--d-lane, 0));
  right: auto;
  width: calc(var(--d-slice) - 2px);
  padding: 0 0.35rem;
}

/* r106: a planned booking is picked up and dropped on a free cell. */
.diary-appt.is-movable { cursor: grab; }

.diary-appt.is-dragging { opacity: 0.55; }

.diary-grid.is-dragging .diary-free { box-shadow: inset 0 0 0 1px rgba(23, 93, 166, 0.25); }

.diary-grid .diary-free.is-drop-target {
  background-color: rgba(23, 93, 166, 0.12);
  box-shadow: inset 0 0 0 2px var(--bsafe-accent);
}

.diary-free.is-drop-target .diary-free-label { display: inline-flex; }

.diary-free.is-drop-only { cursor: default; }

.diary-legend .bi { color: var(--bsafe-ink); }

/* Change a block: a pencil beside the remove cross. */
.diary-blocked.has-edit { padding-right: 3.6rem; }

.diary-blocked-edit {
  position: absolute;
  top: 0.2rem;
  right: 1.9rem;
  padding: 0.05rem 0.35rem;
  border: 0;
  border-radius: 0.25rem;
  background: none;
  color: var(--bsafe-muted);
}

.diary-blocked-edit:hover,
.diary-blocked-edit:focus-visible {
  background-color: rgba(15, 23, 42, 0.07);
  color: var(--bsafe-ink);
}

/* Phones: leave and blocks carry their actions as small buttons. */
.diary-agenda-blocked {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 0.75rem;
}

.diary-agenda-blocked-actions {
  display: flex;
  gap: 0.4rem;
  font-weight: 400;
}

/* r108: the panel's short lists (questionnaires, messages sent). */
.diary-panel-list {
  margin: 0;
  padding: 0;
  list-style: none;
  white-space: normal;
}

.diary-panel-list li + li { margin-top: 0.35rem; }

.diary-panel-list-what { margin-right: 0.35rem; }

.diary-panel-list-meta {
  display: block;
  font-size: 0.8rem;
  color: var(--bsafe-muted);
}

@media (max-width: 575.98px) {
  .diary-toolbar { align-items: stretch; }

  .diary-nav .diary-title {
    order: -1;
    width: 100%;
    margin: 0;
  }

  .diary-views { width: 100%; }

  .diary-views .btn { flex: 1 1 0; }
}

/* ---------------------------------------- employee picker (rct-person, r78) */
/*
 * The booking form's Employee control searches the whole directory as you
 * type. Each option is the name, with the employee number and unit beneath it
 * in the muted meta line every person picker uses — two people of one name are
 * told apart by those, not by guessing.
 *
 * The clear button puts the control back to "Myself". Tom Select draws it only
 * on hover, which a phone never does, so on this control it is always shown
 * once a person is chosen.
 */
#visit-modal .ts-dropdown .option .bm-opt-meta {
  display: block;
  font-size: 0.8125rem;
  color: var(--bsafe-muted);
}

#visit-modal .plugin-clear_button.has-items .clear-button {
  opacity: 1;
}

/*
 * A single picker that keeps focus after a pick (Tom Select does) shows its
 * empty search box on a line of its own under a long label such as "Tomasz
 * Nowak · MFM-0012 · Kingsmuir Depot", and drops it on blur. The next click
 * anywhere below therefore lands on a page that moves 24 px between mousedown
 * and mouseup, and the browser drops it: the first slot clicked after choosing
 * an employee was never ticked. While the list is closed the box stays out of
 * the flow; it comes back the moment the list opens (on typing or a click).
 */
.ts-wrapper.single.has-items:not(.dropdown-active) .ts-control > input {
  position: absolute;
  left: -10000px;
  opacity: 0;
}

/* ------------------------------------------- document viewer (rct-person, r85) */
/*
 * The files card: the name and its comment on the left, the actions on the
 * right — View (images and PDFs), Download (everything), Delete last as the
 * destructive one. Under 576 px the actions drop beneath the name rather than
 * squeezing it.
 *
 * The viewer: a PDF in the browser's own viewer, an image fitted to the
 * window (or at its actual size, scrolling). On a phone the dialog is full
 * screen, so a page of a letter is readable without pinching.
 */
.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.file-row-name {
  min-width: 0;
}

.file-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.375rem;
  flex-shrink: 0;
}

@media (max-width: 575.98px) {
  .file-row {
    flex-direction: column;
    align-items: stretch;
  }

  .file-actions {
    justify-content: flex-start;
  }
}

.file-viewer-body {
  padding: 0;
  background: var(--bs-tertiary-bg);
}

.file-viewer-frame {
  display: block;
  width: 100%;
  height: 75vh;
  border: 0;
}

.file-viewer-image {
  max-height: 75vh;
  overflow: auto;
  text-align: center;
}

.file-viewer-image img {
  display: inline-block;
}

.file-viewer-image.is-fit img {
  max-width: 100%;
  max-height: 75vh;
  height: auto;
}

@media (max-width: 575.98px) {
  .file-viewer-frame,
  .file-viewer-image,
  .file-viewer-image.is-fit img {
    height: auto;
    max-height: none;
  }

  .file-viewer-frame {
    height: calc(100vh - 8.5rem);
  }
}

/* ---------------------------------------------- lam-r2-pdf: the viewer's fallback */
/*
 * What the viewer says in place of a PDF the page cannot draw: a phone browser
 * with no PDF viewer, or a server refusal (no renderer, nothing generated yet).
 * One icon, one sentence that names the problem, one that names the way on.
 * Download, in the footer, becomes the solid button while this is showing.
 */
.file-viewer-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 3rem 1.5rem;
  text-align: center;
}

.file-viewer-fallback .bi {
  font-size: 2.5rem;
  color: var(--bs-secondary-color);
}

.file-viewer-fallback-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.file-viewer-fallback-detail {
  margin: 0;
  max-width: 32rem;
  color: var(--bs-secondary-color);
}

/* ---------------------------------------------- Viewed by (rct-person, r16/r18) */
/*
 * Who has opened a record, from the access log: one row per person, the name
 * and their roles on the left, the last opening and the number of openings on
 * the right. The foot says where the answer comes from, so an IG reviewer
 * does not have to ask.
 */
.viewer-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.viewer-who {
  min-width: 0;
}

.viewer-name {
  font-weight: 600;
  color: var(--bsafe-ink);
}

.viewer-roles,
.viewer-views {
  display: block;
  font-size: 0.8125rem;
  color: var(--bsafe-muted);
}

.viewer-when {
  flex-shrink: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.viewers-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--bsafe-muted);
}

/* Inside the Clinical tab the list sits in the tab, not in a card: a rule
   above and below keeps it reading as a list rather than loose lines. */
.clinical-record section.viewers {
  margin-top: 1.75rem;
}

section.viewers .viewers-list {
  border-top: 1px solid var(--bs-border-color);
  border-bottom: 1px solid var(--bs-border-color);
}

section.viewers .viewer-row {
  padding-left: 0;
  padding-right: 0;
}

section.viewers .viewers-foot {
  padding-top: 0.5rem;
}

/* --------------------------------------------- screening history: audiogram
   The Audiogram view of screening-history.html. The chart is a fixed-height
   box (Chart.js needs a sized, positioned parent); the summary beneath it is
   the same sentence a screen reader gets as the chart's description. */

.chart-mode-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* The one line that says what a trend chart is the trend OF. */
.chart-caption {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--bsafe-muted);
}

.audiogram-canvas {
  position: relative;
  height: 400px;
  width: 100%;
}

.chart-summary {
  margin: 0.75rem 0;
  color: var(--bs-body-color);
}

@media (max-width: 575.98px) {
  .audiogram-canvas { height: 340px; }
}

/* ------------------------------------------------- settings: branding (151) */

/* A sample of the chrome in the colours being typed. The page's own tokens
   are redeclared on this box only (settings.js), so it previews a colour
   without repainting the screen around it before it is saved. */
.branding-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  min-height: calc(1.5em + 0.75rem + 2px);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.5rem;
  background: var(--bs-body-bg);
}

.branding-preview .btn { pointer-events: none; }

.branding-preview-link {
  color: var(--bsafe-accent);
  text-decoration: underline;
}

.branding-preview-pill {
  padding: 0.2rem 0.65rem;
  border-radius: 0.375rem;
  background: var(--bsafe-accent);
  color: #fff;
  font-size: 0.875rem;
}

/* ------------------------------------------------- synthetic data banner */
/* "Synthetic data: every person and record here is made up." One strip at the
   top of the content column on every app page, and above the card on the
   sign-in page (js/synthetic-banner.js, switched by Settings > Branding or
   `bin/bsafe branding:synthetic-banner`). Amber, like the other
   this-is-not-the-real-thing marks, with text that holds 4.5:1 on its ground. */
.synthetic-banner {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--bs-warning-border-subtle);
  background: var(--bs-warning-bg-subtle);
  color: var(--bs-warning-text-emphasis);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
}

.login-card > .synthetic-banner {
  margin-bottom: 1rem;
  border: 1px solid var(--bs-warning-border-subtle);
  border-radius: 0.5rem;
}

/* ------------------------------------------------------------- card stacks */
/* The sub-resource columns under a report document (`.card-stack`). A card
   that has nothing to show for this reader leaves its mount empty, and an
   empty mount must not still take a flex gap, or the column below it starts
   lower than its neighbour for no visible reason. */
.card-stack > :empty {
  display: none;
}

/* ------------------------------------------- high-visibility keyboard focus */

/* Settings > Branding > "High-visibility keyboard focus" (migration 151),
   switched on by `data-focus="high-visibility"` on <html> (shell.js
   applyBranding, login.js). The GOV.UK pattern, which many councils' own
   sites use: a #FFDD00 ground with a near-black edge, legible on white, on
   the slate sidebar and on any brand colour, and never the brand colour
   itself. Links, buttons and menu items are FILLED yellow with dark text and
   a dark underline bar; fields and everything else get a yellow ring with a
   dark ring outside it. `!important` because this is an accessibility setting
   that must win over every component's own focus style, and it is scoped to
   the attribute so the standard focus is untouched when it is off.
   Containers given tabindex="-1" only so script can move focus to them (the
   skip link's <main>, an open modal) are left alone. */
:root {
  --bsafe-focus-hv-ground: #ffdd00;
  --bsafe-focus-hv-ink: #0b0c0c;
}

html[data-focus="high-visibility"] :focus-visible:not([tabindex="-1"]) {
  outline: 3px solid var(--bsafe-focus-hv-ground) !important;
  outline-offset: 0 !important;
  box-shadow: 0 0 0 6px var(--bsafe-focus-hv-ink) !important;
}

html[data-focus="high-visibility"] a:focus-visible:not([tabindex="-1"]),
html[data-focus="high-visibility"] .btn:focus-visible,
html[data-focus="high-visibility"] .nav-link:focus-visible,
html[data-focus="high-visibility"] .dropdown-item:focus-visible,
html[data-focus="high-visibility"] .page-link:focus-visible,
html[data-focus="high-visibility"] .list-group-item-action:focus-visible {
  /* A transparent outline keeps a ring in Windows high-contrast mode, which
     drops backgrounds and shadows. */
  outline: 3px solid transparent !important;
  color: var(--bsafe-focus-hv-ink) !important;
  background-color: var(--bsafe-focus-hv-ground) !important;
  border-color: var(--bsafe-focus-hv-ground) !important;
  box-shadow: 0 -2px var(--bsafe-focus-hv-ground), 0 4px var(--bsafe-focus-hv-ink) !important;
  text-decoration: none !important;
}

html[data-focus="high-visibility"] .btn:focus-visible .bi,
html[data-focus="high-visibility"] .nav-link:focus-visible .bi {
  color: var(--bsafe-focus-hv-ink) !important;
  opacity: 1 !important;
}

/* Fields: GOV.UK's input focus — yellow outside, a dark edge inside. */
html[data-focus="high-visibility"] .form-control:focus,
html[data-focus="high-visibility"] .form-select:focus,
html[data-focus="high-visibility"] .ts-wrapper.focus .ts-control {
  outline: 3px solid var(--bsafe-focus-hv-ground) !important;
  outline-offset: 0 !important;
  border-color: var(--bsafe-focus-hv-ink) !important;
  box-shadow: inset 0 0 0 2px var(--bsafe-focus-hv-ink) !important;
}


/* Dashboard layout source: the "· Layout for Employee" tag stays in the DOM
   but is hidden on phones, where it only crowds the heading. */
@media (max-width: 575.98px) {
  #dashboard-layout-source { display: none !important; }
}

/* ------------------------------------------------- phone tables: stacked cards
   The default for every register: `bindTable()` adds `.table-stack` and writes
   each cell's `data-label` from its column header on every draw; a hand-built
   table opts in with the class and its own `data-label`s. `.table-no-stack`
   opts a grid out (a matrix, a calendar, a sheet edited in place).
   Under 576px each row becomes a block of "Label  value" lines, the row menu
   (kebab) at its top right. Cells Bootstrap already hides (`.d-none`) stay
   hidden. `.col-id` drops the id column on phones; it is still in the markup
   and on desktop - use it only where the row has another way in. */
@media (max-width: 575.98px) {
  /* The repeated header at the foot (footerClone) means nothing in blocks, and
     neither does DataTables' split scroll header if a caller ever scrolls. */
  .table-stack tfoot,
  .dt-scroll-head:has(+ .dt-scroll-body .table-stack),
  .dt-scroll-body:has(.table-stack) ~ .dt-scroll-foot { display: none; }
  .table-stack tr:has(> td.row-menu-cell) {
    position: relative;
    padding-right: 3rem;
  }
  .table-stack td.row-menu-cell {
    position: absolute;
    top: 0.25rem;
    right: 0;
    padding: 0;
  }
  .table-stack .row-menu-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  /* Long values wrap rather than push the block wider than the phone. A
     register's desktop sizing (`#tasks-table { min-width: 68rem }`, nowrap
     cells, `.text-nowrap` chips) is for columns, so blocks override it. */
  .table-stack,
  .table-stack tr,
  .table-stack td { min-width: 0 !important; }
  .table-stack td,
  .table-stack td > *,
  .table-stack td .text-nowrap { white-space: normal !important; max-width: 100%; }
  /* The table sits in DataTables' wrapper, not directly in .table-responsive. */
  .table-responsive:has(.table-stack) { overflow-x: visible; }
  .dt-container:has(.table-stack) .dt-layout-table,
  .dt-container:has(.table-stack) .dt-layout-full { overflow-x: visible; min-width: 0; }

  .table-stack thead { display: none; }
  .table-stack,
  .table-stack tbody { display: block; width: 100%; }
  .table-stack tr {
    display: block;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--bs-border-color);
  }
  .table-stack tr:last-child { border-bottom: 0; }
  .table-stack td {
    display: block;
    padding: 0.2rem 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  /* The label floats left and the value flows right-aligned beside it, so a
     value built of several pieces (a date and a time, two RIDDOR chips) stays
     one value instead of being spread across the line as flex items. */
  .table-stack td[data-label] {
    display: flow-root;
    text-align: right;
  }
  .table-stack td[data-label]::before {
    content: attr(data-label);
    float: left;
    margin-right: 0.75rem;
    text-align: left;
    color: var(--bsafe-muted);
    font-size: 0.8125rem;
    line-height: 1.75;
  }
  .table-stack td.text-end:not([data-label]) { text-align: left !important; }
  /* A status chip is nowrap in Bootstrap; "With occupational health" is wider
     than a 195px window (phone at double size), so let it wrap in a card. */
  .table-stack td[data-label] .badge { white-space: normal; text-align: left; }
  .table-stack td.no-print { padding-top: 0.5rem; }
  .table-stack td.col-id,
  .table-stack th.col-id { display: none; }
}

/* "My health appointments" (`?mine=1`): every row is the caller's own, so the
   Employee column is not drawn at any width. */
#visits-table.is-own-view .col-employee { display: none; }

/* ------------------------------------------------- scrolling modals with a form
   Most modals here wrap header, body and footer in a <form>, which sits between
   `.modal-content` and `.modal-body` and stops Bootstrap's
   `.modal-dialog-scrollable` from working: the whole dialog grew past the
   viewport and the submit button ended up below the fold. Making the form the
   flex column restores it: the header and footer stay put, the body scrolls. */
.modal-dialog-scrollable .modal-content > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.modal-dialog-scrollable .modal-content > form > .modal-body {
  overflow-y: auto;
}

/* ------------------------------------------------- contrast the axe gate caught
   tests/e2e/a11y.spec.ts fails on any colour-contrast violation. Bootstrap's
   grey outline button text (#6c757d) is 4.33:1 on the page grey #f4f6f9, and
   its amber outline text is 1.63:1 on white. Both now take the app's own AA
   inks; borders, hover fills and the "to do" step dots are unchanged. */
.btn-outline-secondary { --bs-btn-color: var(--bsafe-muted); }
.btn-outline-warning { --bs-btn-color: var(--bsafe-attention-ink); }
.lc-step.todo .lc-label { color: var(--bsafe-muted); }

/* Org units tree: the outline-danger Delete buttons sit on the light row
   background, where Bootstrap's #dc3545 reaches only 4.29:1. A deeper red
   keeps the text at 4.5:1 or better (WCAG 1.4.3). */
#org-tree .btn-outline-danger {
  --bs-btn-color: #b02a37;
  --bs-btn-border-color: #b02a37;
  --bs-btn-hover-bg: #b02a37;
  --bs-btn-hover-border-color: #b02a37;
  --bs-btn-active-bg: #b02a37;
  --bs-btn-active-border-color: #b02a37;
}


/* ---------------------------------------------------------------------------
   rct-clin 149 — consent to release an occupational health report
   ---------------------------------------------------------------------------
   The consent panel on occupational-health-report.html (who asked, the
   employee's rights before they answer, a pending correction), the referral
   question printed as body text under a "Your question" eyebrow (P2-7), and
   the "Reports waiting for your consent" tile on the employee's OH home
   (occupational-health.html). Calm by design: a white card with an accent
   rule, not a warning band — nothing here is an error. */

.consent-panel {
  margin: 0 0 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--bsafe-line);
  border-left: 4px solid var(--bsafe-accent);
  border-radius: var(--bs-border-radius, 0.375rem);
  background: var(--bs-body-bg, #fff);
  color: var(--bsafe-ink);
}

.consent-panel > :last-child { margin-bottom: 0; }

.consent-panel-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.consent-panel-line { margin: 0; }

.consent-rights {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
}

.consent-rights li + li { margin-top: 0.5rem; }

/* A pending correction, and (S2c) a refusal that "Record new consent"
   replaced: both sit under a hairline when something precedes them. */
.consent-correction,
.consent-replaced {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--bsafe-line);
}

.consent-panel > .consent-correction:first-child,
.consent-panel > .consent-replaced:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.consent-replaced-label {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
  color: var(--bsafe-muted);
}

.consent-correction-text {
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--bsafe-line);
  background: var(--bs-tertiary-bg, #f8f9fa);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* --- rct-gaps g5 (r56): the 21-day period on a consent request ----------
   Its first and last day, then one muted sentence on what it does and does
   not do. Text only: a date is not a warning. */
.consent-period { margin-top: 0.75rem; }

.consent-period-dates { margin: 0; }

.consent-period-note {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--bsafe-muted);
}

/* The referrer's question, in the document: body text, set a little apart
   from the advice that answers it. */
.report-question {
  margin: 0 0 0.6rem;
  font-weight: 600;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  color: var(--bsafe-ink);
}

/* The employee's tile: one short list of reports to read, each a link. */
.consent-waiting .card-body { padding: 1rem 1.25rem; }

.consent-waiting-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 600;
}

.consent-waiting-list {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.consent-waiting-list li + li { margin-top: 0.5rem; }

.consent-waiting-list a { font-weight: 500; }

/* ==========================================================================
   rct-clin 149 — the employee's questionnaire answers on the appointment
   ========================================================================== */
.answers-block {
  border: 1px solid var(--bsafe-line);
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
}

.answers-block > summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--bsafe-ink);
}

.answers-block > summary:focus-visible {
  outline: 2px solid var(--bsafe-accent);
  outline-offset: 2px;
}

.answers-list { margin-top: 0.5rem; }

.answers-list dt {
  font-weight: 400;
  color: var(--bsafe-muted);
  font-size: 0.875rem;
}

.answers-list dd {
  margin: 0 0 0.5rem;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

/* The report page's bar can hold two captions as long as "Change my answer"
   and "Ask for a correction" plus More. On a phone, tighten the padding so
   More stays on the same line as the two actions. */
@media (max-width: 419.98px) {
  #report-actions { gap: 0.3rem; }
  #report-actions .btn { padding-left: 0.25rem; padding-right: 0.25rem; }
}

/* ==========================================================================
   rct-clin 149 — the case as a hub: collapsed sections with counts
   ========================================================================== */
.case-hub {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0;
}

.hub-section {
  background: var(--bs-body-bg);
  border: 1px solid var(--bsafe-line);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}

.hub-section > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  min-height: 2rem;
}

.hub-section > summary:focus-visible {
  outline: 2px solid var(--bsafe-accent);
  outline-offset: 2px;
}

.hub-title {
  font-weight: 600;
  color: var(--bsafe-ink);
}

.hub-hint {
  color: var(--bsafe-muted);
  font-size: 0.875rem;
}

.hub-body { margin-top: 0.75rem; }

.hub-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hub-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  padding: 0.375rem 0;
}

.hub-list li + li { border-top: 1px solid var(--bsafe-line); }

.hub-item-main { font-weight: 500; }

/* ---- rct-clin S6b - the tasks card: "Assign to" picker and the add-task row ---- */

/* The row follows the width of the CARD, not of the window: on an appointment
   the card sits in half the page, so at 1280px and 1440px it is about 540px
   wide and a one-line row cut the priority to "Medi" and wrapped "Add task".
   Narrow card: the text, the picker and the button each take a line, the date
   and the priority share one. Wide card (a full-width host): one line. */
[data-component="tasks"] { container: tasks-card / inline-size; }

.tasks-card-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tasks-card-text,
.tasks-card-assign,
.tasks-card-submit { flex: 1 1 100%; min-width: 0; }

.tasks-card-due,
.tasks-card-weight { flex: 1 1 calc(50% - 0.25rem); min-width: 0; }

.tasks-card-assign .ts-wrapper .ts-control {
  min-height: calc(1.5em + 0.5rem + 2px);
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  font-size: 0.875rem;
}

@container tasks-card (min-width: 760px) {
  .tasks-card-text { flex: 1 1 14rem; }
  .tasks-card-due { flex: 0 0 10rem; }
  .tasks-card-weight { flex: 0 0 8rem; }
  .tasks-card-assign { flex: 0 0 13rem; }
  .tasks-card-submit { flex: 0 0 auto; }
}

/* ==========================================================================
   rct-clin 149 — messaging with occupational health (r125/r129)
   The line in the compose dialog that says which record a message is filed
   against when it came from "Message OH" on an appointment. Quiet text, not
   an alert: it is a fact about the message, not a warning.
   ========================================================================== */
.compose-link-note {
  padding: .5rem .75rem;
  border-left: 3px solid var(--bs-primary-border-subtle);
  background: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
  font-size: .875rem;
}

/* ------------------------------------------------ OH report rail (W-edges) */

/* Three stations, the second of which can read "Consent withdrawn" and the
   third "Issued to the referrer". At 390 px the shared rail keeps each step at
   its natural width and scrolls sideways (484 px of rail in 348 px of room).
   Below the md breakpoint this rail wraps its stations onto further lines
   instead, so nothing scrolls. */
@media (max-width: 767.98px) {
  .lifecycle-report {
    flex-wrap: wrap;
    row-gap: 0.5rem;
    overflow-x: visible;
  }

  .lifecycle-report .lc-step::after { display: none; }
  .lifecycle-report .lc-step { margin-right: 1.25rem; }
}

/* ------------------------- Restricted processing (rct-restrict, r46, GDPR Art. 18) */
/* The person record's standing fact: the chip, then one plain sentence. */
.restriction-note {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .375rem;
  margin-bottom: 1rem;
  padding: .75rem 1rem;
  border-left: 3px solid var(--bs-dark-border-subtle);
  background: var(--bs-tertiary-bg);
}
.restriction-note .badge { white-space: normal; text-align: left; }
.restriction-note-text {
  margin: 0;
  color: var(--bs-secondary-color);
  font-size: .875rem;
  overflow-wrap: anywhere;
}
/* The reason field opens under the tick-box only while it is ticked. */
.restriction-reason { margin-top: .75rem; }

/* ------------------------- Account lockout (migration 184) */
/* The same note as a restriction, edged in the warning tone of its chip: a
   lock is a barred account, which the status vocabulary calls a warning. */
.lockout-note { border-left-color: var(--bs-warning-border-subtle); }

/* ------------------------------------- retention: review and destroy (r15) */
/* Settings › Retention › Review and destroy (retention-review.html). The bar
   under the due list holds the selection count and the one destructive
   button; the per-row buttons wrap rather than widen the table. */
.retention-review-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--bs-border-color);
}

.retention-review-actions {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.retention-review-actions .btn {
  white-space: nowrap;
}

.retention-review-list {
  padding-left: 1.25rem;
  margin-bottom: 1rem;
}

.retention-review-list li + li {
  margin-top: 0.35rem;
}

@media (max-width: 575.98px) {
  .retention-review-actions { justify-content: flex-start; }
  .retention-review-bar .btn { width: 100%; }
}

/* ==========================================================================
   162 r91 satisfaction survey: the employee's page, the register card and
   the Statistics section. Tokens only; the brand colour comes from them.
   ========================================================================== */
.survey-privacy {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(var(--bsafe-accent-rgb), 0.25);
  border-radius: 0.375rem;
  background: rgba(var(--bsafe-accent-rgb), 0.06);
  color: var(--bsafe-ink);
}

.survey-privacy > .bi {
  flex: 0 0 auto;
  font-size: 1.25rem;
  line-height: 1.4;
  color: var(--bsafe-accent);
}

.survey-question {
  margin: 0 0 1.5rem;
  padding: 0;
  border: 0;
  min-width: 0;
}

.survey-question-text {
  float: none;
  width: auto;
  margin: 0 0 0.35rem;
  padding: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--bsafe-ink);
}

.survey-scale {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.survey-scale .btn {
  min-width: 3rem;
  font-variant-numeric: tabular-nums;
}

.survey-comment { margin: 0 0 0.5rem; }

.survey-actions { margin: 1.25rem 0 0; }

.survey-list {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.survey-list li + li { margin-top: 0.5rem; }

.survey-list a { font-weight: 500; }

.survey-results-questions {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
  color: var(--bsafe-muted);
}

.survey-results-questions li + li { margin-top: 0.15rem; }

.survey-results-score {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.survey-results-suppressed td { color: var(--bsafe-muted); }

.survey-results-comments { margin: 0 0 1rem; }

.survey-results-comments ul {
  margin: 0;
  padding-left: 1.25rem;
}

.survey-results-comments li + li { margin-top: 0.25rem; }

@media (max-width: 575.98px) {
  .survey-scale { gap: 0.4rem; }
  .survey-scale .btn { min-width: 2.75rem; min-height: 2.75rem; }

  .survey-results-table thead { display: none; }
  .survey-results-table,
  .survey-results-table tbody { display: block; width: 100%; }
  .survey-results-table tr {
    display: block;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--bs-border-color);
  }
  .survey-results-table tr:last-child { border-bottom: 0; }
  .survey-results-table th[scope="row"],
  .survey-results-table td {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.25rem 0.75rem;
    padding: 0.2rem 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    text-align: left;
  }
  .survey-results-table th[scope="row"] { font-weight: 600; }
  .survey-results-table td[data-label]::before {
    content: attr(data-label);
    color: var(--bsafe-muted);
    font-size: 0.8125rem;
    flex: 0 0 auto;
  }
  .survey-results-table .survey-results-score { text-align: left; }
  .table-responsive:has(> .survey-results-table) { overflow-x: visible; }
}
/* ------------------------- Sex and gender, and posts held (rct-w-person, r68, r70, r71) */
/* The "Sex and gender" tab: two questions, each a fieldset of plain radios. */
.gender-question {
  margin: 0 0 1.5rem;
  padding: 0;
  border: 0;
}
.gender-question legend {
  float: none;
  width: auto;
  margin-bottom: .5rem;
  padding: 0;
  font-size: 1rem;
  font-weight: 600;
}
/* The write-in opens under "No" and keeps clear of the next radio. */
.gender-write-in {
  margin: .25rem 0 .75rem 1.5rem;
  max-width: 28rem;
}
/* "Posts & cover": each post held, with unit, manager and weekly hours. */
.posts-held-list {
  margin: 1rem 0 0;
  padding: 0;
}
.posts-held-item {
  padding: .5rem 0;
  border-top: 1px solid var(--bs-border-color-translucent);
}
.posts-held-item:first-child { border-top: 0; }
.posts-held-name { display: block; font-weight: 600; }
.posts-held-item .rr-sub { overflow-wrap: anywhere; }

/* ==========================================================================
   RCT r130 — a file question in a health questionnaire
   ========================================================================== */
/*
 * The sent file: a paperclip, its name, then View and Download. One row on
 * a desktop; on a phone a long name wraps rather than pushing the buttons
 * off the side, and the buttons drop under it. Also drawn inside the
 * appointment's "Answers from the employee", whose <dd> keeps the answer's
 * own line breaks (pre-wrap) - the markup's do not count.
 */
.result-file-current {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  min-width: 0;
  margin-bottom: 0.5rem;
  white-space: normal;
}

.result-file-current > .bi { color: var(--bsafe-muted); }

.result-file-name {
  flex: 1 1 10rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.result-file-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.result-file .form-control[type="file"] { max-width: 100%; }

/* The file viewer opened from inside a dialog (the questionnaire, the
   screening) sits above that dialog and dims it, as it would the page. Only
   the viewer's own backdrop (tagged by js/components/files.js) is raised:
   raising every second backdrop put it over any other dialog opened from a
   dialog, such as the map picker, and swallowed its clicks. */
.file-viewer { z-index: 1065; }
.modal-backdrop.file-viewer-backdrop { z-index: 1060; }

/* ---------------------------------------------------------------------------
   lam-offline — the device outbox
   ---------------------------------------------------------------------------
   Two pieces. `.outbox-banner` is the calm card on the report form once a
   report is saved on the device (#form-queued) and, after it has gone, the
   "Sent" card beside it (#form-outbox-sent). `.outbox-panel` is the offcanvas
   js/components/outbox.js appends to <body>, opened from the topbar counter.
   Status is always a word with an icon beside it; the colour only repeats it. */
.outbox-banner {
  margin-bottom: 1.25rem;
  padding: 1.25rem 1.25rem 1rem;
  background: var(--bs-body-bg);
  border: 1px solid var(--bsafe-line);
  border-left: 4px solid var(--bsafe-accent);
  border-radius: 0.5rem;
}

.outbox-banner-sent { border-left-color: var(--bsafe-attention-done-mark); }

.outbox-banner-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--bsafe-ink);
}

.outbox-banner-title .bi { color: var(--bsafe-accent); }
.outbox-banner-sent .outbox-banner-title .bi { color: var(--bsafe-attention-done-mark); }
/* Filed but not submitted: calm, the same quiet amber as a refused item. */
.outbox-banner-attention { border-left-color: var(--bsafe-attention-mark); }
.outbox-banner-attention .outbox-banner-title .bi { color: var(--bsafe-attention-mark); }

.outbox-banner-text {
  margin: 0 0 0.5rem;
  color: var(--bsafe-ink);
  line-height: 1.5;
}

.outbox-banner-refused {
  margin: 0.25rem 0 0.75rem;
  padding-left: 1.1rem;
  color: var(--bsafe-attention-ink);
}

.outbox-banner-actions,
.outbox-item-actions,
.outbox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.outbox-panel { --bs-offcanvas-width: min(26rem, 100vw); }

.outbox-panel .offcanvas-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--bsafe-line);
}

.outbox-eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--bsafe-muted);
}

.outbox-connection {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0 0 1rem;
  color: var(--bsafe-muted);
}

.outbox-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.outbox-item,
.outbox-empty {
  padding: 1rem 0;
  border-bottom: 1px solid var(--bsafe-line);
}

.outbox-empty { color: var(--bsafe-muted); }

.outbox-item-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
}

.outbox-item-title { font-weight: 600; color: var(--bsafe-ink); }

.outbox-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--bsafe-muted);
}

.outbox-status-sending { color: var(--bsafe-accent); }
.outbox-status-sent { color: var(--bsafe-attention-done-ink); }
.outbox-status-sent .bi { color: var(--bsafe-attention-done-mark); }
.outbox-status-refused,
.outbox-status-expired,
.outbox-status-attention { color: var(--bsafe-attention-ink); }
.outbox-status-refused .bi,
.outbox-status-expired .bi,
.outbox-status-attention .bi { color: var(--bsafe-attention-mark); }

.outbox-item-excerpt {
  margin: 0.35rem 0 0;
  color: var(--bsafe-ink);
}

.outbox-item-meta,
.outbox-item-note {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: var(--bsafe-muted);
}

.outbox-rule {
  margin: 1.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--bsafe-muted);
}

/* ------------------------- Investigation: guided root-cause analysis (168, lam-invest) */
/* The Root cause and Findings tabs of the investigation wizard. Calm by
   design: one stage on screen at a time, generous spacing, one solid button
   per stage, and the fishbone drawn only where it has room (576 px up) - the
   lists under it carry the same facts at every width. */

/* The wizard's own stations are the investigation rail (lam-r4-wizard,
   below); the stages inside Root cause are a quieter, unboxed sub-rail, so
   the page never shows two rails of equal weight. */
.rca-stepper.lifecycle {
  background: none;
  border: 0;
  box-shadow: none;
  padding: 0;
}
.rca-stepper .lc-dot { width: 1.4rem; height: 1.4rem; font-size: 0.72rem; }

.rca-intro {
  color: var(--bsafe-muted);
  margin: 0.25rem 0 1.25rem;
}

.rca-stepper {
  flex-wrap: wrap;
  row-gap: 0.5rem;
  overflow-x: visible;
  margin-bottom: 1.5rem;
}
.rca-stepper .lc-step { flex: 0 0 auto; }
.rca-stepper .lc-step::after { min-width: 2rem; }

.rca-step-link {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0.25rem 0.5rem 0.25rem 0;
  border: 0;
  background: none;
  text-align: left;
  border-bottom: 2px solid transparent;
}
.rca-step-link[aria-current="step"] { border-bottom-color: var(--bsafe-accent); }
.rca-step-link[aria-current="step"] .lc-label { color: var(--bsafe-ink); }
.rca-step-link:focus-visible {
  outline: 2px solid var(--bsafe-accent);
  outline-offset: 3px;
  border-radius: 0.25rem;
}

.rca-stage { margin-bottom: 2rem; }

.rca-stage-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
  color: var(--bsafe-ink);
}

.rca-hint {
  color: var(--bsafe-muted);
  margin-bottom: 1rem;
}

.rca-form { margin-bottom: 1.25rem; }
.rca-form-actions { margin-top: 0.75rem; }
.rca-next { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--bsafe-line); }

/* The 5 Whys chain: one card per answer, joined by a thin line. */
.rca-chain {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
}
.rca-chain-item {
  position: relative;
  padding: 0.85rem 1rem;
  margin-left: 0.75rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.5rem;
  background: #fff;
}
.rca-chain-item + .rca-chain-item { margin-top: 1rem; }
.rca-chain-item + .rca-chain-item::before {
  content: "";
  position: absolute;
  left: 1.25rem;
  top: calc(-1rem - 1px);
  height: 1rem;
  border-left: 2px solid var(--bsafe-line);
}
.rca-chain-item.is-root { border-color: var(--bsafe-attention-done-line); background: var(--bsafe-attention-done-bg); }
.rca-chain-q {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bsafe-muted);
  margin-bottom: 0.25rem;
}
.rca-chain-ask { text-transform: none; letter-spacing: 0; font-weight: 400; }
.rca-chain-a { color: var(--bsafe-ink); }
.rca-chain-root {
  margin-top: 0.5rem;
  font-weight: 600;
  color: var(--bsafe-attention-done-ink);
}

/* Row lists: text on the left, small actions on the right; stacked on phones. */
.rca-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}
.rca-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--bsafe-line);
}
.rca-list-compact .rca-item { padding: 0.5rem 0; flex-wrap: nowrap; }
.rca-list-compact .rca-item-text { flex-basis: auto; }
.rca-item-text { flex: 1 1 18rem; min-width: 0; }
.rca-item-meta {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.85rem;
  color: var(--bsafe-muted);
}
.rca-item-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.rca-chain-item .rca-item-actions { margin-top: 0.75rem; }
.rca-empty { color: var(--bsafe-muted); font-style: italic; margin: 0 0 0.5rem; }
.rca-list > .rca-empty { padding: 0.5rem 0; }

/* The six fishbone headings and the three cause lists. */
.rca-bones { margin-bottom: 1.25rem; }
.rca-bone {
  height: 100%;
  padding: 1rem 1.1rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.5rem;
  background: #fff;
}
.rca-bone-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.2rem;
  color: var(--bsafe-ink);
}
.rca-bone-hint { font-size: 0.85rem; color: var(--bsafe-muted); margin-bottom: 0.6rem; }
.rca-cause-group { margin-bottom: 1.5rem; }

/* The fishbone drawing. Colours are tokens, so it follows the branding. */
.rca-fishbone-figure {
  margin: 0 0 1.5rem;
  padding: 1rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.5rem;
  background: #fff;
}
.rca-fishbone { display: block; width: 100%; height: auto; }
.rca-fishbone .fb-spine { stroke: var(--bsafe-ink); stroke-width: 3; }
.rca-fishbone .fb-bone { stroke: var(--bsafe-muted); stroke-width: 2; }
.rca-fishbone .fb-twig { stroke: var(--bsafe-line); stroke-width: 1.5; }
.rca-fishbone .fb-head { fill: rgba(var(--bsafe-accent-rgb), 0.08); stroke: var(--bsafe-accent); stroke-width: 1.5; }
.rca-fishbone .fb-head-text { font-size: 14px; fill: var(--bsafe-ink); }
.rca-fishbone .fb-label { font-size: 15px; font-weight: 600; fill: var(--bsafe-ink); }
.rca-fishbone .fb-factor { font-size: 13px; fill: var(--bsafe-ink); }
.rca-fishbone .fb-more { font-size: 12px; font-style: italic; fill: var(--bsafe-muted); }

/* The saved problem statement at the top of the 5 Whys (168). */
.rca-problem {
  padding: 1rem 1.1rem;
  margin-bottom: 1.5rem;
  border-left: 3px solid var(--bsafe-accent);
  background: #fff;
  border-radius: 0 0.5rem 0.5rem 0;
}
.rca-problem-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bsafe-muted);
  margin-bottom: 0.25rem;
}
.rca-problem-text { color: var(--bsafe-ink); margin-bottom: 0.75rem; }
.rca-done { color: var(--bsafe-ink); font-weight: 600; margin: 0 0 1rem; }
.rca-add-open { margin: 0.25rem 0 1rem; }

/* On a phone the three stages stack, without the connecting lines that
   would otherwise dangle at the end of each wrapped row. */
@media (max-width: 575.98px) {
  .rca-stepper { flex-direction: column; align-items: stretch; row-gap: 0.25rem; }
  .rca-stepper .lc-step::after { display: none; }
}
.rca-list-compact .rca-item:last-child { border-bottom: 0; padding-bottom: 0; }

/* ---------------------------------------------------------------------------
   Actions: their own page, the evidence on it, and the by-service view (169).
   Calm by design: one column of evidence, figures that are links, no chrome.
   --------------------------------------------------------------------------- */
.task-statement {
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 1.25rem;
  overflow-wrap: anywhere;
}

.task-ref {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-decoration: none;
}

.evidence-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.evidence-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.evidence-thumb {
  width: 5.5rem;
  height: 4.25rem;
  object-fit: cover;
  border-radius: 0.375rem;
  border: 1px solid var(--bs-border-color);
  background: var(--bs-tertiary-bg);
}

.evidence-thumb-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: var(--bs-secondary-color);
}

.evidence-meta { flex: 1 1 12rem; min-width: 0; }
.evidence-name { font-weight: 600; overflow-wrap: anywhere; }
.evidence-buttons { display: flex; gap: 0.5rem; }

.by-service-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 2rem;
  margin-bottom: 1rem;
}

.by-service-controls .form-select { min-width: 14rem; }
.by-service-pickers { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; }
.by-service-trail { color: var(--bs-secondary-color); }

.by-service-table th,
.by-service-table td { padding-top: 0.9rem; padding-bottom: 0.9rem; vertical-align: middle; }
.by-service-table tfoot th,
.by-service-table tfoot td { border-top: 2px solid var(--bs-border-color); font-weight: 600; }
.by-service-definitions dt { font-weight: 600; margin-top: 0.5rem; }
.by-service-definitions dd { margin-bottom: 0; color: var(--bs-secondary-color); }

/* ==========================================================================
   lam-kpi-ui — the KPI page (kpis.html) and KPI settings (kpi-settings.html)
   ========================================================================== */
/*
 * Thirty-four measures must still read as a calm page: two pickers and one
 * next step at the top, a single line saying what is being looked at, a
 * status count, then the families as quiet headed sections that open one at
 * a time. A measure is one row with generous padding; status is always an
 * icon AND words, never colour alone.
 */
.kpi-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  margin-bottom: 1.25rem;
}

.kpi-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.kpi-control { min-width: 14rem; }
.kpi-control .form-label { font-size: 0.8rem; font-weight: 600; color: var(--bsafe-muted); margin-bottom: 0.25rem; }
.kpi-control-inline { min-width: 12rem; max-width: 18rem; }
.kpi-head .page-actions { margin-left: auto; }

.kpi-views { margin-bottom: 0.75rem; }
.kpi-views a .bi { margin-right: 0.15rem; }

.kpi-context {
  font-size: 1.05rem;
  color: var(--bsafe-ink);
  margin: 0 0 1.25rem;
  font-variant-numeric: tabular-nums;
}

.kpi-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1.25rem;
}

.kpi-filter-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem; }
.kpi-filter-controls .form-check { margin-bottom: 0; }

.kpi-summary { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }

.kpi-summary-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--bsafe-ink);
}

.kpi-summary-item strong { font-variant-numeric: tabular-nums; }

/* The status words. The colour only repeats what the icon and words say. */
.kpi-rag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}

.kpi-rag-compact { font-size: 0.8rem; font-weight: 500; }
.kpi-rag-green .bi, .kpi-rag-green.kpi-rag { color: var(--bs-success-text-emphasis); }
.kpi-rag-amber .bi { color: var(--bsafe-attention-mark); }
.kpi-rag-amber.kpi-rag { color: var(--bsafe-attention-ink); }
.kpi-rag-red .bi, .kpi-rag-red.kpi-rag { color: var(--bs-danger-text-emphasis); }
.kpi-rag-none .bi, .kpi-rag-none.kpi-rag { color: var(--bsafe-muted); font-weight: 500; }
.kpi-summary-item.kpi-rag-green, .kpi-summary-item.kpi-rag-red, .kpi-summary-item.kpi-rag-amber,
.kpi-summary-item.kpi-rag-none { color: var(--bsafe-ink); }

.kpi-families { display: flex; flex-direction: column; gap: 1rem; }

.kpi-family {
  background: #fff;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.5rem;
}

.kpi-family-head { margin: 0; font-size: 1rem; }

.kpi-family-toggle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  width: 100%;
  padding: 1rem 1.25rem;
  border: 0;
  background: transparent;
  text-align: left;
  color: var(--bsafe-ink);
}

.kpi-family-toggle:hover { background: rgba(var(--bsafe-accent-rgb), 0.04); }
.kpi-family-name { font-weight: 600; font-size: 1.05rem; }
.kpi-family-meta { color: var(--bsafe-muted); font-size: 0.875rem; flex: 1 1 auto; }
.kpi-family-toggle .filter-caret { margin-left: auto; }
.kpi-family-toggle[aria-expanded="true"] .filter-caret { transform: rotate(-135deg); }

.kpi-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--bsafe-line); }

.kpi-row {
  display: grid;
  grid-template-columns: minmax(16rem, 2.2fr) minmax(9rem, 1.2fr) minmax(9rem, 1.2fr) minmax(9rem, 1fr) 128px;
  align-items: center;
  gap: 1rem 1.5rem;
  padding: 1rem 1.25rem;
}

.kpi-row + .kpi-row { border-top: 1px solid var(--bsafe-line); }

.kpi-name { display: flex; flex-direction: column; align-items: flex-start; gap: 0.3rem; }

.kpi-open {
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  color: var(--bsafe-accent);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(var(--bsafe-accent-rgb), 0.35);
  text-underline-offset: 3px;
}

.kpi-open:hover { text-decoration-color: currentColor; }

.kpi-tag {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--bsafe-line);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--bsafe-muted);
  background: #fff;
}

.kpi-tag-lagging { border-color: var(--bsafe-muted); color: var(--bsafe-ink); }

.kpi-label {
  display: none;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bsafe-muted);
}

.kpi-figure, .kpi-target { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.kpi-value { font-size: 1.35rem; font-weight: 600; line-height: 1.2; color: var(--bsafe-ink); }
.kpi-target-figure { font-weight: 600; }
.kpi-per { font-size: 0.8rem; color: var(--bsafe-muted); }
.kpi-muted { color: var(--bsafe-muted); font-size: 0.875rem; }
.kpi-empty { color: var(--bsafe-muted); margin: 1rem 0; }

.kpi-spark { min-height: 32px; display: flex; align-items: center; }
.kpi-spark-svg { overflow: visible; }
.kpi-spark-line { fill: none; stroke: var(--bsafe-accent); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.kpi-spark-dot { fill: var(--bsafe-accent); }
.kpi-spark-target { stroke: var(--bsafe-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.kpi-spark-empty { font-size: 0.75rem; }

/* The service report. */
.kpi-table-card { border-color: var(--bsafe-line); }
.kpi-service-table th, .kpi-service-table td { padding: 0.85rem 1rem; vertical-align: top; }
.kpi-service-table td { font-variant-numeric: tabular-nums; }
.kpi-th-per { display: block; font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 0.75rem; }
.kpi-cell-value { display: block; font-weight: 600; font-size: 1.05rem; }
.kpi-total th, .kpi-total td { border-top: 2px solid var(--bsafe-ink); background: rgba(var(--bsafe-accent-rgb), 0.03); }

.kpi-drill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--bsafe-accent);
  font-weight: 600;
  text-align: left;
}

.kpi-footnote { color: var(--bsafe-muted); font-size: 0.85rem; margin: 0.75rem 0 0; }
.kpi-measures { flex: 1 1 32rem; }

/* The detail panel: wide enough for the trend on a desktop, the whole
   width on a phone. */
.kpi-detail.offcanvas-end { width: min(40rem, 100vw); }
.kpi-detail-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.kpi-detail-figure { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin-bottom: 1rem; }
.kpi-detail-value { display: flex; flex-direction: column; }
.kpi-detail-value .kpi-value { font-size: 2rem; }
.kpi-detail-definition { color: var(--bsafe-ink); margin-bottom: 1.25rem; }
.kpi-detail-grid { margin-bottom: 1.5rem; }
.kpi-detail .report-section-title { margin-top: 1.5rem; }
.kpi-trend { position: relative; height: 15rem; }
.kpi-detail-records { margin-top: 1.5rem; }

@media (max-width: 991.98px) {
  .kpi-row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "name name" "figure status" "target spark";
    gap: 0.75rem 1rem;
  }
  .kpi-name { grid-area: name; }
  .kpi-figure { grid-area: figure; }
  .kpi-status { grid-area: status; }
  .kpi-target { grid-area: target; }
  .kpi-spark { grid-area: spark; justify-content: flex-end; }
  .kpi-label { display: block; }
  .kpi-status { display: flex; flex-direction: column; gap: 0.15rem; }
}

@media (max-width: 575.98px) {
  .kpi-control { min-width: 0; flex: 1 1 100%; }
  .kpi-controls { width: 100%; }
  .kpi-head .page-actions { margin-left: 0; width: 100%; }
  .kpi-family-toggle { padding: 0.9rem 1rem; }
  .kpi-row { padding: 0.9rem 1rem; }
  .kpi-filters { align-items: flex-start; }
}

/* ==========================================================================
   lam-kpi-ui — KPI settings: hours worked and targets (kpi-settings.html)
   ========================================================================== */
/*
 * Hours worked is a quiet grid: services down the side (the name stays put
 * while the months scroll), months across, each figure with a small text
 * label for where it came from. A figure is a plain button until it is
 * selected, so the table never looks like a wall of input boxes. Targets are
 * the same calm rows as the KPIs page, with one Edit button each.
 */
.kpi-set-intro { color: var(--bsafe-muted); max-width: 60rem; margin: 0 0 1.25rem; }

.hours-scroll { max-width: 100%; }
.hours-scroll:focus-visible { outline: 2px solid var(--bsafe-accent); outline-offset: -2px; }

.hours-table th, .hours-table td {
  padding: 0.75rem 0.4rem;
  vertical-align: middle;
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.hours-table th.hours-col { font-weight: 600; line-height: 1.25; }
.hours-mon { display: block; }
.hours-yr { display: block; font-size: 0.7rem; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--bsafe-muted); }

.hours-table .hours-unit {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 11rem;
  max-width: 13rem;
  padding-left: 0.85rem;
  white-space: normal;
  text-align: left;
  background: #fff;
  box-shadow: 1px 0 0 var(--bsafe-line);
}

.hours-table .kpi-total .hours-unit { background: #fafafb; }
.hours-unit-name { display: block; font-weight: 600; }
.hours-unit-meta { display: block; font-size: 0.75rem; font-weight: 400; color: var(--bsafe-muted); }
.hours-depth-1 .hours-unit-name, .hours-depth-1 .hours-unit-meta { padding-left: 1rem; }
.hours-depth-2 .hours-unit-name, .hours-depth-2 .hours-unit-meta { padding-left: 2rem; }
.hours-depth-3 .hours-unit-name, .hours-depth-3 .hours-unit-meta { padding-left: 3rem; }
.hours-depth-4 .hours-unit-name, .hours-depth-4 .hours-unit-meta { padding-left: 4rem; }

.hours-td { min-width: 4rem; }
.back-link + .kpi-views { margin-top: 0.5rem; }
.hours-total, .hours-total-col { font-weight: 600; border-left: 1px solid var(--bsafe-line); }
.hours-month-total { font-weight: 600; }

.hours-figure { display: block; font-size: 0.95rem; }
.hours-source { display: block; font-size: 0.7rem; line-height: 1.2; color: var(--bsafe-muted); }

.hours-cell {
  display: block;
  width: 100%;
  margin: -0.3rem -0.45rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid transparent;
  border-radius: 0.35rem;
  background: none;
  color: var(--bsafe-ink);
  text-align: right;
  box-sizing: content-box;
}

.hours-cell:hover { border-color: var(--bsafe-line); background: rgba(var(--bsafe-accent-rgb), 0.05); }
.hours-cell:focus-visible { outline: 2px solid var(--bsafe-accent); outline-offset: 1px; }
.hours-input { width: 6.5rem; margin-left: auto; text-align: right; }

.kpi-set-list { border-top: 1px solid var(--bsafe-line); }

.kpi-set-row {
  display: grid;
  grid-template-columns: minmax(16rem, 2.2fr) minmax(9rem, 1.2fr) minmax(9rem, 1.2fr) minmax(8rem, 1fr) 7rem;
  align-items: center;
  gap: 1rem 1.5rem;
  padding: 1rem 1.25rem;
}

.kpi-set-row + .kpi-set-row { border-top: 1px solid var(--bsafe-line); }
.kpi-set-name { font-weight: 600; }
.kpi-set-action { text-align: right; }

@media (max-width: 991.98px) {
  .kpi-set-row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "name name" "target baseline" "margin action";
    gap: 0.75rem 1rem;
  }
  .kpi-set-row > :nth-child(1) { grid-area: name; }
  .kpi-set-row > :nth-child(2) { grid-area: target; }
  .kpi-set-row > :nth-child(3) { grid-area: baseline; }
  .kpi-set-row > :nth-child(4) { grid-area: margin; }
  .kpi-set-row > :nth-child(5) { grid-area: action; align-self: end; }
}

@media (max-width: 575.98px) {
  .kpi-set-row { padding: 0.9rem 1rem; }
  .hours-table .hours-unit { min-width: 9.5rem; max-width: 9.5rem; padding-left: 0.6rem; }
  .hours-unit-name { font-size: 0.9rem; }
  .hours-table th, .hours-table td { padding: 0.7rem 0.5rem; }
  .hours-depth-1 .hours-unit-name, .hours-depth-1 .hours-unit-meta { padding-left: 0.5rem; }
  .hours-depth-2 .hours-unit-name, .hours-depth-2 .hours-unit-meta { padding-left: 1rem; }
  .hours-depth-3 .hours-unit-name, .hours-depth-3 .hours-unit-meta,
  .hours-depth-4 .hours-unit-name, .hours-depth-4 .hours-unit-meta { padding-left: 1.5rem; }
}

/* ==========================================================================
   lam-report (167) — the guided incident report
   ========================================================================== */
/*
 * "What are you reporting?" first, then the stepper (Lampton R4, below).
 * Built for a phone at 390 px: one column, large
 * targets, generous spacing and one obvious next step per screen. From 768 px
 * the five answers sit two, then three, to a row; nothing is capped in width.
 */
.report-step {
  padding-block: 0.25rem 1.5rem;
}

.report-step-title {
  font-size: 1.375rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.report-kind-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .report-kind-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1200px) {
  .report-kind-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Each answer is one whole button: the icon, the name, the hint and the
   chevron are all hit area. */
.report-kind {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  min-height: 4.75rem;
  padding: 1rem 1.125rem;
  text-align: left;
  color: var(--bs-body-color);
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.75rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.report-kind:hover {
  border-color: var(--bsafe-accent);
  box-shadow: 0 1px 4px rgba(var(--bsafe-accent-rgb), 0.15);
}

.report-kind:focus-visible {
  outline: 3px solid rgba(var(--bsafe-accent-rgb), 0.45);
  outline-offset: 2px;
}

.report-kind-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.375rem;
  color: var(--bsafe-accent);
  background: rgba(var(--bsafe-accent-rgb), 0.08);
  border-radius: 50%;
}

.report-kind-text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.report-kind-name {
  font-size: 1.0625rem;
  font-weight: 600;
}

.report-kind-hint {
  font-size: 0.9375rem;
  color: var(--bs-secondary-color);
}

.report-kind-go {
  flex: 0 0 auto;
  color: var(--bs-secondary-color);
}

.report-step-other {
  margin: 1.5rem 0 0;
}

.report-step-full {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
}

/* The answer, said back, with the way to change it: the words on the left in
   two lines, "Change" on the right, so a long answer never strands the link. */
.report-kind-chosen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 1rem;
  margin: 0.25rem 0 1.25rem;
}

.report-kind-chosen-label {
  grid-column: 1;
  font-size: 0.875rem;
  color: var(--bs-secondary-color);
}

.report-kind-chosen > strong {
  grid-column: 1;
  font-size: 1.1875rem;
  font-weight: 600;
}

.report-kind-chosen > .btn {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding-inline: 0.5rem;
}

.report-essentials > .card-body {
  padding: 1.25rem;
}

@media (min-width: 576px) {
  .report-essentials > .card-body { padding: 1.5rem; }
}

.report-choice + .report-choice {
  margin-top: 0.75rem;
}

/* On a phone the one solid button takes the width: it is the next step. */
@media (max-width: 575.98px) {
  .report-form-actions > .btn-primary { flex: 1 1 auto; }
  .report-form-actions > .btn { min-height: 2.75rem; }
}

/* After "Send report". The tick is decoration: the heading says it. */
.report-sent {
  padding-block: 1.5rem 1rem;
}

.report-sent:focus {
  outline: none;
}

.report-sent-mark {
  display: block;
  font-size: 2.5rem;
  line-height: 1;
  color: var(--bs-success);
}

.report-sent-title {
  margin: 0.75rem 0 1.5rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.report-sent-ref-label,
.report-sent-facts dt {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
}

.report-sent-ref {
  margin-bottom: 1.5rem;
  font-size: 1.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.report-sent-facts dt {
  margin-bottom: 0.25rem;
}

.report-sent-facts dd {
  margin-bottom: 1.25rem;
}

.report-sent-actions {
  margin-top: 0.5rem;
}

/* Ticks and radio answers: one to a line on a phone, each a full-height target. */
@media (max-width: 575.98px) {
  .report-options {
    flex-direction: column;
    gap: 0 !important;
    margin-top: 0.25rem;
  }

  .report-options .form-check {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 2.75rem;
    margin: 0;
    padding-left: 0;
  }

  .report-options .form-check-input {
    float: none;
    flex: 0 0 auto;
    margin: 0;
  }
}

/* The photo card on the guided form: one plain "Add a photo" control and what
   is attached, and no more. The full form keeps the card's header, count and
   explanations. The input is reset after each pick, so its "No file chosen"
   text only ever repeats the list below it. */
body[data-report-mode="guided"] [data-component="evidence"] .card-header {
  display: none !important;
}

body[data-report-mode="guided"] [data-component="evidence"] .card-body {
  padding: 1.25rem;
}

body[data-report-mode="guided"] [data-component="evidence"] .card-body > .form-text,
body[data-report-mode="guided"] [data-component="evidence"] .list-group-item.text-body-secondary {
  display: none;
}

body[data-report-mode="guided"] #evidence-input,
body[data-report-mode="guided"] #evidence-file-input {
  padding: 0;
  color: transparent;
  background: transparent;
  border: 0;
}

body[data-report-mode="guided"] #evidence-input::file-selector-button,
body[data-report-mode="guided"] #evidence-file-input::file-selector-button {
  min-height: 2.75rem;
  margin: 0;
  padding-inline: 1.25rem;
  color: var(--bsafe-accent);
  background: var(--bs-body-bg);
  border: 1px solid var(--bsafe-accent);
  border-radius: var(--bs-border-radius);
}

/* Just after an answer is clicked, a help tooltip must not pop up under the
   resting pointer (see holdTooltipsUntilPointerMoves in incident-form.js). */
body[data-pointer-at-rest] .tooltip {
  display: none !important;
}

/* Send is the next step; Cancel is a way out, so it reads as a link. */
body[data-report-mode="guided"] #cancel-link {
  color: var(--bs-link-color);
  background: transparent;
  border-color: transparent;
  text-decoration: underline;
}

/* ---- iTrent integration (171, lam-itrent): Settings › Integrations › iTrent ---- */
.itrent-mode-banner {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}
.itrent-mode-banner .bi { font-size: 1.15rem; line-height: 1.4; }
.itrent-feeds {
  display: grid;
  gap: 1.5rem;
}
.itrent-feed .card-body,
.itrent-panel .card-body { padding: 1.5rem; }
.itrent-feed-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: .5rem 1rem;
  margin-bottom: .75rem;
}
.itrent-state {
  font-size: .875rem;
  color: var(--bsafe-muted);
}
.itrent-state::before {
  content: "";
  display: inline-block;
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  margin-right: .4rem;
  background: var(--bsafe-muted);
  vertical-align: middle;
}
.itrent-state-connected::before { background: var(--bsafe-attention-done-mark); }
.itrent-summary { margin-bottom: 1rem; }
.itrent-note { color: var(--bsafe-muted); font-size: .9rem; }
.itrent-counts {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.75rem;
  color: var(--bsafe-muted);
}
.itrent-count { font-weight: 700; color: var(--bsafe-ink); font-variant-numeric: tabular-nums; }
.itrent-history { margin-top: 1.25rem; }
.itrent-history summary { color: var(--bsafe-accent); cursor: pointer; }
.itrent-history table { margin-top: .75rem; }
.itrent-panel { margin-bottom: 1.5rem; }
.itrent-preview-summary { font-weight: 600; margin-bottom: 1rem; }
.itrent-outcome { white-space: nowrap; font-weight: 600; }
.itrent-review-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}
.itrent-review {
  padding: 1.25rem 0;
  border-top: 1px solid var(--bsafe-line);
}
.itrent-review:first-child { border-top: 0; padding-top: .25rem; }
.itrent-review p { margin-bottom: .4rem; }
.itrent-review-why { color: var(--bsafe-muted); }
.itrent-review-choices { margin-bottom: .5rem; }
.itrent-review-choices legend { font-size: 1rem; }
.itrent-review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .75rem;
}
.itrent-confirmed {
  color: var(--bsafe-attention-done-ink);
  background: var(--bsafe-attention-done-bg);
  border: 1px solid var(--bsafe-attention-done-line);
  border-radius: .375rem;
  padding: .6rem .85rem;
  margin: .5rem 0 0;
}
/* The incident people table: the absence iTrent reported, under the name. */
.person-hr-absence {
  display: block;
  font-size: .875rem;
  color: var(--bsafe-muted);
}

/* ------------------------------ calm permission editor (lam2-perm, roles.html) */

/* Search and the granted-only switch sit on one line; the module groups below
   are folded <details>, one quiet line each, with a count on the right. */
.perm-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem 2rem;
  margin-bottom: 0.75rem;
}
.perm-find { flex: 1 1 18rem; max-width: 32rem; }
.perm-granted-only { padding-bottom: 0.4rem; min-height: 0; }
.perm-summary { margin: 0 0 1rem; color: var(--bsafe-muted); font-size: 0.9rem; }
.perm-empty { margin: 1rem 0; color: var(--bsafe-muted); }

.perm-groups { border-top: 1px solid var(--bsafe-line); }
.perm-group { border-bottom: 1px solid var(--bsafe-line); }
.perm-group[hidden], .perm-row[hidden] { display: none; }
.perm-group > summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.25rem;
  cursor: pointer;
  list-style: none;
}
.perm-group > summary::-webkit-details-marker { display: none; }
.perm-group > summary::before {
  content: "";
  flex: none;
  align-self: center;
  width: 0.45rem;
  height: 0.45rem;
  margin-right: 0.35rem;
  border-right: 2px solid var(--bsafe-muted);
  border-bottom: 2px solid var(--bsafe-muted);
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
.perm-group[open] > summary::before { transform: rotate(45deg); }
.perm-group > summary:hover { background: rgba(var(--bsafe-accent-rgb), 0.05); }
.perm-group > summary:focus-visible {
  outline: 3px solid var(--bsafe-accent);
  outline-offset: -2px;
}
.perm-group-name { flex: 1 1 auto; font-weight: 600; }
.perm-group-count {
  flex: none;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--bsafe-muted);
}
.perm-group-has-grants .perm-group-count { color: var(--bsafe-ink); }
.perm-group-changed .perm-group-name::after {
  content: " (changed)";
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--bsafe-muted);
}

.perm-list { padding: 0.25rem 0 1rem 1.6rem; }
.perm-row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin: 0;
  padding: 0.35rem 0.25rem 0.35rem 1.9rem;
  border-radius: 0.25rem;
}
.perm-row .form-check-input { margin-top: 0.2rem; }
.perm-row .form-check-label { flex: 1 1 auto; cursor: pointer; }
.perm-row:hover { background: rgba(var(--bsafe-accent-rgb), 0.05); }
.perm-label { display: block; }
.perm-name {
  display: block;
  font-family: var(--bs-font-monospace);
  font-size: 0.75rem;
  color: var(--bsafe-muted);
  overflow-wrap: anywhere;
}
.perm-flag {
  flex: none;
  font-size: 0.8rem;
  color: var(--bsafe-accent-deep);
}

/* Sticky: the Save / Discard bar follows the person down a long list. */
.perm-savebar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 0.85rem 1.25rem;
  background: #fff;
  border-top: 2px solid var(--bsafe-accent);
  box-shadow: 0 -4px 12px rgba(36, 31, 51, 0.1);
}
.perm-savebar.d-none { display: none; }
.perm-savebar-detail { margin-left: 0.5rem; color: var(--bsafe-muted); font-size: 0.9rem; }
.perm-savebar-actions { display: flex; gap: 0.5rem; }

@media (max-width: 575.98px) {
  .perm-find { max-width: none; }
  .perm-list { padding-left: 0.25rem; }
  .perm-row { padding-left: 1.9rem; }
  .perm-savebar { padding: 0.75rem 1rem; }
  .perm-savebar-actions { width: 100%; }
  .perm-savebar-actions .btn { flex: 1 1 0; }
}

/* Long admin explanations fold under one quiet line (lam2-perm). */
.admin-help { margin-bottom: 1rem; }
.admin-help > summary {
  display: inline-block;
  padding: 0.25rem 0;
  color: var(--bsafe-accent);
  cursor: pointer;
}
.admin-help > summary:hover { color: var(--bsafe-accent-deep); text-decoration: underline; }
.admin-help > summary:focus-visible { outline: 3px solid var(--bsafe-accent); outline-offset: 2px; }

/* ------------------------------------------------ calm screens (lam-dash) */

/* The attention strip shows six tiles; the rest stay in the DOM, folded,
   until "Show all" opens them. */
.dash-tile-folded { display: none; }
.dash-attention-open .dash-tile-folded { display: block; }
.dash-attention-more-row { margin-top: 0.5rem; }

/* Key indicators: one tile per headline KPI. The name reads first (the
   measure is the question), then the figure, its multiplier, and the RAG as
   words with an icon - never the stripe colour alone. */
.dash-kpi {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.dash-kpi .dash-kpi-name {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--bsafe-ink);
  min-height: 2.5em;
  line-height: 1.25;
}
.dash-kpi-unit,
.dash-kpi-target,
.dash-kpi-kind {
  font-size: 0.75rem;
  color: var(--bsafe-muted);
}
.dash-kpi-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.75rem;
  margin-top: auto;
  padding-top: 0.35rem;
}
.dash-kpi-rag {
  font-size: 0.78rem;
  font-weight: 600;
}
.dash-kpi-rag-green { color: var(--bs-success-text-emphasis, #146c43); }
.dash-kpi-rag-amber { color: var(--bs-warning-text-emphasis, #664d03); }
.dash-kpi-rag-red { color: var(--bs-danger-text-emphasis, #842029); }
.dash-kpi-rag-none,
.dash-kpi-rag-no_data { color: var(--bsafe-muted); }

/* An empty cell in a stacked row has no value to show, and its label would
   hang there on its own (an empty RIDDOR cell reads "RIDDOR" and nothing). */
@media (max-width: 575.98px) {
  .table-stack td:empty { display: none; }
  /* The linked-records table runs edge to edge inside its card; stacked, the
     text would touch the card's border. */
  [data-component="entity-links"] .table-stack tr { padding-left: 1rem; padding-right: 1rem; }
}

/* The incident register's RIDDOR cell: each badge keeps to one line and the
   badges stack, instead of sitting side by side and wrapping where they fall. */
.riddor-badges {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}
.riddor-badges .badge { white-space: nowrap; }
@media (max-width: 575.98px) {
  .riddor-badges { align-items: flex-end; }
  .table-stack td .riddor-badges .badge { white-space: normal; text-align: right; }
}

/* A register column that only earns its width on a wide screen. Bootstrap's
   xxl (1400px) is still a 1170px-wide table once the sidebar is taken out, so
   this drops the column below 1600px of viewport instead. */
@media (max-width: 1599.98px) {
  /* !important: a stacked phone row sets its own display on every cell. */
  .col-wide-only { display: none !important; }
}

/* Search hits on a phone: the title takes the whole line and wraps, and the
   note about where it matched sits under it, instead of both being squeezed
   onto one line and the title cut to "INC-2026-0047 . An inj...". */
@media (max-width: 575.98px) {
  .search-hit {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
  }
  .search-hit-title {
    flex-grow: 0;
    max-width: 100%;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }
}

/* The dashboard's bottom row. With the training video the row is delegates,
   video and a narrow notice board (5 / 5 / 2). Without it (the lampton demo
   runs with no video) the notice board used to sit in its narrow 2 with empty
   space beside it: delegates and notices take half the row each instead. */
@media (min-width: 1200px) {
  .dash-section[data-section="delegates"]:has(> #dashboard-tutorials-col.d-none) > #dashboard-delegates-col,
  .dash-section[data-section="delegates"]:has(> #dashboard-tutorials-col.d-none) > #dashboard-notices-col {
    flex: 0 0 auto;
    width: 50%;
  }
}

/* ------------------------------------- inspection finding severity (180) */
/*
 * Lampton S2. A failed answer reveals two small labelled selects under the
 * answer it describes: the finding's severity and its category. They are
 * hidden on every other row, so a passed inspection looks exactly as before.
 */
.audit-finding-controls {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.audit-finding-controls[hidden] { display: none; }

.audit-finding-field {
  display: grid;
  grid-template-columns: 4.75rem minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
}

.audit-finding-field .form-label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--bsafe-muted);
}

/* The findings list: severity as a word in a quiet outlined chip, then the category. */
.audit-finding-facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.15rem 0 0.2rem;
  font-size: 0.85rem;
  color: var(--bsafe-muted);
}

.audit-severity {
  border: 1px solid var(--bsafe-line);
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  font-weight: 600;
}

.audit-severity[data-severity="critical"],
.audit-severity[data-severity="major"] {
  border-color: var(--bsafe-report-red);
  color: var(--bsafe-report-red);
}

/* "Create actions": one block per finding, owner and due date side by side. */
.audit-plan {
  padding: 0.75rem 0;
  border-top: 1px solid var(--bsafe-line);
}

.audit-plan:first-child { border-top: 0; padding-top: 0; }

.audit-plan-type {
  max-width: 24rem;
  margin-bottom: 1.25rem;
}

.audit-plan-facts {
  margin: 0.15rem 0 0.5rem 1.5rem;
  font-size: 0.85rem;
  color: var(--bsafe-muted);
}

.audit-plan-fields {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 0.75rem;
  margin-left: 1.5rem;
}

.audit-plan-fields .form-label { font-size: 0.8rem; margin-bottom: 0.2rem; }

.audit-plan.is-skipped .audit-plan-fields,
.audit-plan.is-skipped .audit-plan-facts { opacity: 0.45; }

@media (max-width: 575.98px) {
  .audit-plan-fields { grid-template-columns: minmax(0, 1fr); margin-left: 0; }
  .audit-plan-facts { margin-left: 0; }
}

/* ---------------------------------------- inspection: findings to closure (lam2-close) */
/* A quiet outlined chip for a standing fact about the record ("Personal
   assessment", "Confirmed unchanged"): bootstrap's text-bg-light is the page
   colour, so it read as bare bold text. */
.audit-chip-quiet {
  border: 1px solid var(--bsafe-line);
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  font-weight: 500;
}

/* The line under a finding saying where its corrective action has got to. */
.audit-finding-trail { margin-top: 0.2rem; }
.audit-action-overdue { color: var(--bsafe-report-red); font-weight: 600; }

/* ---------------------------------- inspection findings, calmer (180) */
/*
 * Lampton S2. A handed-in inspection leads with its findings, grouped under
 * the section they came from, and keeps the full run of answers behind one
 * control. The answers are hidden on screen only: print and the PDF still
 * carry every one of them.
 */
.audit-answers-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.audit-answers-collapsed { display: none; }

@media print {
  .audit-answers-collapsed { display: block; }
}

.audit-finding-group + .audit-finding-group { margin-top: 1.5rem; }

.audit-finding-section {
  font-size: 1rem;
  font-weight: 700;
  color: var(--bsafe-ink);
  margin: 0 0 0.35rem;
}

.audit-finding-note {
  margin: 0 0 0.6rem;
  color: var(--bsafe-muted);
}

/* "Add photo" on a failed answer, and the thumbnails of what was taken. */
.audit-finding-photo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
}

.audit-finding-photo input:focus-visible + .btn {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

.audit-finding-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.audit-finding-photos:empty { display: none; }

.audit-finding-photo .audit-finding-photos { flex-basis: 100%; }

.audit-finding > .audit-finding-photos { margin: 0.4rem 0; }

.audit-photo {
  padding: 0;
  border: 1px solid var(--bsafe-line);
  border-radius: 0.375rem;
  background: var(--bs-body-bg);
  line-height: 0;
  overflow: hidden;
}

.audit-photo img {
  width: 4.5rem;
  height: 4.5rem;
  object-fit: cover;
}

.audit-photo:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

/* ------------------------------------------- calm form builder (Lampton S2) */

/*
 * audit-template.html. A question is ONE line (number, text, answer type,
 * required) and opens in place to edit; one is open at a time. The form's own
 * settings sit in a closed <details>, because the questions are the job.
 */
.form-settings {
  border: 1px solid var(--bsafe-line);
  border-radius: 0.5rem;
  background: var(--bs-body-bg);
}

.form-settings-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.75rem;
  padding: 0.8rem 1rem;
  cursor: pointer;
  list-style: none;
}

.form-settings-summary::-webkit-details-marker { display: none; }

.form-settings-summary::before {
  content: "\f285";
  font-family: "bootstrap-icons";
  font-size: 0.8rem;
  color: var(--bsafe-muted);
  transition: transform 0.15s ease;
}

.form-settings[open] > .form-settings-summary::before { transform: rotate(90deg); }

.form-settings-summary:focus-visible,
.builder-q-toggle:focus-visible {
  outline: 2px solid var(--bsafe-accent);
  outline-offset: -2px;
  border-radius: 0.5rem;
}

.form-settings-title { font-weight: 600; }

.form-settings-hint { font-size: 0.85rem; color: var(--bsafe-muted); }

.form-settings > .detail-grid,
.form-settings > form {
  padding: 0.25rem 1rem 1.1rem;
  margin: 0;
}

.form-settings[open] > .form-settings-summary {
  border-bottom: 1px solid var(--bsafe-line);
  margin-bottom: 0.9rem;
}

/* Sections and criteria: room to breathe, headed by their own name. */
.builder-section { padding: 1.1rem 1.1rem 0.9rem; }

.builder-section + .builder-section { margin-top: 1.25rem; }

.builder-criteria + .builder-criteria { margin-top: 1.25rem; }

.builder-add-criterion { margin-top: 0.5rem; padding-left: 0; }

/* The question list: hairline-separated rows, no rail, no nested boxes. */
.builder-q-list {
  border-top: 1px solid var(--bsafe-line);
}

.builder-q-list > .builder-question,
.builder-q-list > .builder-node + .builder-node {
  margin: 0;
}

.builder-question {
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--bsafe-line);
  border-radius: 0;
  background: transparent;
}

.builder-question > .builder-node-head { margin-bottom: 0; gap: 0.5rem; }

.builder-question.is-open { background: rgba(var(--bsafe-accent-rgb), 0.05); }

.builder-question.is-open > .builder-node-head { padding-right: 0.5rem; padding-top: 0.35rem; }

.builder-q-toggle {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  padding: 0.7rem 0.5rem;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.builder-q-toggle:hover { background: rgba(var(--bsafe-accent-rgb), 0.06); }

.builder-q-chevron {
  flex: none;
  font-size: 0.8rem;
  color: var(--bsafe-muted);
  transition: transform 0.15s ease;
}

.builder-question.is-open .builder-q-chevron { transform: rotate(90deg); }

.builder-q-line {
  display: grid;
  flex: 1;
  grid-template-columns: 3.25rem minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 0.75rem;
  min-width: 0;
}

.builder-q-ref {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--bsafe-muted);
  font-variant-numeric: tabular-nums;
}

.builder-q-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.builder-question.is-open .builder-q-text { font-weight: 600; }

.builder-q-meta {
  display: flex;
  gap: 0.75rem;
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--bsafe-muted);
}

.builder-q-type { min-width: 6.5rem; }

.builder-q-panel { padding: 0.25rem 1rem 1.25rem 2.1rem; }

/* "Add a question": the obvious next step at the foot of each group. */
.builder-add-question {
  width: 100%;
  margin-top: 0.75rem;
  border-style: dashed;
}

.builder-add-section { margin-top: 1.25rem; }

@media (max-width: 575.98px) {
  .builder-section { padding: 0.85rem 0.75rem; }

  .builder-q-toggle { padding: 0.65rem 0.25rem; }

  .builder-q-line {
    grid-template-columns: 2.6rem minmax(0, 1fr);
    row-gap: 0.1rem;
  }

  .builder-q-text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: normal;
  }

  .builder-q-meta { grid-column: 2; }

  .builder-q-type { min-width: 0; }

  .builder-q-panel { padding: 0.25rem 0.5rem 1rem; }

  /* Remove drops under the open question's line instead of crowding it. */
  .builder-question > .builder-node-head { flex-wrap: wrap; }

  .builder-q-toggle { flex: 1 1 100%; }

  .builder-question.is-open > .builder-node-head .builder-q-remove {
    margin: 0 0.5rem 0.5rem auto;
  }

  /* Give the questions the whole width: no rail, no indent, no inner box. */
  .builder-section > .builder-criteria {
    margin-left: 0;
    padding: 0;
    border-left: 0;
  }
}

.builder-live-note { margin: -0.25rem 0 1rem; font-size: 0.9rem; }

/* ==========================================================================
   lam2-offline — inspections in the device outbox
   An inspection opened with signal and finished without: the outbox names
   what each item is, the inspection page carries a "Saved on this device"
   card (the .outbox-banner pattern), and the Files card says calmly that a
   photo taken with no signal is kept on the device.
   ========================================================================== */
.outbox-item-kind {
  margin: 0 0 0.15rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--bsafe-muted);
}

.audit-kept { margin-top: 0.25rem; }

/* One notice at a time: while the device is holding the inspection, the page's
   own "Not finished yet" line is about the copy on the service, so it waits. */
.audit-kept:not(.d-none) ~ #audit-banner { display: none; }

.audit-kept-refused { color: var(--bsafe-attention-ink); }

.files-kept {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  color: var(--bsafe-ink);
}

.files-kept .bi { color: var(--bsafe-accent); }

/* ------------------------------------------------- a short register stays plain
   A register of a handful of rows (roles) needs no filter card, page-size
   choice, search box, pager, repeated header or export bar: they promise a
   volume that is not there. roles.js adds `register-few` to the page when the
   whole set fits on one screen. */
.register-few .register-few-hide,
.register-few .dt-container .dt-layout-start,
.register-few .dt-container .dt-layout-end,
.register-few .dt-container tfoot {
  display: none !important;   /* the layout cells carry Bootstrap's own !important d-md-flex */
}

/* ------------------------------------------------- maintenance pages, calmer (lam2-ppm)
   The register's Asset and Check type columns use the shared `.col-wide-only`
   (below). */

/* The one sentence a page's attention line cannot carry (who to chase for a
   certificate that is running out). Plain text directly under the line, in the
   line's own gutter, so the pair reads as one warning rather than two banners. */
.page-attention:has(+ .page-attention-note:not(.d-none)) { margin-bottom: 0.5rem; }
.page-attention-note {
  margin: 0 0 1rem;
  padding: 0 0.75rem;
  font-size: 0.875rem;
}

/* A closed "More details" inside a dialog: the rarely-used fields stay one
   click away without making the common path longer. */
.form-more {
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius, 0.375rem);
  padding: 0.5rem 0.75rem;
}
.form-more > summary {
  cursor: pointer;
  font-weight: 600;
}
.form-more > summary:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

/* =========================================================================
   Inspection programme (inspection-programme.html)
   A year of form x site by month, and the three figures the health and safety
   team opens it for. Every cell says Done / Due / Overdue / Planned in words
   with an icon; the left edge's tint only reinforces. Under 768 px the table is
   drawn as a list that names only the months holding something.
   ========================================================================= */

/* Waiting for you: the caller's own open inspections, above the figures. */
.programme-mine { border-left: 4px solid var(--bsafe-accent); }

.programme-mine-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.programme-mine-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 0.5rem 0;
}

.programme-mine-item + .programme-mine-item { border-top: 1px solid var(--bsafe-line); }

.programme-mine-what {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.programme-mine-form { font-weight: 600; color: var(--bsafe-ink); }
.programme-mine-site { color: var(--bsafe-muted); }
.programme-mine-due { font-size: 0.85rem; font-weight: 600; }
.programme-mine-due.programme-due { color: var(--bsafe-accent-deep); }
.programme-mine-due.programme-overdue { color: #842029; }

.programme-figure.active {
  border-color: var(--bsafe-accent);
  box-shadow: inset 0 0 0 1px var(--bsafe-accent);
  background: #f4f8fd;
}

.programme-figure-open {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.programme-figure-open:hover .programme-figure-hint { text-decoration: underline; }

.programme-figure-open:focus-visible {
  outline: 2px solid var(--bsafe-accent);
  outline-offset: 3px;
  border-radius: 0.25rem;
}

.programme-figure-hint {
  font-size: 0.8rem;
  color: var(--bsafe-muted);
}

.programme-severities {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.7rem 0 0;
  padding: 0;
  list-style: none;
}

.programme-severity {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--bsafe-line);
  border-radius: var(--bs-border-radius, 0.375rem);
  background: var(--bs-body-bg);
  font: inherit;
  color: var(--bsafe-ink);
  cursor: pointer;
}

.programme-severity:hover { border-color: var(--bsafe-accent); }

.programme-severity:focus-visible {
  outline: 2px solid var(--bsafe-accent);
  outline-offset: 2px;
}

.programme-severity[aria-pressed="true"] {
  border-color: var(--bsafe-accent);
  box-shadow: inset 0 0 0 1px var(--bsafe-accent);
  background: #f4f8fd;
}

.programme-severity-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.programme-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
  color: var(--bsafe-muted);
}

.programme-key { font-weight: 600; }
.programme-key::after { content: ":"; }

.programme-lead {
  margin: 0 0 1.25rem;
  color: var(--bsafe-muted);
}

.programme-wrap { overflow-x: auto; }

.programme-grid {
  width: 100%;
  min-width: 64rem;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.programme-grid th,
.programme-grid td {
  padding: 0.45rem 0.2rem;
  border-bottom: 1px solid var(--bsafe-line);
  vertical-align: top;
}

.programme-grid thead th {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--bsafe-muted);
  text-align: left;
}

.programme-grid abbr { text-decoration: none; }

.programme-grid .programme-form-col {
  width: 11.5rem;
  padding-left: 0.6rem;
  text-align: left;
}

.programme-site-row th {
  padding: 0.6rem 0.6rem;
  background: #f4f6f9;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--bsafe-ink);
}

.programme-form {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--bsafe-ink);
}

.programme-cycle {
  display: block;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--bsafe-muted);
}

.programme-cell {
  display: block;
  margin-bottom: 0.25rem;
  padding: 0.3rem 0.3rem;
  border: 1px solid var(--bsafe-line);
  border-left-width: 3px;
  border-radius: var(--bs-border-radius, 0.375rem);
  background: var(--bs-body-bg);
  font-size: 0.72rem;
  line-height: 1.3;
  color: var(--bsafe-ink);
  text-decoration: none;
  overflow: hidden;
}

.programme-cell:hover { border-color: var(--bsafe-accent); }

.programme-cell:focus-visible {
  outline: 2px solid var(--bsafe-accent);
  outline-offset: 2px;
}

.programme-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 0.25rem;
  font-weight: 700;
}

.programme-word { white-space: nowrap; }

.programme-day,
.programme-ref,
.programme-detail {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.programme-detail { color: var(--bsafe-muted); }

.programme-cell.programme-done { border-left-color: var(--bs-success); }
.programme-cell.programme-done .programme-state { color: #0f5132; }

.programme-cell.programme-due { border-left-color: var(--bsafe-accent); background: #f4f8fd; }
.programme-cell.programme-due .programme-state { color: var(--bsafe-accent-deep); }

.programme-cell.programme-overdue { border-left-color: var(--bs-danger); background: #fdf3f3; }
.programme-cell.programme-overdue .programme-state { color: #842029; }

.programme-cell.programme-planned { border-style: dashed; border-left-width: 1px; }
.programme-cell.programme-planned .programme-state { color: var(--bsafe-muted); }

@media (max-width: 767.98px) {
  .programme-grid { min-width: 0; table-layout: auto; }
  .programme-grid thead { display: none; }

  .programme-grid,
  .programme-grid tbody,
  .programme-grid tr,
  .programme-grid th,
  .programme-grid td { display: block; width: auto; }

  .programme-grid th,
  .programme-grid td { border-bottom: 0; padding: 0; }

  .programme-site-row th { margin: 0.75rem 0 0.5rem; padding: 0.5rem 0.75rem; border-radius: var(--bs-border-radius, 0.375rem); }

  .programme-row {
    margin-bottom: 0.6rem;
    padding: 0.75rem;
    border: 1px solid var(--bsafe-line);
    border-radius: var(--bs-border-radius, 0.375rem);
    background: var(--bs-body-bg);
  }

  .programme-grid .programme-form-col { width: auto; padding: 0 0 0.5rem; }

  .programme-grid .programme-month-cell {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.2rem 0;
  }

  .programme-grid .programme-month-cell.programme-empty-cell { display: none; }

  .programme-month-cell::before {
    content: attr(data-month);
    flex: 0 0 5.5rem;
    padding-top: 0.45rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--bsafe-muted);
  }

  .programme-cells { flex: 1 1 auto; min-width: 0; }

  .programme-cell { margin-bottom: 0; font-size: 0.9rem; }

  .programme-cell + .programme-cell { margin-top: 0.25rem; }
}

/* ==========================================================================
   Lampton R2 (lam-r2-people): who was hurt
   --------------------------------------------------------------------------
   .people-prompt      the record's "Who was hurt?" line, for an accident or
                       ill-health report with nobody recorded as hurt. A calm
                       card in the brand tint, not an alarm: one sentence, one
                       action.
   .person-statement   a witness's statement under their role in the people
                       table: the words, then the signed copy.
   .people-step-*      the report form's "Who was hurt?" step
                       (components/report-people-step.js).
   ========================================================================== */
.people-prompt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin: 0 0 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid rgba(var(--bsafe-accent-rgb), 0.25);
  border-left: 4px solid var(--bsafe-accent);
  border-radius: var(--bs-border-radius, 0.375rem);
  background: rgba(var(--bsafe-accent-rgb), 0.05);
}

.people-prompt-icon {
  font-size: 1.5rem;
  color: var(--bsafe-accent);
}

.people-prompt-body {
  flex: 1 1 14rem;
  min-width: 0;
}

.people-prompt-title {
  margin: 0 0 0.125rem;
  font-size: 1.0625rem;
  font-weight: 600;
}

.people-prompt-text {
  margin: 0;
  color: var(--bs-secondary-color);
}

.person-statement {
  margin-top: 0.25rem;
  font-size: 0.875rem;
}

.person-statement-text {
  display: block;
  color: var(--bs-secondary-color);
  font-style: italic;
  white-space: pre-line;
}

/* The step: a calm column of plain questions. */
.people-step {
  margin-bottom: 1.5rem;
}

.people-step-lead {
  color: var(--bs-secondary-color);
  margin-bottom: 1.5rem;
}

.people-step-section {
  margin-bottom: 2rem;
}

.people-step-section-title {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

/* One answer per row on a phone, so no choice is stranded on a line of its
   own; side by side once there is room. */
.people-step-who {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

@media (min-width: 576px) {
  .people-step-who {
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  }
}

/* "Saved as a draft · INC-…": said once, quietly, on one line. */
.people-step-saved {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.5rem;
  margin: 0.25rem 0 1rem;
  color: var(--bs-secondary-color);
  font-size: 0.9375rem;
}

.people-step-saved .bi {
  color: var(--bsafe-accent);
}

.people-step-saved strong {
  color: var(--bs-body-color);
  font-weight: 600;
}

.people-step-who .btn {
  min-height: 44px;
  text-align: left;
}

.people-step-who .btn[aria-pressed="true"] {
  background: rgba(var(--bsafe-accent-rgb), 0.1);
  border-color: var(--bsafe-accent);
  color: var(--bsafe-accent-deep);
  font-weight: 600;
}

.people-step-card {
  padding: 1rem;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius, 0.375rem);
  background: var(--bs-body-bg);
  margin-bottom: 1rem;
}

.people-step-added {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.people-step-added li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--bs-border-color-translucent);
}

.people-step-added .bi {
  color: var(--bsafe-accent);
}

.people-step-added-meta {
  color: var(--bs-secondary-color);
  font-size: 0.875rem;
}

.people-step-parts summary {
  color: var(--bsafe-accent);
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.people-step-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}

.people-step-choices .form-check {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.people-step-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.report-sent-people {
  margin: 1rem 0 0;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--bsafe-attention-line);
  background: var(--bsafe-attention-bg);
  color: var(--bsafe-attention-ink);
  border-radius: var(--bs-border-radius, 0.375rem);
}

/* ==========================================================================
   Lampton R4 (lam-r4-form): the guided report as a stepper
   ========================================================================== */
/*
 * One section of the form per screen, every applicable question on it, and
 * nothing behind an expander. A thin segmented bar and "Step 3 of 7" say
 * where the reporter is; the section's own heading says what it is. Back is
 * an outline button on the left; the one solid button (Next, the save before
 * "Who was hurt?", or Send) takes the rest of the row on a phone.
 */
.report-progress {
  margin: 0.25rem 0 1.25rem;
}

.report-progress-text {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  color: var(--bs-secondary-color);
}

.report-progress-bar {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.report-progress-bar > li {
  height: 0.25rem;
  border-radius: 999px;
  background: var(--bs-border-color);
}

.report-progress-bar > li.is-done {
  background: rgba(var(--bsafe-accent-rgb), 0.45);
}

.report-progress-bar > li.is-current {
  background: var(--bsafe-accent);
}

.report-stage-title {
  margin-bottom: 1.25rem;
  font-size: 1.375rem;
  font-weight: 600;
}

.report-stage-title:focus {
  outline: none;
}

.report-stage-lead {
  margin-bottom: 1.25rem;
  color: var(--bs-secondary-color);
}

/* The full form shows every section, one after another. */
body:not([data-report-mode="guided"]) .report-stage + .report-stage {
  margin-top: 2rem;
}

body:not([data-report-mode="guided"]) .report-stage-title {
  font-size: 1.125rem;
}

/* Pin the spot: the phone's position, the map and the plan, together.
   Stacked full width on a phone; one row from 576 px. */
.report-pin-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem;
  margin: 0.75rem 0 0.25rem;
}

@media (min-width: 576px) {
  .report-pin-actions {
    display: flex;
    flex-wrap: wrap;
  }
}

.report-pin-actions > .btn {
  min-height: 2.75rem;
}

.report-pin .form-text:empty {
  display: none;
}

/* The stage actions. */
body[data-report-mode="guided"] .report-form-actions {
  align-items: center;
  margin-top: 1.5rem;
}

body[data-report-mode="guided"] .report-form-actions > .btn {
  min-height: 2.75rem;
}

body[data-report-mode="guided"] .report-form-actions > #cancel-link {
  flex-basis: 100%;
  padding-inline: 0;
  text-align: left;
}

/* Check and send: one card, a section per step, Edit on the right. */
.report-summary {
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius-lg);
}

.report-summary-section {
  padding: 1.25rem;
}

.report-summary-section + .report-summary-section {
  border-top: 1px solid var(--bs-border-color);
}

.report-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.report-summary-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
}

.report-summary-edit {
  min-height: 2.75rem;
  padding-inline: 0.5rem;
}

.report-summary-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  column-gap: 1.5rem;
  margin: 0;
}

.report-summary-list dt {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--bs-secondary-color);
}

.report-summary-list dd {
  margin: 0 0 0.75rem;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

@media (min-width: 768px) {
  .report-summary-list {
    grid-template-columns: minmax(12rem, 1fr) minmax(0, 2fr);
  }

  .report-summary-list dd {
    margin-bottom: 0.5rem;
  }
}

.report-summary-blank {
  font-style: italic;
  color: var(--bs-secondary-color);
}

/* Photos and documents: the second picker, under "Take a photo". */
.report-evidence-more {
  margin-top: 1rem;
}

/* "Who was hurt?" on the stepper: Back, then the one solid button. */
.people-step-actions > .btn {
  min-height: 2.75rem;
}

@media (max-width: 575.98px) {
  .people-step-actions > .btn-primary {
    flex: 1 1 auto;
  }
}

/* ---------------------------------------------------------------------------
   Investigation rail (lam-r4-wizard). The wizard's seven stations as ONE
   `.lifecycle` rail, every station on screen at every step and every width,
   in the order the work is done. Each station is a Bootstrap tab; its state
   is an icon AND a word (done, current, to do, or why it is locked), never
   colour alone. The station on screen is underlined. Below 768 px the labels
   are kept for screen readers only and the caption under the rail names the
   station on screen, so seven stations fit a 390 px phone without scrolling.
   --------------------------------------------------------------------------- */
.inv-rail {
  margin-bottom: 1.5rem;
  padding: 0.75rem 1rem;
  overflow-x: visible;
}
.inv-rail .lc-step { flex: 1 1 0; }
.inv-rail .lc-step:last-child { flex: 0 1 auto; }
.inv-rail .lc-step::after { min-width: 0.75rem; margin: 0 0.6rem; }
.inv-rail .lc-label,
.inv-rail .lc-sub { white-space: normal; }

.inv-step-link {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0.35rem 0.25rem 0.35rem 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  text-align: left;
  color: inherit;
}
.inv-step-link.active { border-bottom-color: var(--bsafe-accent); }
.inv-step-link.active .lc-label { color: var(--bsafe-ink); }
.inv-step-link:focus-visible {
  outline: 2px solid var(--bsafe-accent);
  outline-offset: 3px;
  border-radius: 0.25rem;
}

/* Locked: a dashed, empty dot with a padlock, and the reason as its words. */
.lc-step.locked .lc-dot {
  background: transparent;
  border: 2px dashed var(--bsafe-line);
  color: var(--bsafe-muted);
}
.lc-step.locked .inv-step-link { cursor: not-allowed; }

.inv-rail-caption { display: none; }

.inv-complete-intro {
  color: var(--bsafe-muted);
  margin-bottom: 1.25rem;
}

/* Tablet and small laptop: seven stations side by side would squeeze the
   labels into the connectors, so each station stacks its dot over its words
   in seven equal columns, without connectors. */
@media (min-width: 768px) and (max-width: 1399.98px) {
  .inv-rail {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    column-gap: 0.25rem;
  }
  .inv-rail .lc-step::after { display: none; }
  .inv-rail .inv-step-link {
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 0.25rem 0.15rem 0.4rem;
    text-align: center;
  }
  .inv-rail .lc-dot { margin: 0 0 0.35rem; }
  .inv-rail .lc-label { font-size: 0.8rem; overflow-wrap: anywhere; }
}

@media (max-width: 767.98px) {
  .inv-rail { padding: 0.6rem 0.75rem; }
  .inv-rail .lc-step,
  .inv-rail .lc-step:last-child { flex: 1 1 0; }
  .inv-rail .lc-step:last-child { flex: 0 0 auto; }
  .inv-rail .lc-step::after { min-width: 0.25rem; margin: 0 0.2rem; }
  .inv-rail .lc-dot { margin-right: 0; }
  .inv-rail .lc-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .inv-step-link { padding: 0.25rem 0.15rem; }
  .inv-rail-caption {
    display: block;
    margin: -0.75rem 0 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--bsafe-ink);
  }
}

/* ---------------------------------------------------------------------------
   Statistics, calmer (lam2-calm2b). One line a criterion, the rest on hover;
   a lone chart across the card; a league table that leads with the units that
   have something to show; the register's reason for its rows in the filter
   header; saved views newest first with the trash icon on request.
   --------------------------------------------------------------------------- */

/* A description that gives way to one line with an ellipsis. The whole text is
   in the row's `title`, so nothing is lost, only quietened. */
.stats-oneline {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* The label holds the name and its one-line hint; `display: block` lets the
   ellipsis measure against the row, not the text. */
.stats-criterion-label { display: block; min-width: 0; }

/* The button under the league table that unfolds the units with none. */
.league-none-line { margin: 0.5rem 0 0; font-size: 0.875rem; }

/* The one muted line in a folded filter header that says what the register is
   filtered on. It gives way once the card is open: the controls say it then. */
.filter-toggle .filter-summary {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--bsafe-muted);
}
.filter-toggle:not(.collapsed) .filter-summary { display: none; }

/* The trash icon on a saved view is there when it is wanted: on the row under
   the pointer, on the row the keyboard is in, and on the view on screen. It is
   only faded, never removed, so a keyboard user still tabs to it, and where
   there is no hover (a touch screen) it stays. */
.saved-view-row .saved-view-delete { opacity: 0; transition: opacity 0.12s ease; }
.saved-view-row:hover .saved-view-delete,
.saved-view-row:focus-within .saved-view-delete,
.saved-view-row-active .saved-view-delete,
.saved-view-row .saved-view-delete:focus-visible { opacity: 1; }
@media (hover: none) {
  .saved-view-row .saved-view-delete { opacity: 1; }
}

/* ---------------------------------------------------- calmer act 4 (lam2-calm3)
   The statistics action bar is the shared page-actions bar (no rules of its
   own beyond a little air under it); the register toolbar vanishes when it
   holds nothing (the reports register has only the card's own filter control);
   the wizard folds its rarer sources; the saved-views menu folds its older rows. */
.register-toolbar-quiet:empty { display: none; }

.wizard-sources-more-row { margin-top: 0.25rem; }
#wizard-sources-more-btn { text-decoration: none; font-weight: 500; }
#wizard-sources-more-btn:hover,
#wizard-sources-more-btn:focus-visible { text-decoration: underline; }

.saved-views-more {
  color: var(--bsafe-accent);
  font-weight: 500;
}

/* The KPI PDF's figures table (KpiReportHandler::card): a cell reads "0.64 — On
   target" on one line, so the columns take the room the words need instead of
   wrapping into two lines of a narrow cell. Smaller type, tighter padding, and
   the headings keep wrapping (they are words about the column, not figures). */
.kpi-report-table th,
.kpi-report-table td {
  padding: 0.4rem 0.45rem;
  font-size: 0.8125rem;
  vertical-align: middle;
}
.kpi-report-table td:not(:first-child) { white-space: nowrap; }

/* Scheduled jobs: a chaser's printed output (Settings, Run chasers now). Its first
   line is one long sentence ("... PREVIEW ONLY: nothing was sent.") that used
   to run off the right-hand edge of the box, so the honest words of a preview
   were the part nobody could read. Wrapping keeps the table's own lines whole:
   they are shorter than the box from tablet width up. */
@media (min-width: 768px) {
  .chaser-output { white-space: pre-wrap; overflow-wrap: anywhere; }
}

/* ------------------------------------------------- Connect Power BI (lam2-pbi)
   The card under the API access register: the Power Query (M) query an analyst
   pastes, and a preview of what it receives. It is a report document like any
   other (`.report-section-title`, `.detail-grid`, `.report-table`); these rules
   only give the query its monospace block and the three steps their air.
   The query is a read-only textarea rather than a `pre`, so it can be labelled,
   focused, scrolled with the keyboard and selected by hand when the clipboard
   is refused. It never wraps: M reads by its indentation. */
.pbi-query {
  font-family: var(--bs-font-monospace);
  font-size: 0.8125rem;
  line-height: 1.5;
  background: var(--bs-tertiary-bg);
  /* No bottom padding: a scrolled textarea shows the next line through it, a sliver of a line under the last whole one. */
  padding-bottom: 0;
  resize: vertical;
  overflow: auto;
}

.pbi-steps { padding-left: 1.25rem; }
.pbi-steps li + li { margin-top: 0.4rem; }
.pbi-notes { padding-left: 1.25rem; }
.pbi-notes li + li { margin-top: 0.25rem; }

#pbi-result-grid .detail-item dd { font-variant-numeric: tabular-nums; }
