/*
 * Styles of the web app (#98). Only semantic tokens from tokens.css (documentation/design.md), no Tailwind; every
 * component has its own block. Layers: base (elements), components (platform.ui building blocks), shell (frame of
 * every page), page (page-specific rules, login and example page).
 */
@font-face {
  font-family: "Inter";
  src: url("/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@layer base, components, shell, page;

@layer base {
  :root {
    color-scheme: light dark;
  }

  :root[data-theme="light"] {
    color-scheme: light;
  }

  :root[data-theme="dark"] {
    color-scheme: dark;
  }

  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  body {
    margin: 0;
    background: var(--color-background);
    color: var(--color-text-default);
    font-family: var(--font-family-sans);
    font-size: var(--font-size-base);
    line-height: var(--font-line-height-normal);
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
  }

  h1,
  h2,
  h3,
  p {
    margin: 0;
  }

  h1,
  h2,
  h3 {
    text-wrap: balance;
    letter-spacing: -0.015em;
    line-height: var(--font-line-height-tight);
  }

  button,
  input,
  select,
  textarea {
    font: inherit;
    color: inherit;
  }

  a {
    color: var(--color-text-link);
  }

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

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

  .icon {
    display: inline-flex;
    flex: none;
  }

  .ic {
    width: 16px;
    height: 16px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .ic-lg {
    width: 20px;
    height: 20px;
  }

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  @media (prefers-reduced-motion: reduce) {
    * {
      animation: none !important;
      transition: none !important;
    }
  }
}

@layer components {
  /* Buttons: compact with a fine pointer, comfortable (44 px) on touch. */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--size-control-compact);
    padding-inline: var(--space-3);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: var(--color-secondary-default);
    color: var(--color-text-default);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background var(--duration-fast);
  }

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

  .btn.primary {
    background: var(--color-primary-default);
    color: var(--color-text-on-primary);
  }

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

  .btn.ghost {
    background: transparent;
  }

  .btn.ghost:hover {
    background: var(--color-surface-hover);
  }

  .btn.outline {
    background: var(--color-surface-default);
    border-color: var(--color-border-strong);
  }

  .btn.danger {
    background: var(--color-error-solid);
    color: var(--color-error-on-solid);
  }

  .btn[disabled] {
    background: var(--color-surface-sunken);
    color: var(--color-text-disabled);
    cursor: not-allowed;
  }

  /* Fields: the class sits on the input itself or on a wrapper with icons around the input. */
  .field {
    display: grid;
    align-content: start;
    gap: var(--space-1);
    min-width: 0;
  }

  .field label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
  }

  .input {
    min-height: var(--size-control-compact);
    min-width: 0;
    padding-inline: var(--space-3);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface-default);
  }

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

  /* A text of several lines (TextAreaField): padding above and below, grows downwards only. */
  textarea.input {
    padding-block: var(--space-2);
    resize: vertical;
    line-height: var(--font-line-height-normal);
  }

  /* Read-only forms are `inert`: the fields look unavailable, not editable. */
  [inert] .input {
    background: var(--color-surface-sunken);
  }

  /* Dropdowns (select): the closed field looks like an input with a themed chevron (two gradients, so it follows the
     colour tokens in light and dark). Browsers with customizable selects (appearance: base-select) also get the
     opened list in the design; the others keep their native list. */
  select.input {
    appearance: none;
    padding-inline-end: calc(var(--space-3) * 2 + 10px);
    background-color: var(--color-surface-default);
    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% - var(--space-3) - 5px) 50%,
      calc(100% - var(--space-3)) 50%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    cursor: pointer;
  }

  select.input:disabled {
    background-color: var(--color-surface-sunken);
    color: var(--color-text-disabled);
    cursor: default;
  }

  @supports (appearance: base-select) {
    select.input,
    select.input::picker(select) {
      appearance: base-select;
    }

    select.input {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: var(--space-2);
      background-image: none;
      padding-inline: var(--space-3);
    }

    select.input::picker-icon {
      color: var(--color-text-muted);
      transition: rotate var(--duration-fast);
    }

    select.input:open::picker-icon {
      rotate: 180deg;
    }

    select.input::picker(select) {
      margin-top: var(--space-1);
      padding: var(--space-1);
      border: 1px solid var(--color-border-default);
      border-radius: var(--radius-md);
      background: var(--color-surface-raised);
      color: var(--color-text-default);
    }

    select.input option {
      display: flex;
      align-items: center;
      gap: var(--space-2);
      min-height: var(--size-control-compact);
      padding: 0 var(--space-2);
      border-radius: var(--radius-sm);
      cursor: pointer;
    }

    select.input option:hover,
    select.input option:focus-visible {
      background: var(--color-surface-hover);
    }

    select.input option:checked {
      background: var(--color-surface-selected);
      font-weight: var(--font-weight-medium);
    }

    select.input option::checkmark {
      order: 1;
      margin-inline-start: auto;
    }
  }

  /* Popup list of the user menu and "Mehr". */
  .popup {
    position: relative;
  }

  .popup-list {
    position: absolute;
    z-index: 20;
    right: 0;
    top: calc(100% + var(--space-1));
    min-width: 14rem;
    display: grid;
    margin: 0;
    padding: var(--space-1);
    list-style: none;
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-surface-raised);
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
  }

  .menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    min-height: var(--size-control-compact);
    padding: 0 var(--space-2);
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-default);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
  }

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

  /* Modal dialog on the native <dialog>. */
  .dialog {
    max-width: min(32rem, calc(100vw - 2 * var(--space-4)));
    display: grid;
    gap: var(--space-4);
    padding: var(--space-6);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-lg);
    background: var(--color-surface-raised);
    color: var(--color-text-default);
    box-shadow: 0 16px 48px rgb(0 0 0 / 0.28);
  }

  .dialog::backdrop {
    background: rgb(0 0 0 / 0.4);
  }

  .dialog h2 {
    font-size: var(--font-size-xl);
  }

  .dialog h3:not(:first-child) {
    margin-top: var(--space-4);
  }

  .dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-2);
  }

  .btn.icon-only {
    width: var(--size-control-compact);
    padding-inline: 0;
  }

  .kbd {
    padding: 1px 5px;
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
  }

  .btn.primary .kbd {
    border-color: currentColor;
    color: inherit;
  }

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

  /* Form fields with label, hint and error (FieldFrame). */
  .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: var(--space-4);
  }

  /* A part of a form that takes the whole width, e.g. the address block (#100). */
  .form-grid > .form-wide {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
    grid-column: 1 / -1;
  }

  .field .required {
    color: var(--color-error-fg);
  }

  /* A value shown in a field that cannot be changed, e.g. the stock of INDIVIDUAL equipment (#101). */
  .input.readonly-value {
    display: flex;
    align-items: center;
    background: var(--color-surface-sunken);
    color: var(--color-text-muted);
  }

  .instances {
    margin-top: var(--space-6);
  }

  .hint {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
  }

  .hint.error {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--color-error-fg);
  }

  .field.invalid .input {
    border-color: var(--color-error-fg);
    box-shadow: inset 3px 0 0 var(--color-error-fg);
  }

  .input-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  .input-group input {
    width: 100%;
    min-width: 0;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
  }

  .input-group:focus-within {
    outline: 2px solid var(--color-focus);
    outline-offset: 1px;
    border-color: var(--color-focus);
  }

  .input-group.num input {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  .input-group .unit {
    color: var(--color-text-muted);
  }

  fieldset.field {
    margin: 0;
    padding: 0;
    border: 0;
  }

  fieldset.field legend {
    margin-bottom: var(--space-1);
    padding: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
  }

  /* Address fields (#100): street and house number, postal code and city side by side, one column on the phone. */
  fieldset.address-fields {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }

  fieldset.address-fields legend {
    margin-bottom: var(--space-2);
    padding: 0;
    font-weight: var(--font-weight-semibold);
  }

  .address-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-4);
    max-width: 48rem;
  }

  .address-street,
  .address-city {
    grid-column: span 3;
  }

  .address-country {
    grid-column: span 2;
  }

  @media (max-width: 599.98px) {
    .address-grid {
      grid-template-columns: minmax(0, 1fr);
    }

    .address-grid > * {
      grid-column: auto;
    }
  }

  .datetime-parts {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-2);
  }

  .datetime-parts select {
    grid-column: 1 / -1;
  }

  .check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
  }

  .check input {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary-default);
  }

  /* Check box groups side by side (roles by area) and plain lists in a dialog. */
  .role-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: var(--space-4);
  }

  /* A dialog with role sections takes the full width so the sections sit side by side, and keeps its buttons in view. */
  .dialog:has(.role-sections) {
    width: min(48rem, calc(100vw - 2 * var(--space-4)));
  }

  .dialog:has(.role-sections) .dialog-actions {
    position: sticky;
    bottom: calc(-1 * var(--space-6));
    padding-block: var(--space-3);
    background: var(--color-surface-raised);
  }

  .role-area {
    font-weight: var(--font-weight-medium);
  }

  .plain-list {
    margin: 0;
    padding-left: var(--space-5);
  }

  /* Search selection (ARIA combobox). */
  .combobox {
    position: relative;
  }

  .combobox-list {
    position: absolute;
    z-index: 20;
    right: 0;
    left: 0;
    top: calc(100% + var(--space-1));
    max-height: 16rem;
    overflow-y: auto;
    margin: 0;
    padding: var(--space-1);
    list-style: none;
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-surface-raised);
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
  }

  .combobox-option {
    display: grid;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    cursor: pointer;
  }

  .combobox-option .muted {
    font-size: var(--font-size-sm);
  }

  .combobox-option.active,
  .combobox-option:hover {
    background: var(--color-surface-selected);
    color: var(--color-primary-on-subtle);
  }

  .combobox-status {
    padding: var(--space-1) var(--space-2);
    color: var(--color-text-muted);
  }

  /* Status chips: colour plus icon plus label, never colour alone. */
  .chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding-inline: 8px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.01em;
    white-space: nowrap;
  }

  /* Several chips in one cell: they wrap instead of widening the page (phone cards). */
  .chip-list {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    gap: var(--space-1);
    min-width: 0;
  }

  .chip .ic {
    width: 12px;
    height: 12px;
    stroke-width: 2.5;
  }

  .tone-neutral { color: var(--color-neutral-fg); background: var(--color-neutral-bg); }
  .tone-info { color: var(--color-info-fg); background: var(--color-info-bg); }
  .tone-success { color: var(--color-success-fg); background: var(--color-success-bg); }
  .tone-warning { color: var(--color-warning-fg); background: var(--color-warning-bg); }
  .tone-error { color: var(--color-error-fg); background: var(--color-error-bg); }
  .st-inquiry { color: var(--status-job-inquiry-fg); background: var(--status-job-inquiry-bg); }
  .st-offer { color: var(--status-job-offer-fg); background: var(--status-job-offer-bg); }
  .st-confirmed { color: var(--status-job-confirmed-fg); background: var(--status-job-confirmed-bg); }
  .st-completed { color: var(--status-job-completed-fg); background: var(--status-job-completed-bg); }
  .st-cancelled { color: var(--status-job-cancelled-fg); background: var(--status-job-cancelled-bg); text-decoration: line-through; }
  .st-conflict { color: var(--status-conflict-fg); background: var(--status-conflict-bg); }
  .st-overbooked { color: var(--status-overbooked-fg); background: var(--status-overbooked-bg); }
  .st-requested { color: var(--status-staffing-requested-fg); background: var(--status-staffing-requested-bg); }
  .st-staffed { color: var(--status-staffing-confirmed-fg); background: var(--status-staffing-confirmed-bg); }
  .st-declined { color: var(--status-staffing-declined-fg); background: var(--status-staffing-declined-bg); }
  .st-open { color: var(--status-invoice-open-fg); background: var(--status-invoice-open-bg); }
  .st-paid { color: var(--status-invoice-paid-fg); background: var(--status-invoice-paid-bg); }
  .st-overdue { color: var(--status-invoice-overdue-fg); background: var(--status-invoice-overdue-bg); }

  /* Notices: the text stays in text.default so it is readable, colour and symbol carry the kind. */
  .alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    min-width: 0;
    padding: var(--space-3) var(--space-4);
    border: 1px solid;
    border-radius: var(--radius-md);
  }

  .alert .icon {
    margin-top: 2px;
  }

  .alert .body {
    flex: 1;
    display: grid;
    gap: 2px;
    min-width: 0;
  }

  .alert .body p {
    color: var(--color-text-default);
  }

  .alert-title {
    font-weight: var(--font-weight-semibold);
  }

  .alert.info,
  .alert.neutral { color: var(--color-info-fg); background: var(--color-info-bg); border-color: color-mix(in srgb, var(--color-info-fg) 30%, transparent); }
  .alert.success { color: var(--color-success-fg); background: var(--color-success-bg); border-color: color-mix(in srgb, var(--color-success-fg) 30%, transparent); }
  .alert.warning { color: var(--color-warning-fg); background: var(--color-warning-bg); border-color: color-mix(in srgb, var(--color-warning-fg) 30%, transparent); }
  .alert.error { color: var(--color-error-fg); background: var(--color-error-bg); border-color: color-mix(in srgb, var(--color-error-fg) 30%, transparent); }

  /* Empty and loading states. */
  .empty-state {
    display: grid;
    justify-items: center;
    gap: var(--space-2);
    padding: var(--space-8) var(--space-4);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-lg);
    text-align: center;
  }

  .empty-state h2 {
    font-size: var(--font-size-lg);
  }

  .empty-state .muted {
    max-width: 40ch;
  }

  .skeleton-group {
    display: grid;
    gap: var(--space-2);
  }

  .skeleton {
    height: 12px;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--color-surface-sunken), var(--color-surface-hover), var(--color-surface-sunken));
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
  }

  @keyframes shimmer {
    to {
      background-position: -200% 0;
    }
  }

  /* Toasts: bottom right, above the bottom bar on the phone. */
  .toast-region {
    position: fixed;
    z-index: 40;
    right: var(--space-4);
    bottom: calc(var(--size-bottom-nav) + env(safe-area-inset-bottom) + var(--space-4));
    left: var(--space-4);
    display: grid;
    justify-items: end;
    gap: var(--space-2);
    pointer-events: none;
  }

  .toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    max-width: 28rem;
    padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-surface-raised);
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
    pointer-events: auto;
  }

  .toast.success > .icon { color: var(--color-success-fg); }
  .toast.info > .icon,
  .toast.neutral > .icon { color: var(--color-info-fg); }
  .toast.warning > .icon { color: var(--color-warning-fg); }
  .toast.error > .icon { color: var(--color-error-fg); }

  .toast-text {
    flex: 1;
  }

  /* Tables inside components (conflict list); the data table follows in its own block. */
  .table-wrap {
    overflow-x: auto;
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-surface-default);
  }

  table.data {
    width: 100%;
    border-collapse: collapse;
  }

  table.data th {
    height: var(--size-row-compact);
    padding-inline: var(--space-2);
    border-bottom: 1px solid var(--color-border-default);
    background: var(--color-surface-header);
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.05em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
  }

  table.data td {
    height: var(--size-row-compact);
    padding-inline: var(--space-2);
    border-bottom: 1px solid var(--color-border-default);
    white-space: nowrap;
  }

  table.data tr:last-child td {
    border-bottom: 0;
  }

  /* Data table (#98): sticky header, sortable headers, actions per row, pager. */
  .table-wrap table.data thead th {
    position: sticky;
    top: 0;
  }

  table.data tbody tr:hover {
    background: var(--color-surface-hover);
  }

  table.data th.sorted {
    color: var(--color-text-default);
  }

  table.data .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  .sort-button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    cursor: pointer;
  }

  .sort-button .ic {
    width: 12px;
    height: 12px;
  }

  table.data th:not(.sorted) .sort-button .icon {
    opacity: 0.5;
  }

  table.data .actions-col {
    width: 1%;
    text-align: right;
    white-space: nowrap;
  }

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

  .list-search {
    flex: 1 1 16rem;
    max-width: 28rem;
  }

  .pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
  }

  .list-loading {
    opacity: 0.6;
  }

  @media (pointer: coarse) {
    table.data td,
    table.data th {
      height: var(--size-touch-target);
    }
  }

  /* Data table on the phone (#100): every row a card, the first column as title, the others with their label. */
  @media screen and (max-width: 599.98px) {
    .table-wrap:has(> table.cards) {
      overflow: visible;
      border: 0;
      background: transparent;
    }

    table.cards,
    table.cards tbody {
      display: block;
    }

    table.cards thead {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip: rect(0 0 0 0);
    }

    table.cards tbody tr {
      display: flex;
      flex-direction: column;
      gap: var(--space-1);
      margin-bottom: var(--space-2);
      padding: var(--space-3);
      border: 1px solid var(--color-border-default);
      border-radius: var(--radius-md);
      background: var(--color-surface-default);
    }

    table.cards tbody tr:hover {
      background: var(--color-surface-default);
    }

    table.cards td {
      display: flex;
      gap: var(--space-3);
      height: auto;
      padding: 0;
      border: 0;
      white-space: normal;
      overflow-wrap: anywhere;
    }

    table.cards td::before {
      content: attr(data-label);
      flex: 0 0 7.5rem;
      color: var(--color-text-muted);
      font-size: var(--font-size-sm);
    }

    table.cards td.num {
      text-align: left;
    }

    table.cards td:empty {
      display: none;
    }

    /* A chip with a long text (e.g. "Überfällig seit …") wraps instead of widening the card. */
    table.cards td .chip {
      height: auto;
      min-height: 22px;
      padding-block: 2px;
      white-space: normal;
    }

    table.cards td.card-title {
      font-size: var(--font-size-md);
      font-weight: var(--font-weight-semibold);
    }

    table.cards td.card-title::before,
    table.cards td.actions-col::before {
      content: none;
    }

    table.cards td.actions-col {
      justify-content: flex-end;
      width: auto;
    }
  }

  /* Expandable rows (#54): the first cell indented by the depth, a toggle before rows with children, a line for
     loading, failure and children not shown. The row itself takes the focus (tree grid). */
  .tree-cell {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding-inline-start: calc(var(--space-5) * var(--tree-depth, 0));
  }

  .tree-content {
    min-width: 0;
  }

  .tree-toggle,
  .tree-spacer {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: var(--size-control-compact);
    height: var(--size-control-compact);
  }

  .tree-toggle {
    gap: var(--space-1);
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-muted);
    font: inherit;
    cursor: pointer;
  }

  .tree-toggle:hover {
    background: var(--color-surface-hover);
    color: var(--color-text-default);
  }

  .tree-toggle-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  table.data tr.tree-row:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: -2px;
  }

  table.data tr.tree-status td {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
  }

  .tree-status-text {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding-inline-start: calc(var(--space-5) * var(--tree-depth, 0) + var(--size-control-compact));
  }

  .tree-error {
    color: var(--color-error-fg);
  }

  @media (pointer: coarse) {
    .tree-toggle,
    .tree-spacer {
      height: var(--size-touch-target);
    }
  }

  /* On the phone the tree is a list of cards, indented by the depth; the toggle names the children. */
  @media screen and (max-width: 599.98px) {
    table.cards tbody tr.tree-row,
    table.cards tbody tr.tree-status {
      margin-inline-start: calc(var(--space-4) * var(--tree-depth, 0));
    }

    table.cards tr.tree-row .tree-cell {
      flex-wrap: wrap;
      width: 100%;
      padding-inline-start: 0;
    }

    table.cards tr.tree-row .tree-content {
      flex: 1 1 100%;
      order: -1;
    }

    table.cards .tree-spacer {
      display: none;
    }

    table.cards .tree-toggle {
      width: auto;
      min-height: var(--size-touch-target);
      margin-inline-start: calc(-1 * var(--space-2));
      padding-inline: var(--space-2) var(--space-3);
      color: var(--color-text-default);
      font-size: var(--font-size-sm);
      font-weight: var(--font-weight-medium);
    }

    table.cards .tree-toggle-label {
      position: static;
      width: auto;
      height: auto;
      overflow: visible;
      clip: auto;
    }

    table.cards tbody tr.tree-status {
      padding: var(--space-2) var(--space-3);
    }

    table.cards tr.tree-status td::before {
      content: none;
    }

    .tree-status-text {
      padding-inline-start: 0;
    }
  }

  /* Breadcrumb (#54): links separated by "›", the current page not underlined; on the phone parent and page only. */
  .breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
  }

  .breadcrumb li {
    display: inline-flex;
    align-items: center;
    min-width: 0;
  }

  .breadcrumb li + li::before {
    content: "›";
    padding-inline: var(--space-2);
  }

  .breadcrumb a {
    overflow: hidden;
    color: inherit;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

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

  .breadcrumb .crumb-ellipsis {
    display: none;
  }

  @media screen and (max-width: 599.98px) {
    .breadcrumb .crumb-far {
      display: none;
    }

    .breadcrumb .crumb-ellipsis {
      display: inline-flex;
    }

    /* The ellipsis is the first visible link: no separator before it. */
    .breadcrumb li.crumb-ellipsis::before {
      content: none;
    }
  }

  /* Tabs (#100, #101): links with their own URL, the current one underlined; scroll sideways on the phone. */
  .tabs {
    display: flex;
    gap: var(--space-1);
    overflow-x: auto;
    border-bottom: 1px solid var(--color-border-default);
    scrollbar-width: thin;
  }

  .tab {
    display: inline-flex;
    flex: none;
    align-items: center;
    min-height: var(--size-control-compact);
    margin-bottom: -1px;
    padding-inline: var(--space-3);
    border-bottom: 2px solid transparent;
    color: var(--color-text-muted);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
    white-space: nowrap;
  }

  .tab:hover {
    color: var(--color-text-default);
  }

  .tab[aria-current="page"] {
    border-bottom-color: var(--color-primary-default);
    color: var(--color-text-default);
    font-weight: var(--font-weight-semibold);
  }

  .tab:focus-visible {
    outline-offset: -2px;
  }

  @media (pointer: coarse) {
    .tab {
      min-height: var(--size-touch-target);
    }
  }

  /* Editable grid (#98): three states told apart without colour too (design.md): selected row with a petrol edge,
     focused cell with the focus ring, edited cell with an input. */
  .grid-wrap {
    position: relative;
    max-height: 70vh;
    overflow: auto;
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-surface-default);
  }

  .grid-wrap table.data thead th {
    position: sticky;
    z-index: 1;
    top: 0;
  }

  table.grid td {
    position: relative;
    cursor: cell;
  }

  table.grid tr.selected td {
    background: var(--color-surface-selected);
  }

  table.grid tr.selected td:first-child {
    box-shadow: inset 3px 0 0 var(--color-primary-default);
  }

  table.grid td.readonly {
    background: var(--color-surface-sunken);
    color: var(--color-text-muted);
  }

  table.grid td.cell-focus {
    outline: 2px solid var(--color-focus);
    outline-offset: -2px;
  }

  /* The editor lies over the cell and takes no space of its own: the cell keeps its text as an invisible sizer, so
     starting to edit changes neither the cell nor any column width (an input in the flow brings its own intrinsic
     width, and the automatic table layout would widen this column at the cost of the others). */
  table.grid td.editing .cell-sizer {
    visibility: hidden;
  }

  table.grid td.editing .input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding-inline: var(--space-1);
    border-color: var(--color-focus);
  }

  table.grid td.pasted {
    background: color-mix(in srgb, var(--color-info-bg) 60%, transparent);
  }

  table.grid td.invalid {
    box-shadow: inset 3px 0 0 var(--color-error-fg);
    color: var(--color-error-fg);
  }

  .cell-error {
    display: block;
    color: var(--color-error-fg);
    font-size: var(--font-size-xs);
    white-space: normal;
  }

  /* Actions of a grid row: outside the editable cells, so no cell cursor. */
  table.grid td.row-actions {
    width: 1%;
    cursor: default;
    text-align: right;
    white-space: nowrap;
  }

  table.grid td.row-actions .chip {
    margin-inline-end: var(--space-2);
  }

  /* A chip that follows the text of a cell, like the main address mark behind the type. */
  .after-text {
    margin-inline-start: var(--space-2);
  }

  .grid-hint {
    margin-block: var(--space-2);
  }

  .paste-sink {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
  }

  /* On touch the editor keeps 16 px, so iOS does not zoom in. */
  @media (pointer: coarse) {
    table.grid td.editing .input {
      font-size: 16px;
    }
  }

  @media print {
    .grid-wrap {
      max-height: none;
      overflow: visible;
    }
  }

  /* Overview of the shortcuts (?). */
  .shortcut-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    gap: var(--space-6);
  }

  .shortcut-columns h3 {
    margin-bottom: var(--space-2);
    font-size: var(--font-size-md);
  }

  .shortcut-list {
    border-collapse: collapse;
  }

  .shortcut-list th,
  .shortcut-list td {
    padding: var(--space-1) var(--space-2) var(--space-1) 0;
    vertical-align: top;
    text-align: left;
  }

  .shortcut-list th {
    white-space: nowrap;
    font-weight: var(--font-weight-regular);
  }

  /* Printing: content only, light, all rows (no scroll containers), no controls. */
  @media print {
    :root {
      color-scheme: light;
    }

    .toolbar,
    .pager,
    .toast-region,
    .page-head .actions,
    table.data .actions-col,
    .paste-sink {
      display: none !important;
    }

    .table-wrap {
      overflow: visible;
      border: 0;
    }

    table.data thead {
      display: table-header-group;
    }

    table.data tr {
      break-inside: avoid;
    }
  }

  .dialog.wide {
    max-width: min(48rem, calc(100vw - 2 * var(--space-4)));
  }

  /* Sheet (#169): on the phone docked to the bottom edge over the full width, from 600 px a dialog. */
  @media (max-width: 599.98px) {
    .dialog.sheet {
      width: 100%;
      max-width: 100%;
      max-height: 85vh;
      margin: auto 0 0;
      overflow-y: auto;
      border-radius: var(--radius-lg) var(--radius-lg) 0 0;
      padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
    }

    .dialog.sheet .dialog-actions {
      justify-content: stretch;
    }

    .dialog.sheet .dialog-actions .btn {
      flex: 1 1 auto;
    }
  }

  /* File upload. */
  .file-drop {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-lg);
  }

  .file-drop.over {
    border-color: var(--color-focus);
    background: var(--color-surface-selected);
  }

  .file-drop:focus-within label {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
  }

  .upload-list {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .upload-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: var(--space-1) var(--space-3);
  }

  .upload-item progress,
  .upload-item .chip {
    grid-column: 2 / -1;
    justify-self: start;
  }

  .upload-item progress {
    width: 100%;
    height: 6px;
    accent-color: var(--color-primary-default);
  }

  .upload-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* A further section of a page (e.g. the addresses below the company name) and the reference page sections. */
  .page-section,
  .reference-section {
    display: grid;
    gap: var(--space-3);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border-default);
  }

  .page-section h2,
  .reference-section h2 {
    font-size: var(--font-size-lg);
  }

  @media (min-width: 1024px) {
    .toast-region {
      bottom: var(--space-4);
      left: auto;
    }
  }

  @media (pointer: coarse) {
    .btn.icon-only {
      width: var(--size-control-comfortable);
    }
  }

  @media (pointer: coarse) {
    .btn,
    .input,
    .menu-item {
      min-height: var(--size-control-comfortable);
      font-size: var(--font-size-md);
    }

    /* At least 16 px in inputs, otherwise iOS zooms in. */
    .input {
      font-size: max(16px, var(--font-size-md));
    }
  }

  /* Stepper (#102): a whole number with a button each to count down and up. */
  .stepper {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
  }

  .stepper .input {
    width: 5rem;
    text-align: center;
  }

}

@layer shell {
  .skip-link {
    position: absolute;
    z-index: 30;
    left: var(--space-2);
    top: -100px;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    background: var(--color-surface-raised);
  }

  .skip-link:focus {
    top: var(--space-2);
  }

  .shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 1fr;
  }

  .brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-text-default);
    font-size: var(--font-size-lg);
    font-weight: 800;
    letter-spacing: -0.03em;
    text-decoration: none;
  }

  .brand-symbol {
    width: 28px;
    height: 28px;
  }

  .only-dark {
    display: none;
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .only-dark {
      display: block;
    }

    :root:not([data-theme="light"]) .only-light {
      display: none;
    }
  }

  :root[data-theme="dark"] .only-dark {
    display: block;
  }

  :root[data-theme="dark"] .only-light {
    display: none;
  }

  /* Sidebar: desktop only. */
  .shell-side {
    display: none;
  }

  .side-nav,
  .bottom-nav {
    display: grid;
  }

  .side-nav {
    gap: 2px;
  }

  .side-nav a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 6px var(--space-3);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
  }

  .side-nav a:hover {
    background: var(--color-surface-hover);
  }

  .side-nav a.active {
    background: var(--color-surface-selected);
    color: var(--color-primary-on-subtle);
  }

  .shell-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding-bottom: calc(var(--size-bottom-nav) + env(safe-area-inset-bottom));
  }

  /* Without navigation (company choice) there is no bottom bar to leave room for. */
  .shell.no-nav .shell-main {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .topbar {
    position: sticky;
    z-index: 10;
    top: 0;
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding-inline: var(--space-4);
    border-bottom: 1px solid var(--color-border-default);
    background: var(--color-surface-default);
  }

  .topbar-end {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    min-width: 0;
    margin-left: auto;
  }

  .company {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
  }

  .company-name,
  .user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .company-name {
    max-width: 24ch;
  }

  /* On the phone the head stays short: logo without name, company name, theme and user without text. */
  .theme-label,
  .user-name,
  .brand-compact .brand-name {
    display: none;
  }

  /* Main area: a size container for the side column of PageLayout. */
  .content {
    flex: 1;
    container: content / inline-size;
    padding: var(--space-4);
  }

  .content:focus {
    outline: none;
  }

  /* Bottom bar: phone and tablet. */
  .bottom-nav {
    position: fixed;
    z-index: 10;
    right: 0;
    bottom: 0;
    left: 0;
    grid-auto-columns: 1fr;
    grid-auto-flow: column;
    height: calc(var(--size-bottom-nav) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--color-border-default);
    background: var(--color-surface-default);
  }

  .bottom-nav > a,
  .bottom-nav .more {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 2px;
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
    cursor: pointer;
  }

  .bottom-nav > a.active,
  .bottom-nav .more.active {
    color: var(--color-primary-default);
  }

  .bottom-nav .ic {
    width: 22px;
    height: 22px;
  }

  .bottom-nav .popup-list {
    top: auto;
    bottom: calc(100% + var(--space-1));
  }

  /* Page frame: heading with actions, content, side column from 1600 px content width. */
  .page-layout {
    display: grid;
    gap: var(--space-6);
    align-items: start;
  }

  /* One column that never grows beyond the page: a wide grid or table scrolls in its own frame (#59). */
  .page-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
    min-width: 0;
  }

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

  .page-head h1 {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
  }

  .page-head .actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-left: auto;
  }

  .page-aside {
    display: none;
  }

  @container content (min-width: 1600px) {
    .page-layout:has(.page-aside) {
      grid-template-columns: 1fr 300px;
    }

    .page-aside {
      display: grid;
      gap: var(--space-3);
      padding: var(--space-4);
      border: 1px solid var(--color-border-default);
      border-radius: var(--radius-lg);
      background: var(--color-surface-default);
    }
  }

  @media (min-width: 600px) {
    .content {
      padding: var(--space-6);
    }

    .theme-label,
    .brand-compact .brand-name {
      display: inline;
    }
  }

  @media (min-width: 1024px) {
    .shell {
      grid-template-columns: var(--size-sidebar) 1fr;
    }

    .shell-side {
      position: sticky;
      top: 0;
      height: 100vh;
      display: flex;
      flex-direction: column;
      gap: var(--space-5);
      padding: var(--space-4) var(--space-3);
      border-right: 1px solid var(--color-border-default);
      background: var(--color-surface-header);
    }

    .shell-side .brand {
      padding-inline: var(--space-2);
    }

    .brand-compact,
    .bottom-nav {
      display: none;
    }

    .shell-main {
      padding-bottom: 0;
    }

    .topbar {
      padding-inline: var(--space-6);
    }

    .user-name {
      display: inline;
    }
  }

  @media print {
    .shell {
      display: block;
    }

    .shell-side,
    .topbar,
    .bottom-nav,
    .skip-link {
      display: none;
    }

    .shell-main {
      padding: 0;
    }
  }
}

@layer page {
  /* Login (#97): before the shell; the company choice is a page in the shell (#166). */
  .page {
    max-width: 48rem;
    margin: 0 auto;
    padding: var(--space-6) var(--space-4);
  }

  .page > * + * {
    margin-top: var(--space-3);
  }

  .page button {
    min-height: var(--size-control-compact);
    padding: 0 var(--space-4);
    border: 0;
    border-radius: var(--radius-md);
    background: var(--color-primary-default);
    color: var(--color-text-on-primary);
    cursor: pointer;
  }

  /* Plain error paragraph of the login and the example page (not the hint below a field). */
  p.error:not(.hint) {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    background: var(--color-error-bg);
    color: var(--color-error-fg);
  }

  /* Company choice (#166): app buttons in the frame, one per row. */
  .choice {
    display: grid;
    gap: var(--space-2);
    max-width: 40rem;
    padding: 0;
    list-style: none;
  }

  .choice button {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
  }

  /* Session expired (#97): above the page, input stays. */
  .notice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    margin-bottom: var(--space-4);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--color-warning-bg);
    color: var(--color-warning-fg);
  }

  .notice button {
    min-height: var(--size-control-compact);
    padding: 0 var(--space-3);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface-default);
    color: var(--color-text-default);
    cursor: pointer;
  }

  /* Example page (#96): companies of the token. */
  .page-body > .input {
    max-width: 24rem;
  }

  @media (pointer: coarse) {
    .page button,
    .notice button {
      min-height: var(--size-control-comfortable);
      font-size: 16px;
    }
  }

  /* Editable grids (#169 instances, #102 case type positions): the grid from 600 px, below it a list of cards that open a sheet. */
  /* Space between the row actions ("Zeile", "Zeile löschen", "Mehrere anlegen") and the head of the grid. */
  .edit-grid .grid-actions {
    margin-bottom: var(--space-3);
  }

  /* The list and its "Neue Instanz" belong to the phone; on the desktop a new row in the grid is enough. */
  .edit-cards,
  .edit-cards-actions {
    display: none;
  }

  @media (max-width: 599.98px) {
    .edit-grid {
      display: none;
    }

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

    .edit-cards {
      display: grid;
      gap: var(--space-2);
      padding: 0;
      list-style: none;
    }
  }

  .edit-card {
    display: grid;
    width: 100%;
    gap: var(--space-1);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-surface-raised);
    color: var(--color-text-default);
    font: inherit;
    text-align: left;
    min-height: var(--size-control-comfortable);
  }

  button.edit-card {
    cursor: pointer;
  }

  .edit-card.invalid {
    border-color: var(--color-error-fg);
    box-shadow: inset 3px 0 0 var(--color-error-fg);
  }

  .edit-card .title {
    font-weight: 600;
  }

  .edit-card .meta,
  .edit-card .error {
    font-size: var(--font-size-sm);
  }

  .edit-card .meta {
    color: var(--color-text-muted);
  }

  .edit-card .error {
    color: var(--color-error-fg);
  }

  /* Permanently installed equipment of a FIXED case (#102): one block per INSTALLED position. */
  .installed-position {
    display: grid;
    gap: var(--space-3);
    margin-block: var(--space-5);
    padding: var(--space-4);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-surface-raised);
  }

  .installed-position h2 {
    margin: 0;
    font-size: var(--font-size-lg);
  }

  .installed-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    color: var(--color-text-muted);
  }

  .installed-instances {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .installed-instances li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-3);
    min-height: var(--size-control-comfortable);
  }

  .installed-instances li.invalid {
    box-shadow: inset 3px 0 0 var(--color-error-fg);
    padding-left: var(--space-3);
  }

  .installed-instances .title {
    font-weight: 600;
  }

  .installed-instances .meta {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
  }

  .installed-instances .error {
    color: var(--color-error-fg);
    font-size: var(--font-size-sm);
  }

  .installed-instances .btn {
    margin-left: auto;
  }

}

/* Check of a case (#164): one card per quantity and instance. */
@layer page {
  .check-mask {
    display: grid;
    gap: var(--space-4);
    max-width: 40rem;
  }

  .check-lines,
  .check-deviations {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .check-deviations {
    color: var(--color-error-fg);
  }

  .check-line {
    display: grid;
    gap: var(--space-1);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-surface-raised);
  }

  .check-line .title {
    font-weight: 600;
  }

  .check-line .meta {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
  }

  .check-line-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
  }

  .check-switch {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--size-control-comfortable);
  }
}

/* Result and history of a case check (#164). */
@layer page {
  .check-result {
    display: grid;
    gap: var(--space-4);
    max-width: 40rem;
  }

  .check-history {
    display: grid;
    gap: var(--space-3);
    max-width: 40rem;
    margin-top: var(--space-6);
  }

  .check-snapshot {
    margin: 0;
    padding-left: var(--space-5);
    font-size: var(--font-size-sm);
  }
}

/* Custom fields (#103): the arrows of a row and the options of a SELECT field in the sheet. */
@layer page {
  .order-buttons {
    display: flex;
    gap: var(--space-1);
  }

  .custom-field-form {
    display: grid;
    gap: var(--space-4);
  }

  .option-list {
    display: grid;
    gap: var(--space-2);
    border: 0;
    padding: 0;
    margin: 0;
  }

  .option-rows {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .option-line {
    display: flex;
    align-items: center;
    gap: var(--space-1);
  }

  .option-line .input {
    flex: 1;
    min-width: 0;
  }

  .option-list > .btn {
    justify-self: start;
  }

  /* The group "Eigene Felder" in the column choice of a list. */
  .popup-list .menu-heading {
    margin-top: var(--space-2);
    padding: var(--space-1) var(--space-2);
    border-top: 1px solid var(--color-border-default);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
  }

  .custom-fields {
    margin-top: var(--space-6);
  }

  .card-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
  }
}

/* Scan codes (#51): the scan field, the code search in the head and the camera sheet with its target frame. */
@layer components {
  .scan-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    max-width: 32rem;
  }

  .scan-control {
    display: flex;
    align-items: center;
    gap: var(--space-1);
  }

  .scan-control .input {
    flex: 1 1 auto;
    min-width: 0;
  }

  .scan-answer {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    margin: 0;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
  }

  .camera-view {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    border-radius: var(--radius-md);
    background: rgb(0 0 0);
  }

  .camera-video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* The target: a light frame with a dark surround, so it reads on any picture. */
  .camera-frame {
    position: absolute;
    inset: 22% 12%;
    border: 3px solid rgb(255 255 255);
    border-radius: var(--radius-md);
    box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.35);
    pointer-events: none;
  }
}

@layer shell {
  .topbar-search {
    position: relative;
    flex: 0 1 22rem;
    min-width: 0;
  }

  /* In the head the answer floats below the field instead of pushing the head higher. */
  .scan-field.compact .scan-answer {
    position: absolute;
    top: calc(100% + var(--space-1));
    right: 0;
    left: 0;
    z-index: 11;
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
  }

  @media (max-width: 599.98px) {
    .topbar-search {
      flex: 0 0 auto;
      margin-left: auto;
    }

    .topbar-search + .topbar-end {
      margin-left: 0;
    }

    .scan-field.compact .scan-answer {
      position: fixed;
      top: 56px;
      right: var(--space-4);
      left: var(--space-4);
    }
  }
}

/* Choosing several contacts (#41): the search, then every chosen contact with a button to remove it. */
@layer components {
  .contact-picker {
    display: grid;
    gap: var(--space-2);
  }

  .chosen-list {
    display: grid;
    gap: var(--space-1);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .chosen-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    padding-inline-start: var(--space-3);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-surface-raised);
  }

  .chosen-item .btn {
    margin-inline-start: auto;
  }

  /*
   * The own addresses of a contact or a company of contacts (#175): label, chip and one line per address, the
   * actions at the end; on the phone the actions wrap below the text.
   */
  .own-addresses {
    display: grid;
    gap: var(--space-2);
  }

  .own-address-list {
    display: grid;
    gap: var(--space-1);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .own-address-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-surface-raised);
  }

  .own-address-text {
    display: flex;
    flex: 1 1 16rem;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-2);
  }

  .own-address-title {
    font-weight: 600;
  }

  .address-picker {
    display: grid;
    gap: var(--space-1);
  }

  .address-option {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-surface-raised);
    cursor: pointer;
  }

  .address-option:has(input:checked) {
    border-color: var(--color-primary-default);
  }

  .own-address-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin-inline-start: auto;
  }

  /* The range filter of the job list: "von" and "bis" as days next to the search. */
  .range-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
  }

  .range-filter label {
    display: flex;
    align-items: center;
    gap: var(--space-1);
  }
}

/* The status of a job (#42): chips and the buttons to change it wrap onto several lines on the phone. */
@layer components {
  .job-status-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
  }

  .job-status-chips,
  .job-status-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
  }

  .job-status-label {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
  }

  @media (max-width: 599.98px) {
    .job-status-actions {
      width: 100%;
    }

    .job-status-actions .btn {
      flex: 1 1 auto;
      justify-content: center;
    }
  }

  /* The status filter of the job list: the check boxes in a row below the toolbar. */
  .status-filter fieldset.field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
  }

  .status-filter fieldset.field legend {
    float: left;
    margin: 0;
    padding: 0;
  }
}

/* The times of a job (#41): one group over the whole width, the six fields side by side as far as they fit. */
@layer components {
  fieldset.job-times {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }

  fieldset.job-times legend {
    margin-bottom: var(--space-2);
    padding: 0;
    font-weight: var(--font-weight-semibold);
  }

  .job-times-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: var(--space-4);
    width: 100%;
  }
}

/* The venue of a job (#50): the address fields and the note over the whole width, the ways to fill it below. */
@layer components {
  fieldset.job-venue {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    display: grid;
    gap: var(--space-4);
  }

  fieldset.job-venue > legend {
    margin-bottom: var(--space-2);
    padding: 0;
    font-weight: var(--font-weight-semibold);
  }

  .job-venue-actions,
  .job-venue-source {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
  }

  .job-venue-source {
    margin-bottom: var(--space-3);
  }

  /* A long label wraps instead of widening the page on the phone. */
  .job-venue-actions .btn {
    max-width: 100%;
    padding-block: var(--space-1);
    white-space: normal;
    text-align: left;
  }
}

/*
 * Calendar (#104): a month as weeks of seven columns with bars over their days, a week as rows, on the phone a list of
 * the days. The colours of an entry are the status pair of the design tokens, set per bar as --cal-fg (strong part) and
 * --cal-bg (setup and teardown); fg on bg is checked for contrast, so the inverse is too. The status is also told by
 * a symbol and text, never by colour alone.
 */
@layer components {
  .calendar {
    --cal-head: 1.75rem;
    --cal-lane: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-top: var(--space-3);
  }

  .calendar-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
  }

  .calendar-nav,
  .calendar-views,
  .calendar-controls {
    display: flex;
    align-items: center;
    gap: var(--space-1);
  }

  .calendar-views {
    margin-inline-start: auto;
  }

  .calendar-controls {
    flex-basis: 100%;
  }

  .calendar-controls .field {
    margin: 0;
  }

  .calendar-title {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
  }

  .calendar-keys {
    margin: 0;
  }

  .calendar-body.list-loading {
    pointer-events: none;
  }

  /* Month */
  .calendar-month {
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-surface-raised);
    overflow: hidden;
  }

  .calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    border-bottom: 1px solid var(--color-border-default);
    background: var(--color-surface-sunken);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
  }

  .calendar-weekdays span {
    padding: var(--space-1) var(--space-2);
  }

  .calendar-week {
    position: relative;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    column-gap: 0;
    min-height: 5.5rem;
    border-bottom: 1px solid var(--color-border-default);
  }

  .calendar-week:last-child {
    border-bottom: 0;
  }

  .calendar-day {
    grid-row: 1 / -1;
    padding: var(--space-1) var(--space-2);
    border-inline-start: 1px solid var(--color-border-default);
    font-size: var(--font-size-sm);
  }

  .calendar-day:first-child {
    border-inline-start: 0;
  }

  .calendar-day.weekend {
    background: var(--color-surface-sunken);
  }

  .calendar-day.outside .calendar-daynum {
    color: var(--color-text-disabled);
  }

  .calendar-daynum {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding-inline: var(--space-1);
    border-radius: var(--radius-full);
    color: var(--color-text-muted);
  }

  .calendar-day.today .calendar-daynum {
    background: var(--color-primary-default);
    color: var(--color-text-on-primary);
    font-weight: var(--font-weight-semibold);
  }

  .calendar-bar {
    display: flex;
    min-width: 0;
    align-self: center;
    height: calc(var(--cal-lane) - 4px);
    margin-inline: 2px;
    border-radius: var(--radius-sm);
    color: var(--cal-bg);
    font-size: var(--font-size-sm);
    text-decoration: none;
    overflow: hidden;
  }

  .calendar-bar.open-start {
    margin-inline-start: 0;
    border-start-start-radius: 0;
    border-end-start-radius: 0;
  }

  .calendar-bar.open-end {
    margin-inline-end: 0;
    border-start-end-radius: 0;
    border-end-end-radius: 0;
  }

  .calendar-part {
    display: flex;
    flex: 1 1 0;
    align-items: center;
    gap: var(--space-1);
    min-width: 0;
    padding-inline: var(--space-1);
    overflow: hidden;
    white-space: nowrap;
  }

  .calendar-part.event {
    background: var(--cal-fg);
    color: var(--cal-bg);
  }

  /* Setup and teardown: the light colour of the status with a dashed edge, so it shows on the page background too. */
  .calendar-part.setup,
  .calendar-part.teardown {
    background: var(--cal-bg);
    color: var(--cal-fg);
    border: 1px dashed var(--cal-fg);
  }

  .calendar-part.setup {
    border-inline-end: 0;
  }

  .calendar-part.teardown {
    border-inline-start: 0;
  }

  .calendar-part .ic {
    width: 14px;
    height: 14px;
    flex: none;
  }

  .calendar-title-text {
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: var(--font-weight-medium);
  }

  .calendar-subtitle {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--font-size-xs);
    opacity: 0.85;
  }

  .calendar-bar.strike .calendar-title-text,
  .calendar-row-title.strike,
  .calendar-list-title.strike {
    text-decoration: line-through;
  }

  .calendar-bar:hover {
    filter: brightness(0.95);
  }

  .calendar-more {
    z-index: 1;
    align-self: center;
    justify-self: start;
    margin-inline: var(--space-1);
    padding: 0 var(--space-1);
    border: 0;
    background: transparent;
    color: var(--color-text-default);
    font: inherit;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    text-decoration: underline;
    cursor: pointer;
  }

  .calendar-more[aria-expanded="true"] {
    background: var(--color-surface-selected);
    border-radius: var(--radius-sm);
  }

  .calendar-bar:focus-visible,
  .calendar-more:focus-visible,
  .calendar-row-label:focus-visible,
  .calendar-list-item:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 1px;
  }

  /* The entries of a day behind "+N weitere" */
  .calendar-daypanel {
    padding: var(--space-3);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface-raised);
  }

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

  .calendar-daypanel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
  }

  .calendar-daypanel h3,
  .calendar-daylist h3 {
    margin: 0;
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
  }

  /* Week: one row per entry */
  .calendar-weekrows {
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-surface-raised);
    overflow: hidden;
  }

  .calendar-row {
    display: grid;
    grid-template-columns: minmax(8rem, 14rem) minmax(0, 1fr);
    border-bottom: 1px solid var(--color-border-default);
  }

  .calendar-row:last-child {
    border-bottom: 0;
  }

  .calendar-row.head {
    background: var(--color-surface-sunken);
    color: var(--color-text-muted);
    font-weight: var(--font-weight-medium);
  }

  .calendar-track {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: var(--cal-lane);
    min-height: 2.5rem;
    align-items: center;
  }

  .calendar-track.head {
    min-height: 0;
  }

  .calendar-track .calendar-day {
    grid-row: 1;
    align-self: stretch;
    padding-block: var(--space-1);
  }

  .calendar-track.head .calendar-day {
    background: transparent;
  }

  .calendar-track .calendar-bar {
    z-index: 1;
  }

  .calendar-row-label {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    padding: var(--space-1) var(--space-3);
    color: var(--color-text-default);
    text-decoration: none;
    border-inline-start: 4px solid var(--cal-fg);
  }

  .calendar-row-label:hover .calendar-row-title {
    text-decoration: underline;
  }

  .calendar-row-title {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    min-width: 0;
    font-weight: var(--font-weight-medium);
  }

  .calendar-row-title .ic {
    flex: none;
    width: 14px;
    height: 14px;
  }

  .calendar-row-title span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .calendar-row-label .calendar-subtitle {
    color: var(--color-text-muted);
  }

  /* List of days (phone) and of one day */
  .calendar-daylist {
    margin-bottom: var(--space-4);
  }

  .calendar-daylist h3 {
    margin-bottom: var(--space-2);
  }

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

  .calendar-daylist .calendar-list {
    margin-top: 0;
  }

  .calendar-list-item {
    display: grid;
    gap: 2px;
    min-height: var(--size-touch-target);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border-default);
    border-inline-start: 6px solid var(--cal-fg);
    border-radius: var(--radius-md);
    background: var(--color-surface-raised);
    color: var(--color-text-default);
    text-decoration: none;
  }

  .calendar-list-title {
    font-weight: var(--font-weight-semibold);
  }

  .calendar-list-status {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    width: fit-content;
    padding: 0 var(--space-2);
    border-radius: var(--radius-full);
    background: var(--cal-bg);
    color: var(--cal-fg);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
  }

  .calendar-list-status .ic {
    width: 12px;
    height: 12px;
  }

  .calendar-list-period,
  .calendar-list-item .calendar-subtitle {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    opacity: 1;
  }

  @media screen and (max-width: 599.98px) {
    .calendar-views {
      margin-inline-start: 0;
    }

    .calendar-keys {
      display: none;
    }
  }

  @media (pointer: coarse) {
    .calendar-more {
      min-height: var(--size-touch-target);
    }
  }

  @media print {
    .calendar-nav,
    .calendar-views,
    .calendar-controls,
    .calendar-keys {
      display: none;
    }

    .calendar-part {
      print-color-adjust: exact;
    }
  }
}

/* Loading (#47): load board with progress, the load mask with the feedback to the last scan, scans and reconciliation. */
@layer components {
  .progress {
    overflow: hidden;
    height: 0.625rem;
    min-width: 6rem;
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-neutral-bg);
  }

  .progress-fill {
    height: 100%;
    background: var(--color-primary-default);
  }

  .progress.complete .progress-fill {
    background: var(--color-success-fg);
  }

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

  .range-choice {
    flex-wrap: wrap;
    align-items: end;
  }

  button.tab {
    border-top: 0;
    border-right: 0;
    border-left: 0;
    background: none;
    font: inherit;
    font-weight: var(--font-weight-medium);
    cursor: pointer;
  }
}

@layer page {
  .load-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
  }

  .load-head .btn {
    margin-left: auto;
  }

  .load-scan {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
  }

  .load-scan .scan-field {
    width: 100%;
  }

  .load-quantity,
  .load-active-case {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-neutral-bg);
  }

  .load-active-case {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .load-active-case .btn {
    margin-left: auto;
  }

  .load-quantity-title {
    font-weight: var(--font-weight-semibold);
  }

  .load-report {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    min-height: 5rem;
    margin-bottom: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    font-size: 1.125rem;
  }

  .load-report.empty {
    align-items: center;
    border: 1px dashed var(--color-border-default);
    font-size: inherit;
  }

  .load-report-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .load-report-title {
    font-weight: var(--font-weight-semibold);
  }

  .load-report ul {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    font-size: 1rem;
  }

  .load-lists {
    display: grid;
    gap: var(--space-6);
    margin-top: var(--space-4);
  }

  @media (min-width: 1024px) {
    .load-lists {
      grid-template-columns: 1fr 1fr;
      align-items: start;
    }
  }

  .load-scan-list,
  .load-recon-list,
  .load-job-list {
    display: flex;
    flex-direction: column;
    list-style: none;
  }

  .load-scan-list > li,
  .load-recon-list > li {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-border-default);
    list-style: none;
  }

  .load-recon-list > li {
    flex-direction: column;
    align-items: stretch;
  }

  .load-scan-text,
  .load-recon-head {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-1);
  }

  .load-recon-head {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .load-scan-text .meta,
  .load-recon-list .meta {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
  }

  .load-scan-text .title,
  .load-recon-head .title {
    font-weight: var(--font-weight-medium);
  }

  .load-outstanding-group h3 {
    margin: var(--space-3) 0 var(--space-1);
    font-size: var(--font-size-md);
  }

  .load-outstanding-list {
    display: flex;
    flex-direction: column;
    list-style: none;
  }

  .load-outstanding-list > li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-border-default);
    list-style: none;
  }

  .load-outstanding-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 12rem;
  }

  .load-outstanding-text .title {
    font-weight: var(--font-weight-medium);
  }

  .load-outstanding-text .meta {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
  }

  .load-outstanding-actions {
    display: flex;
    gap: var(--space-2);
  }

  .direction-choice {
    margin-bottom: var(--space-2);
  }

  .load-totals {
    margin-bottom: var(--space-1);
    font-weight: var(--font-weight-medium);
  }

  .load-job-list > li {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-border-default);
  }
}

/*
 * Overview of a job (#56): key figures as tiles and the structure as a tree with one bar per job on a shared time axis.
 * The bar uses the status pair of the design tokens as in the calendar (#104): strong event, lighter setup and teardown
 * with a dashed edge. On the phone the bar column is dropped; the text period stays.
 */
@layer components {
  .stat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: var(--space-3);
    margin: var(--space-3) 0;
  }

  .stat-tile {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
    padding: var(--space-3);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
    background: var(--color-surface-raised);
    color: var(--color-text-default);
    font: inherit;
    text-align: start;
  }

  .stat-tile.tone-warning {
    border-color: var(--color-warning-fg);
    background: var(--color-warning-bg);
    color: var(--color-warning-fg);
  }

  .stat-tile.interactive {
    cursor: pointer;
  }

  .stat-tile.interactive:hover {
    border-color: var(--color-primary-default);
  }

  .stat-value {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
  }

  .stat-label {
    font-weight: var(--font-weight-medium);
  }

  .stat-detail {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
  }

  .overview-section {
    margin-top: var(--space-5);
  }

  .overview-tree {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .overview-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 3fr);
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-border-default);
  }

  .overview-head {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
  }

  .overview-job {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-2);
    min-width: 0;
    padding-inline-start: calc(var(--level, 0) * var(--space-4));
  }

  .overview-name {
    font-weight: var(--font-weight-medium);
    overflow-wrap: anywhere;
  }

  .overview-row.cancelled .overview-name {
    text-decoration: line-through;
  }

  .overview-period {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
  }

  .overview-track {
    display: flex;
    height: 1.25rem;
    overflow: hidden;
  }

  .overview-gap {
    flex: none;
  }

  .overview-part {
    flex: none;
    box-sizing: border-box;
    min-width: 3px;
  }

  .overview-part.event {
    border-radius: var(--radius-sm);
    background: var(--bar-fg);
  }

  .overview-part.setup,
  .overview-part.teardown {
    background: var(--bar-bg);
    border: 1px dashed var(--bar-fg);
  }

  .overview-part.setup {
    border-inline-end: 0;
  }

  .overview-part.teardown {
    border-inline-start: 0;
  }

  .overview-list,
  .overview-positions {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .overview-list > li {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-border-default);
  }

  .overview-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-3);
  }

  .overview-item-name {
    font-weight: var(--font-weight-medium);
  }

  .overview-item-sum {
    flex: 1 1 12rem;
  }

  .overview-positions {
    margin-top: var(--space-2);
    padding-inline-start: var(--space-4);
  }

  .overview-positions > li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-3);
    padding: var(--space-1) 0;
  }

  @media (max-width: 599.98px) {
    .overview-row {
      grid-template-columns: minmax(0, 1fr);
      gap: var(--space-1);
    }

    .overview-head,
    .overview-bar-cell {
      display: none;
    }

    .overview-period {
      padding-inline-start: calc(var(--level, 0) * var(--space-4));
    }
  }
}

/* The mail pages (#69): settings form, mail log and the detail of one mail. */
@layer components {
  .mail-form {
    display: grid;
    gap: var(--space-5);
    max-width: 48rem;
  }

  .mail-bcc-row {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .mail-bcc-row .field {
    flex: 1 1 auto;
  }

  .mail-bcc-row .btn {
    margin-top: var(--space-5);
  }

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

  .mail-placeholders code {
    font-family: var(--font-family-mono, monospace);
  }

  .mail-preview {
    display: grid;
    gap: var(--space-3);
  }

  .mail-test-result {
    display: grid;
    gap: var(--space-2);
  }

  .mail-facts {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: var(--space-1) var(--space-4);
    margin: 0;
  }

  .mail-facts dt {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
  }

  .mail-facts dd {
    margin: 0;
    overflow-wrap: anywhere;
  }

  .mail-body {
    margin: 0;
    padding: var(--space-3);
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    font: inherit;
    background: var(--color-surface-sunken);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-md);
  }

  .mail-error {
    margin: 0;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    color: var(--color-error-fg);
  }

  @media (max-width: 599.98px) {
    .mail-facts {
      grid-template-columns: minmax(0, 1fr);
    }

    .mail-facts dd {
      margin-bottom: var(--space-2);
    }

    .block-preview {
      width: 100%;
      min-height: 16rem;
      border: 1px solid var(--color-border-default);
      background: var(--color-surface-default);
    }
  }
}
