/* ── Shared components (CLAUDE.md 12, 32): every state styled from tokens; pages add no CSS of their own ── */

/* ── Icons (Lucide sprite) ── */
.icon {
  display: inline-block;
  flex: none;
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}

.icon-sm {
  width: 14px;
  height: 14px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-h);
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: background-color var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease), transform var(--motion-fast) var(--ease);
}

.btn:hover {
  border-color: var(--color-border-hover);
  background: var(--color-surface-2);
  box-shadow: var(--shadow-btn-hover);
}

.btn .icon {
  width: 16px;
  height: 16px;
}

.btn:active {
  transform: translateY(1px);
}

/* a solid outline (at least 3:1, WCAG 1.4.11) with the soft halo around it */
.btn:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  box-shadow: var(--focus-ring);
}

.btn-primary {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: var(--color-on-accent);
}

.btn-primary:hover {
  border-color: var(--color-primary-hover);
  background: var(--color-primary-hover);
}

.btn-primary:active {
  border-color: var(--color-primary-active);
  background: var(--color-primary-active);
}

/* tonal: a second action beside the primary one */
.btn-secondary {
  border-color: var(--color-primary-soft-strong);
  background: var(--color-primary-soft);
  color: var(--color-link);
}

.btn-secondary:hover {
  border-color: var(--color-primary-soft-strong);
  background: var(--color-primary-soft-strong);
}

.btn-danger {
  border-color: var(--color-danger);
  background: var(--color-surface);
  color: var(--color-danger);
}

.btn-danger:hover {
  border-color: var(--color-danger);
  background: var(--color-danger-bg);
}

/* filled: the confirming button of a destructive action */
.btn-danger-solid {
  border-color: var(--color-danger);
  background: var(--color-danger);
  color: var(--color-on-danger);
}

.btn-danger-solid:hover {
  border-color: var(--color-danger-strong);
  background: var(--color-danger-strong);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.btn-ghost:hover {
  border-color: transparent;
  background: var(--color-surface-3);
  box-shadow: none;
}

.btn-sm {
  min-height: var(--control-h-sm);
  padding: 0 var(--space-3);
  font-size: var(--fs-sm);
}

.btn-sm .icon {
  width: 14px;
  height: 14px;
}

.btn-lg {
  min-height: var(--control-h-lg);
  padding: 0 var(--space-5);
  font-size: var(--fs-md);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: 0;
  width: var(--control-h);
}

.btn-sm.btn-icon {
  width: var(--control-h-sm);
}

/* joined buttons: one outline, inner corners square */
.btn-group {
  display: inline-flex;
}

.btn-group > .btn {
  border-radius: 0;
}

.btn-group > .btn + .btn {
  margin-left: -1px;
}

.btn-group > .btn:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.btn-group > .btn:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.btn-group > .btn:only-child {
  border-radius: var(--radius-md);
}

.btn-group > .btn:hover,
.btn-group > .btn:focus-visible {
  position: relative;
}

/* disabled: a muted fill from tokens, not opacity, so the label stays readable on every variant */
.btn:disabled,
.btn[aria-disabled="true"] {
  border-color: var(--color-disabled-border);
  background: var(--color-disabled-bg);
  color: var(--color-disabled-text);
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}

.btn-ghost:disabled,
.btn-ghost[aria-disabled="true"] {
  border-color: transparent;
  background: transparent;
}

/* a primary button stays primary while its request runs */
.btn-primary[aria-busy="true"]:disabled {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: var(--color-on-accent);
}

/* busy: set by guardButton() while a request runs */
.btn[aria-busy="true"]::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Form fields ── */
.fld {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

/* a group of ticks posted as one field (fieldset reset; its legend is .fld-label) */
.fld-group {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.fld label,
.fld-label {
  color: var(--color-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

.fldrequired {
  color: var(--color-danger);
}

.fld input,
.fld select,
.fld textarea,
.input {
  width: 100%;
  min-height: var(--control-h);
  padding: var(--space-1) var(--control-px);
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  box-shadow: var(--shadow-btn);
  transition: border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease);
}

.fld input:hover,
.fld select:hover,
.fld textarea:hover,
.input:hover {
  border-color: var(--color-border-input-hover);
}

.fld textarea {
  min-height: 96px;
  padding-top: var(--space-2);
  resize: vertical;
}

.fld input:focus,
.fld select:focus,
.fld textarea:focus,
.input:focus {
  outline: none;
  border-color: var(--color-focus);
  box-shadow: var(--focus-ring);
}

.fld input:disabled,
.fld select:disabled,
.fld textarea:disabled,
.fld input[readonly] {
  border-color: var(--color-border);
  background: var(--color-surface-3);
  color: var(--color-text-muted);
  box-shadow: none;
  cursor: not-allowed;
}

.fld [aria-invalid="true"],
.fld [aria-invalid="true"]:hover {
  border-color: var(--color-danger);
}

.fld [aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px var(--color-danger-bg);
}

.fld input[data-input-filter="decimal"] {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* the browser's file button drawn as the tonal button, in both themes */
.fld input[type="file"] {
  padding: var(--space-1);
  cursor: pointer;
}

.fld input[type="file"]::file-selector-button {
  margin-right: var(--space-3);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-primary-soft-strong);
  border-radius: var(--radius-sm);
  background: var(--color-primary-soft);
  color: var(--color-link);
  font: inherit;
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease);
}

.fld input[type="file"]:hover::file-selector-button {
  background: var(--color-primary-soft-strong);
}

.fld input[type="file"]:disabled::file-selector-button {
  border-color: var(--color-disabled-border);
  background: var(--color-disabled-bg);
  color: var(--color-disabled-text);
  cursor: not-allowed;
}

/* one select arrow in both themes: a chevron drawn from two token-coloured gradients (no image, no literal colour) */
.fld select:not([multiple]),
select.input:not([multiple]) {
  padding-right: calc(var(--control-px) + 20px);
  -webkit-appearance: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--color-text-muted) 50%), linear-gradient(135deg, var(--color-text-muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

/* ticks and choices in the brand colour */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--color-primary);
}

/* one password reveal control: the app's own toggle, never the browser's */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
  display: none;
}

/* the show/hide toggle sits inside the field, so a password field is as wide as the others */
.pwd-field {
  position: relative;
}

.pwd-field input {
  width: 100%;
  padding-right: var(--control-h);
}

.pwd-field .pwd-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  height: calc(var(--control-h) - 2px);
  width: calc(var(--control-h) - 2px);
  border-radius: var(--radius-md);
}

/* sign-in CAPTCHA image: the drawing is light on purpose, so it keeps its own frame in dark mode */
.captcha-img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
}

.fld-help {
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  line-height: var(--lh-base);
}

.fld-error {
  min-height: 0;
  color: var(--color-danger);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
}

.fld-error:empty {
  display: none;
}

.form-error-summary {
  margin-bottom: var(--space-4);
}

.form-error-title {
  margin: 0;
}

/* each invalid field, a link to it */
.form-error-list {
  margin: var(--space-1) 0 0;
  padding-left: var(--space-5);
  font-weight: var(--fw-regular);
}

.form-error-link {
  color: inherit;
  text-decoration: underline;
}

/* ── Alerts (inline messages) ── */
.alert {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  border-left: 4px solid currentColor;
  border-radius: var(--radius-md);
  font-weight: var(--fw-medium);
}

.alert-info {
  background: var(--color-info-bg);
  color: var(--color-info);
}

.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.alert-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.alert-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

/* ── Status pill and badge: always icon or text with colour, never colour alone ── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px 2px 8px;
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  border-radius: var(--radius-pill);
  background: var(--color-neutral-bg);
  color: var(--color-neutral);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: 18px;
  white-space: nowrap;
}

/* a mark before the word: the word carries the meaning; the mark's shape differs per meaning too, so it reads without colour
   (docs/standards/ux_principles.md §8): neutral ring, info circle, success rounded square, warning triangle, danger square */
.pill::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  background: transparent;
}

.pill-info::before {
  background: currentColor;
}

.pill-success::before {
  border-radius: 2px;
  background: currentColor;
  transform: rotate(45deg) scale(0.9);
}

.pill-warning::before {
  width: 8px;
  height: 7px;
  border: 0;
  border-radius: 0;
  background: currentColor;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.pill-danger::before {
  border-radius: 0;
  background: currentColor;
}

.pill-info {
  background: var(--color-info-bg);
  color: var(--color-info);
}

.pill-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.pill-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.pill-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  color: var(--color-on-accent);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}

.statusAttended {
  color: var(--color-success);
}

.statusOverdue {
  color: var(--color-danger);
  font-weight: var(--fw-semibold);
}

/* ── Div table (CLAUDE.md 12): table layout from 768px, stacked cards below ── */
.table-wrap {
  overflow-x: auto;
}

.containerDiv {
  width: 100%;
  font-size: var(--fs-sm);
}

.rowDivHeader {
  display: none;
}

/* phones: each row is its own card, the first cell (the record's code) as its title */
.rowDiv {
  display: block;
  margin-bottom: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.rowDiv:last-child {
  margin-bottom: 0;
}

.rowDiv > .cellDiv:first-child {
  margin-bottom: var(--space-1);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

/* the record's own link (its code) reads as the row's title */
.cellDiv a {
  font-weight: var(--fw-semibold);
  text-decoration: none;
}

.cellDiv a:hover {
  text-decoration: underline;
}

.cellDiv {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-1) 0;
}

.cellDiv[data-label]::before {
  content: attr(data-label);
  flex: 0 0 40%;
  color: var(--color-text-muted);
  font-weight: var(--fw-medium);
  text-align: left;
}

@media (min-width: 768px) {
  /* the box scrolls both ways, so the header row stays on top; common.js marks the edges that have columns beyond them */
  .table-wrap {
    max-height: var(--table-max-h);
    overflow: auto;
    isolation: isolate;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
  }

  .table-wrap.scroll-right {
    box-shadow: inset -24px 0 16px -16px var(--color-scroll-edge);
  }

  .containerDiv {
    display: table;
    border-collapse: collapse;
  }

  .rowDivHeader,
  .rowDiv {
    display: table-row;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .rowDiv > .cellDiv:first-child {
    margin-bottom: 0;
    padding-bottom: var(--cell-py);
  }

  .cellDivHeader,
  .cellDiv {
    display: table-cell;
    padding: var(--cell-py) var(--cell-px);
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
    overflow-wrap: break-word;
  }

  .rowDiv:last-child .cellDiv {
    border-bottom: 0;
  }

  .cellDiv[data-label]::before {
    content: none;
  }

  .cellDivHeader {
    position: sticky;
    top: 0;
    z-index: 2;
    padding-top: 10px;
    padding-bottom: 10px;
    border-bottom-color: var(--color-table-head-line);
    background: var(--color-table-head);
    color: var(--color-table-head-text);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-caps);
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
  }

  /* the first column (the record's code) stays in place when the table scrolls sideways */
  .rowDivHeader > .cellDivHeader:first-child,
  .rowDiv > .cellDiv:first-child {
    position: sticky;
    left: 0;
  }

  .rowDivHeader > .cellDivHeader:first-child {
    z-index: 3;
  }

  .rowDiv > .cellDiv:first-child {
    z-index: 1;
    background: var(--color-surface);
  }

  .table-wrap.scroll-left .rowDivHeader > .cellDivHeader:first-child,
  .table-wrap.scroll-left .rowDiv > .cellDiv:first-child {
    box-shadow: 8px 0 8px -8px var(--color-scroll-edge);
  }

  .rowDiv:hover .cellDiv {
    background: var(--color-row-hover);
  }

  .cellDiv.num,
  .cellDivHeader.num {
    text-align: right;
  }

  /* an amount never breaks across lines */
  .cellDiv.num {
    white-space: nowrap;
  }
}

/* amounts line up: every digit the same width */
.cellDiv.num {
  font-variant-numeric: tabular-nums;
}

.sort-header {
  cursor: pointer;
  user-select: none;
}

.sort-header:hover {
  color: var(--color-table-head-hover);
}

.sort-header:focus-visible {
  outline: 2px solid var(--color-table-head-focus);
  outline-offset: -2px;
}

/* every sortable column shows it can be sorted; the sorted one shows its direction */
.sort-header::after {
  padding-left: var(--space-1);
}

.sort-header[aria-sort="none"]::after {
  content: "\2195";
  color: var(--color-table-head-sort-idle);
}

.sort-header[aria-sort="ascending"]::after {
  content: "\2191";
  color: var(--color-table-head-sort);
}

.sort-header[aria-sort="descending"]::after {
  content: "\2193";
  color: var(--color-table-head-sort);
}

/* ── Tabs: they wrap on phones, scroll sideways from 768px ── */
.tabs {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

@media (min-width: 768px) {
  .tabs {
    flex-wrap: nowrap;
    column-gap: var(--space-5);
    overflow-x: auto;
  }
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: -1px;
  padding: var(--space-2) 2px var(--space-3);
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-weight: var(--fw-medium);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease);
}

.tab:hover {
  border-bottom-color: var(--color-border-strong);
  color: var(--color-text);
}

.tab:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.tab .badge {
  background: var(--color-neutral-bg);
  color: var(--color-neutral);
}

.tab[aria-selected="true"],
.tab[aria-current="page"] {
  border-bottom-color: var(--color-primary);
  color: var(--color-link);
  font-weight: var(--fw-semibold);
}

.tab[aria-selected="true"] .badge,
.tab[aria-current="page"] .badge {
  background: var(--color-primary);
  color: var(--color-on-accent);
}

/* ── Breadcrumb ── */
.breadcrumb {
  width: 100%;
  margin: 0;
  padding: 0;
  font-size: var(--fs-sm);
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumb li + li::before {
  content: "\203A";
  padding: 0 var(--space-2);
  color: var(--color-text-subtle);
}

.breadcrumb a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--color-link);
  text-decoration: underline;
}

.breadcrumb [aria-current="page"] {
  color: var(--color-text);
  font-weight: var(--fw-medium);
}

/* ── Pagination ── */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

/* ── List toolbar (shared list, common.js initListTable): quick search, Filters button, filter panel ── */
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

/* the search takes the left; the toolbar's buttons sit at the right edge */
.list-search {
  flex: 1 1 240px;
  max-width: var(--card-narrow-w);
  margin-right: auto;
}

/* the Filters button reads as pressed while its panel is open */
.list-filter-btn[aria-expanded="true"] {
  border-color: var(--color-primary-soft-strong);
  background: var(--color-primary-soft);
  color: var(--color-link);
}

/* phones: Excel and PDF show their icons only; the name stays for screen readers */
@media (max-width: 767px) {
  .list-export > span {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

.list-filter-panel {
  margin-bottom: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
}

/* the search field carries the search icon inside its left edge */
.list-search {
  position: relative;
}

.list-search > .icon {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--color-text-subtle);
  transform: translateY(-50%);
  pointer-events: none;
}

.list-search > .icon ~ .input {
  padding-left: 38px;
}

.table-wrap[aria-busy="true"] {
  opacity: 0.6;
}

/* ── Stat cards (dashboard counts, each a link to its list tab) ── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.stat-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "icon value" "icon label";
  align-items: center;
  column-gap: var(--space-4);
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  box-shadow: var(--shadow-card);
  transition: border-color var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease), transform var(--motion-fast) var(--ease);
}

.stat-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}

.stat-card:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  box-shadow: var(--focus-ring);
}

.stat-card-icon {
  display: inline-flex;
  grid-area: icon;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: var(--color-neutral-bg);
  color: var(--color-neutral);
}

.stat-card-icon .icon {
  width: 24px;
  height: 24px;
}

.stat-card-icon.is-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.stat-card-icon.is-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.stat-card-icon.is-info {
  background: var(--color-info-bg);
  color: var(--color-info);
}

.stat-card-value {
  grid-area: value;
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-tight);
}

.stat-card-label {
  grid-area: label;
  color: var(--color-text-muted);
  font-weight: var(--fw-medium);
}

/* a figure not worked out yet: text in body size, not a large '--' */
.stat-card-value.is-empty {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  letter-spacing: normal;
}

/* what each figure means, under its section (no script: details / summary) */
.stat-defs {
  margin-top: var(--space-4);
  font-size: var(--fs-sm);
}

.stat-defs summary {
  color: var(--color-link);
  font-weight: var(--fw-medium);
  cursor: pointer;
}

.stat-defs summary:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.stat-defs dl {
  margin: var(--space-3) 0 0;
}

.stat-def + .stat-def {
  margin-top: var(--space-2);
}

.stat-def dt {
  font-weight: var(--fw-semibold);
}

.stat-def dd {
  margin: 0;
  color: var(--color-text-muted);
}

/* ── Keyboard shortcut help (common.js showShortcutHelp) ── */
.shortcut-list {
  margin: 0;
}

.shortcut-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.shortcut-row + .shortcut-row {
  margin-top: var(--space-2);
}

.shortcut-row dt {
  flex: 0 0 auto;
  min-width: var(--space-10);
}

.shortcut-row dd {
  margin: 0;
}

kbd {
  display: inline-block;
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-text);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

/* ── Home: My tasks and Waiting for me side by side from 1024px ── */
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.card-head .card-title {
  margin: 0;
}

@media (min-width: 1024px) {
  .home-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--space-5);
    margin-bottom: var(--space-5);
  }

  .home-row > .card {
    margin-bottom: 0;
  }
}

.home-waiting {
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-waiting-item {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}

.home-waiting-item:first-child {
  padding-top: 0;
}

.home-waiting-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.home-waiting-type {
  font-weight: var(--fw-semibold);
}

.home-waiting-work {
  overflow-wrap: break-word;
}

.home-waiting-meta {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

/* ── Record header (detail pages): avatar, name, key facts and status above the sections ── */
.record-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

.record-avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--color-brand-deep-2), var(--color-brand-deep));
  color: var(--color-on-primary);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
}

.record-heading {
  flex: 1 1 260px;
  min-width: 0;
}

.record-name {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
}

.record-facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  margin: var(--space-1) 0 0;
  padding: 0;
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  list-style: none;
}

.record-facts li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.record-facts .icon {
  width: 15px;
  height: 15px;
}

/* a code is read as one token: never broken at its hyphens */
.code-chip {
  white-space: nowrap;
  padding: 1px var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-3);
  color: var(--color-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ── Detail list (read-only record): label above value, two columns from 768px ── */
.detail-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4) var(--space-8);
  margin: var(--space-2) 0 0;
}

.detail-item {
  min-width: 0;
  padding-bottom: var(--space-3);
  border-bottom: 1px dashed var(--color-border);
}

.detail-item dt {
  margin-bottom: 2px;
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
}

.detail-item dd {
  margin: 0;
  color: var(--color-text);
  font-weight: var(--fw-medium);
  overflow-wrap: anywhere;
}

@media (min-width: 768px) {
  .detail-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .detail-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* a popup is narrower than the screen: two columns at most */
  .popup-body .detail-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ── Logo tiles (spec m01 CR-1 L-5, L-6): any shape is shown whole ── */
.logo-tiles {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  margin: var(--space-2) 0 0;
}

.logo-tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  margin: 0;
}

.logo-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  gap: var(--space-2);
}

.logo-preview {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.logo-tile figcaption {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-weight: var(--fw-medium);
  overflow-wrap: anywhere;
}

@media (min-width: 768px) {
  .logo-tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ── Popup (CLAUDE.md 12): .popup-overlay > .popup-wrap.pp-{small|medium}-x ── */
/* phones: a sheet from the bottom edge, buttons in thumb reach; centred card from 768px */
.popup-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--space-6) 0 0;
  background: var(--color-overlay);
  -webkit-backdrop-filter: var(--glass-blur-soft);
  backdrop-filter: var(--glass-blur-soft);
  animation: fade-in var(--motion-base) var(--ease);
}

/* the overlay is already a solid dim colour: without the blur nothing else changes */
@media (prefers-reduced-transparency: reduce), (forced-colors: active) {
  .popup-overlay {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

.popup-wrap {
  z-index: var(--z-popup);
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: calc(100vh - var(--space-6));
  max-height: calc(100dvh - var(--space-6));
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-bottom: 0;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-3);
  animation: sheet-up var(--motion-base) var(--ease);
}

/* the sheet's grab bar (a cue only; closing stays on Close, Cancel, Esc and the backdrop) */
.popup-wrap::before {
  content: "";
  flex: none;
  width: 36px;
  height: 4px;
  margin: var(--space-2) auto 0;
  border-radius: var(--radius-pill);
  background: var(--color-border-strong);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes sheet-up {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
}

.pp-small-x {
  max-width: var(--popup-small-w);
}

.pp-medium-x {
  max-width: var(--popup-medium-w);
}

.popup-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.popup-header h2 {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
}

/* the close button lines up with the header's right edge */
.popup-header .popup-close {
  margin-right: calc(-1 * var(--space-2));
  color: var(--color-text-muted);
}

.popup-header .popup-close:hover {
  color: var(--color-text);
}

/* a shade at the top or bottom edge only while more content is hidden there: covers scroll with the content,
   shades stay with the box */
.popup-body {
  overflow-y: auto;
  padding: var(--space-5);
  background:
    linear-gradient(var(--color-surface), var(--color-surface)) top / 100% var(--space-3) no-repeat local,
    linear-gradient(var(--color-surface), var(--color-surface)) bottom / 100% var(--space-3) no-repeat local,
    linear-gradient(var(--color-border-strong), transparent) top / 100% 6px no-repeat scroll,
    linear-gradient(transparent, var(--color-border-strong)) bottom / 100% 6px no-repeat scroll,
    var(--color-surface);
}

.popup-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-border);
  border-radius: 0;
  background: var(--color-surface-2);
}

/* phones: footer buttons share the width */
.popup-footer > .btn {
  flex: 1 1 0;
}

@media (min-width: 768px) {
  .popup-overlay {
    align-items: center;
    padding: var(--space-4);
  }

  .popup-wrap {
    max-height: calc(100vh - 2 * var(--space-4));
    border-bottom: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    animation: pop-in var(--motion-base) var(--ease);
  }

  .popup-wrap::before {
    content: none;
  }

  .popup-footer {
    padding-bottom: var(--space-4);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  }

  .popup-footer > .btn {
    flex: 0 0 auto;
  }
}

/* ── Toasts (one region, top right; below the top bar on phones) ── */
.toast-region {
  position: fixed;
  top: calc(var(--topbar-h) + var(--space-2));
  right: var(--space-4);
  left: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  gap: var(--space-2);
  width: 100%;
  max-width: 420px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-info);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: var(--fw-medium);
  box-shadow: var(--shadow-3);
  pointer-events: auto;
  animation: pop-in var(--motion-base) var(--ease);
}

.toast-success {
  border-left-color: var(--color-success);
}

.toast-error {
  border-left-color: var(--color-danger);
}

.toast-warning {
  border-left-color: var(--color-warning);
}

/* ── Connection band (ux_principles §5): red while the connection is lost (saving held), green once it is back; text always says which ── */
.offline-banner {
  position: sticky;
  top: var(--topbar-h);
  z-index: var(--z-sticky);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid currentColor;
  background: var(--color-danger-bg);
  color: var(--color-danger);
  font-weight: var(--fw-semibold);
  text-align: center;
}

.offline-banner.is-online {
  background: var(--color-success-bg);
  color: var(--color-success);
}

/* ── Loading, empty, error and no-permission states ── */
.skeleton {
  display: block;
  height: 1em;
  margin: var(--space-2) 0;
  border-radius: var(--radius-sm);
  background: var(--color-skeleton);
  animation: pulse 1.4s ease-in-out infinite;
}

.skeleton-row {
  height: 32px;
}

@keyframes pulse {
  50% {
    opacity: 0.5;
  }
}

.empty-state,
.state-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-10) var(--space-4);
  color: var(--color-text-muted);
  text-align: center;
}

.empty-state p,
.state-panel p {
  margin: 0;
}

.empty-state > .icon,
.state-panel > .icon {
  box-sizing: content-box;
  width: 26px;
  height: 26px;
  padding: 14px;
  border-radius: 50%;
  background: var(--color-surface-3);
  color: var(--color-text-subtle);
}

.state-ref {
  font-size: var(--fs-xs);
}

/* ── User and role chip: the button of the user menu (change password, sign out) ── */
.user-menu {
  position: relative;
}

.user-chip {
  gap: var(--space-2);
  max-width: 280px;
  min-height: 44px;
  padding: var(--space-1) var(--space-2) var(--space-1) var(--space-1);
  font-weight: var(--fw-regular);
  text-align: left;
}

/* initials of the signed-in user */
.avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-primary-soft-strong);
  color: var(--color-link);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
}

.user-chip-text {
  display: none;
  flex-direction: column;
  min-width: 0;
  line-height: var(--lh-tight);
}

@media (min-width: 768px) {
  .user-chip-text {
    display: inline-flex;
  }
}

.user-menu-list {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: var(--z-dropdown);
  min-width: 260px;
  margin: 0;
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-3);
  list-style: none;
  animation: pop-in var(--motion-fast) var(--ease);
}

.user-menu-head {
  display: flex;
  flex-direction: column;
  padding: var(--space-2) var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-1);
}

.user-menu-head-name {
  font-weight: var(--fw-semibold);
}

.user-menu-head-role {
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-weight: var(--fw-medium);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.user-menu-item .icon {
  color: var(--color-text-muted);
}

.user-menu-item:hover {
  background: var(--color-surface-3);
}

.user-menu-item.is-danger,
.user-menu-item.is-danger .icon {
  color: var(--color-danger);
}

.user-menu-item:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 3px var(--color-focus);
}

/* preferences (spec m02 S6): one group per preference; the chosen option is marked by aria-pressed, weight and border, not colour alone */
.user-menu-group {
  margin-top: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--color-border);
}

.user-menu-group-title {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}

.user-menu-options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.user-menu-option {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
}

.user-menu-option:hover {
  background: var(--color-surface-2);
}

.user-menu-option[aria-pressed="true"] {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  font-weight: var(--fw-semibold);
  cursor: default;
}

.user-menu-option:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 1px;
}

/* the note under the SMS / e-mail switches (spec m06 S3) */
.user-menu-note {
  padding: 0 var(--space-3) var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
}

/* ── Notification bell (spec m06 S1): a disclosure beside the user menu; unread is marked by weight and a dot plus text, not colour alone ── */
.bell-menu {
  position: relative;
}

.bell-btn {
  position: relative;
}

.bell-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: var(--color-danger);
}

.bell-panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: var(--z-dropdown);
  width: min(360px, calc(100vw - 2 * var(--space-4)));
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-3);
  animation: pop-in var(--motion-fast) var(--ease);
}

.bell-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2) var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

.bell-panel-title {
  font-weight: var(--fw-semibold);
}

.bell-list {
  max-height: 60vh;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.bell-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-2);
  border-bottom: 1px solid var(--color-border);
  overflow-wrap: anywhere;
}

.bell-item.is-unread .bell-item-text,
.rowDiv.is-unread .col1 {
  font-weight: var(--fw-semibold);
}

.bell-item.is-unread .bell-item-text::before,
.unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: var(--space-2);
  border-radius: 50%;
  background: var(--color-primary);
  content: "";
}

.bell-item-time {
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
}

.bell-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.bell-empty {
  margin: 0;
  padding: var(--space-4) var(--space-2);
  color: var(--color-text-muted);
  text-align: center;
}

/* delivery detail of one notification (spec m06 S5): one block per recipient */
.delivery-recipient + .delivery-recipient {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.delivery-recipient-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
  font-size: var(--fs-md);
}

/* audit entry (spec m07 S2): before / after that are not flat objects, as formatted text */
.audit-value-title {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--fs-md);
}

.audit-value {
  margin: 0;
  padding: var(--space-3);
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.bell-view-all {
  display: block;
  padding: var(--space-2) var(--space-2) var(--space-1);
  color: var(--color-link);
  text-align: center;
}

.user-menu-sep {
  margin-top: var(--space-1);
  padding-top: var(--space-1);
  border-top: 1px solid var(--color-border);
}

/* ── Rule hint (new password): each rule ticked by icon and hidden text, never colour alone ── */
.rule-list {
  margin: var(--space-1) 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-sm);
}

.rule-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  color: var(--color-text-muted);
}

.rule-list li.is-met {
  color: var(--color-success);
}

/* ── Sign-in form on the landing page: taller controls, heading, note ── */
.auth-card {
  --control-h: var(--control-h-lg);
}

.auth-title {
  margin: 0;
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
}

.auth-subtitle {
  margin: var(--space-2) 0 0;
  color: var(--color-text-muted);
}

.auth-note {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
}

.auth-note .icon {
  width: 16px;
  height: 16px;
  color: var(--color-success);
}

.auth-footer {
  width: 100%;
  max-width: var(--auth-card-w);
  margin: 0;
  color: var(--color-text-subtle);
  font-size: var(--fs-xs);
  text-align: center;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  color: var(--color-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  text-decoration: none;
}

.lang-switch:hover {
  border-color: var(--color-border-hover);
  background: var(--color-surface-3);
}

/* ── Brand panel of the landing page (spec m02 CR-1): text on the deep navy; the logo sits on a light plate ── */
.brand-eyebrow {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
  color: var(--color-nav-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
}

.brand-eyebrow .product-mark {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.brand-logo {
  display: block;
  max-width: 100%;
  max-height: 48px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-lg);
  background: var(--color-on-primary);
}

.brand-logo.brand-logo-clear {
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.brand-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xl);
  background: var(--color-on-primary);
  color: var(--color-brand-deep);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  box-shadow: var(--shadow-3);
}

.brand-name {
  max-width: 18em;
  margin: var(--space-3) 0 0;
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-tight);
  overflow-wrap: anywhere;
}

.brand-about {
  max-width: 34em;
  margin: var(--space-3) 0 0;
  color: var(--color-nav-text);
  font-size: var(--fs-md);
  overflow-wrap: anywhere;
}

/* narrow screens: a compact brand head, so the form shows on the first screen; the about line follows the form */
.brand-about-wide {
  display: none;
}

.brand-about-narrow {
  margin: 0 0 var(--space-5);
}

@media (min-width: 1024px) {
  .brand-eyebrow {
    margin-bottom: var(--space-8);
  }

  .brand-logo {
    max-height: 72px;
    padding: var(--space-2);
  }

  .brand-initials {
    width: 88px;
    height: 88px;
    font-size: var(--fs-2xl);
  }

  .brand-name {
    margin-top: var(--space-5);
    font-size: var(--fs-3xl);
  }

  .brand-about-wide {
    display: block;
  }

  .brand-about-narrow {
    display: none;
  }
}

.brand-details-title {
  margin: 0 0 var(--space-3);
  color: var(--color-nav-title);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-details {
  margin: 0;
  padding: 0;
  list-style: none;
}

.brand-details li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  overflow-wrap: anywhere;
}

.brand-details a,
.brand-powered a {
  color: inherit;
  text-decoration: underline;
}

.brand-details a .icon {
  margin-left: var(--space-1);
}

.brand-details a:focus-visible {
  outline: 2px solid var(--color-on-primary);
  outline-offset: 2px;
}

.brand-powered {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-8) 0 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-brand-line);
  color: var(--color-nav-text);
  font-size: var(--fs-sm);
}

/* the product logo is transparent: no plate */
.product-logo {
  height: 28px;
  width: auto;
}

.user-chip-name {
  overflow: hidden;
  font-weight: var(--fw-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip-role {
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Several-files field (spec m05 S2): the chosen files under the control, each with Remove; long names wrap ── */
.file-queue {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-queue:empty {
  display: none;
}

.file-queue-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  font-size: var(--fs-sm);
}

.file-queue-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* the accent swatch on S4 (spec m05 S1): a disabled colour input, the size of a chip */
.accent-swatch {
  width: var(--space-6);
  height: var(--space-6);
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  vertical-align: middle;
  opacity: 1;
}

/* ── BOQ Builder (spec m08 S7): grid inputs fill their cell; header forms sit in the action row; the item picker's results ── */
.boq-grid .boq-in {
  width: 100%;
  min-width: 0;
}

.boq-grid textarea.boq-in {
  resize: vertical;
}

.inline-form {
  display: contents;
}

.pick-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.pick-list:empty {
  display: none;
}

/* ── Contractor signature specimens (spec m08 S9): the image whole, on a light plate, newest first ── */
.signature-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.signature-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.signature-specimen {
  max-width: 100%;
  max-height: calc(var(--space-12) * 2);
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  object-fit: contain;
}

.pick-list .btn {
  width: 100%;
  justify-content: flex-start;
  text-align: start;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* ── Searchable select (Tom Select): library styles re-coloured from tokens ── */
.fld .ts-wrapper {
  width: 100%;
}

.ts-wrapper .ts-control,
.ts-wrapper.single.input-active .ts-control {
  min-height: var(--control-h);
  padding: var(--space-1) var(--control-px);
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  box-shadow: none;
  cursor: pointer;
}

.ts-wrapper .ts-control input {
  color: var(--color-text);
  font: inherit;
}

/* the library's base theme has no arrow: the same chevron as a plain select */
.ts-wrapper.single .ts-control {
  padding-right: calc(var(--control-px) + 20px);
  background-image: linear-gradient(45deg, transparent 50%, var(--color-text-muted) 50%), linear-gradient(135deg, var(--color-text-muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.ts-wrapper.focus .ts-control {
  border-color: var(--color-focus);
  box-shadow: var(--focus-ring);
}

.ts-wrapper.disabled .ts-control {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  opacity: 1;
  cursor: not-allowed;
}

.ts-dropdown {
  z-index: var(--z-dropdown);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-2);
}

.ts-dropdown .option,
.ts-dropdown .no-results {
  padding: var(--space-2) var(--control-px);
}

.ts-dropdown .active {
  background: var(--color-primary-soft);
  color: var(--color-text);
}

.ts-dropdown .selected {
  font-weight: var(--fw-semibold);
}

/* ── Date picker (jQuery UI): library styles re-coloured from tokens; library CSS loads before this file ── */
.ui-datepicker.ui-widget {
  /* appended to body: above the popup overlay and popup, so it opens inside popups too (below toasts) */
  z-index: calc(var(--z-popup) + 1) !important;
  padding: var(--space-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-2);
}

.ui-datepicker .ui-widget-header {
  border: 0;
  background: var(--color-surface-2);
  color: var(--color-text);
}

.ui-datepicker select.ui-datepicker-month,
.ui-datepicker select.ui-datepicker-year {
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
}

.ui-datepicker .ui-state-default {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  text-align: center;
}

.ui-datepicker .ui-state-hover,
.ui-datepicker .ui-state-focus {
  background: var(--color-surface-2);
}

.ui-datepicker .ui-state-highlight {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  color: var(--color-text);
  font-weight: var(--fw-semibold);
}

.ui-datepicker .ui-state-active {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: var(--color-on-accent);
}

.ui-datepicker .ui-state-disabled {
  opacity: 0.4;
}

.ui-datepicker th {
  color: var(--color-text-muted);
}

input[data-widget="date"] {
  cursor: pointer;
  caret-color: transparent;
}

/* milestone gauge (spec m10 S3): an SVG ring whose arc length is the % (stroke-dasharray presentation attribute, no inline style) */
.ms-gauge-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
}

.ms-card-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.ms-gauge {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

.ms-gauge-track {
  fill: none;
  stroke: var(--color-border);
  stroke-width: 3.2;
}

.ms-gauge-arc {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 3.2;
  stroke-linecap: round;
}

.ms-gauge-arc.is-delayed {
  stroke: var(--color-danger);
}

.ms-gauge-arc.is-complete {
  stroke: var(--color-success);
}

.ms-gauge-text {
  fill: var(--color-text);
  font-size: 7px;
  font-weight: var(--fw-semibold);
  text-anchor: middle;
  dominant-baseline: middle;
}

/* ── Measurement Book (spec m11 S7, S8): deduction rows shaded, the line total, an item over its scope ── */
.rowDiv.is-deduction,
.rowDiv.is-deduction .cellDiv {
  background: var(--color-danger-bg);
}

.mb-line-total {
  font-weight: var(--fw-semibold);
}

.rowDiv.is-excess .cellDiv {
  background: var(--color-warning-bg);
}

/* a stored letter or reply shown with its line breaks (notice body, response) */
.text-block {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ── Visual Audit and the Work site page (spec m17 S4, S5): a photo grid, the gallery buckets, the milestone stepper ── */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.media-item {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.media-item img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
}

.media-item figcaption {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}

/* ── Platform health (spec m01 CR-3 S10; CR-7a): Authority toolbar, summary strip, one dense checks table, the Authority in sections ── */
.health-toolbar {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.health-toolbar-label,
.health-tile-label,
.health-section-title,
.health-sub-title {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
}

.health-toolbar-fields {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: flex-end;
}

.health-toolbar-fields > .fld {
  flex: 1 1 18rem;
  min-width: 0;
  margin: 0;
}

.health-toolbar .fld-help {
  margin: 0;
}

.health-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: var(--space-6);
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.health-tile {
  min-width: 0;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
}

.health-overall,
.health-tile-checks {
  grid-column: 1 / -1;
}

.health-overall {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  border-top: 0;
}

.health-tile-value {
  margin: var(--space-1) 0 0;
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
}

.health-tile-meta {
  margin: 2px 0 0;
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
}

.health-overall-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--color-on-primary);
}

.health-overall-icon .icon {
  width: 22px;
  height: 22px;
}

.health-overall.is-state-0 {
  background: linear-gradient(90deg, var(--color-success-bg), transparent);
}

.health-overall.is-state-1 {
  background: linear-gradient(90deg, var(--color-warning-bg), transparent);
}

.health-overall.is-state-2 {
  background: linear-gradient(90deg, var(--color-danger-bg), transparent);
}

.health-overall.is-state-0 .health-overall-icon {
  background: var(--color-success);
}

.health-overall.is-state-1 .health-overall-icon {
  background: var(--color-warning);
}

.health-overall.is-state-2 .health-overall-icon {
  background: var(--color-danger);
}

.health-overall.is-state-0 .health-tile-value,
.health-count.is-state-0 b {
  color: var(--color-success);
}

.health-overall.is-state-1 .health-tile-value,
.health-count.is-state-1 b {
  color: var(--color-warning);
}

.health-overall.is-state-2 .health-tile-value,
.health-count.is-state-2 b {
  color: var(--color-danger);
}

.health-counts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  align-items: baseline;
}

.health-count {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  letter-spacing: 0;
}

.health-count b {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
}

.health-panel {
  margin-bottom: var(--space-6);
}

.health-name {
  font-weight: var(--fw-medium);
}

.health-name .icon {
  margin-right: var(--space-2);
  color: var(--color-text-muted);
  vertical-align: -3px;
}

.health-key {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
}

.health-key[data-label]::before {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}

.health-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 2px var(--space-4);
  color: var(--color-text-muted);
}

.health-fact b {
  color: var(--color-text);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}

.health-note {
  color: var(--color-text-muted);
}

/* a row needing attention: a coloured edge as well as its state word */
.health-row.is-state-1 {
  border-left: 3px solid var(--color-warning);
}

.health-row.is-state-2 {
  border-left: 3px solid var(--color-danger);
}

.health-authority {
  padding: 0;
  overflow: hidden;
}

.health-auth-band {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-6);
  align-items: center;
  padding: var(--space-4) var(--space-5);
  background: linear-gradient(120deg, var(--color-brand-deep), var(--color-brand-deep-2));
  color: var(--color-on-primary);
}

.health-auth-code {
  margin: 0;
  color: var(--color-nav-text);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
}

.health-auth-name {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  overflow-wrap: anywhere;
}

.health-auth-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.health-auth-band .pill {
  background: var(--color-surface);
}

.health-auth-band a {
  color: var(--color-on-primary);
  text-decoration: underline;
}

.health-tag {
  padding: 2px 10px;
  border: 1px solid var(--color-brand-line);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.health-sections {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.health-section {
  min-width: 0;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
}

.health-section:first-child {
  border-top: 0;
}

.health-section-title {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.health-kv {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px var(--space-4);
  margin: 0;
  font-size: var(--fs-sm);
}

.health-kv dt {
  color: var(--color-text-muted);
}

.health-kv dd {
  margin: 0;
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
  text-align: right;
  overflow-wrap: anywhere;
}

.health-estimated {
  color: var(--color-text-subtle);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
}

.health-section > .fld-help {
  margin: var(--space-3) 0 0;
}

.health-meter {
  margin-bottom: var(--space-3);
}

.health-meter-top {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  margin: 0 0 4px;
  font-size: var(--fs-sm);
}

.health-meter-top b {
  font-variant-numeric: tabular-nums;
}

/* a native progress bar: no inline width, so it stays inside the CSP */
.health-bar {
  display: block;
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--color-surface-3);
  appearance: none;
}

.health-bar::-webkit-progress-bar {
  border-radius: var(--radius-pill);
  background: var(--color-surface-3);
}

.health-bar::-webkit-progress-value {
  border-radius: var(--radius-pill);
  background: var(--color-primary);
}

.health-bar::-moz-progress-bar {
  border-radius: var(--radius-pill);
  background: var(--color-primary);
}

.health-bar.is-full::-webkit-progress-value {
  background: var(--color-danger);
}

.health-bar.is-full::-moz-progress-bar {
  background: var(--color-danger);
}

.health-bar.is-warn::-webkit-progress-value {
  background: var(--color-warning);
}

.health-bar.is-warn::-moz-progress-bar {
  background: var(--color-warning);
}

/* m01 CR-7c: storage meters under the subscription details */
.storage-meters {
  margin-top: var(--space-4);
}

.health-sub-title {
  padding: var(--space-3) var(--space-5) var(--space-2);
  border-top: 1px solid var(--color-border);
}

.health-authority > .health-table {
  margin: 0 var(--space-5) var(--space-5);
}

.health-pair {
  display: grid;
  gap: var(--space-6);
}

.health-pair > .health-panel {
  min-width: 0;
  margin-bottom: 0;
}

@media (min-width: 768px) {
  .health-row.is-state-1,
  .health-row.is-state-2 {
    border-left: 0;
  }

  .health-row.is-state-1 > .cellDiv:first-child {
    box-shadow: inset 3px 0 0 var(--color-warning);
  }

  .health-row.is-state-2 > .cellDiv:first-child {
    box-shadow: inset 3px 0 0 var(--color-danger);
  }

  .health-name,
  .health-table .num {
    white-space: nowrap;
  }

  .health-table .num {
    text-align: right;
  }

  .health-auth-tags {
    margin-left: auto;
  }
}

@media (min-width: 1024px) {
  .health-strip {
    grid-template-columns: minmax(0, 1.4fr) repeat(4, minmax(0, 1fr));
  }

  .health-tile {
    border-top: 0;
    border-left: 1px solid var(--color-border);
  }

  .health-overall,
  .health-tile-checks {
    grid-column: auto;
  }

  .health-overall {
    border-left: 0;
  }

  .health-sections {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .health-section {
    border-left: 1px solid var(--color-border);
  }

  .health-section:nth-child(-n+2) {
    border-top: 0;
  }

  .health-section:nth-child(odd) {
    border-left: 0;
  }
}

@media (min-width: 1400px) {
  .health-sections {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .health-section {
    border-top: 0;
  }

  .health-section:nth-child(odd) {
    border-left: 1px solid var(--color-border);
  }

  .health-section:first-child {
    border-left: 0;
  }
}

@media (min-width: 1600px) {
  .health-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.gallery-buckets {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 1024px) {
  .gallery-buckets {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.gallery-bucket-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
}

.stepper {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.stepper-step {
  flex: 1 1 10rem;
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-top-width: 4px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.stepper-step.is-complete {
  border-top-color: var(--color-success);
}

.stepper-step.is-delayed {
  border-top-color: var(--color-danger);
}

.stepper-step.is-in-progress {
  border-top-color: var(--color-primary);
}

.stepper-name {
  margin: 0;
  font-weight: var(--fw-semibold);
  overflow-wrap: anywhere;
}

.stepper-meta {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}

/* ── Charts (spec m18 D10): the canvas sits above its data table, which always shows ── */
.chart-panel {
  position: relative;
  height: 18rem;
  margin-bottom: var(--space-4);
}

.chart-panel canvas {
  max-width: 100%;
}

/* ── Side pane (ux_principles §6.1): a large form over the list, full height on the right; the same popup markup and openPagePopup()
   with .popup-overlay.popup-side; phones keep the bottom sheet ── */
@media (min-width: 768px) {
  .popup-overlay.popup-side {
    align-items: stretch;
    justify-content: flex-end;
    padding: 0;
  }

  .popup-side > .popup-wrap {
    max-width: var(--popup-medium-w);
    max-height: none;
    height: 100vh;
    height: 100dvh;
    border-width: 0 0 0 1px;
    border-radius: 0;
    animation: pane-in var(--motion-base) var(--ease);
  }

  .popup-side > .popup-wrap > .popup-body {
    flex: 1 1 auto;
  }

  .popup-side .popup-footer {
    border-radius: 0;
  }
}

@keyframes pane-in {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
}

/* ── Help note (ux_principles §10): open on the first visit, then folded behind "What is this?" ── */
.help-note {
  margin-bottom: var(--space-4);
}

.help-note-toggle {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-h-sm);
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-link);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.help-note-toggle:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.help-note-body {
  margin-top: var(--space-2);
}

.help-note-body > .alert {
  margin: 0;
}

/* ── Who has the record (ux_principles §9.1) and its time left (§9.2) ── */
.record-with {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: calc(-1 * var(--space-3)) 0 var(--space-5);
  padding: 0;
  list-style: none;
}

.record-with-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-info);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: var(--fs-sm);
}

.record-with-item.is-mine {
  border-left-color: var(--color-warning);
  background: var(--color-warning-bg);
}

.record-with-item > .icon {
  color: var(--color-text-muted);
}

.record-with-text {
  font-weight: var(--fw-semibold);
}

.record-with-part,
.record-with-wait {
  color: var(--color-text-muted);
}

.record-with-item.is-mine .record-with-part {
  color: var(--color-text);
  font-weight: var(--fw-medium);
}

.record-due {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-weight: var(--fw-medium);
}

.record-due.is-late {
  color: var(--color-danger);
}

/* print-only parts (base.css shows them on paper) */
.print-only {
  display: none;
}

/* ── Error and refused page (ux_principles §4): renderErrorPage(); centred card, English then Hindi, reference, way back ── */
.error-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: var(--space-6) var(--space-4);
  background: var(--color-bg);
}

.error-card {
  width: 100%;
  max-width: var(--popup-medium-w);
  padding: var(--space-8);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-accent);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-2);
}

.error-code {
  margin: 0 0 var(--space-2);
  color: var(--color-text-subtle);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
}

.error-title {
  margin-bottom: var(--space-4);
  font-size: var(--fs-xl);
}

.error-lang + .error-lang {
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
}

.error-label {
  margin: var(--space-3) 0 var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
}

.error-lang p {
  margin: 0;
}

.error-ref {
  margin-top: var(--space-6);
  padding: var(--space-4);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
}

.error-ref .error-label {
  margin-top: 0;
}

.error-ref code {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.06em;
  word-spacing: 0.2em;
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-6) 0 0;
}

/* ── Automatic drafts (ux_principles §6.3): the found-draft band and the "Draft saved at" line at the top of a form ── */
.draft-band {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
}

.draft-band-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.draft-status {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--fs-xs);
  text-align: right;
}

/* a dialog text with line breaks (the read-only draft): one line per field */
.popup-body > p {
  white-space: pre-line;
}
