/* What the lab application's pages need beyond the site's stylesheets:
   the account in the header, messages, the demo banner, the list's
   filters and table, state badges, forms and the history. Colours come
   from the site's tokens, so both colour schemes apply. */

/* The account sits at the foot of the sidebar, and at the end of the
   title's row once the header stacks above the page. */
.lab-account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 0.875rem;
}
@media (max-width: 55rem) {
  .lab-account { grid-column: 2; margin-top: 0; padding-top: 0; border-top: 0; }
}
/* On a phone the title's row has room for the initials and the
   sign-out button only; the access tokens open from the password page,
   which the initials lead to. */
@media (max-width: 30rem) {
  .lab-account-tokens { display: none; }
}
.lab-account form { margin: 0; }
.lab-account > a { text-decoration: none; font-weight: 600; }

.lab-messages { list-style: none; margin: 0 0 var(--space-4); padding: 0; }
.lab-message {
  font-family: var(--font-ui);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 0.25rem;
  background: var(--surface);
}
.lab-message + .lab-message { margin-top: var(--space-2); }
.lab-message--success { border-left-color: var(--checked-fg); }
.lab-message--error {
  background: var(--banner-bg);
  color: var(--banner-fg);
  border-color: var(--banner-border);
}

.lab-demo {
  font-family: var(--font-ui);
  margin: 0 0 var(--space-4);
  padding: var(--space-2) var(--space-3);
  border: 1px dashed var(--banner-border);
  border-radius: 0.25rem;
  background: var(--banner-bg);
  color: var(--banner-fg);
}
.site-header > .lab-demo {
  margin: auto 0 calc(-1 * var(--space-3));
  padding: 0.42rem 0.55rem;
  font-size: 0.71875rem;
  line-height: 1.38;
}
.site-header > .lab-demo + .lab-account { margin-top: 0; }
@media (max-width: 55rem) {
  .site-header > .lab-demo {
    grid-column: 1 / -1;
    margin: 0;
  }
  :root[data-sidebar="collapsed"] .site-header > .lab-demo { display: none; }
}
.lab-demo-accounts { margin-top: var(--space-5); font-family: var(--font-ui); }
.lab-demo-accounts ul { padding-left: var(--space-4); }

/* The link back to a record's list, above its heading. */
.lab-back {
  margin: 0 0 0.25rem;
  font-family: var(--font-ui);
  font-size: 0.8125rem;
}
.lab-back a { color: var(--muted); text-decoration: none; }
.lab-back a:hover { color: var(--link); text-decoration: underline; }
.lab-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-4);
}
.lab-heading .actions { font-family: var(--font-ui); }

.lab-pick { margin: 0; font-family: var(--font-ui); }

/* A name the collection lacks. */
.lab-mark { color: var(--muted); font-size: 0.875em; }

.badge--planned { background: var(--surface); color: var(--fg); border-color: var(--border); }
.badge--running { background: var(--checked-bg); color: var(--checked-fg); }
.badge--ended { background: var(--retired-bg); color: var(--retired-fg); }
.badge--cancelled { background: transparent; color: var(--muted); border-color: var(--border); }
.badge--failed { background: transparent; color: var(--banner-fg); border-color: var(--banner-border); }
.badge--followup { background: var(--draft-bg); color: var(--draft-fg); }
.badge--flask { background: var(--draft-bg); color: var(--draft-fg); }
.badge--warning { background: var(--banner-bg); color: var(--banner-fg); border-color: var(--banner-border); }

.lab-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin: 0 0 var(--space-4);
  font-family: var(--font-ui);
}
.lab-actions form { margin: 0; }
.lab-note { max-width: var(--measure); }

/* The lots a task step made and took, and the links to record either. */
.lab-step-lots, .lab-step-actions { font-size: 0.875rem; margin: var(--space-1) 0 0; }
.lab-step-actions { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); font-family: var(--font-ui); }
.lab-step-actions details a { display: block; }

.lab-form { max-width: 40rem; font-family: var(--font-ui); }
.lab-field { margin: 0 0 var(--space-3); }
.lab-field > label { display: block; font-weight: 600; margin-bottom: var(--space-1); }
.lab-field input[type="checkbox"] + label { display: inline; }
.lab-field :is(input:not([type="checkbox"]), select, textarea) {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--muted);
  border-radius: 0.25rem;
  padding: 0.3rem 0.5rem;
  width: 100%;
}
.lab-field :is(input:not([type="checkbox"], [type="file"]), select:not([multiple])) {
  min-height: calc(1.55em + 0.6rem + 2px);
}
.lab-field select:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.lab-field--error :is(input, select, textarea) { border-color: var(--focus); }
/* Native single choices take the searchable list's look where the
   browser supports customizable selects; others keep the system list. */
@supports (appearance: base-select) {
  .lab-field select:not([multiple]),
  .lab-field select:not([multiple])::picker(select) {
    appearance: base-select;
  }
  .lab-field select:not([multiple]) {
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
  }
  .lab-field select:not([multiple]):open {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
  }
  .lab-field select:not([multiple]):disabled {
    background: var(--surface);
    color: var(--muted);
    cursor: default;
  }
  .lab-field select:not([multiple])::picker-icon {
    content: "";
    display: inline-block;
    flex: none;
    width: 0.65rem;
    height: 0.4rem;
    margin-inline-start: auto;
    background: var(--muted);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain;
  }
  .lab-field select:not([multiple]):open::picker-icon {
    transform: rotate(180deg);
  }
  .lab-field select:not([multiple])::picker(select) {
    box-sizing: border-box;
    padding: 0;
    margin-block: 0.25rem;
    font: inherit;
    color: var(--fg);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    box-shadow: 0 4px 12px rgb(0 0 0 / 0.15);
  }
  .lab-field select:not([multiple]) option {
    padding: 0.3rem 0.5rem;
    color: var(--fg);
    background: transparent;
    cursor: pointer;
  }
  .lab-field select:not([multiple]) option::checkmark {
    display: none;
  }
  .lab-field select:not([multiple]) option:checked { color: var(--link); }
  .lab-field select:not([multiple]) option:hover,
  .lab-field select:not([multiple]) option:focus {
    background: var(--surface);
    outline: none;
  }
  .lab-field select:not([multiple]) option:disabled {
    color: var(--muted);
    cursor: default;
  }
}
.lab-field-group {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
}
.lab-field-group > .lab-field {
  margin: 0;
  flex: 0 0 auto;
  min-width: 0;
}
.lab-field-group > .lab-field[hidden] { display: none; }
.lab-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2) var(--space-3);
  margin: 0 0 var(--space-3);
}
.lab-row > .lab-field,
.lab-row > .lab-field-group {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
}
.lab-row > .lab-field--number,
.lab-row > .lab-field--unit,
.lab-row > .lab-field--date,
.lab-row > .lab-field--code,
.lab-row > .lab-field-group {
  flex: 0 0 auto;
}
.lab-row > .lab-field--number:has(> .lab-help) { width: 8.5rem; }
.lab-row > .lab-field--number > .lab-help {
  width: max-content;
  max-width: min(22rem, calc(100vw - 4rem));
}
.lab-field.lab-field--number > input,
.lab-field.lab-field--number > .lab-input-unit > input {
  width: 8.5rem;
  max-width: 100%;
  font-variant-numeric: tabular-nums;
}
.lab-field.lab-field--number > .lab-input-unit {
  width: fit-content;
  max-width: 100%;
}
.lab-field.lab-field--number > .lab-input-unit > input { flex: 0 0 8.5rem; }
.lab-field.lab-field--number > .lab-input-action { max-width: 20rem; }
.lab-field.lab-field--number > .lab-input-action > input {
  flex: 0 0 8.5rem;
  width: 8.5rem;
}
.lab-field.lab-field--unit > select { width: 7rem; max-width: 100%; }
.lab-field.lab-field--date > input { width: 11rem; max-width: 100%; }
.lab-field.lab-field--code > input,
.lab-field.lab-field--code > .lab-input-action {
  width: 14rem;
  max-width: 100%;
}
.lab-input-unit {
  display: flex;
  align-items: stretch;
}
.lab-input-unit > input {
  flex: 1 1 auto;
  min-width: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.lab-input-unit:has(> [data-vessel-unit-target="unit"][hidden]) > input {
  border-radius: 0.25rem;
}
.lab-input-unit__unit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  padding: 0 0.6rem;
  line-height: 1;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--muted);
  border-left: 0;
  border-radius: 0 0.25rem 0.25rem 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.lab-input-unit__unit[hidden] { display: none; }
.lab-input-unit__unit:empty::before { content: "–"; color: var(--muted); }
.lab-field--error .lab-input-unit__unit { border-color: var(--focus); }
.lab-input-action {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.lab-input-action > .ts-wrapper,
.lab-input-action > select,
.lab-input-action > input {
  flex: 1 1 auto;
  min-width: 0;
}
.lab-input-action > .lab-button {
  flex: none;
  white-space: nowrap;
}
.lab-action-new {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex: none;
}
.lab-action-new[hidden] { display: none; }
.lab-action-or {
  flex: none;
  font-size: 0.78125rem;
  color: var(--muted);
  user-select: none;
}
.lab-section {
  margin: 0.65rem 0 0;
  padding-top: 0.55rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.lab-section--first {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.lab-section > :last-child { margin-bottom: 0; }
.lab-section:last-of-type { margin-bottom: 0.65rem; }
.lab-section__head { margin: 0 0 0.4rem; }
.lab-section__title {
  margin: 0;
  padding: 0;
  font-size: 0.71875rem;
  font-weight: 700;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  color: var(--muted);
}
.lab-section--mode .lab-section__title {
  color: var(--link);
  margin-bottom: 0.4rem;
}
.lab-mode-switch {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.lab-mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-left: 2.5px solid var(--link);
  border-radius: 0 0.25rem 0.25rem 0;
  overflow: hidden;
  background: var(--bg);
}
.lab-mode-tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.42rem 0.65rem;
  margin: 0;
  font-weight: 500;
  font-size: 0.8125rem;
  line-height: 1.25;
  color: var(--muted);
  background: var(--bg);
  border-top: 2.5px solid transparent;
  cursor: pointer;
  user-select: none;
  text-align: center;
}
.lab-mode-tab + .lab-mode-tab { border-left: 1px solid var(--border); }
.lab-mode-tab:hover {
  color: var(--fg);
  background: color-mix(in srgb, var(--surface) 55%, var(--bg));
}
.lab-mode-tab:has(:checked) {
  color: var(--fg);
  font-weight: 600;
  background: var(--surface);
  border-top-color: var(--link);
}
.lab-mode-tab:has(:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
  z-index: 1;
}
.lab-mode-body {
  border-left: 2.5px solid var(--link);
  padding: 0.6rem 0 0.1rem 0.75rem;
}
.lab-mode-stack { display: grid; }
.lab-mode-branch {
  grid-area: 1 / 1;
  min-width: 0;
}
.lab-mode-branch > :last-child { margin-bottom: 0; }
.lab-mode-branch[inert] {
  visibility: hidden;
  pointer-events: none;
}
.lab-field .lab-suggested-number__input[readonly] {
  background: var(--surface);
  color: var(--muted);
  cursor: default;
}
.lab-suggested-number > .lab-button[hidden] {
  display: none;
}

/* Searchable choices (Tom Select), styled with the site's tokens to
   match .lab-field text inputs in height, type, border and focus ring. */
.ts-wrapper {
  --ts-pr-min: 0.5rem;
  --ts-pr-caret: 1.75rem;
  font: inherit;
  color: var(--fg);
}
.ts-wrapper .ts-control {
  position: relative;
  align-items: center;
  min-height: calc(1.55em + 0.6rem + 2px);
  padding: 0.3rem 1.75rem 0.3rem 0.5rem;
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--muted);
  border-radius: 0.25rem;
  box-shadow: none;
}
.ts-wrapper.full .ts-control,
.ts-wrapper.single.input-active .ts-control {
  background: var(--bg);
}
.ts-wrapper.multi.has-items .ts-control {
  padding: 0.3rem 1.75rem 0.3rem 0.5rem;
}
.ts-wrapper.focus .ts-control,
.ts-wrapper.dropdown-active .ts-control {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  box-shadow: none;
}
.lab-field--error .ts-wrapper .ts-control { border-color: var(--focus); }
.ts-wrapper.disabled .ts-control {
  background: var(--surface);
  color: var(--muted);
}
.ts-wrapper .ts-control > input {
  flex: 1 1 4rem;
  width: auto;
  min-width: 4rem;
  padding: 0;
  color: var(--fg);
  font: inherit;
  border: 0;
}
.ts-wrapper .ts-control > input::placeholder { color: var(--muted); }
.ts-wrapper.single .ts-control { flex-wrap: nowrap; }
.ts-wrapper .ts-control::after {
  content: "";
  position: absolute;
  right: 0.5rem;
  top: 50%;
  width: 0.65rem;
  height: 0.4rem;
  transform: translateY(-50%);
  pointer-events: none;
  background: var(--muted);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain;
}
.ts-wrapper.dropdown-active .ts-control::after {
  transform: translateY(-50%) rotate(180deg);
}
.ts-wrapper.single .ts-control > .item {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ts-wrapper.single.ts-dash-empty:is(.focus, .input-active, .dropdown-active) .ts-control > .item[data-value=""] {
  display: none;
}
.ts-wrapper.multi .ts-control { gap: var(--space-1); }
.ts-wrapper.multi .ts-control > .item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  padding: 0.05rem 0 0.05rem 0.4rem;
  font-size: 0.875em;
  line-height: 1.3;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.2rem;
}
.ts-wrapper.multi .ts-control > .item.active {
  color: var(--fg);
  background: var(--surface);
  border-color: var(--link);
}
.ts-wrapper.multi.disabled .ts-control > .item,
.ts-wrapper.multi.disabled .ts-control > .item.active {
  color: var(--muted);
  background: var(--surface);
  border-color: var(--border);
}
.ts-wrapper.multi .ts-control > .item .remove {
  padding: 0 0.25rem;
  margin-left: var(--space-1);
  color: var(--muted);
  border-left: 1px solid var(--border);
  cursor: pointer;
}
.ts-wrapper.multi .ts-control > .item.active .remove {
  border-left-color: var(--border);
}
.ts-wrapper.multi .ts-control > .item .remove:hover {
  color: var(--fg);
  background: transparent;
}
.ts-dropdown {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.15);
}
.ts-dropdown.ts-dropdown--up {
  top: auto;
  bottom: 100%;
  margin: 0 0 2px;
}
.ts-dropdown .optgroup-header {
  color: var(--muted);
  background: var(--surface);
  font-weight: 600;
  font-size: 0.8125rem;
  border-top: 1px solid var(--border);
}
.ts-dropdown .option { color: var(--fg); }
.ts-dropdown .active {
  background: var(--surface);
  color: var(--link);
}
.ts-dropdown [data-selectable] .highlight {
  background: color-mix(in srgb, var(--link) 18%, transparent);
  color: inherit;
}
.ts-dropdown .no-results { color: var(--muted); }
.lab-help { color: var(--muted); font-size: 0.875rem; margin: var(--space-1) 0 0; }
.errorlist {
  list-style: none;
  margin: var(--space-1) 0 0;
  padding: 0;
  color: var(--banner-fg);
  font-weight: 600;
}
.lab-buttons { display: flex; align-items: center; gap: var(--space-3); }

/* The dialog in the shell that a form chosen on a page opens in: a
   header with the title and the record the form acts on, the fields in
   a body that scrolls, and a footer, with the note on required fields
   and the buttons, that stays at the dialog's foot. Its width follows
   the form's: narrow by default, wide, or nearly the whole window for
   a sheet; a narrow screen is filled. */
.lab-dialog {
  position: fixed;
  width: min(28rem, calc(100vw - 2 * var(--space-3)));
  margin: clamp(1.75rem, 5vh, 3.5rem) auto auto;
  max-height: calc(100dvh - clamp(1.75rem, 5vh, 3.5rem) - var(--space-3));
  padding: 0;
  overflow: hidden;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}
.lab-dialog:has(.lab-dialog--compact) { width: min(22rem, calc(100vw - 2 * var(--space-3))); }
.lab-dialog:has(.lab-dialog--wide) { width: min(40rem, calc(100vw - 2 * var(--space-3))); }
.lab-dialog:has(.lab-dialog--sheet) { width: min(76rem, calc(100vw - 2 * var(--space-3))); }
.lab-form-root.lab-dialog--compact > .lab-form { max-width: 22rem; }
.lab-form-root.lab-dialog--narrow > .lab-form { max-width: 28rem; }
.lab-dialog[open] { display: flex; flex-direction: column; }
.lab-dialog::backdrop { background: rgb(0 0 0 / 0.5); }
#lab-dialog-body,
#lab-subdialog-body,
.lab-dialog .lab-form-root {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.lab-dialog .lab-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  max-width: none;
  font-size: 0.875rem;
  padding: 0.65rem var(--space-4) 0;
  overflow: auto;
}
.lab-dialog .lab-field,
.lab-dialog .lab-field-group,
.lab-dialog .lab-row { margin: 0 0 0.6rem; }
.lab-dialog .lab-field > label,
.lab-dialog fieldset.lab-field > legend { margin-bottom: 0.2rem; }
.lab-dialog .lab-field :is(input:not([type="checkbox"]), select, textarea) {
  padding: 0.22rem 0.45rem;
}
.lab-dialog .lab-field :is(input:not([type="checkbox"], [type="file"]), select:not([multiple])),
.lab-dialog .ts-wrapper .ts-control {
  min-height: calc(1.45em + 0.44rem + 2px);
}
.lab-dialog .ts-wrapper .ts-control,
.lab-dialog .ts-wrapper.multi.has-items .ts-control {
  padding: 0.22rem 1.75rem 0.22rem 0.45rem;
}
.lab-dialog .lab-field textarea { min-height: 2.25rem; max-height: 5rem; }
.lab-dialog .lab-help { font-size: 0.78125rem; margin-top: 0.15rem; }
.lab-dialog-head {
  padding: 0.65rem 3rem 0.5rem var(--space-4);
  border-bottom: 1px solid var(--border);
}
.lab-dialog-head h2 { margin: 0; font-size: 1.0625rem; }
.lab-dialog-context { margin: 0; color: var(--muted); font-family: var(--font-ui); font-size: 0.8125rem; }
.lab-dialog-head .lab-dialog-context { margin-top: 0.15rem; }
.lab-dialog-notice {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem 0.85rem;
  padding: 0.55rem var(--space-4);
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  line-height: 1.4;
  border-bottom: 1px solid var(--border);
}
.lab-dialog-notice--failed {
  color: var(--level-out-fg);
  background: var(--level-out-bg);
  border-bottom-color: color-mix(in srgb, var(--level-out-fg) 30%, var(--border));
}
.lab-dialog-notice--session {
  color: var(--banner-fg);
  background: var(--banner-bg);
  border-bottom-color: var(--banner-border);
}
.lab-dialog-notice__text {
  flex: 1 1 16rem;
  min-width: 0;
}
.lab-dialog-notice__text strong {
  display: block;
  margin-bottom: 0.1rem;
}
.lab-dialog-notice__text p { margin: 0; }
.lab-dialog-notice__actions { flex: none; margin: 0; }
.lab-dialog-notice--session .lab-dialog-notice__link {
  color: var(--banner-fg);
  background: var(--bg);
  border-color: var(--banner-border);
  font-weight: 600;
}
.lab-dialog-notice--session .lab-dialog-notice__link:hover {
  border-color: currentColor;
}
.lab-dialog-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
  font-family: var(--font-ui);
}
.lab-dialog .lab-dialog-foot {
  position: sticky;
  bottom: 0;
  margin: auto calc(-1 * var(--space-4)) 0;
  padding: 0.55rem var(--space-4);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.lab-required-note { margin: 0; color: var(--muted); font-size: 0.8125rem; }
.lab-dialog-foot .lab-buttons {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  margin: 0 0 0 auto;
}
.lab-required { color: var(--link); }
fieldset.lab-field { min-width: 0; padding: 0; border: 0; }
fieldset.lab-field > legend { padding: 0; margin-bottom: var(--space-1); font-weight: 600; }
.lab-error-summary,
.lab-warning {
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  color: var(--banner-fg);
  background: var(--banner-bg);
  border: 1px solid var(--banner-border);
  border-radius: 0.25rem;
  font-family: var(--font-ui);
  font-size: 0.875rem;
}
.lab-error-summary p { margin: 0 0 var(--space-1); font-weight: 600; }
.lab-error-summary ul { margin: 0; padding-left: var(--space-4); }
.lab-error-summary a { color: inherit; font-weight: 600; }
.lab-warning p { margin: 0; }
.lab-discard {
  margin: var(--space-3) 0 0;
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--link);
  border-radius: 0.25rem;
  font-family: var(--font-ui);
}
.lab-discard p { margin: 0 0 var(--space-2); }
.lab-discard__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: 0; }
@media (max-width: 40rem) {
  .lab-dialog,
  .lab-dialog:has(.lab-dialog--compact),
  .lab-dialog:has(.lab-dialog--wide),
  .lab-dialog:has(.lab-dialog--sheet) {
    inset: 0;
    width: auto;
    max-width: none;
    height: auto;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
  .lab-mode-branch[inert] { display: none; }
  .lab-row {
    flex-direction: column;
    align-items: stretch;
  }
  .lab-row > .lab-field,
  .lab-row > .lab-field-group,
  .lab-row > .lab-field--number:has(> .lab-help) {
    flex: none;
    width: 100%;
  }
  .lab-row > .lab-field--number > .lab-help {
    width: auto;
    max-width: none;
  }
  .lab-input-action:has(.lab-action-new) { flex-wrap: wrap; }
  .lab-input-action:has(.lab-action-new) > .ts-wrapper,
  .lab-input-action:has(.lab-action-new) > select,
  .lab-input-action:has(.lab-action-new) > input,
  .lab-input-action:has(.lab-action-new) > .lab-action-new {
    flex: 1 1 100%;
  }
}
.lab-dialog-close {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  font: inherit;
  line-height: 1;
  padding: 0.2rem 0.55rem;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  cursor: pointer;
}

.lab-history { font-family: var(--font-ui); padding-left: var(--space-4); }
.lab-history > li + li { margin-top: var(--space-2); }
.lab-history ul { margin: var(--space-1) 0 0; padding-left: var(--space-4); }
.lab-history__time { color: var(--muted); }

/* Chemical class and record classification badge, and the substance
   page's route tree as nested lists connected by branch lines. */
.badge--class { background: var(--bg); color: var(--muted); border-color: var(--border); }

.route-tree {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  line-height: 1.65;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.route-tree li + li { margin-top: 0.25rem; }
.route-tree > li + li {
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.route-tree ul {
  margin: 0.28rem 0 0.25rem 0.55rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
  list-style: none;
}
.route-tree ul > li { position: relative; }
.route-tree ul > li::before {
  content: "";
  position: absolute;
  left: -1rem;
  top: 0.8em;
  width: 0.65rem;
  border-top: 1px solid var(--border);
}
.route-tree .route-step { color: var(--muted); }
.route-tree .route-step > a {
  display: inline-block;
  padding: 0.04rem 0.42rem;
  margin-right: 0.12rem;
  font-weight: 600;
  line-height: 1.45;
  background: color-mix(in srgb, var(--link) 8%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--link) 24%, transparent);
  border-radius: 0.2rem;
}
.route-tree .route-step > a:hover,
.route-tree .route-step > a:focus-visible {
  background: color-mix(in srgb, var(--link) 14%, var(--bg));
  border-color: color-mix(in srgb, var(--link) 42%, transparent);
}
.route-tree .route-compound > a { font-weight: 400; }
.route-tree .badge { vertical-align: baseline; margin-left: 0.1rem; }

/* The inventory: stock levels, its tables, the consumption chart and the
   rows of a delivery note. Each of the seven levels' background and
   text keep a contrast of at least 4.5:1 in both colour schemes. */
:root {
  --level-out-bg: #f8d4d4;
  --level-out-fg: #6e1414;
  --level-critical-bg: #fbdcbc;
  --level-critical-fg: #5e2e00;
  --level-low-bg: #fbf0a8;
  --level-low-fg: #4d3f00;
  --level-watch-bg: #ddf0cc;
  --level-watch-fg: #21401a;
  --level-ok-bg: #a3d68f;
  --level-ok-fg: #123510;
  --level-undelivered-bg: #d3dceb;
  --level-undelivered-fg: #22324d;
  --level-dormant-bg: #5d636b;
  --level-dormant-fg: #ffffff;
  --heat-1-bg: #fbe4e6;
  --heat-1-fg: #5c1a22;
  --heat-2-bg: #f4b8be;
  --heat-2-fg: #4d1219;
  --heat-3-bg: #e0707a;
  --heat-3-fg: #2a0508;
  --heat-4-bg: #b3202c;
  --heat-4-fg: #ffffff;
  --heat-5-bg: #5a0a10;
  --heat-5-fg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --level-out-bg: #5a1c1c;
    --level-out-fg: #ffdada;
    --level-critical-bg: #5a3212;
    --level-critical-fg: #ffe1c4;
    --level-low-bg: #4a4212;
    --level-low-fg: #fff3b8;
    --level-watch-bg: #26401c;
    --level-watch-fg: #dcf5cf;
    --level-ok-bg: #3a7a2c;
    --level-ok-fg: #ffffff;
    --level-undelivered-bg: #33415a;
    --level-undelivered-fg: #dfe7f3;
    --level-dormant-bg: #686d74;
    --level-dormant-fg: #ffffff;
    --heat-1-bg: #3a2226;
    --heat-1-fg: #f6dde0;
    --heat-2-bg: #5a262d;
    --heat-2-fg: #fbe3e6;
    --heat-3-bg: #80232e;
    --heat-3-fg: #ffffff;
    --heat-4-bg: #a8202d;
    --heat-4-fg: #ffffff;
    --heat-5-bg: #c62832;
    --heat-5-fg: #ffffff;
  }
}

.level-out { background: var(--level-out-bg); color: var(--level-out-fg); }
.level-critical { background: var(--level-critical-bg); color: var(--level-critical-fg); }
.level-low { background: var(--level-low-bg); color: var(--level-low-fg); }
.level-watch { background: var(--level-watch-bg); color: var(--level-watch-fg); }
.level-ok { background: var(--level-ok-bg); color: var(--level-ok-fg); }
.level-undelivered { background: var(--level-undelivered-bg); color: var(--level-undelivered-fg); }
.level-dormant { background: var(--level-dormant-bg); color: var(--level-dormant-fg); }
/* An item that entered stock this year. */
.mark-new { color: var(--link); font-family: var(--font-ui); font-size: 0.7em; font-weight: 600; margin-left: 0.15em; }
.stock { font-weight: 600; }
span.stock[class*="level-"] { padding: 0 var(--space-2); border-radius: 0.25rem; }
.level-label { font-weight: 400; font-size: 0.875em; }

/* The consumption heat: five steps from a pale pink to a blackish red,
   by the fifth of the consuming items a value falls in. */
.heat-1 { background: var(--heat-1-bg); color: var(--heat-1-fg); }
.heat-2 { background: var(--heat-2-bg); color: var(--heat-2-fg); }
.heat-3 { background: var(--heat-3-bg); color: var(--heat-3-fg); }
.heat-4 { background: var(--heat-4-bg); color: var(--heat-4-fg); }
.heat-5 { background: var(--heat-5-bg); color: var(--heat-5-fg); }
.heat-swatch {
  display: inline-block;
  width: 1.5em;
  height: 1em;
  vertical-align: middle;
  border-radius: 0.2rem;
}

/* Two table styles: .main-table for the main lists and .aux-table
   for every other table (widgets, detail panes, record pages, forms,
   and key-value tables via .kv-table). One sort-indicator style covers
   both server header links and client button.sort-header. */
.main-table {
  width: 100%;
  font-size: 0.8125rem;
}
.main-table thead { background: var(--surface); }
.main-table :is(th, td) {
  height: 1.875rem;
  padding: 0.2rem 0.6rem;
  white-space: nowrap;
  vertical-align: middle;
  border-right: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.main-table :is(th, td):last-child { border-right: 0; }
.main-table tbody td {
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.main-table tbody tr:last-child td { border-bottom: 0; }
.main-table th { font-size: 0.75rem; font-weight: 600; vertical-align: bottom; }
/* Every main table's header row is two header lines high, its text at
   the bottom, so that the rows of every list start at one height. */
.main-table thead th { height: 2.5rem; vertical-align: bottom; }
.main-table th small { display: block; color: var(--muted); font-size: 0.6875rem; font-weight: 400; }
.main-table .num,
.main-table .number {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.main-table .nowrap { white-space: nowrap; }
.main-table .muted { color: var(--muted); }
.main-table td a { text-decoration: none; }
.main-table td a:hover { text-decoration: underline; }
.main-table td.col-strong { font-weight: 600; }
.main-table .article-number {
  font-family: var(--font-mono);
  font-size: 0.71875rem;
  font-weight: 400;
  color: var(--muted);
  margin-right: 0.3rem;
}
.main-table .badge {
  font-size: 0.6875rem;
  line-height: 1.35;
  padding: 0 0.42rem;
  white-space: nowrap;
}
.main-table tr.category-start > td { border-top: 1px solid var(--border); }
/* A barely visible tint per category, and the article number and name
   dimmed on the rows that continue the article of the row above. */
:root {
  --tint-mix: 5%;
  --tint-1: #2f6fd0;
  --tint-2: #2e9a4f;
  --tint-3: #c98a12;
  --tint-4: #7a4fc4;
  --tint-5: #138a8a;
  --tint-6: #c23d6b;
}
@media (prefers-color-scheme: dark) {
  :root { --tint-mix: 9%; }
}
.main-table tbody tr.tint-1 > td:not(.stock, [class*="heat-"]) { background: color-mix(in srgb, var(--tint-1) var(--tint-mix), var(--bg)); }
.main-table tbody tr.tint-2 > td:not(.stock, [class*="heat-"]) { background: color-mix(in srgb, var(--tint-2) var(--tint-mix), var(--bg)); }
.main-table tbody tr.tint-3 > td:not(.stock, [class*="heat-"]) { background: color-mix(in srgb, var(--tint-3) var(--tint-mix), var(--bg)); }
.main-table tbody tr.tint-4 > td:not(.stock, [class*="heat-"]) { background: color-mix(in srgb, var(--tint-4) var(--tint-mix), var(--bg)); }
.main-table tbody tr.tint-5 > td:not(.stock, [class*="heat-"]) { background: color-mix(in srgb, var(--tint-5) var(--tint-mix), var(--bg)); }
.main-table tbody tr.tint-6 > td:not(.stock, [class*="heat-"]) { background: color-mix(in srgb, var(--tint-6) var(--tint-mix), var(--bg)); }
.main-table tr.same-article > :is(td.col-number, td.col-name),
.main-table tr.same-article > :is(td.col-number, td.col-name) a { color: var(--muted); }
.main-table tr[data-state="cancelled"] td,
.main-table tr[data-state="failed"] td { color: var(--muted); }
.main-table progress { width: 4rem; vertical-align: middle; }
.main-table tbody tr:hover > td:not(.stock, [class*="heat-"]) { background: var(--surface); }

.aux-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}
.aux-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  text-align: left;
  padding: 0.3rem 0.55rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.aux-table td,
.aux-table tbody th {
  padding: 0.27rem 0.55rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}
.aux-table tbody tr:last-child td,
.aux-table tbody tr:last-child th { border-bottom: 0; }
.aux-table tbody tr:hover td,
.aux-table tbody tr:hover th {
  background: color-mix(in srgb, var(--surface) 65%, transparent);
}
.aux-table thead th.num,
.aux-table thead th.number { text-align: right; }
.aux-table .num,
.aux-table .number {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.aux-table .nowrap { white-space: nowrap; }
.aux-table .muted { color: var(--muted); }
.aux-table td a { text-decoration: none; }
.aux-table td a:hover { text-decoration: underline; }
.aux-table abbr {
  text-decoration: none;
  border-bottom: 1px dotted color-mix(in srgb, var(--muted) 55%, transparent);
  cursor: help;
}

.kv-table tr + tr {
  border-top: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.kv-table th,
.kv-table td {
  border-bottom: 0;
  padding: 0.27rem 0.6rem;
  vertical-align: top;
}
.kv-table th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  width: 38%;
  white-space: nowrap;
}
.kv-table td {
  padding-left: 0.2rem;
  color: var(--fg);
  overflow-wrap: anywhere;
}
.kv-table tbody tr:hover th,
.kv-table tbody tr:hover td { background: none; }
.kv-table .copy-button {
  margin-left: 0;
  font-size: 0.6875rem;
  padding: 0.05rem 0.4rem;
}

.main-table thead th > a,
th > button.sort-header {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-decoration: none;
  outline-offset: 2px;
}
.main-table thead th > a:hover,
th > button.sort-header:hover { color: var(--fg); text-decoration: underline; }
.main-table thead th > a:focus-visible,
th > button.sort-header:focus-visible {
  outline: 2px solid var(--focus);
  border-radius: 0.15rem;
}
.main-table thead th > a::after,
th > button.sort-header::after {
  content: " ⇅";
  content: " ⇅" / "";
  font-size: 0.625rem;
  opacity: 0.45;
}
th[aria-sort="ascending"] > :is(a, button.sort-header)::after {
  content: " ▲";
  content: " ▲" / "";
  opacity: 1;
  color: var(--fg);
}
th[aria-sort="descending"] > :is(a, button.sort-header)::after {
  content: " ▼";
  content: " ▼" / "";
  opacity: 1;
  color: var(--fg);
}

/* The main lists: the menu band above the table, the compact item
   table and the note below it. The band holds two rows: the section's
   tabs with their counts, the list's summary and its actions; then the
   search, the filters and the layout picker. The details of one item
   and the fixed-height screen frame have their own rules further
   down. */
body.lab-frame { max-width: none; }
.lab-count { color: var(--muted); font-family: var(--font-ui); }
.menu-band {
  flex: none;
  margin: 0 0 0.625rem;
  font-family: var(--font-ui);
}
.menu-band__top {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.35rem 0.85rem;
  min-height: 2.75rem;
  border-bottom: 1px solid var(--border);
}
.menu-tabs { display: flex; min-width: 0; }
.menu-tabs ul {
  display: flex;
  align-items: stretch;
  gap: 1.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.menu-tabs li { display: flex; margin: 0; }
.menu-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  margin-bottom: -1px;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2.5px solid transparent;
}
.menu-tabs a:hover { color: var(--fg); text-decoration: none; }
.menu-tabs a[aria-current="page"] {
  font-weight: 700;
  color: var(--fg);
  border-bottom-color: var(--link);
}
.menu-tabs a:focus-visible { outline-offset: -2px; }
/* The count of a tab: a square label with a hairline border, the
   current tab's in the link colour. */
.menu-count {
  font-size: 0.82em;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.menu-band__summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  margin-left: auto;
  font-size: 0.78125rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.menu-band__summary :is(p, .lab-count) { margin: 0; font-size: inherit; }
.menu-band__actions {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  flex: none;
}
.menu-band__actions:empty { display: none; }
/* A primary action of a list, a link or a button alike; the filled one
   is the list's main action. */
.lab-button {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.85rem;
  padding: 0 0.72rem;
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
}
.lab-button:hover { border-color: var(--muted); text-decoration: none; }
.lab-button--primary {
  font-weight: 600;
  color: var(--bg);
  background: var(--link);
  border-color: var(--link);
}
.lab-button--primary:hover { border-color: var(--link); filter: brightness(1.08); }
.lab-button--danger {
  color: var(--level-out-fg);
  background: var(--bg);
  border-color: color-mix(in srgb, var(--level-out-fg) 38%, var(--border));
}
.lab-button--danger:hover {
  background: var(--level-out-bg);
  border-color: var(--level-out-fg);
}
.lab-button--new {
  color: var(--link);
  background: var(--bg);
  border-color: color-mix(in srgb, var(--link) 36%, var(--border));
}
.lab-button--new::before {
  content: "+";
  content: "+" / "";
  margin-inline-end: 0.3em;
}
.lab-button--new:hover {
  background: color-mix(in srgb, var(--link) 9%, var(--bg));
  border-color: var(--link);
}

.menu-band__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
}
/* The filter form's controls are items of the tools row themselves, and
   a control outside the form, such as the item list's stock status menu,
   follows them, so the row reads in the order the keyboard visits it. */
.menu-band__tools .lab-filters { display: contents; }
.menu-band__end {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
  margin-left: auto;
}
.menu-band__tools button[type="submit"]:not(.lab-button) {
  height: 1.9rem;
  padding: 0 0.55rem;
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
}
/* The search field, wide, with its magnifier inside. */
.filter-search {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 1 21rem;
  width: 21rem;
  min-width: 10rem;
  margin: 0;
}
.filter-search__icon {
  position: absolute;
  left: 0.55rem;
  width: 0.875rem;
  height: 0.875rem;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
  stroke-linecap: round;
  pointer-events: none;
}
.filter-search input[type="search"] {
  width: 100%;
  height: 1.9rem;
  padding: 0 0.55rem 0 1.75rem;
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
}
.filter-search input[type="search"]:hover { border-color: var(--muted); }
.filter-slot { display: contents; }
/* A filter as one bordered control: its name in muted text, a hairline,
   then the chosen value in bold with a chevron. A click anywhere on it
   opens the select or the menu; lab.js opens the select's picker from
   the name. A filter set away from its default shows its value in the
   link colour. */
.filter-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 1.9rem;
  margin: 0;
  padding: 0 0 0 0.55rem;
  white-space: nowrap;
  cursor: pointer;
  flex: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
}
.filter-control:hover { border-color: var(--muted); }
.filter-control:has(:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.filter-control__name {
  padding-right: 0.45rem;
  font-size: 0.75rem;
  color: var(--muted);
  border-right: 1px solid var(--border);
  user-select: none;
}
.filter-control select,
.filter-control .filter-control__value {
  appearance: none;
  height: 100%;
  max-width: 11rem;
  margin: 0;
  padding: 0 1.4rem 0 0.45rem;
  font: inherit;
  font-weight: 600;
  color: var(--fg);
  text-overflow: ellipsis;
  cursor: pointer;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 0.5rem center / 0.6rem;
  border: 0;
  border-radius: 0 0.25rem 0.25rem 0;
}
.filter-control :is(select, .filter-control__value):focus-visible { outline: 0; }
.filter-control:has(option:checked:not([value=""], [data-default])) select,
.filter-control .filter-control__value[data-active] { color: var(--link); }
/* The menu button stretches over the whole control. */
.filter-control--menu .filter-control__value::before {
  content: "";
  position: absolute;
  inset: 0;
}
/* A check box as a chip whose whole surface toggles it. */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 1.9rem;
  margin: 0;
  padding: 0 0.58rem;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  flex: none;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
}
.filter-chip:hover { border-color: var(--muted); }
.filter-chip input { margin: 0; }
.filter-chip:has(input:checked) {
  color: var(--link);
  background: color-mix(in srgb, var(--link) 11%, var(--bg));
  border-color: color-mix(in srgb, var(--link) 55%, var(--border));
}
.lab-menu-button::after { content: " ▾"; content: " ▾" / ""; }

/* The switch between the two views: a compact segmented control of two
   radio buttons, which are hidden but keep their native behaviour; the
   label of the checked one is filled. */
.view-switch {
  display: inline-flex;
  height: 1.85rem;
  align-items: stretch;
  flex: none;
  min-width: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 0.22rem;
}
.view-switch label { position: relative; display: flex; cursor: pointer; }
.view-switch label + label { border-left: 1px solid var(--border); }
.view-switch label {
  align-items: center;
  padding: 0 0.45rem;
  color: var(--fg);
  background: var(--bg);
}
.view-switch label:hover { background: var(--surface); }
.view-switch label:has(:checked) { color: var(--bg); background: var(--link); }
.layout-icon {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
}
/* The icons show the list's own split: stacked or side by side. */
.layout-icon__cols { display: none; }
main:has(.split--outer.split--columns) .layout-icon__rows { display: none; }
main:has(.split--outer.split--columns) .layout-icon__cols { display: inline; }
.view-switch label:has(:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }
.heat-scale {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.cat-meta { color: var(--muted); font-size: 0.75rem; }
.cat-cas { font-family: var(--font-mono); font-size: 0.71875rem; }
.cat-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.badge--cross,
.badge--sealed {
  background: color-mix(in srgb, var(--link) 10%, var(--bg));
  color: var(--link);
  border-color: color-mix(in srgb, var(--link) 32%, transparent);
}
.age-old {
  display: inline-block;
  padding: 0 0.42rem;
  border-radius: 99px;
  font-size: 0.71875rem;
  font-weight: 600;
  line-height: 1.4;
  background: var(--draft-bg);
  color: var(--draft-fg);
  border: 1px solid color-mix(in srgb, var(--draft-fg) 30%, transparent);
}
[popovertarget]:has(+ :popover-open) { outline: 2px solid var(--link); outline-offset: 2px; }
.lab-table-note { margin: var(--space-2) 0 0; color: var(--muted); font-family: var(--font-ui); font-size: 0.8125rem; }
.lab-table-note strong { color: var(--fg); font-weight: 600; }
.lab-frame .lab-table-note { flex: none; margin: 0.35rem 0 0; font-size: 0.75rem; line-height: 1.35; }

/* Menus that open as popups. Browsers with full CSS Anchor Positioning
   place each popup against its trigger button and flip or clamp to the
   viewport; older browsers fall back to lab.js marking data-placed and
   setting left and top. */
.lab-popup {
  padding: 0;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--muted);
  border-radius: 0.25rem;
  box-shadow: 0 6px 22px rgb(0 0 0 / 0.18);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 400;
  text-align: left;
  white-space: normal;
  max-height: calc(100vh - 2rem);
  overflow: auto;
}
.lab-popup[data-placed] { position: fixed; inset: auto; margin: 0; }
@supports (anchor-name: --a) and (position-anchor: --a) and (top: anchor(bottom)) and (position-try-fallbacks: flip-block) {
  @position-try --popover-below-inset {
    top: calc(anchor(bottom) + 8px);
    bottom: auto;
    left: 16px;
    right: auto;
  }
  @position-try --popover-above-inset {
    top: auto;
    bottom: calc(anchor(top) + 8px);
    left: 16px;
    right: auto;
  }
  @position-try --popover-fit {
    top: auto;
    bottom: 16px;
    left: 16px;
    right: auto;
  }
  .lab-popup[popover] {
    position: fixed;
    inset: auto;
    margin: 0;
    top: calc(anchor(bottom) + 8px);
    left: max(16px, anchor(left));
    max-width: calc(100vw - 2rem);
    max-height: calc(100vh - 2rem);
    position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline, --popover-below-inset, --popover-above-inset, --popover-fit;
  }
  [popovertarget="stock-menu"] { anchor-name: --stock-menu-anchor; }
  #stock-menu { position-anchor: --stock-menu-anchor; }
  [popovertarget="item-actions"] { anchor-name: --item-actions-anchor; }
  #item-actions { position-anchor: --item-actions-anchor; }
  [popovertarget="lot-actions"] { anchor-name: --lot-actions-anchor; }
  #lot-actions { position-anchor: --lot-actions-anchor; }
}
.pane-actions { min-width: 11rem; padding: var(--space-1); }
.pane-actions a {
  display: block;
  padding: 0.3rem 0.6rem;
  color: var(--fg);
  text-decoration: none;
  border-radius: 0.2rem;
  white-space: nowrap;
}
.pane-actions a:is(:hover, :focus-visible) { background: var(--surface); }

.stock-menu { width: min(23rem, calc(100vw - 2rem)); padding: var(--space-1); }
.stock-menu ul { list-style: none; margin: 0; padding: 0; }
.stock-menu li + li { margin-top: 0; }
.stock-menu li:first-child { border-bottom: 1px solid var(--border); margin-bottom: var(--space-1); padding-bottom: var(--space-1); }
.stock-menu a {
  display: grid;
  grid-template-columns: 1rem 1fr auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.6rem;
  color: var(--fg);
  text-decoration: none;
  border-radius: 0.2rem;
}
.stock-menu a:is(:hover, :focus-visible, [aria-current]) { background: var(--surface); }
.stock-menu strong { display: block; font-weight: 500; }
.stock-menu a[aria-current] strong { font-weight: 700; }
.stock-menu small { display: block; color: var(--muted); font-size: 0.75rem; }
.stock-menu .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.swatch { display: inline-block; width: 0.9rem; height: 0.9rem; border: 1px solid color-mix(in srgb, var(--fg) 15%, transparent); border-radius: 0.15rem; }
.swatch-all { border-color: transparent; text-align: center; line-height: 0.9rem; }
.stock-menu a[aria-current] .swatch-all::before { content: "✓"; content: "✓" / ""; }

/* Details panes: hidden outside the details view and off paper. */
.item-detail {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  min-width: 0;
  min-height: 0;
}
#item-detail { display: none; }
.pane-head {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border);
}
.pane-head__main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.55rem;
  min-width: 0;
}
.pane-head h2 { margin: 0; font-size: 0.95rem; line-height: 1.25; }
.pane-head h2 a { text-decoration: none; }
.pane-head h2 a:hover { text-decoration: underline; }
.pane-head__meta { margin: 0; color: var(--muted); font-size: 0.78125rem; }
.pane-head__actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  flex: none;
}
.pane-head__btn,
.pane-head__menu-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.55rem;
  font-family: var(--font-ui);
  font-size: 0.78125rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.22rem;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.pane-head__btn:hover,
.pane-head__menu-btn:hover { border-color: var(--muted); text-decoration: none; }
.pane-head__open {
  font-size: 0.78125rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}
.pane-head__open:hover { text-decoration: underline; }
.widget__head h3 {
  margin: 0;
  font-size: 0.71875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
details.widget > summary.widget__head h3::before {
  content: "▸";
  content: "▸" / "";
  font-size: 0.6875rem;
  color: var(--muted);
  width: 0.7rem;
  display: inline-block;
}
details.widget[open] > summary.widget__head h3::before {
  content: "▾";
  content: "▾" / "";
}
.pane-list { list-style: none; margin: 0; padding: 0; }
.pane-list li {
  padding: 0.35rem 0.6rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.pane-list li:first-child { border-top: 0; }
.pane-list strong { display: block; }
.detail-note {
  margin: 0 0 var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--border);
  background: var(--surface);
  font-size: 0.75rem;
}
.quarter-bars {
  list-style: none;
  display: flex;
  gap: var(--space-3);
  height: 7rem;
  margin: 0 0 1.75rem;
  padding: 1.25rem var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.quarter-bar { position: relative; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; }
.quarter-bars li + li { margin-top: 0; }
.quarter-bar .bar { flex-shrink: 0; min-height: 1px; background: var(--border); }
.quarter-bar.current .bar { background: var(--link); }
.quarter-bar .bar-value { flex-shrink: 0; text-align: center; font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.quarter-bar .bar-label { position: absolute; top: 100%; left: 0; right: 0; padding-top: 0.3rem; color: var(--muted); font-size: 0.6875rem; text-align: center; white-space: nowrap; }
/* While a choice loads, the old details stay in view but take no click. */
#item-detail.htmx-request,
#lot-detail.htmx-request { opacity: 0.5; pointer-events: none; }

/* Paper has no use for the list's controls or popups; the details stay
   hidden, as `#item-detail` above leaves them. Collapsible widgets
   print open, and sort header buttons print so column headers stay. */
@media print {
  .menu-band__tools, .menu-band__actions, .menu-tabs, .lab-table-note,
  .lab-heading .actions, .record-band .lab-back, .main-table input[name="item"],
  [popover] { display: none; }
  .record-band h1 {
    border-bottom: 0;
    white-space: normal;
    font-size: 1.35rem;
    margin: 0;
  }
  /* On paper the list's heading names the page in place of its tabs. */
  .menu-band > h1.visually-hidden {
    position: static;
    width: auto;
    height: auto;
    margin: 0 0 0.5rem;
    overflow: visible;
    clip: auto;
    clip-path: none;
    white-space: normal;
  }
  details.widget::details-content { content-visibility: visible; }
  th > button.sort-header {
    display: inline;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
  }
  th > button.sort-header::after { content: none; }
  .main-table th:not(.num):not(.number),
  .main-table td:not(.num):not(.number) { white-space: normal; }
}

/* On screen, splits arrange two panes in the golden ratio, stacked
   (rows) or side by side (columns), and nest freely. The outer split
   zooms to its first pane in the table view, following lab.js's
   data-view or the radio switch without script. Paper keeps the whole
   table without details. */
@media screen {
  .table-scroll.table-sticky { overflow: auto; scrollbar-gutter: stable; max-height: calc(100vh - 4rem); }
  .table-sticky thead { position: sticky; top: 0; z-index: 2; }
  .table-sticky thead :is(th, td) { background: var(--surface); }
  .table-sticky :is(th, td):first-child { position: sticky; left: 0; }
  .table-sticky tbody td:first-child { z-index: 1; background: var(--bg); }
  .table-sticky thead :is(th, td):first-child { z-index: 3; }

  .main-table { table-layout: fixed; }
  .main-table :is(th, td),
  .main-table th small,
  .main-table .planning-lines li {
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .main-table thead th > a,
  .main-table thead th > button.sort-header {
    display: inline-block;
    position: relative;
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    padding-inline-end: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    outline-offset: -2px;
  }
  .main-table thead th > a::after,
  .main-table thead th > button.sort-header::after {
    position: absolute;
    inset-inline-end: 0.15rem;
    inset-block-end: 0;
  }

  .main-table col.w-5 { width: 5rem; }
  .main-table col.w-6 { width: 6rem; }
  .main-table col.w-7 { width: 7rem; }
  .main-table col.w-8 { width: 8rem; }
  .main-table col.w-9 { width: 9rem; }
  .main-table col.w-10 { width: 10rem; }
  .main-table col.w-11 { width: 11rem; }
  .main-table col.w-12 { width: 12rem; }
  .main-table col.w-14 { width: 14rem; }

  /* Leave room for the flexible column when the table scrolls. */
  .note-table { min-width: 37rem; }
  .article-table { min-width: 47rem; }
  .category-table { min-width: 62rem; }
  .category-table:has(col:nth-child(7)) { min-width: 72rem; }
  #category-lots { min-width: 46rem; }
  #category-lots:has(col:nth-child(7)) { min-width: 53rem; }
  .registry-table { min-width: 63rem; }
  .batch-table { min-width: 68rem; }
  .bulk-table, .vessel-table { min-width: 69rem; }
  .planning-table { min-width: 73rem; }
  .item-table { min-width: 74rem; }
  .item-table:has(col:nth-child(11)) { min-width: 83rem; }
  .task-table { min-width: 83rem; }

  .main-table td.col-name {
    max-width: 22rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .main-table tbody tr[data-item] { cursor: pointer; }
  .main-table tbody tr[aria-current="true"] > td:not(.stock, [class*="heat-"]) {
    background: color-mix(in srgb, var(--link) 14%, var(--bg));
  }
  .main-table tbody tr[aria-current="true"] > td:first-child { box-shadow: inset 3px 0 0 var(--link); }
  .main-table tbody tr:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: -2px;
  }

  .split {
    display: grid;
    gap: 0.65rem;
    min-width: 0;
    min-height: 0;
  }
  .split__pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
  }
  .split__pane > .table-scroll,
  .split__pane > .item-detail,
  .split__pane > .split {
    flex: 1 1 0;
    min-height: 0;
  }
  .item-detail > .split {
    flex: 1 1 0;
    min-height: 0;
  }

  .split.split--rows[data-major="first"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1.618fr) minmax(0, 1fr);
  }
  .split.split--rows[data-major="second"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(0, 1.618fr);
  }
  .split.split--columns[data-major="first"] {
    grid-template-columns: minmax(0, 1.618fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }
  .split.split--columns[data-major="second"] {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.618fr);
    grid-template-rows: minmax(0, 1fr);
  }

  .split.split--outer[data-view="table"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }
  .split.split--outer[data-view="table"] > .split__pane:last-child {
    display: none;
  }
  .split.split--outer[data-view="details"] #item-detail {
    display: flex;
  }

  .widget-grid {
    flex: 1 1 0;
    min-height: 0;
    min-width: 0;
    display: grid;
    gap: 0.55rem;
    align-items: stretch;
    grid-auto-rows: minmax(0, 1fr);
  }
  .widget-grid--1 { grid-template-columns: minmax(0, 1fr); }
  .widget-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .widget-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .widget-grid > .widget,
  .widget-grid__col > .widget {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
  }
  .widget-grid__col {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-height: 0;
    min-width: 0;
  }
  .widget-grid__col > .widget { flex: 1 1 0; }
  .widget-grid .widget__head { flex: none; }
  .widget-grid .widget__body {
    flex: 1 1 0;
    min-height: 0;
    overflow: auto;
  }
  /* One column: the widgets above the last keep their content's height,
     the last takes the rest. */
  .widget-grid--1 {
    display: flex;
    flex-direction: column;
  }
  .widget-grid--1 > .widget { flex: 0 1 auto; max-height: 50%; }
  .widget-grid--1 > .widget:not(:last-child) > .widget__body { flex: 0 1 auto; }
  .widget-grid--1 > .widget:last-child { flex: 1 1 0; max-height: none; }
  .widget-grid .aux-table:not(.kv-table) th,
  .widget-grid .aux-table:not(.kv-table) td { white-space: nowrap; }
  /* Marks such as "nachgetragen" wrap below the delivery number. */
  .note-table td:first-child { white-space: normal; }

  @media (width < 56.25rem) {
    .split.split--columns[data-major="first"],
    .split.split--columns[data-major="second"],
    .split.split--rows[data-major="first"],
    .split.split--rows[data-major="second"] {
      grid-template-columns: minmax(0, 1fr);
      grid-template-rows: auto auto;
    }
    .split.split--outer[data-view="table"] {
      grid-template-rows: auto;
    }
    .split__pane > .table-scroll,
    .split__pane > .item-detail,
    .split__pane > .split,
    .item-detail > .split {
      flex: 0 1 auto;
      min-height: auto;
    }
    .split.split--outer[data-view="details"] .split__pane > .table-scroll {
      max-height: 34vh;
    }
    .widget-grid {
      grid-template-columns: minmax(0, 1fr);
      grid-auto-rows: auto;
    }
    .widget-grid .widget__body { overflow: visible; }
  }

  /* Main-list table box and sticky header styling applies at every screen
     width; the fixed-viewport frame below only stretches it above 900 px. */
  body.lab-frame .table-scroll {
    position: relative;
    overflow: auto;
    scrollbar-gutter: stable;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    background: var(--bg);
  }
  body.lab-frame .table-scroll table {
    border-collapse: separate;
    border-spacing: 0;
  }
  body.lab-frame .table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
  body.lab-frame .table-sticky thead :is(th, td):first-child { z-index: 3; }

  /* Opt-in fixed-viewport frame for the main lists on screens at least
     56.25rem (900 px) wide: no page scroll, tables and each widget body
     scroll in their own boxes under sticky headers. Off below 900 px
     and in print. */
  @media (min-width: 56.25rem) {
    html:has(body.lab-frame) {
      height: 100vh;
      overflow: hidden;
      scrollbar-gutter: auto;
    }
    body.lab-frame {
      height: 100vh;
      min-height: 0;
      overflow: hidden;
      grid-template-rows: minmax(0, 1fr);
    }
    body.lab-frame .site-header {
      grid-row: 1;
      height: 100vh;
    }
    body.lab-frame main {
      position: relative;
      grid-row: 1;
      height: 100vh;
      min-height: 0;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      padding: 0 2.5rem 0.75rem var(--space-5);
    }
    body.lab-frame .lab-messages { flex: none; margin: 0.75rem 0 0.45rem; }
    /* The menu band spans the page from the sidebar to the window's
       edge; its two rows keep one height and do not wrap, so the
       table starts at the same height on every list. */
    body.lab-frame { column-gap: 0; padding-right: 0; }
    body.lab-frame .menu-band {
      margin: 0 -2.5rem 0.625rem calc(-1 * var(--space-5));
    }
    .menu-band__top {
      flex-wrap: nowrap;
      height: 2.75rem;
      padding: 0 2.5rem 0 var(--space-5);
    }
    .menu-band__tools {
      flex-wrap: nowrap;
      height: 2.75rem;
      padding: 0 2.5rem 0 var(--space-5);
      background: var(--surface);
      /* A window too narrow for every control scrolls the row sideways
         rather than clipping it. */
      overflow-x: auto;
      scrollbar-width: thin;
    }
    body.lab-frame .menu-tabs {
      overflow-x: auto;
      scrollbar-width: none;
    }
    body.lab-frame .menu-band__summary {
      overflow: hidden;
      white-space: nowrap;
    }
    body.lab-frame .menu-band__summary > * {
      overflow: hidden;
      text-overflow: ellipsis;
    }
    body.lab-frame .split--outer {
      flex: 1 1 0;
      min-height: 0;
      overflow: hidden;
    }
    /* Positioned, so that absolutely positioned descendants such as
       visually hidden labels stay inside the scroll box instead of
       lengthening the page. */
    body.lab-frame .table-scroll {
      flex: 1 1 0;
      min-height: 0;
      max-height: none;
      margin: 0;
    }
    body.lab-frame .split__pane > .item-detail {
      height: 100%;
      overflow: hidden;
    }
    /* Record pages share the menu band's fixed top frame while only
       the content below the band scrolls, keeping the band flush to
       the window's edge. */
    body.record-frame .record-refresh {
      display: flex;
      flex-direction: column;
      flex: 1 1 0;
      min-height: 0;
    }
    body.record-frame .record-band { margin-bottom: 0; }
    /* The lists' frame stretches their table box; a record's tables
       keep their content's height, a tall one its cap. */
    body.record-frame .record-body .table-scroll {
      flex: none;
      min-height: auto;
      max-height: none;
    }
    body.record-frame .record-body .table-scroll--tall { max-height: 24rem; }
    body.record-frame .record-body {
      flex: 1 1 0;
      min-height: 0;
      overflow: auto;
      margin: 0 -2.5rem -0.75rem calc(-1 * var(--space-5));
      padding: 0.75rem 2.5rem 1.25rem var(--space-5);
    }
    .record-band .record-head__title {
      flex-wrap: nowrap;
      overflow-x: auto;
      scrollbar-width: none;
    }
    .record-band h1 { white-space: nowrap; }
  }

  /* The switch between the views is animated where the browser has view
     transitions and the user has not asked for less motion. */
  @media (prefers-reduced-motion: no-preference) {
    :root { --view-duration: 0.25s; }
    .split--outer > .split__pane > .table-scroll.table-sticky { view-transition-name: main-table; }
    .split--outer > .split__pane > #item-detail { view-transition-name: item-pane; }
    ::view-transition-group(main-table) { overflow: clip; animation-duration: var(--view-duration); }
    ::view-transition-old(main-table),
    ::view-transition-new(main-table) {
      width: 100%;
      height: 100%;
      object-fit: none;
      object-position: left top;
    }
    ::view-transition-group(item-pane) { animation-duration: var(--view-duration); }
    ::view-transition-old(item-pane) { animation: item-pane-out var(--view-duration) ease both; }
    ::view-transition-new(item-pane) { animation: item-pane-in var(--view-duration) ease both; }
    @keyframes item-pane-in { from { opacity: 0; transform: translateY(100%); } }
    @keyframes item-pane-out { to { opacity: 0; transform: translateY(100%); } }
  }
}

.note-lines { margin: 0; padding-left: var(--space-3); }
table.note-lines { padding: 0; }
.note-lines select { max-width: 30rem; }
.badge--historical { background: var(--surface); color: var(--fg); border-color: var(--border); }
.badge--reversed { background: transparent; color: var(--muted); border-color: var(--border); }

.consumption-chart { margin: 0 0 var(--space-3); max-width: 40rem; }
.consumption-chart svg { width: 100%; height: auto; font-family: var(--font-ui); font-size: 11px; }
.consumption-chart rect { fill: var(--link); }
.consumption-chart text { fill: var(--muted); }
.consumption-chart .chart-axis { stroke: var(--border); }
.consumption-chart .chart-mean { stroke: var(--focus); stroke-width: 2; stroke-dasharray: 6 4; }
.consumption-chart figcaption { color: var(--muted); font-family: var(--font-ui); font-size: 0.875rem; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The planning: multi-line cells for tasks and actions, priority badges
   and the mark of a late task. */
.planning-lines { list-style: none; margin: 0; padding: 0; }
.planning-lines > li + li { margin-top: 0.2rem; }
.priority--high { background: var(--banner-bg); color: var(--banner-fg); border-color: var(--banner-border); }
.priority--medium { background: var(--draft-bg); color: var(--draft-fg); }
.priority--low { background: var(--surface); color: var(--muted); border-color: var(--border); }
.badge--late { background: var(--banner-bg); color: var(--banner-fg); border-color: var(--banner-border); }

/* The overview at /lab/: the stock bar and its legend, the chart of the
   deliveries per month, and the summary framed by the site's home page. */
.stock-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  min-height: 1.75rem;
  border-radius: 0.2rem;
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stock-bar a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 1.8rem;
  text-decoration: none;
}
.stock-bar a:hover, .stock-bar a:focus-visible { text-decoration: underline; }
.stock-legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.85rem;
  margin: 0.45rem 0 0;
  padding: 0;
  font-size: 0.75rem;
  color: var(--muted);
}
.stock-legend li { display: inline-flex; align-items: center; gap: 0.3rem; margin: 0; }
.stock-legend .swatch { width: 0.72rem; height: 0.72rem; border-radius: 0.125rem; }
.stock-count {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.lab-empty { color: var(--muted); font-family: var(--font-ui); }
.deliveries-chart { margin: 0; overflow-x: auto; }
.deliveries-chart svg { width: 100%; min-width: 34rem; height: auto; display: block; font-family: var(--font-ui); font-size: 11px; }
.deliveries-chart rect.current { fill: var(--link); }
.deliveries-chart rect.previous { fill: var(--border); }
.deliveries-chart text { fill: var(--muted); }
.deliveries-chart text.chart-value {
  fill: var(--fg);
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.deliveries-chart text.chart-value.previous { fill: var(--muted); font-weight: 400; }
.deliveries-chart .chart-axis { stroke: var(--border); }
.chart-legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.85rem;
  margin: 0.4rem 0 0;
  padding: 0;
  font-size: 0.75rem;
  color: var(--muted);
}
.chart-legend li { display: inline-flex; align-items: center; gap: 0.3rem; margin: 0; }
.chart-legend .swatch { width: 0.72rem; height: 0.72rem; border-radius: 0.125rem; }
.chart-swatch--current { background: var(--link); }
.chart-swatch--previous { background: var(--border); }
body.lab-framed { display: block; min-height: 0; margin: 0; padding: 0; max-width: none; }
body.lab-framed main { padding: 0; }
body.lab-framed .lab-demo { margin-bottom: var(--space-2); }
body.lab-framed .figures-strip { margin-bottom: 0.6rem; }

/* Record pages: shared menu band, two-column widget grid, link rule,
   compact consumption widget and widget-local adjustments. */
main:has(.record-band) { padding-top: 0; }
.record-band .menu-band__top { align-items: stretch; }
.record-band .record-head__title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.record-band h1 {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  margin: 0 0 -1px;
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  color: var(--fg);
  border-bottom: 2.5px solid var(--link);
}
.record-band .badge {
  font-size: 0.6875rem;
  line-height: 1.4;
  padding: 0.02rem 0.48rem;
  white-space: nowrap;
}
.record-band .record-head__key {
  font-family: var(--font-mono);
  font-size: 0.71875rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--muted);
  padding: 0.04rem 0.38rem;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
  border-radius: 0.2rem;
  white-space: nowrap;
}
/* The back link comes first in the markup, before the heading, and
   shows at the row's end as a button. */
.record-band .lab-back {
  order: 2;
  display: flex;
  align-items: center;
  flex: none;
  margin: 0 0 0 auto;
  font-size: inherit;
}
.record-band .lab-back a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 1.85rem;
  padding: 0 0.72rem;
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  color: var(--fg);
  white-space: nowrap;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
}
.record-band .lab-back a:hover {
  color: var(--fg);
  text-decoration: none;
  border-color: var(--muted);
}
.record-band .lab-back a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.record-band .lab-back a [aria-hidden="true"] { color: var(--muted); }
.record-band__tools .lab-actions {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  margin: 0;
}
.record-band__tools .lab-actions form { display: contents; }

@media screen {
  .overview-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(19rem, 0.95fr);
    gap: 0.85rem;
    align-items: start;
  }
  .overview-col {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    min-width: 0;
  }
  .record-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 20rem;
    gap: 0.9rem;
    align-items: start;
  }
  .record-main {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    min-width: 0;
  }
  .record-aside {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    min-width: 0;
  }
  .substance-trio {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 0.85rem;
    align-items: stretch;
  }
  .substance-trio > .widget {
    display: flex;
    flex-direction: column;
  }
  .substance-trio > .widget > .widget__body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
  }
  .substance-trio .widget__foot { margin-top: auto; }
  @media (max-width: 60rem) {
    .overview-grid, .record-grid { grid-template-columns: minmax(0, 1fr); }
    .record-aside { position: static; }
  }
  .table-scroll--tall { max-height: 24rem; overflow: auto; }
}

/* Consistent link treatment across record-page content: no underline at
   rest, underline on hover and keyboard focus, same --link colour for
   visited records, and a clear focus ring. */
:is(.record-grid, .figures-strip) a:not(.lab-button),
:is(.record-grid, .figures-strip) a:not(.lab-button):visited {
  color: var(--link);
  text-decoration: none;
  text-underline-offset: 0.16em;
  text-decoration-thickness: 1.5px;
}
:is(.record-grid, .figures-strip) a:not(.lab-button):hover {
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
}
:is(.record-grid, .figures-strip) a:not(.lab-button):focus-visible {
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 0.125rem;
}

.record-aside .kv-table th {
  width: 41%;
  white-space: normal;
  overflow-wrap: break-word;
}
.record-aside .kv-table td { padding-left: 0.35rem; }

.figures-strip { gap: 0.6rem; margin-bottom: 0.9rem; }
.figure-tile { padding: 0.45rem 0.7rem; gap: 0.14rem; }
.figure-tile__label { font-weight: 500; }
.figures-strip .stock {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  padding: 0.05rem 0.45rem;
  border-radius: 0.25rem;
}
.history-change { font-family: var(--font-mono); font-size: 0.71875rem; }
.item-note {
  padding: 0.45rem 0.6rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.item-note > :first-child { margin-top: 0; }
.item-note > :last-child { margin-bottom: 0; }
details.widget > summary.widget__head:hover {
  background: color-mix(in srgb, var(--surface) 75%, var(--border));
}
.widget__foot {
  padding: 0.42rem 0.65rem;
  font-size: 0.75rem;
  background: color-mix(in srgb, var(--surface) 45%, var(--bg));
  border-top: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.widget__foot a { font-weight: 500; }
.widget__body--flush > p.lab-empty {
  padding: 0.55rem 0.65rem;
  font-size: 0.75rem;
}

/* Compact consumption widget (item page): side-by-side chart and dense
   scrollable quarter table when the main column has room, stacked
   compactly when narrower. */
.widget--consumption { container-type: inline-size; }
.consumption-layout {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
@container (min-width: 41rem) {
  .consumption-layout {
    display: grid;
    grid-template-columns: minmax(14.5rem, 1fr) minmax(23.5rem, 1.15fr);
    gap: 0.75rem;
    align-items: start;
  }
}
.consumption-layout .consumption-chart {
  margin: 0;
  max-width: 28rem;
}
@container (min-width: 41rem) {
  .consumption-layout .consumption-chart { max-width: none; }
}
.consumption-layout .consumption-chart svg {
  display: block;
  width: 100%;
  height: auto;
  font-family: var(--font-ui);
  font-size: 10px;
}
.consumption-layout .consumption-chart .chart-grid {
  stroke: color-mix(in srgb, var(--border) 60%, transparent);
  stroke-dasharray: 2 2;
}
.consumption-layout .consumption-chart .chart-value {
  fill: var(--fg);
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.consumption-layout .consumption-chart .chart-year {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.consumption-layout .consumption-chart .chart-mean {
  stroke: var(--focus);
  stroke-width: 1.5;
  stroke-dasharray: 5 3;
}
.consumption-layout .consumption-chart figcaption {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.3rem;
  font-size: 0.71875rem;
  line-height: 1.3;
  color: var(--muted);
}
.consumption-layout .consumption-chart figcaption::before {
  content: "";
  display: inline-block;
  width: 1.1rem;
  border-top: 2px dashed var(--focus);
  flex: none;
}
/* Capped also where a frame stretches its table boxes: on a record
   page and in a list's dialog. */
.consumption-table-wrap,
body.lab-frame .table-scroll.consumption-table-wrap,
body.record-frame .record-body .table-scroll.consumption-table-wrap {
  max-height: 11.5rem;
  overflow: auto;
  border: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
  border-radius: 0.2rem;
}
@container (min-width: 41rem) {
  .consumption-table-wrap,
  body.lab-frame .table-scroll.consumption-table-wrap,
  body.record-frame .record-body .table-scroll.consumption-table-wrap {
    max-height: 12.25rem;
  }
}
.widget .consumption-table { font-size: 0.71875rem; }
.widget .consumption-table thead th {
  padding: 0.22rem 0.42rem;
  font-size: 0.65625rem;
  line-height: 1.2;
  white-space: normal;
  vertical-align: bottom;
}
.widget .consumption-table tbody :is(th, td) {
  padding: 0.17rem 0.42rem;
  white-space: nowrap;
}
.widget .consumption-table tbody th {
  font-weight: 600;
  color: var(--fg);
}
.widget .consumption-table tr.year-start > :is(th, td) {
  border-top: 1px solid var(--border);
}
.widget .consumption-table td.consumption-total { font-weight: 600; }
.widget .consumption-table td.consumption-action { text-align: right; }

/* Item page: prevent mid-word breaks in the 10-column Buchungen table;
   let .table-scroll handle horizontal scrolling without overflowing
   the widget. */
#movements td { overflow-wrap: normal; }
#movements td:nth-child(3) { white-space: nowrap; }
#movements td:nth-child(8) { min-width: 11.5rem; }
#movements td:nth-child(8) a { white-space: nowrap; }
#movements td:nth-child(9) { overflow-wrap: break-word; }

/* Task page: slack summary row inside the forecast widget footer. */
.task-slack {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}

/* Delivery note and open-delivery forms: multi-column head fields,
   row-sum bar with muted unbooked badge, growing rows table, stock-after
   preview pills, and quiet row-removal icon button. */
.lab-form.note-form {
  max-width: 68rem;
}
.lab-dialog .lab-form.note-form {
  max-width: none;
}
.note-head-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-2);
}
.note-head-fields > .lab-field {
  margin: 0;
  min-width: 0;
}
.note-head-fields > .lab-field:has(textarea),
.note-head-fields > .lab-field:has(input[type="checkbox"]) {
  grid-column: 1 / -1;
}
.note-head-fields textarea {
  min-height: 2.5rem;
}
.note-lines-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  margin: var(--space-3) 0 var(--space-2);
}
.note-lines-sum {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.note-lines-unbooked {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  font-size: 0.71875rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
}
.note-lines-add {
  margin-left: auto;
}
.note-lines-add[hidden] {
  display: none;
}
.note-lines-wrap {
  min-width: 0;
}
.note-lines {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  margin: 0 0 var(--space-3);
  font-family: var(--font-ui);
  font-size: 0.875rem;
}
.note-lines thead th {
  padding: 0.4rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: left;
  color: var(--muted);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.note-lines thead th:first-child { border-top-left-radius: 0.22rem; }
.note-lines thead th:last-child { border-top-right-radius: 0.22rem; }
.note-lines thead th.note-line-count { text-align: right; }
.note-lines tbody td {
  padding: 0.45rem 0.5rem;
  vertical-align: top;
  background: var(--bg);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
}
.note-lines tbody tr:last-child td { border-bottom: 0; }
.note-lines tbody tr:last-child td:first-child { border-bottom-left-radius: 0.22rem; }
.note-lines tbody tr:last-child td:last-child { border-bottom-right-radius: 0.22rem; }
.note-lines td.lab-field { margin: 0; }
.note-lines .ts-wrapper,
.note-lines .ts-control { width: 100%; min-width: 0; }
.note-lines .note-line-item { width: auto; }
.note-lines .note-line-batch { width: 24%; }
.note-line-batch .lab-action-new:not([hidden]) {
  display: inline-flex;
  margin-top: 0.25rem;
}
.note-line-new-batch {
  height: 1.55rem;
  padding: 0 0.5rem;
  font-size: 0.78125rem;
}
.note-line-unknown {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.78125rem;
  color: var(--muted);
}
.note-lines .note-line-count { width: 5.25rem; }
.note-lines .note-line-count input {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.note-lines .note-line-preview {
  width: 11rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  padding-top: 0.65rem;
}
.note-lines .note-line-actions {
  width: 2.25rem;
  text-align: center;
  padding-top: 0.5rem;
}
.note-line-stock .stock {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  padding: 0.1rem 0.45rem;
  border-radius: 0.25rem;
  font-size: 0.8125rem;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.note-line-stock .stock--too-few {
  background: var(--level-out-bg);
  color: var(--level-out-fg);
}
.note-line-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-family: var(--font-ui);
  font-size: 1.1rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.25rem;
  cursor: pointer;
}
.note-line-remove:hover {
  color: var(--level-out-fg);
  background: var(--level-out-bg);
  border-color: color-mix(in srgb, var(--level-out-fg) 35%, transparent);
}
.note-line-remove:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.note-line-remove[hidden] {
  display: none;
}
@media (max-width: 48rem) {
  .note-head-fields {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Live server-rendered booking preview box on stock forms (filling,
   count correction, withdrawal, transfer, vessel correction). */
.booking-preview {
  margin: var(--space-3) 0;
  padding: 0.8rem 0.95rem;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
  border-radius: 0.35rem;
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
.booking-preview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  margin: 0 0 0.55rem;
}
.booking-preview-title {
  font-size: 0.78125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--fg);
}
.booking-preview-unbooked {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.2rem;
}
.booking-preview-lines {
  display: grid;
  gap: 0.38rem;
  margin: 0;
  padding: 0;
}
.booking-preview-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.2rem 0.75rem;
}
.booking-preview-line dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}
.booking-preview-line dd {
  margin: 0 0 0 auto;
  text-align: right;
  color: var(--fg);
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 0.2rem 0.4rem;
}
.booking-preview-arrow {
  color: var(--muted);
}
.booking-preview .stock {
  display: inline-flex;
  align-items: baseline;
  padding: 0.05rem 0.45rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.35;
}
.booking-preview .stock--too-few {
  background: var(--level-out-bg);
  color: var(--level-out-fg);
}
.booking-preview-mark {
  display: inline-block;
  padding: 0.02rem 0.4rem;
  font-size: 0.71875rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.2rem;
}
.booking-preview-message {
  color: var(--level-out-fg);
  font-weight: 500;
  text-align: right;
}
.booking-preview-note {
  margin: 0.55rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}
