/* Copyright (c) Health Dynamics Consulting Ltd. All rights reserved. Proprietary: see LICENSE. */
/*
 * Layer 3 of 5: components. Patterns from GOV.UK, NHS.UK and the MOJ pattern library, drawn in Health Dynamics
 * tokens as our own CSS (no kit installed, no kit branding). Each pattern's markup, PHP helper and JS helper are in
 * docs/design-standard.md. Older class names are kept and styled to match (marked "older name").
 */

/* ================================================================ Buttons */
/* One primary (cerise) button per page: the next thing to do. Everything else is secondary or a link. */
.btn {
  --btn-bg: var(--hd-primary);
  --btn-fg: #fff;
  --btn-border: var(--hd-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--hd-space-2);
  min-height: var(--wfp-target);
  padding: 0 22px;
  border-radius: var(--hd-radius-pill);
  border: 2px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: .95rem;
  line-height: 1.2;
  text-transform: var(--hd-ui-case);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--wfp-motion), border-color var(--wfp-motion), color var(--wfp-motion);
  white-space: nowrap;
}
.btn .arrow { display: inline-block; transition: transform var(--wfp-motion); }
.btn:hover { --btn-bg: var(--hd-primary-hover); --btn-border: var(--hd-primary-hover); color: var(--btn-fg); }
.btn:focus-visible { outline: none; box-shadow: var(--hd-focus-ring); }
.btn:hover .arrow { transform: translateX(4px); }
/* Secondary: white with a 3:1 edge. .btn-ghost and .btn-light are older names for it. */
.btn-secondary, .btn-ghost, .btn-light, .btn-accent { --btn-bg: var(--hd-surface); --btn-fg: var(--hd-text); --btn-border: var(--hd-border-input); }
.btn-secondary:hover, .btn-ghost:hover, .btn-light:hover, .btn-accent:hover { --btn-bg: var(--hd-grey-bg); --btn-fg: var(--hd-text); --btn-border: var(--hd-oxford); }
.btn-secondary[aria-current="true"], .btn-secondary[aria-current="page"], .btn-secondary[aria-pressed="true"] { --btn-bg: var(--hd-oxford); --btn-fg: #fff; --btn-border: var(--hd-oxford); }
.btn-danger { --btn-bg: var(--hd-error); --btn-fg: #fff; --btn-border: var(--hd-error); }
.btn-danger:hover { --btn-bg: #8f1c13; --btn-border: #8f1c13; }
/* Small: 36px. .btn-compact is the older name. */
.btn-small, .btn-compact { min-height: var(--wfp-target-sm); padding: 0 16px; font-size: .88rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-link {
  background: none; border: 0; padding: 0; color: var(--hd-link); font: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.btn-link:hover { color: var(--hd-oxford); }
.btn-icon { min-width: 28px; min-height: 28px; flex: none; }

/* Button group: primary, then secondary, then a link, in one row that wraps. */
.btn-group { display: flex; flex-wrap: wrap; align-items: center; gap: var(--hd-space-3) var(--hd-space-4); margin: var(--hd-space-5) 0 0; }
.btn-group > a:not(.btn) { font-weight: 500; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--hd-space-3) var(--hd-space-4); align-items: center; margin-top: var(--hd-space-5); }

.outlined-pill { display: inline-block; border: 2px solid var(--hd-oxford); border-radius: var(--hd-radius-pill); padding: var(--hd-space-1) var(--hd-space-5); }

/* ================================================================ Cards */
.card {
  position: relative;
  background: var(--hd-surface);
  border: 1px solid var(--hd-border);
  border-radius: var(--hd-radius);
  box-shadow: var(--hd-shadow);
  padding: var(--hd-space-6);
  margin-bottom: var(--hd-space-5);
  transition: transform var(--wfp-motion), box-shadow var(--wfp-motion);
}
/* Card headings in oxford, not cerise (agreed): cerise means "act". */
.card > h2, .card > h3, .card-title { color: var(--hd-heading); }
.card > h2 { font-size: var(--hd-text-h2); }
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: var(--hd-space-2) var(--hd-space-3); margin-bottom: var(--hd-space-3); }
.card-head > h2, .card-head > h3 { margin: 0; }
/* The one card that holds what is asked of the person: a 4px cerise top rule. */
.card-accent { border-top: 4px solid var(--hd-primary); }
.card.hoverable:hover { transform: translateY(-3px); box-shadow: var(--hd-shadow-md); }
.card.hoverable::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  border-radius: var(--hd-radius) var(--hd-radius) 0 0; background: var(--hd-card-stripe); opacity: 0; transition: opacity var(--wfp-motion);
}
.card.hoverable:hover::before { opacity: 1; }

/* Stat tile: at most four in a row; each says what it is compared with. */
.stat { font-family: var(--font-heading); font-weight: 800; font-size: 1.9rem; line-height: 1.1; color: var(--wfp-stat); }
.stat-tile { display: flex; flex-direction: column; gap: var(--hd-space-1); padding: var(--hd-space-5); }
.stat-tile .stat-label { font-weight: 700; color: var(--hd-muted); font-size: var(--wfp-text-hint); margin: 0; }
.stat-tile .stat { margin: 0; }
.stat-tile .stat-compare { color: var(--hd-muted); font-size: var(--wfp-text-hint); margin: 0; }

/* ================================================================ Forms */
/* Label, then hint, then error message, then the control (agreed). */
.field { margin-bottom: var(--hd-space-6); }
.field label, .label {
  display: block;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--wfp-text-label);
  margin-bottom: var(--hd-space-1);
}
.field .required { font-weight: 400; color: var(--hd-muted); font-size: 13px; }
.field-hint, .help { display: block; color: var(--hd-muted); font-size: var(--wfp-text-hint); margin: 0 0 var(--hd-space-2); }
.field > .help:last-child { margin: var(--hd-space-1) 0 0; }
.input, .select, textarea.input {
  display: block;
  width: 100%;
  min-height: var(--wfp-target);
  padding: var(--hd-space-2) var(--hd-space-3);
  border: 2px solid var(--hd-border-input);
  border-radius: var(--hd-radius-sm);
  background: var(--hd-surface);
  color: var(--hd-text);
  font-family: var(--font-body);
  font-size: 1rem;
}
.input:focus-visible, .select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--hd-accent); box-shadow: var(--hd-focus-ring); }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--hd-error); }
.input.code { font-family: var(--font-mono); font-size: 22px; letter-spacing: .3em; max-width: 220px; }
.input-width-2 { width: 4.5em !important; }
.input-width-4 { width: 6em !important; }
.input-width-10 { max-width: 23ch; }
.input-width-20 { max-width: 41ch; }

/* Error message beside the field: a red bar down the field group, the message in bold red, "Error:" read out. */
.field-error {
  color: var(--hd-error); font-weight: 700; font-size: var(--wfp-text-label);
  margin: 0 0 var(--hd-space-2); display: flex; gap: var(--hd-space-2); align-items: flex-start;
}
.field-error .icon { vertical-align: 0; margin-top: 2px; }
.field.has-error, .field-group-error { border-left: 5px solid var(--hd-error); padding-left: var(--hd-space-4); }
/* Older templates print the error under the control; it still reads as an error. */
.input + .field-error, .select + .field-error, textarea + .field-error { margin: var(--hd-space-2) 0 0; }

/* Error summary: title "There is a problem", a link to each field, focused when the page loads with errors. */
.error-summary {
  border: 3px solid var(--hd-error);
  border-radius: var(--hd-radius-sm);
  background: var(--hd-surface);
  padding: var(--hd-space-4) var(--hd-space-5);
  margin-bottom: var(--hd-space-6);
}
.error-summary:focus { outline: 3px solid var(--hd-focus-color); outline-offset: 2px; }
.error-summary-title { font-size: 1.15rem; margin: 0 0 var(--hd-space-2); }
.error-summary-list { margin: 0; padding-left: 1.2em; }
.error-summary-list a { color: var(--hd-error); font-weight: 700; }
.error-summary-list a:hover { color: var(--hd-oxford); }
.error-summary-body { margin: 0 0 var(--hd-space-2); }

/* Month and year input: two number fields in a fieldset, not the browser's date picker. */
.date-input { display: flex; flex-wrap: wrap; gap: var(--hd-space-4); margin-top: var(--hd-space-1); }
.date-input-item { display: flex; flex-direction: column; }
.date-input-item label { font-weight: 500; margin-bottom: var(--hd-space-1); }
.date-input-item .input { width: auto; }

/* Fieldsets and legends. The plain fieldset is the default for new forms (.fieldset-plain); the older boxed one stays. */
fieldset { border: 1px solid var(--hd-border); border-radius: var(--hd-radius); padding: var(--hd-space-5); margin: 0 0 var(--hd-space-5); }
legend { font-family: var(--font-heading); font-weight: 800; padding: 0 var(--hd-space-2); color: var(--hd-heading); }
.fieldset-plain, .fieldset { border: 0; padding: 0; margin: 0 0 var(--hd-space-6); }
.fieldset-plain > legend, .fieldset > legend { padding: 0; font-size: var(--hd-text-h3); font-weight: 700; margin-bottom: var(--hd-space-1); }
.fieldset-legend-page { font-size: var(--hd-text-h1) !important; font-weight: 800 !important; margin-bottom: var(--hd-space-4) !important; }

/* Radios and checkboxes: native controls (state reaches assistive technology), 24 to 28px targets. */
.radios, .checkboxes { display: flex; flex-direction: column; gap: var(--hd-space-2); margin-top: var(--hd-space-2); }
.radios-inline { flex-direction: row; flex-wrap: wrap; gap: var(--hd-space-2) var(--hd-space-5); }
.radio, .checkbox { display: flex; gap: var(--hd-space-3); align-items: flex-start; }
.radio input { width: 28px; height: 28px; margin: 0; flex: none; accent-color: var(--hd-primary); }
.checkbox input { width: 24px; height: 24px; margin-top: 2px; flex: none; accent-color: var(--hd-cerise-dark); }
.field label.radio, .field label.checkbox { display: flex; font-weight: 400; font-size: 1rem; margin: 0; }
.radio .item-hint, .checkbox .item-hint { display: block; color: var(--hd-muted); font-size: var(--wfp-text-hint); }

.inline-form { display: inline-flex; gap: var(--hd-space-2); align-items: center; margin: 0; }
.inline-form .select { width: auto; min-height: 32px; padding: 0 var(--hd-space-2); font-size: 14px; }

/* Disabled fields look disabled: a shaded fill and a dashed edge, not an editable box. Prefer hiding with a reason. */
.input:disabled, .select:disabled, textarea:disabled, select:disabled, input:disabled:not([type=checkbox]):not([type=radio]),
fieldset:disabled .input, fieldset:disabled .select, fieldset:disabled textarea, fieldset:disabled select {
  background: var(--hd-bg); color: var(--hd-text-soft); border-style: dashed; cursor: not-allowed; opacity: 1;
}
input[type=checkbox]:disabled, input[type=radio]:disabled { cursor: not-allowed; opacity: .6; }
/* Viewers: screens are read only, so a value shows as text and buttons they cannot use are not shown. */
body[data-viewer] input:disabled:not([type=checkbox]):not([type=radio]), body[data-viewer] select:disabled, body[data-viewer] textarea:disabled,
body[data-viewer] fieldset:disabled .input, body[data-viewer] fieldset:disabled .select, body[data-viewer] fieldset:disabled textarea {
  border: 0; background: transparent; padding-left: 0; padding-right: 0; color: var(--hd-text); cursor: default;
  -webkit-appearance: none; appearance: none; background-image: none; box-shadow: none; resize: none;
}
body[data-viewer] .btn:disabled, body[data-viewer] .btn[aria-disabled="true"], body[data-viewer] [data-edit-only] { display: none !important; }

/* A list of tick boxes in place of a multiple select. */
.tick-list { border: 1px solid var(--hd-border); border-radius: var(--hd-radius-sm); padding: var(--hd-space-2) var(--hd-space-3); margin: 0; max-height: 220px; overflow-y: auto; }
.tick-list legend { font-weight: 600; padding: 0 var(--hd-space-1); font-family: var(--font-body); font-size: var(--wfp-text-label); }
.tick-list .check { display: flex; align-items: center; gap: var(--hd-space-2); min-height: 28px; }

/* Segmented control (two to four views of one thing): a 3:1 edge, the chosen one in oxford. */
.seg { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 0; max-width: 100%; }
.seg-label { margin-right: var(--hd-space-2); font-family: var(--font-heading); font-weight: 700; }
.seg-btn { border: 2px solid var(--hd-border-input); background: var(--hd-surface); color: var(--hd-text); min-height: 40px; padding: 6px var(--hd-space-4); font-family: var(--font-heading); font-weight: 700; font-size: .88rem; cursor: pointer; margin-left: -2px; }
.seg-btn:first-of-type { border-radius: var(--hd-radius-pill) 0 0 var(--hd-radius-pill); margin-left: 0; }
.seg-btn:last-of-type { border-radius: 0 var(--hd-radius-pill) var(--hd-radius-pill) 0; }
.seg-btn:hover { background: var(--hd-grey-bg); }
.seg-btn[aria-pressed="true"], .seg-btn[aria-selected="true"] { background: var(--hd-oxford); color: #fff; border-color: var(--hd-oxford); }
.seg-btn:focus-visible { outline: none; box-shadow: var(--hd-focus-ring); position: relative; z-index: 1; }
.seg .seg-select { display: none; width: auto; }
@media (max-width: 599px) {
  .seg { flex-wrap: nowrap; }
  .seg:has(.seg-select) .seg-btn { display: none; }
  .seg .seg-select { display: inline-block; }
}

/* ================================================================ Messages */
/* Alerts (older name, still used for flashes and inline messages): colour plus an icon plus a word. */
.alert {
  display: flex; gap: var(--hd-space-3); align-items: flex-start;
  padding: var(--hd-space-3) var(--hd-space-4);
  border-radius: var(--hd-radius-sm);
  border-left: 5px solid currentColor;
  margin-bottom: var(--hd-space-4);
  font-size: 1rem;
}
.alert .icon { margin-top: 2px; vertical-align: 0; }
.alert p { margin: 0; color: var(--hd-text); }
.alert strong { font-family: var(--font-heading); }
.alert-error { color: var(--hd-error); background: var(--hd-error-bg); }
.alert-warning { color: var(--hd-warning); background: var(--hd-warning-bg); }
.alert-success { color: var(--hd-success); background: var(--hd-success-bg); }
.alert-info { color: var(--hd-info); background: var(--hd-info-bg); }
/* The most prominent notice (the terms): white on oxford. */
.alert-black { color: #fff; background: var(--hd-oxford); }
.alert-black p, .alert-black a { color: #fff; }
.alert-black a { text-decoration: underline; font-weight: 600; }
.alert-black a:focus-visible { outline-color: #fff; }

/* Notification banner: page-level news at the top of the main content. Important (deep blue) or success (green). */
.notification-banner { border: 2px solid var(--hd-info); border-radius: var(--hd-radius-sm); background: var(--hd-surface); overflow: hidden; margin-bottom: var(--hd-space-6); }
.notification-banner-header { background: var(--hd-info); color: #fff; padding: 6px var(--hd-space-4); }
.notification-banner-title { margin: 0; font-family: var(--font-body); font-weight: 700; font-size: var(--wfp-text-label); color: #fff; }
.notification-banner-content { padding: var(--hd-space-3) var(--hd-space-4); }
.notification-banner-content > :last-child { margin-bottom: 0; }
.notification-banner-heading { font-family: var(--font-heading); font-weight: 700; font-size: var(--hd-text-h3); margin: 0 0 var(--hd-space-2); }
.notification-banner-success { border-color: var(--hd-success); }
.notification-banner-success .notification-banner-header { background: var(--hd-success); }

/* Warning callout ("check this figure"): peach with an amber edge and a heading. */
.warning-callout { background: var(--hd-warning-bg); border: 1px solid var(--hd-amber); border-radius: var(--hd-radius-sm); padding: var(--hd-space-4) var(--hd-space-5); margin-bottom: var(--hd-space-6); }
.warning-callout-heading { font-family: var(--font-body); font-weight: 700; font-size: 1rem; color: var(--hd-warning); margin: 0 0 var(--hd-space-1); }
.warning-callout > :last-child { margin-bottom: 0; }

/* Inset text: a quote, an example or extra detail, set apart by a rule. */
.inset-text { border-left: 5px solid var(--hd-border); padding: var(--hd-space-2) 0 var(--hd-space-2) var(--hd-space-4); margin: 0 0 var(--hd-space-6); color: var(--hd-text-soft); }
.inset-text > :last-child { margin-bottom: 0; }

/* Scope banner: what this person sees ("You see Medicine."). Sits under the top bar. */
.scope-banner { display: flex; flex-wrap: wrap; gap: var(--hd-space-2) var(--hd-space-3); align-items: center; background: var(--hd-tint-blue); color: var(--hd-text); padding: var(--hd-space-2) var(--gutter); font-size: .92rem; }
.scope-banner a { color: var(--hd-deep-blue); }

/* ================================================================ Status tags */
/* One vocabulary, always a word with its colour (see design-standard.md). Older .badge classes map on. */
.tag, .badge {
  display: inline-flex; align-items: center; gap: var(--hd-space-1);
  padding: 2px 10px;
  border-radius: var(--wfp-tag-radius);
  font-family: var(--font-body);
  font-size: var(--wfp-text-badge);
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: .01em;
  white-space: nowrap;
  background: var(--hd-grey-bg);
  color: var(--hd-text-soft);
  vertical-align: middle;
}
.tag .icon, .badge .icon { width: 16px; height: 16px; vertical-align: -3px; }
.tag-grey, .badge-muted { background: var(--hd-grey-bg); color: var(--hd-text-soft); }
.tag-blue, .badge-info { background: var(--hd-info-bg); color: var(--hd-info); }
.tag-green, .badge-success { background: var(--hd-success-bg); color: var(--hd-success); }
.tag-amber, .badge-warning { background: var(--hd-warning-bg); color: var(--hd-warning); }
.tag-red, .badge-error { background: var(--hd-error-bg); color: var(--hd-error); }
.tag-pink { background: var(--hd-tint-pink); color: var(--hd-cerise-dark); }
.tags { display: inline-flex; flex-wrap: wrap; gap: var(--hd-space-2); }

/* "Not shown": a figure outside the person's parts. Never 0 or blank; the reason is read out and shown on hover. */
.not-shown { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--hd-space-1) var(--hd-space-2); }
.not-shown-reason { color: var(--hd-muted); font-size: var(--wfp-text-hint); }

/* ================================================================ Tables (table standard) */
/* 15px text, compact 40px rows, header in the heading face on the table-head fill with a 2px rule, sticky header,
   numbers right aligned in tabular figures, units in the header not the cells. */
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--hd-border); border-radius: var(--hd-radius); background: var(--hd-surface); margin-bottom: var(--hd-space-5); }
/* A scroll box with the header kept in view: for long tables. */
.table-wrap.table-scroll-y { max-height: 70vh; overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--hd-table-text-size); font-variant-numeric: lining-nums; }
table.data caption { text-align: left; font-family: var(--font-heading); font-weight: 700; font-size: var(--hd-text-h3); color: var(--hd-heading); padding: var(--hd-space-3) var(--hd-space-3) var(--hd-space-2); }
table.data thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--hd-table-header-fill);
  color: var(--hd-text-soft);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: .88rem;
  text-align: left;
  text-transform: var(--hd-ui-case);
  vertical-align: bottom;
  padding: 9px var(--hd-space-3);
  border-bottom: 2px solid var(--hd-border);
  white-space: nowrap;
}
table.data td { padding: 6px var(--hd-space-3); border-bottom: 1px solid var(--hd-border); height: var(--hd-table-row-height); vertical-align: middle; }
table.data tbody th, table.data tfoot th { position: static; background: transparent; text-align: left; font-family: var(--font-body); font-weight: 600; font-size: inherit; white-space: normal; padding: 6px var(--hd-space-3); border-bottom: 1px solid var(--hd-border); color: var(--hd-text); }
table.data tfoot th, table.data tfoot td { font-weight: 700; background: var(--hd-surface); border-top: 2px solid var(--hd-border); }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--hd-tint-sky); }
table.data tbody tr:hover a:not(.btn) { color: var(--hd-cerise-dark); }
table.data tr.selected { background: var(--hd-tint-pink); box-shadow: inset 3px 0 0 var(--hd-primary); }
table.data td.changed { background: var(--hd-tint-peach); box-shadow: inset 3px 0 0 var(--hd-amber); }
table.data td.invalid { box-shadow: inset 0 0 0 2px var(--hd-error); }
table.data th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.group-row th { background: var(--hd-grey-bg); font-size: .88rem; padding: 6px var(--hd-space-3); }
body.compact table.data td { height: 36px; }
/* One line per record: the table scrolls in its box rather than squeezing a column. */
table.data.data-nowrap td, table.data.data-nowrap tbody th { white-space: nowrap; }
/* NHS-style stacked rows for short tables on a phone: each cell becomes "label: value" (cells carry data-label). */
@media (max-width: 639px) {
  table.data.data-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.data.data-stack, table.data.data-stack tbody, table.data.data-stack tr, table.data.data-stack td, table.data.data-stack tbody th { display: block; width: 100%; }
  table.data.data-stack tr { border-bottom: 2px solid var(--hd-border); padding: var(--hd-space-2) 0; }
  table.data.data-stack td, table.data.data-stack tbody th { display: flex; justify-content: space-between; gap: var(--hd-space-3); height: auto; border: 0; padding: 4px var(--hd-space-3); text-align: right; }
  table.data.data-stack td::before, table.data.data-stack tbody th::before { content: attr(data-label); font-weight: 700; text-align: left; color: var(--hd-text-soft); }
}

/* Wide tables: one style for every scrolling table area (table-scroll.js). */
.scroll-frame { position: relative; margin-bottom: var(--hd-space-5); }
.scroll-frame > .scroll-area { position: relative; }
.scroll-frame > .scroll-area > .table-wrap, .scroll-frame > .scroll-area > [data-scroll-x] { margin-bottom: 0; }
.scroll-controls { display: none; justify-content: flex-end; gap: var(--hd-space-1); margin-bottom: var(--hd-space-1); }
.scroll-frame.scrolls > .scroll-controls { display: flex; }
.scroll-button { min-width: 32px; min-height: 28px; padding: 0 var(--hd-space-2); border: 1px solid var(--hd-border-input); border-radius: var(--hd-radius-pill); background: var(--hd-surface); color: var(--hd-text); font-size: 18px; line-height: 1; cursor: pointer; }
.scroll-button:hover:not(:disabled) { background: var(--hd-grey-bg); }
.scroll-button:disabled { opacity: .4; cursor: default; }
.scroll-frame > .scroll-area::before, .scroll-frame > .scroll-area::after { content: ""; position: absolute; top: 1px; bottom: 14px; width: 18px; pointer-events: none; opacity: 0; transition: opacity var(--wfp-motion); z-index: 3; }
.scroll-frame > .scroll-area::before { left: 1px; background: linear-gradient(to right, rgba(16, 17, 49, .18), rgba(16, 17, 49, 0)); border-radius: var(--hd-radius) 0 0 var(--hd-radius); }
.scroll-frame > .scroll-area::after { right: 1px; background: linear-gradient(to left, rgba(16, 17, 49, .18), rgba(16, 17, 49, 0)); border-radius: 0 var(--hd-radius) var(--hd-radius) 0; }
.scroll-frame.more-left > .scroll-area::before, .scroll-frame.more-right > .scroll-area::after { opacity: 1; }
.scroll-frame.scrolls .table-wrap, .scroll-frame.scrolls [data-scroll-x] { scrollbar-width: auto; scrollbar-color: var(--hd-muted) var(--hd-bg); }
.scroll-frame.scrolls .table-wrap::-webkit-scrollbar { height: 12px; }
.scroll-frame.scrolls .table-wrap::-webkit-scrollbar-thumb { background: var(--hd-muted); border-radius: 6px; }
.scroll-frame.scrolls .table-wrap::-webkit-scrollbar-track { background: var(--hd-bg); }
.row-actions { display: flex; gap: var(--hd-space-1); justify-content: flex-end; white-space: nowrap; }
.legend-item { min-height: 26px; }

/* ================================================================ Summary list (check answers, record facts) */
.summary-list { margin: 0 0 var(--hd-space-6); }
.summary-list-row { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(0, 2fr) auto; gap: var(--hd-space-4); border-bottom: 1px solid var(--hd-border); padding: 9px 0; }
.summary-list-row:first-child { padding-top: 0; }
.summary-list dt { font-weight: 700; }
.summary-list dd { margin: 0; overflow-wrap: anywhere; }
.summary-list .summary-list-actions { text-align: right; white-space: nowrap; }
.summary-list.no-actions .summary-list-row { grid-template-columns: minmax(140px, 1fr) minmax(0, 2fr); }
@media (max-width: 639px) {
  .summary-list-row, .summary-list.no-actions .summary-list-row { grid-template-columns: 1fr; gap: var(--hd-space-1); }
  .summary-list .summary-list-actions { text-align: left; }
}
/* Key-value lists (older name): the same look without row elements. */
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0 var(--hd-space-5); margin: 0 0 var(--hd-space-4); font-size: .95rem; }
dl.facts dt { font-weight: 700; padding: 8px 0; border-bottom: 1px solid var(--hd-border); }
dl.facts dd { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--hd-border); }
@media (max-width: 639px) {
  dl.facts { grid-template-columns: 1fr; }
  dl.facts dt { border-bottom: 0; padding-bottom: 0; }
}

/* ================================================================ Task list */
/* Each task: its name (a link while it can be done), an optional hint, and its status as a tag on the right. */
.task-list { list-style: none; margin: 0 0 var(--hd-space-6); padding: 0; border-top: 1px solid var(--hd-border); }
.task-list-item { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: var(--hd-space-2) var(--hd-space-4); padding: var(--hd-space-4) 0; border-bottom: 1px solid var(--hd-border); }
.task-list-name { display: flex; flex-direction: column; gap: var(--hd-space-1); max-width: 60ch; }
.task-list-name > a { font-weight: 700; }
.task-list-hint { color: var(--hd-muted); font-size: var(--wfp-text-hint); }
.task-list-status { display: flex; flex-wrap: wrap; align-items: center; gap: var(--hd-space-2); }
.card > .task-list { border-top: 0; }
.card > .task-list > .task-list-item:first-child { padding-top: var(--hd-space-1); }
.card > .task-list > .task-list-item:last-child { border-bottom: 0; padding-bottom: 0; }

/* ================================================================ Filter panel and chips (MOJ) */
.filter-panel { background: var(--hd-surface); border: 1px solid var(--hd-border); border-radius: var(--hd-radius); padding: var(--hd-space-5); display: flex; flex-direction: column; gap: var(--hd-space-4); }
.filter-panel > h2, .filter-panel-heading { font-size: var(--hd-text-h3); margin: 0; }
.filter-panel .field { margin: 0; }
.filter-panel-fields { display: flex; flex-direction: column; gap: var(--hd-space-4); }
.filter-panel .fieldset-plain { margin: 0; }
.filter-panel-head { display: flex; justify-content: space-between; align-items: center; gap: var(--hd-space-2); }
/* Compact filters (7 Nov 2026, option A): the panel's Hide link; on a phone the sheet's round close button. */
.filter-panel-close { display: inline-flex; align-items: center; min-height: var(--wfp-target-sm); padding: 0 4px; border: 0; background: none; color: var(--hd-link); font: inherit; font-size: .88rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.filter-panel-close:hover { color: var(--hd-oxford); }
.filter-panel-close .icon { display: none; }
.filter-sheet-only, .filter-panel-actions.filter-sheet-only { display: none; }
/* The Filters button in the list toolbar: oxford when the panel is open; the number of filters applied in a pill. */
.filter-toggle[aria-expanded="true"] { background: var(--hd-oxford); border-color: var(--hd-oxford); color: #fff; }
.filter-toggle-count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--hd-radius-pill); background: var(--hd-primary); color: #fff; font-size: .78rem; font-weight: 700; }
@media (scripting: none) {
  .filter-toggle, .filter-panel-close { display: none; }
}
@media (max-width: 899px) {
  /* The phone sheet: the whole screen, a header with the close button, the fields, then the actions at the bottom. */
  .filters-sheet-open .filter-panel { position: fixed; inset: 0; z-index: 85; display: flex; flex-direction: column; gap: 0; padding: 0; border: 0; border-radius: 0; overflow: hidden; }
  .filters-sheet-open .filter-panel-head { padding: var(--hd-space-3) var(--hd-space-4); border-bottom: 1px solid var(--hd-border); }
  .filters-sheet-open .filter-panel-heading { font-size: 1.2rem; }
  .filters-sheet-open .filter-panel-fields { flex: 1 1 auto; overflow: auto; padding: var(--hd-space-4); }
  .filters-sheet-open .filter-panel-actions { flex-direction: column; align-items: stretch; padding: var(--hd-space-3) var(--hd-space-4); border-top: 1px solid var(--hd-border); background: var(--hd-table-header-fill); }
  .filters-sheet-open .filter-panel-actions > a, .filters-sheet-open .filter-panel-actions > .btn-link { align-self: center; min-height: var(--wfp-target); display: inline-flex; align-items: center; }
  .filters-sheet-open .filter-panel-actions .btn-secondary { background: var(--hd-primary); border-color: var(--hd-primary); color: #fff; }
  .filters-sheet-open .filter-sheet-only { display: flex; }
  .filters-sheet-open .filter-panel-close { width: var(--wfp-target); height: var(--wfp-target); justify-content: center; padding: 0; border: 2px solid var(--hd-border-input); border-radius: 50%; background: var(--hd-surface); color: var(--hd-text); }
  .filters-sheet-open .filter-panel-close .icon { display: block; width: 20px; height: 20px; }
  .filters-sheet-open .filter-panel-close-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  body.filter-sheet-lock { overflow: hidden; }
}
.filter-panel-actions { display: flex; flex-wrap: wrap; gap: var(--hd-space-2) var(--hd-space-4); align-items: center; }
/* Filter bars (older pattern, kept for wide pages): labels above the controls. */
.posts-bar, .filter-bar { display: flex; flex-wrap: wrap; gap: var(--hd-space-3); align-items: end; margin-bottom: var(--hd-space-5); }
.posts-bar .field, .filter-bar .field { margin: 0; }
.posts-bar .field label, .filter-bar .field label { font-size: .88rem; }
.posts-bar .field .input, .posts-bar .field .select, .filter-bar .field .input, .filter-bar .field .select { min-height: 40px; font-size: .92rem; }
.posts-bar .spacer { margin-left: auto; }
.list-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--hd-space-3); margin: 0 0 var(--hd-space-4); }
/* The result count and a removable chip for each filter in use. */
.filter-summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--hd-space-2) var(--hd-space-3); margin: 0 0 var(--hd-space-4); }
.filter-count { font-weight: 700; margin: 0; }
.filter-chips { display: flex; flex-wrap: wrap; gap: var(--hd-space-2); list-style: none; margin: 0; padding: 0; }
.filter-chip {
  display: inline-flex; align-items: center; gap: var(--hd-space-2); min-height: 36px; padding: 2px 6px 2px 12px;
  border: 2px solid var(--hd-border-input); border-radius: var(--hd-radius-pill); background: var(--hd-surface); color: var(--hd-text);
  font: inherit; font-size: var(--hd-text-small); font-weight: 600; cursor: pointer; text-decoration: none;
}
.filter-chip:hover { background: var(--hd-grey-bg); border-color: var(--hd-oxford); color: var(--hd-text); }
.filter-chip:focus-visible { outline: none; box-shadow: var(--hd-focus-ring); }
.filter-chip .icon { width: 22px; height: 22px; padding: 4px; border-radius: 50%; background: var(--hd-grey-bg); vertical-align: 0; }
.filter-chip strong { font-weight: 600; }

/* ================================================================ Navigation within a page */
/* Breadcrumbs: on every page below the top level, above the caption. */
.crumbs-trail, .crumbs { display: flex; flex-wrap: wrap; gap: var(--hd-space-2); list-style: none; margin: 0 0 var(--hd-space-4); padding: 0; font-size: var(--wfp-text-hint); color: var(--hd-muted); }
.crumbs-trail li + li::before, .crumbs li + li::before { content: "/"; margin-right: var(--hd-space-2); color: var(--hd-muted); }
.crumbs-trail a, .crumbs a { color: var(--hd-link); }
.crumbs-trail [aria-current] { color: var(--hd-muted); }

/* Back link: question pages only, above the content. */
.back-link { display: inline-flex; align-items: center; gap: var(--hd-space-1); min-height: 24px; margin: 0 0 var(--hd-space-4); font-size: .92rem; color: var(--hd-text); }
.back-link .icon { width: 16px; height: 16px; vertical-align: 0; }
.back-link:hover { color: var(--hd-link); }

/* Tabs: two to four views of the same thing. Current: a 3px cerise underline. */
.tabs { display: flex; gap: var(--hd-space-6); border-bottom: 1px solid var(--hd-border); margin-bottom: var(--hd-space-6); overflow-x: auto; }
.tabs a, .tabs button[role="tab"] {
  display: inline-flex; align-items: center; min-height: var(--wfp-target);
  padding: var(--hd-space-2) 0; margin-bottom: -1px; border: 0; border-bottom: 3px solid transparent; background: none;
  color: var(--hd-text); text-decoration: none; font-family: var(--font-heading); font-weight: 700; font-size: 1rem; white-space: nowrap; cursor: pointer;
  text-transform: var(--hd-ui-case);
}
.tabs a:hover, .tabs button[role="tab"]:hover { color: var(--hd-cerise-dark); }
.tabs a[aria-current="page"], .tabs button[role="tab"][aria-selected="true"] { border-bottom-color: var(--hd-primary); color: var(--hd-cerise-dark); }
[role="tabpanel"]:focus-visible { outline-offset: 6px; }

/* Side menu of a record (Case) page: grouped links, current item with a cerise edge on pink. */
.side-menu { font-size: .92rem; }
.side-menu-heading { margin: var(--hd-space-4) 0 var(--hd-space-1); font-family: var(--font-body); font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--hd-muted); }
.side-menu-heading:first-child { margin-top: 0; }
.side-menu ul { list-style: none; margin: 0; padding: 0; }
.side-menu a { display: flex; justify-content: space-between; gap: var(--hd-space-2); min-height: 36px; align-items: center; padding: 6px 12px; color: var(--hd-text); text-decoration: none; border-left: 4px solid transparent; font-weight: 500; }
.side-menu a:hover { background: var(--hd-grey-bg); }
.side-menu a[aria-current="page"] { border-left-color: var(--hd-primary); background: var(--hd-tint-pink); color: var(--hd-cerise-dark); font-weight: 700; }

/* Pager: a count, page links and how many a page. */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--hd-space-3); margin: var(--hd-space-3) 0; }
.pager-count { margin: 0; font-size: .95rem; color: var(--hd-text-soft); }
.pager-pages { display: flex; flex-wrap: wrap; align-items: center; gap: var(--hd-space-1); list-style: none; margin: 0; padding: 0; }
.pager-pages button { min-width: 36px; min-height: 36px; padding: 0 var(--hd-space-2); border: 1px solid transparent; border-radius: 6px; background: none; color: var(--hd-text); font: inherit; font-size: .95rem; cursor: pointer; }
.pager-pages button:hover { background: var(--hd-grey-bg); }
.pager-pages button[aria-current="page"] { background: var(--hd-oxford); color: #fff; font-weight: 700; }
.pager-pages button[disabled] { opacity: .55; cursor: not-allowed; background: none; }
.pager-pages .gap { padding: 0 var(--hd-space-1); color: var(--hd-muted); }
.pager-size { display: inline-flex; align-items: center; gap: var(--hd-space-1); font-size: .95rem; }
.pager-size button { min-height: 32px; padding: 0 var(--hd-space-2); border: 1px solid transparent; border-radius: var(--hd-radius-pill); background: none; font: inherit; cursor: pointer; color: var(--hd-text); }
.pager-size button:hover { background: var(--hd-grey-bg); }
.pager-size button[aria-pressed="true"] { border-color: var(--hd-oxford); font-weight: 700; }

/* Current view in a row of link buttons. */
.editor-actions a[aria-current="page"], nav.view-links a[aria-current="page"] { background: var(--hd-oxford); color: #fff; border-color: var(--hd-oxford); }

/* ================================================================ Menus, dialogs, toasts */
/* Dropdown menus built on details/summary, so they work without JavaScript. */
.menu { position: relative; }
.menu > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: var(--hd-space-2);
  min-height: var(--wfp-target-sm); padding: 0 var(--hd-space-4); border-radius: var(--hd-radius-pill);
  font-family: var(--font-heading); font-weight: 700; font-size: .88rem; color: var(--hd-text);
  border: 2px solid var(--hd-border-input); background: var(--hd-surface);
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { background: var(--hd-grey-bg); }
.menu > summary:focus-visible { outline: none; box-shadow: var(--hd-focus-ring); }
.menu > summary .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.menu > summary[aria-label="Account menu"] .label { max-width: 160px; }
@media (max-width: 1279px) { .menu > summary .label { max-width: 160px; } .menu > summary[aria-label="Account menu"] .label { max-width: 110px; } }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + var(--hd-space-2)); min-width: 240px;
  background: var(--hd-surface); border: 1px solid var(--hd-border); border-radius: var(--hd-radius); box-shadow: var(--hd-shadow-md);
  padding: var(--hd-space-2); z-index: 60;
}
.menu-panel a, .menu-panel button {
  display: flex; align-items: center; gap: var(--hd-space-2); width: 100%; min-height: 40px; padding: var(--hd-space-2) var(--hd-space-3);
  border: 0; background: none; border-radius: var(--hd-radius-sm); color: var(--hd-text); text-decoration: none; font: inherit; font-size: .92rem; text-align: left; cursor: pointer;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--hd-grey-bg); }
.menu-panel .current { font-weight: 700; }
.menu-panel hr { border: 0; border-top: 1px solid var(--hd-border); margin: var(--hd-space-2) 0; }
/* Walkthrough fix (8 Nov 2026): a menu is as wide as its longest item needs, up to 380px and never past the screen's
   edge; an item with a hint has the hint under its label, not squeezed into a column beside it. */
.menu-panel { width: max-content; max-width: min(380px, calc(100vw - 2 * var(--hd-space-4))); }
.menu-panel a:has(> .menu-hint), .menu-panel button:has(> .menu-hint) { flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; }
.menu-label { padding: var(--hd-space-2) var(--hd-space-3); font-size: 13px; color: var(--hd-muted); margin: 0; }
/* A record's actions and saved views in one menu beside its title. */
.page-more { flex: none; }
.page-more-panel { min-width: 300px; display: grid; gap: var(--hd-space-3); padding: var(--hd-space-3); }
.page-more-panel .btn { width: 100%; justify-content: flex-start; }
.page-more-views .views-bar { margin-top: 0; display: grid; gap: var(--hd-space-2); }
.page-more-views .views-bar .select, .page-more-views .views-bar .input { width: 100%; max-width: none; }

dialog.modal { border: 0; border-radius: var(--hd-radius); box-shadow: var(--hd-shadow-md); padding: var(--hd-space-6); max-width: 520px; width: calc(100% - 32px); color: var(--hd-text); }
dialog.modal::backdrop { background: rgba(16, 17, 49, .45); }
dialog.shortcuts .shortcuts-table td { height: 36px; }

.toasts { position: fixed; right: var(--hd-space-4); bottom: var(--hd-space-4); z-index: 90; display: grid; gap: var(--hd-space-2); max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: var(--hd-space-3); align-items: flex-start; background: var(--hd-surface); border: 1px solid var(--hd-border); border-left: 4px solid currentColor; border-radius: var(--hd-radius); box-shadow: var(--hd-shadow-md); padding: var(--hd-space-3) var(--hd-space-4); font-size: .95rem; }
.toast p { margin: 0; color: var(--hd-text); flex: 1; }
.toast button { background: none; border: 0; cursor: pointer; color: var(--hd-muted); padding: 0; }
.toast.error { color: var(--hd-error); }
.toast.success { color: var(--hd-success); }
.toast.info { color: var(--hd-info); }
.toast.warning { color: var(--hd-warning); }

/* ================================================================ Odds and ends */
.progress { height: 10px; background: var(--hd-grey-bg); border-radius: var(--hd-radius-pill); overflow: hidden; min-width: 120px; }
.progress > span { display: block; height: 100%; background: var(--wfp-progress); border-radius: var(--hd-radius-pill); transition: width var(--wfp-motion); }
.empty { text-align: left; padding: var(--hd-space-8) var(--hd-space-6); border: 1px dashed var(--hd-border-input); border-radius: var(--hd-radius); background: var(--hd-surface); }
.empty h2 { color: var(--hd-heading); }
/* Results folded away under a heading. "Help with this page" uses the same details. */
details.results-fold > summary, details.help-details > summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; color: var(--hd-link); }
details.results-fold > summary .h3-like { font-family: var(--font-heading); font-weight: 700; font-size: var(--hd-text-h3); color: var(--hd-heading); }
details.results-fold[open] > summary { margin-bottom: var(--hd-space-4); }
details.help-details { margin: 0 0 var(--hd-space-5); }
details.help-details > summary { text-decoration: underline; text-underline-offset: 3px; }
details.help-details > div { border-left: 5px solid var(--hd-border); padding: var(--hd-space-2) 0 var(--hd-space-2) var(--hd-space-4); margin-top: var(--hd-space-2); }
.qr { width: 200px; height: 200px; border: 1px solid var(--hd-border); border-radius: var(--hd-radius-sm); padding: var(--hd-space-2); background: var(--hd-surface); }
.swatch { height: 56px; border-radius: var(--hd-radius-sm); border: 1px solid var(--hd-border); }

/* ================================================================ Case pages (Forecasts and Scenarios, 7 Nov 2026) */
/* The record header's Actions menu: each action with a hint; Delete last, in red. */
.case-actions > summary { min-height: var(--wfp-target); padding: 0 var(--hd-space-5); font-size: .95rem; }
.case-actions-panel { min-width: 300px; }
.case-actions-panel a, .case-actions-panel button { flex-direction: column; align-items: flex-start; gap: 0; }
.case-actions-hint { color: var(--hd-muted); font-size: var(--wfp-text-hint); font-weight: 400; }
.case-actions-panel .case-actions-danger { color: var(--hd-error); }
/* The side menu; on a phone a "Contents" disclosure at the top. On wide screens the disclosure is always open. */
.case-contents > summary { display: none; }
.case-menu-count { color: var(--hd-muted); font-weight: 500; font-size: var(--wfp-text-hint); }
.side-menu a[aria-current="page"] .case-menu-count { color: inherit; }
.case-main { display: flex; flex-direction: column; gap: var(--hd-space-4); }
.case-main > .tabs { margin: 0; }
.case-section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: var(--hd-space-3) var(--hd-space-5); }
.case-section-head h3 { margin: 0; }
.case-main .views-bar { margin: 0; }
/* The Overview. */
.case-does { border-top: 4px solid var(--hd-accent); }
.case-does h3, .case-setup h3 { margin-top: 0; }
.case-overview-figures { display: flex; flex-direction: column; gap: var(--hd-space-3); }
.case-overview-chart { display: flex; flex-direction: column; gap: var(--hd-space-4); }
.case-overview-chart .field { margin: 0; }
/* Where posts end up (8 Nov 2026): each check count is a filter. */
.where-checks { margin-bottom: var(--hd-space-4); }
.where-check { text-align: left; font: inherit; cursor: pointer; border: 1px solid var(--hd-border); }
.where-check[aria-pressed="true"] { border-color: var(--hd-oxford); box-shadow: inset 0 0 0 1px var(--hd-oxford); }
.case-setup .summary-list { margin-bottom: 0; }
/* Known changes: the toolbar's view and Group by on the right, the count and chips on their own line under it. */
.known-changes .l-list-toolbar { align-items: flex-end; }
.known-changes .l-list-toolbar > .known-summary-line { order: 3; flex: 1 0 100%; }
.known-changes .known-group { margin: 0 0 0 auto; }
.known-changes .known-group label { display: block; font-weight: 700; font-size: var(--wfp-text-label); }
.known-changes .known-summary-line .filter-summary { margin: 0; }
@media (max-width: 899px) {
  .case-contents { background: var(--hd-surface); border: 1px solid var(--hd-border); border-radius: var(--hd-radius); }
  .case-contents > summary { display: flex; align-items: center; justify-content: space-between; gap: var(--hd-space-2); min-height: 48px; padding: var(--hd-space-2) var(--hd-space-4); cursor: pointer; list-style: none; font-family: var(--font-heading); }
  .case-contents > summary::-webkit-details-marker { display: none; }
  .case-contents[open] > summary .icon { transform: rotate(180deg); }
  .case-contents .case-menu { padding: 0 var(--hd-space-2) var(--hd-space-3); }
  .case-contents .side-menu a { min-height: var(--wfp-target); }
  .case-header .page-header-actions, .case-actions, .case-actions > summary { width: 100%; }
  .case-actions > summary { justify-content: center; }
  .case-actions .menu-panel { position: absolute; left: 0; right: 0; top: calc(100% + var(--hd-space-2)); min-width: 0; width: auto; max-width: none; }
  .known-changes .known-group { margin-left: 0; }
}
@media (min-width: 640px) { .case-setup .summary-list-row { grid-template-columns: minmax(140px, 1fr) minmax(0, 2.5fr) 11rem; } }
/* The known changes table in the narrower Case page column: the change has room, and the table scrolls in its box. */
.known-table { min-width: 980px; }
.known-table td:nth-child(3) { min-width: 18rem; }
.known-table .select-compact { min-width: 8rem; }
.known-table .input-compact { min-width: 8rem; }

/* ================================================================ Hybrid app design (agreed 8 November 2026) */
/* Pattern sources: Carbon (icon buttons, data table toolbar and batch actions, notifications, empty states, progress,
   modal, side panel), Fluent (command bar), SAP Fiori (dynamic page header). Drawn in Health Dynamics tokens. */

/* Icon buttons: 40px round (44px on a phone), an aria-label, and an oxford tooltip on hover and focus. */
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: var(--wfp-control); height: var(--wfp-control); padding: 0; border: 0; border-radius: var(--hd-radius-pill);
  background: transparent; color: var(--hd-text); cursor: pointer; font: inherit; text-decoration: none; list-style: none;
}
.icon-btn::-webkit-details-marker { display: none; }
.icon-btn:hover { background: var(--wfp-hover); color: var(--hd-text); }
.icon-btn:focus-visible { outline: 3px solid var(--hd-focus-color); outline-offset: 2px; }
.icon-btn .icon { width: 20px; height: 20px; }
[data-tip] { position: relative; }
.icon-btn[data-tip]:hover::after, .icon-btn[data-tip]:focus-visible::after, .icon-seg[data-tip]:hover::after, .icon-seg[data-tip]:focus-visible::after,
.menu > summary[data-tip]:hover::after, .menu > summary[data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 80;
  padding: 6px 10px; border-radius: 6px; background: var(--wfp-tooltip-bg); color: #fff; font-family: var(--font-body);
  font-weight: 600; font-size: .78rem; line-height: 1.3; white-space: nowrap; pointer-events: none; box-shadow: var(--hd-shadow-md);
}
.site-header > .rail-toggle[data-tip]:hover::after, .site-header > .rail-toggle[data-tip]:focus-visible::after { left: 0; transform: none; }
.header-actions > :last-child [data-tip]:hover::after, .header-actions > :last-child [data-tip]:focus-visible::after { left: auto; right: 0; transform: none; }
.menu.open > summary[data-tip]::after, details[open] > summary[data-tip]::after { display: none; }

/* Toolbar controls: compact, 40px, one row (two density levels: compact for toolbars and tables, regular for forms). */
.page-toolbar .btn, .table-toolbar .btn { min-height: var(--wfp-control); padding: 0 14px; font-size: .85rem; border-width: 1px; }
.page-toolbar .btn .icon, .case-line .btn .icon { width: 18px; height: 18px; }
.page-toolbar .select, .page-toolbar .input, .table-toolbar .select { min-height: var(--wfp-control); }
.page-toolbar .seg-btn, .table-toolbar .seg-btn { min-height: var(--wfp-control); padding: 4px 12px; font-size: .85rem; border-width: 1px; }
.page-toolbar .filter-bar, .page-toolbar .view-settings { margin: 0; gap: 6px var(--hd-space-2); align-items: center; flex-wrap: wrap; }
/* In the toolbar a control's label sits inside the pill, before its value (compact select). */
.page-toolbar .field { margin: 0; display: inline-flex; align-items: center; gap: 2px; min-height: var(--wfp-control); padding: 0 2px 0 12px; border: 1px solid var(--hd-border-input); border-radius: var(--hd-radius-pill); background: var(--hd-surface); }
.page-toolbar .field > label, .page-toolbar .pick-field > .field-label { margin: 0; font-weight: 600; font-size: .85rem; color: var(--hd-text-soft); white-space: nowrap; }
.page-toolbar .field .select, .page-toolbar .field .input { border: 0; min-height: 38px; background-color: transparent; font-weight: 700; font-size: .85rem; padding-top: 0; padding-bottom: 0; box-shadow: none; }
.page-toolbar .field .select:focus-visible, .page-toolbar .field .input:focus-visible { box-shadow: var(--hd-focus-ring); border-radius: var(--hd-radius-pill); }
.page-toolbar .filter-toggle { gap: 6px; }
.page-toolbar .pick-field > .pick-menu > summary { border: 0; min-height: 38px; background: transparent; font-weight: 700; font-size: .85rem; }
.page-toolbar .field .select { width: auto; min-width: 0; max-width: 16rem; }
.page-toolbar .seg-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.toolbar-divider { width: 1px; height: 24px; background: var(--hd-border); margin: 0 var(--hd-space-1); flex: none; }
.toolbar-more > summary { min-height: 0; padding: 0; border: 0; }
.toolbar-more .menu-panel { right: 0; left: auto; min-width: 260px; }
.toolbar-more .menu-panel a, .toolbar-more .menu-panel button { background: none; border: 0; border-radius: var(--hd-radius-sm); color: var(--hd-text); font-family: var(--font-body); font-weight: 500; font-size: .92rem; min-height: 40px; text-align: left; justify-content: flex-start; }
.toolbar-more .menu-panel form { margin: 0; }
.toolbar-more .menu-panel form button { width: 100%; }
.menu-panel .menu-danger { color: var(--hd-error); }
.menu-hint { display: block; color: var(--hd-muted); font-size: var(--wfp-text-hint); font-weight: 400; }

/* Data table toolbar (Carbon data table): the count and chips, then the density switch; the batch bar over it. */
.table-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--hd-space-2) var(--hd-space-3); min-height: var(--wfp-chips-height); }
.table-toolbar .filter-summary { flex: 1 1 auto; margin: 0; }
.table-toolbar-end { display: flex; align-items: center; gap: var(--hd-space-2); margin-left: auto; }
.density-switch .seg-btn.icon-seg { padding: 4px 10px; min-width: 42px; }
.density-switch .icon { width: 18px; height: 18px; }
/* Table density (remembered for the person): standard rows use the design token (40px, the default); compact (36px) is an option (product owner, 8 Nov 2026). */
body[data-density="compact"] table.data td { padding-top: 6px; padding-bottom: 6px; height: var(--wfp-row-compact); }
body[data-density="compact"] table.data th { padding-top: 8px; padding-bottom: 8px; }
body[data-density="regular"] table.data td { padding-top: 9px; padding-bottom: 9px; height: var(--hd-table-row-height); }
/* Row selection. */
table.data .select-cell { width: 44px; padding-right: 0; }
table.data .select-cell input { width: 18px; height: 18px; margin: 0; accent-color: var(--hd-oxford); }
table.data tr.is-selected td { background: var(--hd-tint-blue); }
/* The batch action bar: oxford with white text, above the table while rows are ticked. */
.batch-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--hd-space-2) var(--hd-space-3); min-height: var(--wfp-toolbar-height); padding: 6px var(--hd-space-4); background: var(--wfp-batch-bg); color: #fff; border-radius: var(--hd-radius-sm) var(--hd-radius-sm) 0 0; }
.batch-bar + .table-wrap { border-top-left-radius: 0; border-top-right-radius: 0; }
.batch-bar-count { font-family: var(--font-heading); }
.batch-bar-grow { flex: 1 1 auto; }
.batch-bar .btn { --btn-bg: transparent; --btn-fg: #fff; --btn-border: rgba(255, 255, 255, .7); min-height: var(--wfp-target-sm); }
.batch-bar .btn:hover { --btn-bg: rgba(255, 255, 255, .14); --btn-border: #fff; }
.batch-bar .btn:focus-visible, .batch-bar .icon-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: none; }
.batch-bar .icon-btn { color: #fff; }
.batch-bar .icon-btn:hover { background: rgba(255, 255, 255, .14); }
.batch-bar .batch-bar-cancel { --btn-border: transparent; }

/* Inline notification (Carbon): about this page, an icon and a title in the alert tints, 8px radius. */
.inline-notification { display: flex; gap: var(--hd-space-3); align-items: flex-start; padding: var(--hd-space-3) var(--hd-space-4); border-radius: var(--hd-radius-sm); border-left: 4px solid currentColor; background: var(--hd-info-bg); color: var(--hd-info); margin: 0 0 var(--hd-space-4); }
.inline-notification > .icon { flex: none; margin-top: 2px; }
.inline-notification-text { color: var(--hd-text); }
.inline-notification-text > * { margin: 0; }
.inline-notification-title { font-weight: 700; }
.inline-notification-success { background: var(--hd-success-bg); color: var(--hd-success); }
.inline-notification-warning { background: var(--hd-warning-bg); color: var(--hd-warning); }
.inline-notification-error { background: var(--hd-error-bg); color: var(--hd-error); }
.toast a { color: var(--hd-link); }

/* Empty state (Carbon): an outline icon in a grey circle, an h3, one plain sentence and one action. */
.empty-state { display: flex; flex-direction: column; align-items: flex-start; gap: var(--hd-space-3); padding: var(--hd-space-8) var(--hd-space-6); background: var(--hd-surface); border: 1px solid var(--hd-border); border-radius: var(--hd-radius); }
.empty-state-icon { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 50%; background: var(--hd-grey-bg); color: var(--hd-text-soft); }
.empty-state-icon .icon { width: 26px; height: 26px; }
.empty-state h3, .empty-state p { margin: 0; }
.empty-state p { max-width: 60ch; color: var(--hd-text-soft); }

/* Progress (Fluent progress bar, Carbon progress indicator): deep blue on grey, a line in words under it. */
.progress-block { display: flex; flex-direction: column; gap: var(--hd-space-2); }
.progress-label { margin: 0; font-weight: 700; }
.progress-description { margin: 0; color: var(--hd-text-soft); font-size: var(--wfp-text-hint); }
.progress.is-indeterminate > span { width: 30% !important; animation: wfp-progress 1.4s ease-in-out infinite; }
@keyframes wfp-progress { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) { .progress.is-indeterminate > span { animation: none; width: 100% !important; opacity: .45; } }
.progress-steps { display: flex; flex-wrap: wrap; gap: var(--hd-space-2) var(--hd-space-6); list-style: none; margin: 0 0 var(--hd-space-5); padding: 0; }
.progress-step { display: flex; align-items: center; gap: var(--hd-space-2); font-family: var(--font-heading); font-weight: 700; font-size: .9rem; color: var(--hd-muted); }
.progress-step-mark { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; border: 2px solid currentColor; }
.progress-step-mark .icon { width: 14px; height: 14px; }
.progress-step.is-done { color: var(--hd-success); }
.progress-step.is-done .progress-step-mark { background: var(--hd-success); border-color: var(--hd-success); color: #fff; }
.progress-step.is-current { color: var(--hd-deep-blue); }
.progress-step.is-current .progress-step-mark { box-shadow: inset 0 0 0 4px var(--hd-surface); background: var(--hd-deep-blue); }
.progress-step.is-current .progress-step-label { color: var(--hd-text); }

/* Modal dialog (Carbon modal): only to confirm what cannot be undone. 12px radius, oxford title. */
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--hd-space-3); margin: calc(-1 * var(--hd-space-2)) calc(-1 * var(--hd-space-2)) var(--hd-space-3) 0; }
.modal-title { margin: 0; font-size: var(--hd-text-h2); color: var(--hd-heading); }
.modal-body > :first-child { margin-top: 0; }
.modal-actions { display: flex; flex-wrap: wrap; gap: var(--hd-space-3); margin-top: var(--hd-space-6); }

/* Stat tiles: oxford figures (cerise is for the one primary action); deep blue for progress. */
.stat-tile .stat { color: var(--wfp-stat); }

/* The Case page's header (15 Nov 2026): one slim line under the top bar, kept in view, that never changes height as the
   page scrolls: the kind, what it is based on, the tags with the calculated chip, then Compare and More. */
.case-line {
  position: sticky; top: var(--wfp-topbar-height); z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--hd-space-3);
  min-height: var(--wfp-toolbar-height);
  margin: calc(-1 * var(--main-pad-top)) calc(-1 * var(--main-pad-x)) var(--hd-space-5);
  padding: 6px var(--main-pad-x);
  background: var(--hd-surface); border-bottom: 1px solid var(--hd-border);
}
.case-line-text { display: flex; flex-wrap: nowrap; align-items: center; gap: 4px var(--hd-space-3); flex: 1 1 320px; min-width: 0; }
.case-line-text > * { margin: 0; }
.case-line .tags { display: flex; flex-wrap: nowrap; align-items: center; gap: var(--hd-space-1); flex: 0 0 auto; }
/* What it is based on gives way first (shortened with its full text on hover), so the line stays one line. */
.case-line .page-header-meta { color: var(--hd-text-soft); font-size: .88rem; flex: 0 1 auto; min-width: 4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case-line .btn { min-height: var(--wfp-control); padding: 0 14px; font-size: .85rem; border-width: 1px; }
.case-line-actions { display: flex; align-items: center; gap: var(--hd-space-2); margin-left: auto; }
.case-actions-bar { display: flex; align-items: center; gap: var(--hd-space-2); }
/* The chip's place holds its line, so it never wraps the header onto a second line as it changes. */
.case-line .calc-line-chip { flex-wrap: nowrap; white-space: nowrap; }
@media (max-width: 899px) {
  .case-line { position: static; }
  .case-line-text, .case-line .tags { flex-wrap: wrap; }
  /* On a phone the tags and the chip wrap within the width rather than push the page sideways. */
  .case-line .tags { flex: 1 1 100%; min-width: 0; }
  .case-line .tags > *, .case-line .calc-line-chip > * { min-width: 0; max-width: 100%; }
  .case-line .page-header-meta { white-space: normal; }
  .case-line .calc-line-chip { flex-wrap: wrap; white-space: normal; }
  .case-line .calc-line-chip .tag, .case-line .calc-chip > summary { white-space: normal; }
  .case-line-actions { margin-left: 0; }
}

/* One toolbar line per Case page (15 Nov 2026): the page's views as a segmented control, its view settings and action on the right. */
.case-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--hd-space-2) var(--hd-space-3); min-height: var(--wfp-toolbar-height); padding-bottom: var(--hd-space-2); border-bottom: 1px solid var(--hd-border); }
.case-views .seg-btn { min-height: var(--wfp-control); padding: 0 var(--hd-space-3); font-size: .85rem; border-width: 1px; }
.case-notes:empty { display: none; }
.case-saved-views > summary { min-height: var(--wfp-control); padding: 0 var(--hd-space-3); font-size: .85rem; border-width: 1px; }
.case-saved-views .menu-panel { width: min(420px, calc(100vw - 2 * var(--hd-space-4))); }
.case-saved-views .views-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--hd-space-2); }
.case-saved-views .views-bar .select, .case-saved-views .views-bar .input { flex: 1 1 12rem; }
.case-saved-views .menu-panel .views-bar button { width: auto; min-height: var(--wfp-control); padding: 0 14px; border: 1px solid var(--hd-border-input); border-radius: var(--hd-radius-pill); font-family: var(--font-heading); font-weight: 700; font-size: .85rem; }
/* The empty state of a results page with no figures yet (the CalcStates board): shown once, in place of the page. */
.calc-empty { margin: var(--hd-space-4) 0; }

/* The structure canvas (8 Nov 2026): the picture fills the page, with zoom and the key floating on it. */
.canvas-float { position: absolute; z-index: 5; background: var(--hd-surface); border: 1px solid var(--hd-border); border-radius: var(--hd-radius); box-shadow: 0 12px 32px rgba(16, 17, 49, .10); }

@media (max-width: 639px) {
  .page-toolbar .field > label { display: none; }
  .page-toolbar .field { padding-left: 4px; }
  .page-toolbar .field .select { max-width: 9.5rem; }
  .page-toolbar-end { margin-left: 0; }
}

/* Side panel (Carbon), unified rules (8 Nov 2026): "Why does this number look like this?" beside the figures. */
.side-panel { position: fixed; top: var(--wfp-topbar-height); right: 0; bottom: 0; width: min(420px, 100vw); background: var(--hd-surface); border-left: 1px solid var(--hd-border); box-shadow: var(--hd-shadow-md); z-index: 46; display: flex; flex-direction: column; }
.side-panel-head { display: flex; justify-content: space-between; align-items: center; gap: var(--hd-space-2); min-height: var(--wfp-toolbar-height); padding: var(--hd-space-2) var(--hd-space-2) var(--hd-space-2) var(--hd-space-5); border-bottom: 1px solid var(--hd-border); }
.side-panel-title { margin: 0; font-size: 1rem; }
.side-panel-body { padding: var(--hd-space-4) var(--hd-space-5) var(--hd-space-8); overflow-y: auto; display: flex; flex-direction: column; gap: var(--hd-space-4); font-size: .9rem; }
.side-panel-body h3 { font-size: .95rem; margin: 0 0 var(--hd-space-2); }
.why-subject { display: grid; grid-template-columns: 1fr 1fr; gap: var(--hd-space-2) var(--hd-space-3); }
.why-subject .field { margin: 0; }
.why-subject .field:last-child { grid-column: 1 / -1; }
.why-rules { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--hd-space-3); }
.why-rule { border: 1px solid var(--hd-border); border-radius: 8px; padding: var(--hd-space-3); }
.why-rule p { margin: 0 0 var(--hd-space-1); }
.why-rule-head { display: flex; flex-wrap: wrap; gap: var(--hd-space-1); align-items: center; }
[data-why] { cursor: help; }
.rules-table tr.is-muted td { color: var(--hd-text-muted, #6b7280); }
.rule-preset-group { margin-bottom: var(--hd-space-5); }
.rule-preset-family { font-weight: 700; font-size: 1.05rem; margin-bottom: var(--hd-space-2); }
.rule-post-list { max-height: 260px; overflow-y: auto; }
