/*
 * Design tokens and the parts every page needs: type, links, focus, page head, callouts, buttons, forms, tables,
 * badges, records, empty states, the logged-out card. The side panel and top bar live in shell.css (logged-in
 * pages), toasts in toast.css, the confirm dialog in confirm.css; page rules in their own files.
 * Direction (2026-11 redesign): calm slate neutrals, one file-folder blue (#1d4f86), 8 px radius, hairline borders
 * and small shadows, the platform's own line icons; a yellow focus ring that is impossible to miss.
 */

:root {
  --ink: #0f172a;
  --text: #334155;
  --muted: #64748b;
  --paper: #ffffff;
  --surface: #f8fafc;
  --surface-2: #f1f5f9;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --control: #8391a7; /* form control borders: 3:1 against white (WCAG 1.4.11) */
  --primary: #1d4f86;
  --primary-dark: #163d68;
  --primary-soft: #eaf1f9;
  --focus: #ffbf47;
  --error: #b91c1c;
  --success: #166534;
  --warning: #92400e;
  --info: #1d4f86;
  --radius: 8px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px -4px rgba(15, 23, 42, 0.14);
  --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, 0.25);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--paper);
}

h1, h2, h3 { color: var(--ink); line-height: 1.3; margin: 0 0 0.75rem; }
h1 { font-size: 1.5rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.125rem; font-weight: 650; margin-top: 2.25rem; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 1rem; }
strong, b { color: var(--ink); }

a { color: var(--primary); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--primary-dark); text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 0;
  box-shadow: 0 0 0 5px var(--ink);
}
a:focus-visible { background: var(--focus); color: var(--ink); box-shadow: 0 3px 0 var(--ink); outline: none; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.visually-hidden {
  position: absolute !important; /* unslop-ignore: accessibility utility must win over component rules */
  width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.skip-link { position: absolute; left: -999px; top: 0; padding: 0.5rem 1rem; background: var(--focus); color: var(--ink); z-index: 100; }
.skip-link:focus { left: 0; }

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

.link-button { font: inherit; background: none; border: 0; padding: 0; cursor: pointer; color: var(--primary); text-decoration: underline; text-underline-offset: 0.18em; }
.link-button:hover { color: var(--primary-dark); text-decoration-thickness: 2px; }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 2rem; height: 2rem; border-radius: 7px;
  background: var(--primary-soft); color: var(--primary);
  font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.02em;
}

/* Page ------------------------------------------------------------------- */

.page { display: block; width: 100%; max-width: 77.5rem; padding: 1.75rem 1rem 3rem; }
.page:focus { outline: none; }

/* Head row: h1 left; page tools (help, favorite; Ds\Http\PageTools) and the page's actions right. */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 0.5rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0 auto 0 0; }
.page-head > .button, .page-head > form, .page-head > p, .page-head > div:not(.page-tools) { margin: 0; }
.page-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; margin: 0; }
.page-tools form { margin: 0; }
.page-head + p, h1 + p { color: var(--muted); }

/* Back links ("Zurück") above a heading. */
.page > p:first-child > a:only-child { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.875rem; color: var(--muted); text-decoration: none; }
.page > p:first-child > a:only-child::before { content: "\2190"; }
.page > p:first-child > a:only-child:hover { color: var(--primary); text-decoration: underline; }

/* Callouts --------------------------------------------------------------- */
/* .notice in the templates: info (default), --success, --error; an icon (icon()) sits in the left gutter. */

.notice {
  position: relative;
  margin: 0 0 1rem; padding: 0.75rem 1rem 0.75rem 2.75rem;
  border: 1px solid #cfe0f2; border-radius: var(--radius);
  background: #f0f6fc; color: #1e3a5f; font-size: 0.9rem;
}
.notice > .icon:first-child { position: absolute; left: 0.9rem; top: 0.85rem; color: #2563eb; }
.notice a { color: inherit; font-weight: 600; }
.notice--success { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
.notice--success > .icon:first-child { color: #16a34a; }
.notice--warning { background: #fffaeb; border-color: #fde68a; color: #713f12; }
.notice--warning > .icon:first-child { color: #d97706; }
.notice--error { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
.notice--error > .icon:first-child { color: #dc2626; }
.notice ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }

/* Buttons ---------------------------------------------------------------- */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font: inherit; font-size: 0.875rem; font-weight: 600; line-height: 1.3;
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--primary); border-radius: var(--radius);
  background: var(--primary); color: #fff;
  text-decoration: none; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.button:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.button:active { transform: translateY(1px); }
.button--secondary { background: var(--paper); color: var(--ink); border-color: var(--line-strong); }
.button--secondary:hover { background: var(--surface); border-color: var(--control); color: var(--ink); }
.button--ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
.button--ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--ink); }
.button--danger { background: var(--error); border-color: var(--error); color: #fff; }
.button--danger:hover { background: #991b1b; border-color: #991b1b; color: #fff; }
.button--small { padding: 0.3rem 0.65rem; font-size: 0.8125rem; }
.button .icon { width: 16px; height: 16px; }
a.button:focus-visible { background: var(--focus); color: var(--ink); border-color: var(--ink); }

/* Forms ------------------------------------------------------------------ */

.form { max-width: 34rem; margin-bottom: 2rem; }
.form--wide { max-width: 44rem; }
.field { margin: 0 0 1.25rem; padding: 0; border: 0; min-width: 0; }
.field label, .field legend { display: block; font-weight: 600; color: var(--ink); font-size: 0.875rem; margin-bottom: 0.3rem; }
.field legend { padding: 0; }
.hint { color: var(--muted); margin: 0 0 0.4rem; font-size: 0.8125rem; }
.field__error { color: var(--error); font-weight: 600; font-size: 0.875rem; margin: 0 0 0.4rem; }
.field--error { border-left: 3px solid var(--error); padding-left: 0.85rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="date"],
input[type="number"], input[type="url"], input[type="tel"], input[type="time"], input:not([type]), textarea, select {
  width: 100%;
  font: inherit; font-size: 0.9375rem;
  color: var(--ink);
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--control);
  border-radius: var(--radius);
  background: var(--paper);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
select { width: auto; max-width: 100%; padding-right: 2rem; }
input:hover, textarea:hover, select:hover { border-color: var(--muted); }
textarea { min-height: 6rem; resize: vertical; }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--error); }
input[type="file"] { font: inherit; font-size: 0.875rem; max-width: 100%; }
input[type="file"]::file-selector-button { font: inherit; font-weight: 600; margin-right: 0.75rem; padding: 0.4rem 0.8rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--paper); color: var(--ink); cursor: pointer; }
.input--code { max-width: 9rem; font-size: 1.375rem; letter-spacing: 0.2em; font-variant-numeric: tabular-nums; }

.choice { display: flex; align-items: center; gap: 0.6rem; font-weight: 400; margin: 0.4rem 0; }
.field .choice { font-weight: 400; font-size: 0.9375rem; color: var(--text); }
.choice input { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--primary); flex: none; }

.form__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; }

.danger-zone { margin-top: 2.5rem; border-top: 1px solid var(--line); padding-top: 1.25rem; }

/* Tables and records ----------------------------------------------------- */

.table-wrap { overflow-x: auto; margin-bottom: 1.5rem; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; margin-bottom: 1.5rem; }
.table-wrap .table { margin-bottom: 0; }
.table th, .table td { text-align: left; vertical-align: top; padding: 0.7rem 1rem; border-bottom: 1px solid var(--line); }
.table thead th { background: var(--surface); color: #475569; font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; padding-top: 0.6rem; padding-bottom: 0.6rem; white-space: nowrap; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody tr { transition: background-color 0.12s ease; }
/* Light zebra; hover one step stronger. Muted text darkens on hover and active rows: --muted is 4.34:1 on
   --surface-2 and 4.18:1 on --primary-soft, #475569 stays above 6.6:1. */
.table tbody tr:nth-child(even) { background: var(--surface); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:hover .muted, .table tr.is-active .muted { color: #475569; }
.table tbody th { font-weight: 600; color: var(--ink); }
.table tbody th a, .table tbody tr > td:first-child > a:first-child:last-child { color: var(--primary); font-weight: 600; text-decoration: none; }
.table tbody th a:hover, .table tbody tr > td:first-child > a:first-child:last-child:hover { color: var(--primary-dark); text-decoration: underline; }
.table tbody th .muted { font-weight: 400; }
.table__actions { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; }
.table__actions form { margin: 0; }
/* As a cell it stays a table cell (a flex cell breaks the row lines); its children line up instead. */
td.table__actions, th.table__actions { display: table-cell; }
td.table__actions > *, th.table__actions > * { display: inline-flex; vertical-align: middle; margin: 0.1rem 0.9rem 0.1rem 0; }
.table tr.is-active th, .table tr.is-active td { background: var(--primary-soft); }

/* Status pills: text always carries the meaning, the dot and colour only support it. */
.badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.75rem; font-weight: 600; line-height: 1.5; white-space: nowrap;
  padding: 0.05rem 0.55rem; border-radius: 999px;
  background: #e0ecf9; color: var(--primary);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge--muted { background: var(--surface-2); color: #475569; }

.record { margin: 0 0 2rem; border-top: 1px solid var(--line); }
.record__row { padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
/* Labels quiet, values carry the weight. */
.record dt { font-weight: 500; color: var(--muted); font-size: 0.875rem; }
.record dd { margin: 0.2rem 0 0; color: var(--ink); white-space: pre-line; overflow-wrap: anywhere; }
/* Empty value ("Nicht angegeben", dd.muted): italic and smaller signal "empty"; --muted keeps 4.5:1 on white and on
   the tinted label column (#f8fafc), a paler slate would not. */
.record dd.muted { color: var(--muted); font-style: italic; font-size: 0.875rem; }
.record__row[hidden] { display: none; }

/* Record card: a detail section (or a whole record) as a card. Optional head (__head: tinted bar, blue left edge,
   h2 with a quiet legal citation __cite, section_title()); a .record directly inside runs edge to edge with a tinted
   label column; a .hint below or above it gets its own padding and hairline; other content is inset. */
.record-card { margin: 1.25rem 0 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.record-card__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem 1rem; padding: 0.7rem 1rem 0.7rem calc(1rem - 3px); background: var(--surface); border-bottom: 1px solid var(--line); border-left: 3px solid var(--primary); }
.record-card__head h2 { margin: 0; font-size: 1.125rem; }
.record-card__cite { font-size: 0.875rem; font-weight: 400; color: var(--muted); }
.record-card > .record { border-top: 0; }
.record-card > .record { margin: 0; }
.record.record-card { margin: 0 0 2rem; }
.record-card > .record > .record__row, .record.record-card > .record__row { padding: 0; }
/* Rows keep their bottom line (it closes the label column before content below); as the card's last child the
   record slides 1px under the card edge, so the last visible row's line never doubles the border. */
.record-card > .record:last-child { margin-bottom: -1px; }
.record.record-card > .record__row:last-child { border-bottom: 0; }
.record-card > .record dt, .record.record-card > .record__row > dt { padding: 0.7rem 1rem 0; }
.record-card > .record dd, .record.record-card > .record__row > dd { margin: 0; padding: 0.2rem 1rem 0.7rem; }
.record-card > .hint { margin: 0; padding: 0.75rem 1rem 0.9rem; border-top: 1px solid var(--line); }
.record-card__head + .hint, .record-card > .record + .hint { border-top: 0; }
.record-card > .hint + .record { border-top: 1px solid var(--line); }
.record-card:not(.record) > :not(.record-card__head, .record, .hint) { margin-left: 1rem; margin-right: 1rem; }
.record-card__head + :not(.record, .hint) { margin-top: 1.25rem; }
.record-card:not(.record) > :last-child:not(.record, .hint) { margin-bottom: 1.25rem; }

/* Empty state: a muted paragraph alone under a heading or list head reads as "nothing here yet". */
.empty { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; padding: 2rem 1rem; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); }
.empty .icon { width: 28px; height: 28px; color: var(--control); }
.empty p { margin: 0; }

/* Below 40rem a stacked table shows each row as a block, cells labelled by data-label. */
@media (max-width: 39.99rem) {
  .table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table--stack tr { display: block; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); }
  .table--stack tbody tr:last-child { border-bottom: 0; }
  .table--stack th, .table--stack td { display: block; border: 0; padding: 0.1rem 0; }
  .table--stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); }
  .table--stack .table__actions { padding-top: 0.5rem; }
}

@media (min-width: 40rem) {
  .page { padding: 1.75rem 2rem 3rem; }
  .record__row { display: grid; grid-template-columns: 15rem 1fr; gap: 1.5rem; }
  .record dd { margin: 0; }
  .record-card__head { padding: 0.7rem 1.25rem 0.7rem calc(1.25rem - 3px); }
  .record-card > .record > .record__row, .record.record-card > .record__row { gap: 0; }
  .record-card > .record dt, .record.record-card > .record__row > dt { padding: 0.7rem 1.25rem; background: var(--surface); border-right: 1px solid var(--line); }
  .record-card > .record dd, .record.record-card > .record__row > dd { padding: 0.7rem 1.25rem; }
  .record-card > .hint { padding: 0.75rem 1.25rem 0.9rem; }
  .record-card:not(.record) > :not(.record-card__head, .record, .hint) { margin-left: 1.25rem; margin-right: 1.25rem; }
}

/* Logged-out pages (login, code, password): one centred card with the logo. ------------------------------- */

.no-shell { background: var(--surface); }
.plain { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 3rem 1rem; }
.plain__logo { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; margin-bottom: 1.5rem; color: var(--muted); font-size: 0.875rem; font-weight: 600; text-decoration: none; }
.plain__logo img { display: block; width: 140px; height: auto; }
.plain__card { max-width: 28rem; padding: 2rem; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-md); }
.plain__card h1 { font-size: 1.375rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; } /* unslop-ignore: global motion off switch */
}

@media print {
  body { font-size: 11pt; color: #000; }
  .page { max-width: none; padding: 0; }
  .page-tools, .skip-link { display: none !important; } /* unslop-ignore: print must hide tools */
  .table-wrap { box-shadow: none; border-color: #999; }
}
