/* platform-ui: Design-System aller Projekte.
   Richtung «Leitstand» (dicht, technisch, Blau als einziger Akzent) mit runden Formen.
   Farben nur über die Tokens in :root; der dunkle Satz folgt dem System.
   Keine Inline-Styles nötig: Die CSP der Apps erlaubt nur 'self'. */

@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-sans-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-sans-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-mono-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-mono-500.woff2") format("woff2"); }

/* ---------- Tokens ---------- */
:root {
  color-scheme: light dark;

  --ui-font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ui-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ui-text: .875rem;     /* 14 px, Grundgrösse */
  --ui-text-sm: .8125rem; /* 13 px */
  --ui-text-xs: .75rem;   /* 12 px */
  --ui-text-lg: 1rem;
  --ui-title: 1.375rem;

  --ui-radius: 9px;       /* Knöpfe, Felder, Meldungen */
  --ui-radius-lg: 14px;   /* Karten, Tabellen */
  --ui-radius-pill: 999px;

  --ui-space-1: .25rem; --ui-space-2: .5rem; --ui-space-3: .75rem; --ui-space-4: 1rem; --ui-space-6: 1.5rem; --ui-space-8: 2rem;
  --ui-content: 80rem;    /* breiteste Seite */
  --ui-narrow: 24rem;     /* Login, kurze Formulare */

  /* Flächen und Text (hell) */
  --ui-bg: oklch(97% .006 250);
  --ui-surface: oklch(100% 0 0);
  --ui-bar: oklch(100% 0 0);
  --ui-input: oklch(100% 0 0);
  --ui-fg: oklch(24% .025 255);
  --ui-muted: oklch(50% .025 255);
  --ui-line: oklch(87% .012 250);
  --ui-line-soft: oklch(92% .008 250);
  --ui-line-strong: oklch(78% .018 250);
  --ui-hover: oklch(95.5% .008 250);
  --ui-head: oklch(97% .006 250);

  /* Akzent */
  --ui-accent: oklch(47% .15 258);
  --ui-accent-hover: oklch(42% .15 258);
  --ui-on-accent: oklch(100% 0 0);
  --ui-accent-soft: oklch(94% .025 258);
  --ui-accent-soft-fg: oklch(38% .13 258);
  --ui-link: oklch(47% .15 258);
  --ui-focus: oklch(58% .16 255);

  /* Status: nur für Zustände, nie als Akzent */
  --ui-ok-fg: oklch(45% .11 155);   --ui-ok-bg: oklch(95% .04 155);   --ui-ok-line: oklch(83% .08 155);
  --ui-warn-fg: oklch(50% .12 70);  --ui-warn-bg: oklch(96% .05 85);  --ui-warn-line: oklch(85% .1 85);
  --ui-bad-fg: oklch(50% .19 27);   --ui-bad-bg: oklch(96% .025 27);  --ui-bad-line: oklch(85% .07 27);
  --ui-bad-strong: oklch(55% .2 27);
  --ui-bad-hover: oklch(93% .045 27);
  --ui-info-fg: oklch(38% .13 258); --ui-info-bg: oklch(94% .025 258); --ui-info-line: oklch(84% .06 258);
  --ui-off-fg: oklch(45% .02 255);  --ui-off-bg: oklch(93% .008 250);

  --ui-shadow-menu: 0 8px 24px oklch(24% .025 255 / .12);
  --ui-qr-bg: oklch(100% 0 0); /* QR-Codes brauchen in beiden Schemata weissen Grund */

  /* Datenfarben für Diagramme (chart). Reihenfolge blue, orange, aqua, yellow;
     red nur für Fehlerreihen. Geprüft mit dem Palette-Validator (Farbsehschwächen,
     Abstand, Kontrast) gegen --ui-surface, hell und dunkel getrennt. */
  --ui-chart-blue: oklch(57.5% .163 255.5);
  --ui-chart-orange: oklch(67.1% .175 40.6);
  --ui-chart-aqua: oklch(66.9% .141 162.1);
  --ui-chart-yellow: oklch(76.4% .161 75.1);
  --ui-chart-red: oklch(62.3% .191 24.9);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ui-bg: oklch(18% .015 255);
    --ui-surface: oklch(21% .017 255);
    --ui-bar: oklch(21% .017 255);
    --ui-input: oklch(17% .015 255);
    --ui-fg: oklch(91% .01 250);
    --ui-muted: oklch(68% .02 250);
    --ui-line: oklch(31% .02 255);
    --ui-line-soft: oklch(27% .018 255);
    --ui-line-strong: oklch(38% .02 255);
    --ui-hover: oklch(25% .018 255);
    --ui-head: oklch(23% .018 255);

    --ui-accent: oklch(66% .14 255);
    --ui-accent-hover: oklch(72% .13 255);
    --ui-on-accent: oklch(16% .02 255);
    --ui-accent-soft: oklch(30% .05 258);
    --ui-accent-soft-fg: oklch(90% .05 255);
    --ui-link: oklch(75% .12 250);
    --ui-focus: oklch(72% .13 255);

    --ui-ok-fg: oklch(78% .13 155);   --ui-ok-bg: oklch(28% .05 155);   --ui-ok-line: oklch(40% .08 155);
    --ui-warn-fg: oklch(82% .12 80);  --ui-warn-bg: oklch(30% .05 80);  --ui-warn-line: oklch(42% .08 80);
    --ui-bad-fg: oklch(74% .15 25);   --ui-bad-bg: oklch(28% .06 25);   --ui-bad-line: oklch(40% .09 25);
    --ui-bad-strong: oklch(66% .18 25);
    --ui-bad-hover: oklch(33% .08 25);
    --ui-info-fg: oklch(85% .07 255); --ui-info-bg: oklch(30% .05 258); --ui-info-line: oklch(42% .07 258);
    --ui-off-fg: oklch(75% .015 250); --ui-off-bg: oklch(28% .015 255);

    --ui-shadow-menu: 0 8px 24px oklch(0% 0 0 / .45);

    --ui-chart-blue: oklch(62.2% .161 255.1);
    --ui-chart-orange: oklch(62.2% .173 40.1);
    --ui-chart-aqua: oklch(62.1% .128 163.1);
    --ui-chart-yellow: oklch(67% .143 73.2);
    --ui-chart-red: oklch(57.5% .186 25.2);
  }
}

/* ---------- Grundlagen ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--ui-bg); color: var(--ui-fg);
  font-family: var(--ui-font); font-size: var(--ui-text); line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { max-width: 100%; }
code, kbd, pre, samp { font-family: var(--ui-mono); font-size: .95em; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 2px; }
::selection { background: var(--ui-accent-soft); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: var(--ui-space-4); top: -3rem; z-index: 50; padding: var(--ui-space-2) var(--ui-space-3); border-radius: var(--ui-radius); background: var(--ui-accent); color: var(--ui-on-accent); }
.skip:focus { top: var(--ui-space-4); }

/* ---------- Seitenrahmen ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--ui-bar); border-bottom: 1px solid var(--ui-line); }
.topbar-inner { margin: 0 auto; max-width: var(--ui-content); display: flex; align-items: center; gap: var(--ui-space-4); padding: var(--ui-space-2) var(--ui-space-4); min-height: 3.25rem; }
.brand { display: inline-flex; align-items: center; gap: var(--ui-space-2); font-size: var(--ui-text-lg); font-weight: 600; color: inherit; text-decoration: none; white-space: nowrap; }
.brand-mark { width: 1.125rem; height: 1.125rem; border-radius: 6px; background: var(--ui-accent); flex: none; }
.nav { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; min-width: 0; }
.nav a { padding: var(--ui-space-1) var(--ui-space-3); border-radius: var(--ui-radius); color: var(--ui-muted); text-decoration: none; font-size: var(--ui-text-sm); font-weight: 500; }
.nav a:hover { background: var(--ui-hover); color: var(--ui-fg); }
.nav a[aria-current="page"] { background: var(--ui-accent-soft); color: var(--ui-accent-soft-fg); font-weight: 600; }
/* Suchfeld der Kopfzeile (Page.Search): füllt den Platz bis zum Benutzer. */
.topbar-search { flex: 1; min-width: 0; max-width: 28rem; margin: 0; }
.topbar-search .input { margin: 0; padding-block: .3125rem; }
.user { margin-left: auto; display: flex; align-items: center; gap: var(--ui-space-3); font-size: var(--ui-text-sm); color: var(--ui-muted); white-space: nowrap; }
.user form { margin: 0; }
.main { margin: 0 auto; max-width: var(--ui-content); padding: var(--ui-space-8) var(--ui-space-4) calc(var(--ui-space-8) * 2); }
.narrow { margin-inline: auto; max-width: var(--ui-narrow); }
.footer { margin: 0 auto; max-width: var(--ui-content); padding: 0 var(--ui-space-4) var(--ui-space-8); font-size: var(--ui-text-xs); color: var(--ui-muted); }
@media (max-width: 40rem) {
  .topbar-inner { flex-wrap: wrap; }
  .nav { order: 3; flex-basis: 100%; }
  .topbar-search { order: 3; flex-basis: 100%; max-width: none; }
  .main { padding-top: var(--ui-space-6); }
}

/* ---------- Seitenleiste (Page.Sidebar) ---------- */
/* Breit: links neben dem Inhalt, bleibt beim Scrollen stehen. Schmal: über
   dem Inhalt; sobald JavaScript läuft (ui.js setzt html.js), nur nach einem
   Klick auf «Menü». */
.shell { margin: 0 auto; max-width: var(--ui-content); display: flex; gap: var(--ui-space-8); padding: 0 var(--ui-space-4); }
.sidebar { flex: none; width: 13rem; position: sticky; top: 3.25rem; align-self: flex-start; max-height: calc(100vh - 3.25rem); overflow-y: auto; padding: var(--ui-space-6) 0; }
.main-shell { flex: 1; min-width: 0; margin: 0; max-width: none; padding-inline: 0; }
.sidebar-group + .sidebar-group { margin-top: var(--ui-space-6); }
/* Block "sidebar-top": z. B. Auswahl des Bereichs über den Gruppen. */
.sidebar-top { padding: 0 var(--ui-space-3); margin-bottom: var(--ui-space-6); }
.sidebar-title { padding: 0 var(--ui-space-3); font-size: var(--ui-text-xs); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--ui-muted); }
.sidebar ul { margin-top: var(--ui-space-2); display: grid; gap: 2px; }
.sidebar a { display: flex; align-items: center; justify-content: space-between; gap: var(--ui-space-2); min-height: 2rem; padding: var(--ui-space-1) var(--ui-space-3); border-radius: var(--ui-radius); color: var(--ui-muted); text-decoration: none; font-size: var(--ui-text-sm); font-weight: 500; }
.sidebar a:hover { background: var(--ui-hover); color: var(--ui-fg); }
.sidebar a[aria-current="page"] { background: var(--ui-accent-soft); color: var(--ui-accent-soft-fg); font-weight: 600; }
.topbar .sidebar-toggle { display: none; } /* vor .btn-ghost geschützt */
@media (max-width: 48rem) {
  .shell { flex-direction: column; gap: 0; }
  .sidebar { position: static; width: auto; max-height: none; padding-bottom: 0; }
  .js .topbar .sidebar-toggle { display: inline-flex; }
  .js .sidebar:not(.sidebar-open) { display: none; }
}

/* Symbole (ui.Icon, NavItem.Icon): nehmen die Textfarbe an. */
.icon { width: 1rem; height: 1rem; flex: none; vertical-align: -.1875em; }
.sidebar a .icon { color: var(--ui-muted); }
.sidebar a[aria-current="page"] .icon, .sidebar a:hover .icon { color: inherit; }
.sidebar a .icon + span { flex: 1; min-width: 0; }

/* ---------- Theme «Leitwarte» (Page.Theme = ui.ThemeLeitwarte) ---------- */
/* Seitenleiste über die ganze Höhe: Icon und Name der App oben, Benutzer
   unten, keine Kopfzeile. Schmal: Leiste mit Namen und «Menü» oben. */
.lw { display: flex; min-height: 100vh; }
.lw-side { width: 15rem; position: sticky; top: 0; align-self: flex-start; height: 100vh; max-height: 100vh; display: flex; flex-direction: column;
  padding: var(--ui-space-4) var(--ui-space-3); background: var(--ui-bar); border-right: 1px solid var(--ui-line); }
.lw-side a { min-height: 2.25rem; }
.lw-side .sidebar-top { padding: 0; }
.lw-brand { display: flex; align-items: center; gap: var(--ui-space-3); color: inherit; text-decoration: none; font-weight: 600; min-width: 0; }
.lw-side .lw-brand-side { justify-content: flex-start; padding: var(--ui-space-1) var(--ui-space-2) var(--ui-space-6); color: var(--ui-fg); font-size: var(--ui-text); font-weight: 600; }
.lw-side .lw-brand-side:hover { background: none; }
.lw-logo { width: 2rem; height: 2rem; border-radius: 7px; flex: none; }
.lw-name { display: grid; line-height: 1.25; font-size: var(--ui-text-lg); min-width: 0; }
.lw-name small { font-size: var(--ui-text-xs); font-weight: 400; color: var(--ui-muted); }
.lw-search { margin: 0 0 var(--ui-space-6); }
.lw-foot { margin-top: auto; padding-top: var(--ui-space-4); border-top: 1px solid var(--ui-line-soft); display: grid; gap: var(--ui-space-2); }
.lw-foot ul { display: grid; gap: 2px; }
.lw-user { display: flex; align-items: center; gap: var(--ui-space-2); padding: 0 0 0 var(--ui-space-3); font-size: var(--ui-text-sm); color: var(--ui-muted); }
.lw-user-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lw-user form { margin: 0; }
.lw-main { flex: 1; min-width: 0; margin: 0; max-width: var(--ui-content); padding: var(--ui-space-8) var(--ui-space-8) calc(var(--ui-space-8) * 2); }
.lw-bar { display: none; }
@media (max-width: 48rem) {
  .lw { flex-direction: column; min-height: 0; }
  .lw-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--ui-space-4); position: sticky; top: 0; z-index: 30;
    padding: var(--ui-space-2) var(--ui-space-4); background: var(--ui-bar); border-bottom: 1px solid var(--ui-line); }
  .lw-bar .sidebar-toggle { display: none; }
  .js .lw-bar .sidebar-toggle { display: inline-flex; }
  .lw-side { position: static; align-self: stretch; width: auto; height: auto; max-height: none; border-right: 0; border-bottom: 1px solid var(--ui-line); }
  .lw-side .lw-brand-side { display: none; }
  .lw-main { padding: var(--ui-space-6) var(--ui-space-4) calc(var(--ui-space-8) * 2); }
}

/* Benutzermenü (Page.Menu) */
.user-button { padding: var(--ui-space-1) var(--ui-space-3); border-radius: var(--ui-radius); max-width: 16rem; overflow: hidden; text-overflow: ellipsis; }
.user-button:hover, .menu[open] > .user-button { background: var(--ui-hover); color: var(--ui-fg); }
.menu-items form { margin: 0; }
.menu-items a[aria-current="page"] { font-weight: 600; }

/* ---------- Abstände und Anordnung ---------- */
.stack { display: flex; flex-direction: column; gap: var(--ui-space-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--ui-space-2); }
.stack-lg { display: flex; flex-direction: column; gap: var(--ui-space-8); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ui-space-2); }
.row-end { justify-content: flex-end; }
.row-between { justify-content: space-between; }
.row-bottom { align-items: flex-end; } /* Felder mit Beschriftung neben einem Knopf */
.grow { flex: 1 1 12rem; min-width: 0; } /* nimmt in .row den freien Platz */
/* Feld nur so breit wie sein Inhalt; mit der Feldklasse, damit es gegen
   .input/.select (width: 100%, weiter unten) gewinnt. */
.fit, .input.fit, .select.fit, .textarea.fit { width: auto; max-width: 100%; }
/* Spalten oder Teile nur auf breiten bzw. schmalen Bildschirmen. */
@media (max-width: 48rem) { .wide-only { display: none; } }
@media (min-width: 48.01rem) { .narrow-only { display: none; } }
.grid { display: grid; gap: var(--ui-space-6); grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
.grid > *, .stack > *, .row > * { min-width: 0; }
/* Raster mit 12 Spalten: Kinder mit span-1 … span-12 (ohne Klasse: ganze
   Breite). Richtet sich nach der Breite des Rasters selbst (Container
   Query), nicht des Fensters, damit die Seitenleiste mitzählt (neben ihr ist
   der Inhalt höchstens gut 60rem breit). Unter 44rem stehen span-3 zu zweit,
   span-1/2 zu dritt und alles ab span-4 allein; unter 28rem steht alles
   untereinander (span-1 und span-2 zu zweit). */
.grid-12 { display: grid; gap: var(--ui-space-6); grid-template-columns: repeat(12, minmax(0, 1fr)); container-type: inline-size; }
.grid-12 > * { grid-column: span 12; min-width: 0; }
.grid-12 > .span-1 { grid-column: span 1; } .grid-12 > .span-2 { grid-column: span 2; }
.grid-12 > .span-3 { grid-column: span 3; } .grid-12 > .span-4 { grid-column: span 4; }
.grid-12 > .span-5 { grid-column: span 5; } .grid-12 > .span-6 { grid-column: span 6; }
.grid-12 > .span-7 { grid-column: span 7; } .grid-12 > .span-8 { grid-column: span 8; }
.grid-12 > .span-9 { grid-column: span 9; } .grid-12 > .span-10 { grid-column: span 10; }
.grid-12 > .span-11 { grid-column: span 11; } .grid-12 > .span-12 { grid-column: span 12; }
@container (max-width: 44rem) {
  .grid-12 > :is(.span-1, .span-2) { grid-column: span 4; }
  .grid-12 > .span-3 { grid-column: span 6; }
  .grid-12 > :is(.span-4, .span-5, .span-6, .span-7, .span-8, .span-9, .span-10, .span-11) { grid-column: span 12; }
}
@container (max-width: 28rem) {
  .grid-12 > :is(.span-1, .span-2) { grid-column: span 6; }
  .grid-12 > .span-3 { grid-column: span 12; }
}
/* Ein summary (Knopf oder Link zum Aufklappen) bleibt so breit wie sein Text. */
:is(.stack, .stack-sm, .stack-lg) > summary { align-self: flex-start; }

/* ---------- Vorschaubilder ---------- */
/* Seiten eines Scans o. Ä. als Raster kleiner Bilder: <div class="thumbs"> mit <a class="thumb" href="…">
   <img src="…" alt="…"><span>Seite 1</span></a>. Jedes Bild ist ein Link auf die grosse Ansicht.
   thumbs-lg für die grosse Ansicht (Spalten ab 22rem). Bilder brauchen width/height im HTML,
   damit die Seite beim Laden nicht springt. */
.thumbs { display: grid; gap: var(--ui-space-3); grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); }
.thumbs-lg { grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); }
/* thumbs-md: Kacheln mit Titel, z. B. Dokumente (Spalten ab 10rem). */
.thumbs-md { grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: var(--ui-space-4); }
.thumb { display: flex; flex-direction: column; gap: var(--ui-space-1); min-width: 0; color: var(--ui-muted); font-size: var(--ui-text-xs); text-decoration: none; }
.thumb img { display: block; width: 100%; height: auto; border: 1px solid var(--ui-line); border-radius: var(--ui-radius); background: var(--ui-surface); }
a.thumb:hover img, a.thumb:focus-visible img { border-color: var(--ui-accent); }
/* Titel unter dem Bild (<strong>), weitere <span> darunter als Zusatz; jede Zeile einzeilig. */
.thumb strong { color: var(--ui-fg); font-size: var(--ui-text-sm); font-weight: 500; }
.thumb > strong, .thumb > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.thumb:hover strong { color: var(--ui-accent); }

/* Zeile mit kleinem Bild links (Treffer einer Suche): <a class="media"><img …><div class="media-body">…</div></a>. */
.media { display: flex; gap: var(--ui-space-4); align-items: flex-start; color: inherit; text-decoration: none; }
.media > img { flex: none; width: 3.5rem; height: auto; border: 1px solid var(--ui-line); border-radius: calc(var(--ui-radius) - 3px); background: var(--ui-surface); }
.media-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
a.media:hover strong { color: var(--ui-accent); }
/* Ganze Zeile als Link (z. B. in panel-list): ohne Unterstrich, der Titel (<strong>) zeigt das Überfahren. */
.row-link { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--ui-space-1) var(--ui-space-3); color: inherit; text-decoration: none; }
.row-link:hover strong, .row-link:focus-visible strong { color: var(--ui-accent); }
/* Fundstelle im Text, Treffer hervorgehoben. */
mark { background: var(--ui-warn-bg); color: inherit; border-radius: 3px; padding: 0 2px; }

/* ---------- Dokument-Ansicht ---------- */
/* Vorschau links, Angaben rechts: <div class="viewer-split"><section class="viewer-pane">
   <iframe class="viewer" src="…"></iframe></section><div class="stack">…</div></div>.
   Breit: Die Vorschau ist so hoch wie das Fenster und bleibt beim Scrollen der Angaben
   stehen. Schmal: Vorschau oben, drei Viertel der Fensterhöhe. */
.viewer-split { display: grid; gap: var(--ui-space-6); grid-template-columns: minmax(0, 1fr); }
.viewer-pane { min-width: 0; display: flex; flex-direction: column; gap: var(--ui-space-2); }
.viewer { display: block; width: 100%; height: 75vh; border: 1px solid var(--ui-line); border-radius: var(--ui-radius-lg); background: var(--ui-surface); }
img.viewer { height: auto; max-height: 75vh; object-fit: contain; }
@media (min-width: 64rem) {
  .viewer-split { grid-template-columns: minmax(0, 1fr) 22rem; }
  .viewer-pane { position: sticky; top: calc(3.25rem + var(--ui-space-4)); align-self: start; }
  .viewer { height: calc(100vh - 3.25rem - var(--ui-space-4) * 2 - 1.75rem); min-height: 28rem; }
  img.viewer { max-height: calc(100vh - 3.25rem - var(--ui-space-4) * 2 - 1.75rem); }
}

/* ---------- Text ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--ui-space-3) var(--ui-space-6); }
.page-title { font-size: var(--ui-title); font-weight: 600; line-height: 1.2; text-wrap: balance; }
.page-sub { margin-top: var(--ui-space-1); font-size: var(--ui-text-sm); color: var(--ui-muted); }
.section-title { font-size: var(--ui-text-lg); font-weight: 600; line-height: 1.3; }
.hint { font-size: var(--ui-text-sm); color: var(--ui-muted); }
.muted { color: var(--ui-muted); }
.mono { font-family: var(--ui-mono); }
.num { font-variant-numeric: tabular-nums; }
.break { overflow-wrap: anywhere; }
.link { color: var(--ui-link); text-decoration: underline; text-underline-offset: 2px; }
.link:hover { text-decoration: none; }
.label-caps { font-size: var(--ui-text-xs); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--ui-muted); }

/* ---------- Knöpfe ---------- */
.btn, .btn-secondary, .btn-danger, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--ui-space-2);
  min-height: 2.125rem; padding: .375rem .875rem; border-radius: var(--ui-radius); border: 1px solid transparent;
  font: inherit; font-size: var(--ui-text-sm); font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn { background: var(--ui-accent); color: var(--ui-on-accent); }
.btn:hover { background: var(--ui-accent-hover); }
.btn-secondary { background: var(--ui-surface); color: var(--ui-fg); border-color: var(--ui-line-strong); }
.btn-secondary:hover { background: var(--ui-hover); }
/* Löschen und Widerrufen: als Knopf erkennbar, leicht roter Grund. */
.btn-danger { background: var(--ui-bad-bg); color: var(--ui-bad-fg); border-color: var(--ui-bad-line); }
.btn-danger:hover { background: var(--ui-bad-hover); }
.btn-ghost { background: transparent; color: var(--ui-muted); padding-inline: var(--ui-space-2); }
.btn-ghost:hover { background: var(--ui-hover); color: var(--ui-fg); }
.btn-block { width: 100%; }
.btn-sm { min-height: 1.75rem; padding: .1875rem .625rem; font-size: var(--ui-text-xs); }
:is(.btn, .btn-secondary, .btn-danger, .btn-ghost):disabled, :is(.btn, .btn-secondary, .btn-danger, .btn-ghost)[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* ---------- Formulare ---------- */
.field { display: flex; flex-direction: column; gap: var(--ui-space-1); }
.label { font-size: var(--ui-text-sm); font-weight: 600; }
.input, .select, .textarea {
  display: block; width: 100%; min-height: 2.25rem; padding: .4375rem .75rem; border-radius: var(--ui-radius);
  border: 1px solid var(--ui-line-strong); background: var(--ui-input); color: var(--ui-fg); font: inherit; font-size: var(--ui-text-lg);
}
@media (min-width: 40rem) { .input, .select, .textarea { font-size: var(--ui-text); } } /* iOS zoomt unter 16 px */
.textarea { min-height: 6rem; resize: vertical; }
.textarea.mono, .input.mono { font-family: var(--ui-mono); }
.input-code { font-family: var(--ui-mono); letter-spacing: .18em; }
/* Kleines Zahlenfeld, z. B. ein Limit in einer Tabellenzeile. */
.input.input-sm { width: 7rem; min-height: 1.75rem; padding: .1875rem .5rem; font-size: var(--ui-text-sm); }
/* Teile eines Formulars, die nur bei einer Auswahl gelten: In
   .reveal-when steht eine <option class="reveal-trigger">; die .reveal
   darin erscheinen nur, wenn sie gewählt ist. Ohne Unterstützung für :has
   bleiben sie sichtbar. */
.reveal-when:has(.reveal-trigger):not(:has(.reveal-trigger:checked)) .reveal { display: none; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--ui-focus); outline: 2px solid var(--ui-focus); outline-offset: -1px; }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--ui-bad-strong); }
.field-error { font-size: var(--ui-text-xs); color: var(--ui-bad-fg); }
.field-hint { font-size: var(--ui-text-xs); color: var(--ui-muted); }
.check { display: inline-flex; align-items: center; gap: var(--ui-space-2); font-size: var(--ui-text-sm); }
.check input { width: 1rem; height: 1rem; accent-color: var(--ui-accent); margin: 0; }
.divider-text { display: flex; align-items: center; gap: var(--ui-space-3); font-size: var(--ui-text-xs); color: var(--ui-muted); }
.divider-text::before, .divider-text::after { content: ""; flex: 1; border-top: 1px solid var(--ui-line); }

/* ---------- Flächen ---------- */
.card { background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius-lg); padding: var(--ui-space-6); }
.card-tight { padding: var(--ui-space-4); }
/* Karte oder Kennzahl als Link: ganze Fläche klickbar, Rahmen zeigt es an. */
a.card, a.stat { color: inherit; text-decoration: none; }
a.card:hover, a.stat:hover { border-color: var(--ui-accent); }
.panel { background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius-lg); overflow: hidden; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--ui-space-2); padding: var(--ui-space-3) var(--ui-space-4); border-bottom: 1px solid var(--ui-line); }
.panel-list > * { padding: var(--ui-space-3) var(--ui-space-4); }
.panel-list > * + * { border-top: 1px solid var(--ui-line-soft); }
.panel-list > .check { display: flex; }
.panel-foot { padding: var(--ui-space-3) var(--ui-space-4); border-top: 1px solid var(--ui-line); }
/* position: relative, damit absolut gesetzte Teile (z. B. sr-only im Tabellenkopf)
   mit abgeschnitten werden und die Seite nicht quer scrollt. */
.scroll-x { overflow-x: auto; position: relative; }
.danger-zone { border: 1px solid var(--ui-bad-line); border-radius: var(--ui-radius-lg); padding: var(--ui-space-6); background: var(--ui-surface); }
.danger-zone .section-title { color: var(--ui-bad-fg); }

/* ---------- Tabellen ---------- */
.table { width: 100%; border-collapse: collapse; text-align: left; font-size: var(--ui-text-sm); }
.table th { padding: var(--ui-space-2) var(--ui-space-4); background: var(--ui-head); color: var(--ui-muted); font-size: var(--ui-text-xs); font-weight: 500; letter-spacing: .02em; border-bottom: 1px solid var(--ui-line); white-space: nowrap; }
.table td { padding: .5625rem var(--ui-space-4); border-top: 1px solid var(--ui-line-soft); vertical-align: top; }
.table tbody tr:first-child td { border-top: 0; }
.table tbody tr:hover { background: var(--ui-hover); }
/* Nur die Zellen selbst: Zahlen in einer Zelle (z. B. Datum in einer aufgeklappten Quittung) bleiben links. */
.table :is(td, th).num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .mono { font-size: .95em; }
.table .actions { text-align: right; white-space: nowrap; }
/* Zeile mit Fehler: roter Strich am Anfang; der Text sagt den Zustand, die Farbe hilft nur. */
.table tr.row-bad td:first-child { box-shadow: inset 3px 0 0 var(--ui-bad-strong); }
.table tr.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--ui-warn-fg); }
.table-compact td { padding-block: .3125rem; }
/* Tabelle, deren Zeilen in einem schmalen Kasten umbrechen statt quer zu scrollen:
   <section class="panel table-wrap"><table class="table table-flow">…</table></section>.
   table-wrap misst die eigene Breite (Container Query); unter 46rem steht jede Zeile
   als Block, die erste Zelle (Name) steht auf einer eigenen Zeile,
   die übrigen Zellen folgen nebeneinander und brechen um. Die Spaltenköpfe sind dann
   nur noch für Screenreader da: Zellen brauchen eine eigene Beschriftung (hint), wo nötig.
   Kopf eines Kastens (Gerät, Status) gehört in panel-head, nicht in die Tabelle. */
.table-wrap { container-type: inline-size; position: relative; }
@container (max-width: 46rem) {
  .table-flow, .table-flow :is(thead, tbody, tfoot) { display: block; }
  .table-flow tr { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ui-space-1) var(--ui-space-4); padding: .5625rem var(--ui-space-4); }
  .table-flow tbody tr + tr { border-top: 1px solid var(--ui-line-soft); }
  /* Spaltenköpfe passen nicht mehr über die Zellen: nur noch für Screenreader. */
  .table-flow thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .table-flow :is(td, th) { display: block; padding: 0; border: 0; background: none; }
  .table-flow :is(td, th):first-child { flex: 1 1 100%; min-width: 0; }
  .table-flow :is(td, th).num { text-align: left; }
  .table-flow tr.row-bad { box-shadow: inset 3px 0 0 var(--ui-bad-strong); }
  .table-flow tr.row-warn { box-shadow: inset 3px 0 0 var(--ui-warn-fg); }
  .table-flow tr:is(.row-bad, .row-warn) td:first-child { box-shadow: none; }
}
.empty { padding: var(--ui-space-8) var(--ui-space-4); text-align: center; color: var(--ui-muted); }

/* ---------- Zustände ---------- */
.pill { display: inline-flex; align-items: center; gap: var(--ui-space-1); padding: .0625rem .5rem; border-radius: var(--ui-radius-pill); font-size: var(--ui-text-xs); font-weight: 600; line-height: 1.5; white-space: nowrap; }
.pill-ok { background: var(--ui-ok-bg); color: var(--ui-ok-fg); }
.pill-warn { background: var(--ui-warn-bg); color: var(--ui-warn-fg); }
.pill-bad { background: var(--ui-bad-bg); color: var(--ui-bad-fg); }
.pill-info { background: var(--ui-info-bg); color: var(--ui-info-fg); }
.pill-off { background: var(--ui-off-bg); color: var(--ui-off-fg); }
.dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; flex: none; background: var(--ui-off-fg); }
.dot-ok { background: var(--ui-ok-fg); } .dot-warn { background: var(--ui-warn-fg); } .dot-bad { background: var(--ui-bad-strong); }
.badge { display: inline-flex; min-width: 1.25rem; justify-content: center; padding: 0 .375rem; border-radius: var(--ui-radius-pill); background: var(--ui-accent-soft); color: var(--ui-accent-soft-fg); font-size: var(--ui-text-xs); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Meldungen ---------- */
.alert, .notice, .warning, .info { padding: var(--ui-space-3) var(--ui-space-4); border-radius: var(--ui-radius); border: 1px solid; font-size: var(--ui-text-sm); }
.alert { background: var(--ui-bad-bg); border-color: var(--ui-bad-line); color: var(--ui-bad-fg); }
.notice { background: var(--ui-ok-bg); border-color: var(--ui-ok-line); color: var(--ui-ok-fg); }
/* Meldung des Layouts oben in <main>: Abstand zum Seiteninhalt. */
.main > .notice { margin-bottom: var(--ui-space-6); }
.warning { background: var(--ui-warn-bg); border-color: var(--ui-warn-line); color: var(--ui-warn-fg); }
.info { background: var(--ui-info-bg); border-color: var(--ui-info-line); color: var(--ui-info-fg); }

/* Zustand als Text (z. B. «3 gescheitert» in einer Tabelle); der Text sagt
   den Zustand, die Farbe hilft nur. */
.text-ok { color: var(--ui-ok-fg); }
.text-warn { color: var(--ui-warn-fg); }
.text-bad { color: var(--ui-bad-fg); }

/* ---------- Füllstand ---------- */
/* <progress class="meter" max="100" value="42">42 %</progress>, z. B. ein
   Kontingent. meter-warn und meter-bad ab den Schwellen der App. */
.meter { display: block; width: 100%; height: .5rem; border: 0; border-radius: var(--ui-radius-pill); overflow: hidden; background: var(--ui-off-bg); color: var(--ui-accent); -webkit-appearance: none; appearance: none; }
.meter::-webkit-progress-bar { background: var(--ui-off-bg); border-radius: var(--ui-radius-pill); }
.meter::-webkit-progress-value { background: currentColor; border-radius: var(--ui-radius-pill); }
.meter::-moz-progress-bar { background: currentColor; border-radius: var(--ui-radius-pill); }
.meter-warn { color: var(--ui-warn-fg); }
.meter-bad { color: var(--ui-bad-strong); }

/* ---------- Seiten blättern ---------- */
/* <nav class="pager" aria-label="Seiten"> mit Links; die aktuelle Seite mit
   aria-current="page". */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ui-space-1); font-size: var(--ui-text-sm); }
.pager a, .pager span { display: inline-flex; align-items: center; justify-content: center; min-width: 2rem; min-height: 2rem; padding: 0 var(--ui-space-2); border-radius: var(--ui-radius); border: 1px solid var(--ui-line); background: var(--ui-surface); color: var(--ui-fg); text-decoration: none; }
.pager a:hover { background: var(--ui-hover); }
.pager [aria-current="page"] { background: var(--ui-accent); border-color: var(--ui-accent); color: var(--ui-on-accent); font-weight: 600; }

/* ---------- Auswahl-Chip ---------- */
/* <label class="chip"><input type="checkbox" class="sr-only"> Text</label>:
   ein Kästchen als Knopf, «+» oder «✓» davor. */
.chip { display: inline-flex; align-items: center; gap: .375rem; padding: .1875rem .625rem; border-radius: var(--ui-radius-pill); border: 1px solid var(--ui-line-strong); font-size: var(--ui-text-xs); cursor: pointer; user-select: none; }
.chip:hover { background: var(--ui-hover); }
.chip::before { content: "+"; font-weight: 600; color: var(--ui-muted); }
.chip:has(:checked) { background: var(--ui-accent-soft); border-color: var(--ui-accent-soft); color: var(--ui-accent-soft-fg); }
.chip:has(:checked)::before { content: "✓"; color: inherit; }
.chip:has(:focus-visible) { outline: 2px solid var(--ui-focus); outline-offset: 2px; }
/* Auswahlknöpfe (data-pick, data-pick-list): Knöpfe als Chip, gewählt mit aria-pressed. */
button.chip { background: none; color: inherit; font: inherit; font-size: var(--ui-text-xs); }
button.chip[aria-pressed="true"] { background: var(--ui-accent-soft); border-color: var(--ui-accent-soft); color: var(--ui-accent-soft-fg); }
button.chip[aria-pressed="true"]::before { content: "✓"; color: inherit; }
button.chip:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 2px; }
/* Filter als Links (z. B. Suche): <a class="chip" href="…" aria-current="true"> ist der aktive. */
a.chip { color: inherit; text-decoration: none; }
a.chip[aria-current="true"] { background: var(--ui-accent-soft); border-color: var(--ui-accent-soft); color: var(--ui-accent-soft-fg); }
a.chip[aria-current="true"]::before { content: "✓"; color: inherit; }
a.chip:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 2px; }
/* Eine Filterzeile: Beschriftung links, Chips daneben. */
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ui-space-2); }
.filter-row > .label { width: 6rem; flex: none; margin: 0; color: var(--ui-muted); font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: var(--ui-space-2); margin-top: var(--ui-space-2); }

/* ---------- Hochladen (data-upload) ---------- */
/* Ablagefläche: ein Label um das Dateifeld, auch per Klick. */
.dropzone { display: grid; place-items: center; gap: var(--ui-space-2); padding: var(--ui-space-8) var(--ui-space-4); border: 2px dashed var(--ui-line-strong); border-radius: var(--ui-radius-lg); background: var(--ui-surface); text-align: center; color: var(--ui-muted); cursor: pointer; }
.dropzone:hover, .dragging .dropzone { border-color: var(--ui-accent); color: var(--ui-fg); }
.dropzone:has(:focus-visible) { outline: 2px solid var(--ui-focus); outline-offset: 2px; }
.upload-list { display: grid; gap: var(--ui-space-1); margin-top: var(--ui-space-4); }
.upload-list:empty { display: none; }
.upload-row { display: flex; justify-content: space-between; gap: var(--ui-space-3); padding: var(--ui-space-2) var(--ui-space-3); border: 1px solid var(--ui-line); border-radius: var(--ui-radius); background: var(--ui-surface); font-size: var(--ui-text-sm); }
.upload-row > :first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-row > :last-child { flex: none; color: var(--ui-muted); }
.upload-row .text-bad { color: var(--ui-bad-fg); }
/* Datei über der Seite (Page.Upload): Hinweis über allem. */
.drop-overlay { display: none; }
.dragging .drop-overlay { display: grid; place-items: center; position: fixed; inset: 0; z-index: 50; background: var(--ui-accent-soft); color: var(--ui-accent-soft-fg); font-size: var(--ui-text-lg); font-weight: 600; border: 3px dashed var(--ui-accent); pointer-events: none; }

/* ---------- Listen und Textbreite ---------- */
.steps { list-style: decimal; padding-left: 1.25rem; display: grid; gap: var(--ui-space-2); }
.bullets { list-style: disc; padding-left: 1.25rem; display: grid; gap: var(--ui-space-1); }
.measure { max-width: 42rem; }
.measure-wide { max-width: 56rem; }

/* ---------- Kennzahlen, Liste von Werten ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--ui-space-2) var(--ui-space-6); font-size: var(--ui-text-sm); }
.kv dt { color: var(--ui-muted); }
.kv dd { min-width: 0; overflow-wrap: anywhere; }
.code-block { display: block; overflow-x: auto; padding: var(--ui-space-3) var(--ui-space-4); border-radius: var(--ui-radius); background: var(--ui-head); border: 1px solid var(--ui-line); font-size: var(--ui-text-sm); line-height: 1.6; white-space: pre; }
/* Langer Text im Codeblock (Mail, Schlüssel): bricht um, scrollt ab 32rem. */
.code-wrap { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 32rem; overflow: auto; }
.qr { display: inline-block; padding: var(--ui-space-2); border-radius: var(--ui-radius); background: var(--ui-qr-bg); }

/* ---------- Menü (details/summary, geht ohne JavaScript) ---------- */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-items { position: absolute; right: 0; z-index: 40; margin-top: var(--ui-space-1); min-width: 12rem; padding: var(--ui-space-1); border-radius: var(--ui-radius); border: 1px solid var(--ui-line); background: var(--ui-surface); box-shadow: var(--ui-shadow-menu); }
.menu-items a, .menu-items button { display: block; width: 100%; padding: var(--ui-space-2) var(--ui-space-3); border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; font-size: var(--ui-text-sm); text-align: left; text-decoration: none; cursor: pointer; }
.menu-items a:hover, .menu-items button:hover { background: var(--ui-hover); }

/* ---------- Tabs ---------- */
/* <div data-tabs> mit <div role="tablist" class="tablist"> und Links
   <a role="tab" class="tab" href="#id" aria-controls="id">, dazu die Panels
   <section id="id" role="tabpanel">. Ohne JavaScript fehlt die Leiste und alle
   Panels stehen untereinander, jedes mit seiner Überschrift (.tab-heading,
   mit JavaScript ausgeblendet). */
.tablist { display: flex; gap: 2px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; box-shadow: inset 0 -1px 0 var(--ui-line); }
.tablist::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: var(--ui-space-2) var(--ui-space-3); border-bottom: 2px solid transparent; color: var(--ui-muted); text-decoration: none; font-size: var(--ui-text-sm); font-weight: 500; white-space: nowrap; }
.tab:hover { color: var(--ui-fg); border-bottom-color: var(--ui-line-strong); }
.tab[aria-selected="true"] { color: var(--ui-fg); font-weight: 600; border-bottom-color: var(--ui-accent); }
[data-tabs] > [role="tablist"] { display: none; }
.js [data-tabs] > [role="tablist"] { display: flex; }
.js [role="tabpanel"].tab-hidden { display: none; }
.js [data-tabs] .tab-heading { display: none; }

/* ---------- htmx ---------- */
.htmx-indicator { opacity: 0; transition: opacity .2s ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .htmx-indicator { transition: none; } }

/* ---------- Diagramme (Paket chart) ---------- */
.chart { position: relative; display: grid; gap: var(--ui-space-2); min-width: 0; }
.chart:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 4px; border-radius: var(--ui-radius); }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--ui-space-2) var(--ui-space-4); font-size: var(--ui-text-sm); color: var(--ui-muted); }
.chart-legend li { display: inline-flex; align-items: center; gap: var(--ui-space-2); }
.chart-key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; background: currentColor; }
.chart-body { display: grid; grid-template-columns: max-content 1fr; gap: var(--ui-space-1) var(--ui-space-2); }
.chart-y { display: flex; flex-direction: column; justify-content: space-between; text-align: right;
  font-size: var(--ui-text-xs); color: var(--ui-muted); font-variant-numeric: tabular-nums; line-height: 1;
  padding-bottom: 0; margin: -.5em 0; }
.chart-plot { position: relative; height: 12rem; min-width: 0; }
.chart-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-x { display: flex; justify-content: space-between; font-size: var(--ui-text-xs); color: var(--ui-muted); font-variant-numeric: tabular-nums; }
.chart-grid { stroke: var(--ui-line-soft); stroke-width: 1; }
.chart-base { stroke: var(--ui-line-strong); stroke-width: 1; }
.chart-cross { stroke: var(--ui-muted); stroke-width: 1; visibility: hidden; }
.chart-active .chart-cross { visibility: visible; }
.chart-line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: currentColor; stroke: none; opacity: .1; }
/* Gestapelte Flächen kräftiger; die Linie obendrauf trennt die Teile. */
.chart-area.chart-stack { opacity: .3; }
.chart-blue { color: var(--ui-chart-blue); }
.chart-orange { color: var(--ui-chart-orange); }
.chart-aqua { color: var(--ui-chart-aqua); }
.chart-yellow { color: var(--ui-chart-yellow); }
.chart-red { color: var(--ui-chart-red); }
.chart-tip { position: absolute; top: 0; z-index: 2; min-width: 9rem; padding: var(--ui-space-2) var(--ui-space-3);
  background: var(--ui-surface); border: 1px solid var(--ui-line); border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow-menu); font-size: var(--ui-text-sm); pointer-events: none; color: var(--ui-fg); }
.chart-tip-time { color: var(--ui-muted); font-size: var(--ui-text-xs); }
.chart-tip-row { display: flex; align-items: center; gap: var(--ui-space-2); }
.chart-tip-row strong { font-variant-numeric: tabular-nums; }
.chart-tip-row span:last-child { color: var(--ui-muted); }
.chart-table summary { cursor: pointer; font-size: var(--ui-text-sm); color: var(--ui-muted); width: max-content; }
.chart-table .table { margin-top: var(--ui-space-2); }
.chart-spark { display: block; width: 6rem; height: 1.5rem; overflow: visible; }
/* Säulen (chart.Bars): Teile mit 1 px Fläche dazwischen; beim Überfahren
   treten die anderen Säulen zurück. */
.chart-seg { fill: currentColor; stroke: var(--ui-surface); stroke-width: 1px; }
.chart-active .chart-bar:not(.chart-bar-on) { opacity: .45; }
.chart-key-box { width: 10px; height: 10px; border-radius: 2px; }

/* Kennzahl-Kacheln */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: var(--ui-space-4); }
.stat { display: grid; align-content: start; gap: var(--ui-space-1); padding: var(--ui-space-4); background: var(--ui-surface);
  border: 1px solid var(--ui-line); border-radius: var(--ui-radius-lg); min-width: 0; }
.stat-label { font-size: var(--ui-text-sm); color: var(--ui-muted); }
.stat-value { font-size: 1.75rem; font-weight: 600; line-height: 1.2; }
.stat-delta { font-size: var(--ui-text-sm); color: var(--ui-muted); }
.stat-delta-good { color: var(--ui-ok-fg); }
.stat-delta-bad { color: var(--ui-bad-fg); }
/* Kachel mit Zustand: farbiger Rand links, Zahl in der Farbe bei Warnung und Fehler. */
.stat-ok, .stat-warn, .stat-bad, .stat-info { border-left-width: 4px; }
.stat-ok { border-left-color: var(--ui-ok-fg); }
.stat-info { border-left-color: var(--ui-accent); }
.stat-warn { border-left-color: var(--ui-warn-fg); }
.stat-warn .stat-value { color: var(--ui-warn-fg); }
.stat-bad { border-left-color: var(--ui-bad-strong); }
.stat-bad .stat-value { color: var(--ui-bad-fg); }

/* Verlauf: ein Kästchen je Tag oder Lauf, schlechtester Zustand gewinnt.
   <span class="history" role="img" aria-label="…"><span class="history-ok" title="18.11. erfolgreich"></span>…</span> */
.history { display: inline-flex; flex-wrap: wrap; gap: 3px; vertical-align: middle; }
.history > span { width: .75rem; height: .75rem; border-radius: 3px; background: var(--ui-off-bg); flex: none; }
.history > .history-ok { background: var(--ui-ok-fg); }
.history > .history-warn { background: var(--ui-warn-fg); }
.history > .history-bad { background: var(--ui-bad-strong); }
.history > .history-info { background: var(--ui-accent); }
/* In Tabellen bleibt der Verlauf auf einer Zeile; schmale Tabellen scrollen (scroll-x). */
.table .history { flex-wrap: nowrap; }

/* ---------- Drucken ---------- */
/* Blatt zum Ausdrucken (z. B. Trennblatt beim Scannen): <main class="sheet"> mit
   <p class="sheet-title">, mittig auf der Seite. no-print verschwindet im Druck. */
.sheet { min-height: 100vh; max-width: 48rem; margin-inline: auto; padding: var(--ui-space-8); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--ui-space-6); text-align: center; }
.sheet-title { font-size: clamp(3rem, 12vw, 6rem); font-weight: 600; letter-spacing: .04em; line-height: 1; }
@media print {
  :root {
    color-scheme: light;
    --ui-print-bg: oklch(100% 0 0);
    --ui-print-fg: oklch(0% 0 0);
  }
  body { background: var(--ui-print-bg); color: var(--ui-print-fg); }
  .topbar, .sidebar, .lw-bar, .skip, .no-print { display: none !important; }
  .sheet { min-height: 0; height: 100vh; padding: 0; }
}
