/* =====================================================================
   Stammbaum UI – Komponenten-Bibliothek v0.3 (Stand 23.10.2026)
   ---------------------------------------------------------------------
   Ergänzt app/static/css/app.css (Keplinger Corporate Design).
   Regeln, Einsatz und Beispiele: docs/ui/DESIGN.md
   Maschinenlesbarer Katalog:     docs/ui/components.json
   Jinja-Makros:                  docs/ui/_ui.html

   Konventionen
   - Neue Komponenten tragen das Präfix "ui-". Bestehende Klassen aus
     app.css (.btn, .field, .card, .flash, .badge, table.list, .tabs,
     .modal, .toolbar) bleiben gültig und werden hier nur ergänzt.
   - Farben, Abstände und Größen nur über die Tokens unten. Keine
     Hex-Werte in Templates oder Modul-CSS.
   - Kein Framework, keine Webfonts, kein CDN (ENTWICKLUNG.md Regel 5).
   - Die Oberfläche ist hell (CI). Dunkelmodus: offen (DESIGN.md, F-UI-03).
   ===================================================================== */

/* ---------- 1. Tokens ------------------------------------------------ */
:root {
  /* Markenfarben (Keplinger CD) */
  --navy: #183E74;          /* Primärfarbe: Kopfzeile, Primärschaltfläche, Tabellenkopf, Links */
  --navy-dark: #10294d;     /* Hover/aktiv auf Navy */
  --navy-050: #e8eef7;      /* Info-Hintergrund, Auswahl, Hover in Listen */
  --navy-100: #d3deee;      /* ausgewählte Zeile */
  --yellow: #FFEA00;        /* Akzent: aktiver Menüpunkt, Hervorhebung – nie als Textfarbe auf Weiß */
  --amber: #FABB0C;         /* Akzent: Fokus-Halo, Zähler, Markierung "überschrieben" */
  --amber-050: #fff4d6;     /* Hintergrund überschriebene Zelle / Warnung */
  --lightblue: #B9C4D4;     /* dekorative Linien (nicht für Feldränder: Kontrast 1,8:1) */

  /* Neutrale (leicht blaustichig, passend zu Navy) */
  --bg: #ffffff;
  --surface: #ffffff;
  --rowgray: #F4F6F9;       /* Zebra, Nur-lesen-Feld */
  --gray: #EDEDED;          /* Trennlinien in Listen */
  --line: #d5dbe5;          /* Kartenrand, Tabellenlinien */
  --field-border: #7d8899;  /* Feldrand: 3,6:1 auf Weiß (WCAG 1.4.11) */
  --text: #1d2430;          /* Fließtext 15,5:1 */
  --muted: #5b6574;         /* Nebeninfo 5,4:1 auch auf Zeilengrau */
  --placeholder: #7d8899;   /* Vorschlagswerte (fixe Maße) */

  /* Bedeutungsfarben – immer mit Symbol oder Text, nie Farbe allein */
  --ok: #1d7a3a;   --ok-bg: #e6f2e9;     /* erledigt, gedeckt, gespeichert */
  --warn: #8a4f00; --warn-bg: #fff4d6;   /* Hinweis, knapp, nach Druck geändert */
  --err: #b42318;  --err-bg: #fdecea;    /* Fehler, nicht gedeckt, Minusbestand */
  --info: #183E74; --info-bg: #e8eef7;   /* Systemvorschlag, neu */

  /* Typografie: nur Arial (CD) */
  --font: Arial, Helvetica, sans-serif;
  --fs-xs: 11px;  /* Plaketten, Tooltips */
  --fs-sm: 12px;  /* Feldbeschriftung, Nebeninfo */
  --fs-md: 14px;  /* Standard */
  --fs-lg: 16px;  /* Tablet-Text, wichtige Zahl */
  --fs-xl: 19px;  /* Belegtitel */
  --fs-2xl: 22px; /* Seitentitel */
  --fs-kpi: 28px; /* Kennzahl */

  /* Abstände (4er-Raster) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;

  /* Zeilenhöhen und Zielgrößen */
  --row-dense: 28px;   /* Listen im Büro (Standard) */
  --row-normal: 36px;  /* Formulare, Maßzeilen-Grid */
  --target-min: 24px;  /* WCAG 2.5.8 Mindestgröße am PC */
  --target-touch: 56px;/* Tablet/Handy in Halle und Lager (≈1,5 cm, Handschuhe) */

  --radius: 4px;
  --shadow-pop: 0 6px 18px rgba(16, 41, 77, .18);
  --shadow-dialog: 0 12px 40px rgba(16, 41, 77, .28);
  --focus-ring: 0 0 0 2px #fff, 0 0 0 4px var(--navy), 0 0 0 6px var(--amber);
  --z-sticky: 20; --z-pop: 40; --z-modal: 50; --z-toast: 90;
}

/* ---------- 2. Grundlagen -------------------------------------------- */
.ui-caption { color: var(--muted); text-transform: uppercase; font-size: 10px; letter-spacing: .05em; }
.ui-num, td.num, th.num, .num input { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.ui-unit { color: var(--muted); font-size: var(--fs-sm); margin-left: 2px; }
.ui-muted { color: var(--muted); }
.ui-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ui-row { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.ui-spacer { flex: 1; }

/* Fokus: sichtbar auf jedem Hintergrund (Navy-Ring + Amber-Halo) */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius);
}
input, select, textarea { border-color: var(--field-border); }

/* Symbole (SVG-Sprite aus _icons.html) */
.i { width: 16px; height: 16px; flex: none; vertical-align: -3px; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i-lg { width: 20px; height: 20px; }
.i-xl { width: 28px; height: 28px; }

/* Tastenkürzel */
kbd, .ui-kbd { font: 11px/1 var(--font); padding: 2px 5px; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 3px; background: var(--rowgray); color: var(--muted); white-space: nowrap; }

/* ---------- 3. Schaltflächen (ergänzt .btn aus app.css) --------------- */
.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; line-height: 1.2; }
.btn .i { margin: 0 -2px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--navy-050); }
.btn.icon-only { padding: 6px; min-width: 32px; justify-content: center; }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; }  /* kein pointer-events:none – der Tooltip (title) nennt den Grund */
.btn.small { min-height: var(--target-min); }  /* Zeilenaktionen in Listen: WCAG-Mindestgröße, Zeilen bleiben kompakt */
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 14px; height: 14px;
  border: 2px solid currentColor; border-color: var(--navy) transparent var(--navy) transparent; border-radius: 50%;
  animation: ui-spin .8s linear infinite; }
.btn.primary.is-busy::after { border-color: #fff transparent #fff transparent; }
.btn.touch { min-height: var(--target-touch); padding: 12px 22px; font-size: var(--fs-lg); font-weight: bold; }
.ui-btn-group { display: inline-flex; }
.ui-btn-group > .btn { border-radius: 0; margin-left: -1px; }
.ui-btn-group > .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.ui-btn-group > .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.ui-btn-group > .btn.is-active { background: var(--navy); color: #fff; }
@keyframes ui-spin { to { transform: rotate(360deg); } }

/* ---------- 4. Felder (ergänzt .field) -------------------------------- */
.field > span .req { color: var(--err); }
.field .ui-hint { font-size: var(--fs-xs); color: var(--muted); }
.field.is-invalid input, .field.is-invalid select, .field.is-invalid textarea { border-color: var(--err); background: var(--err-bg); }
.field .ui-error { display: flex; gap: 4px; align-items: flex-start; font-size: var(--fs-sm); color: var(--err); }
.field.is-warning input { border-color: var(--warn); background: var(--warn-bg); }
.field .ui-warning { font-size: var(--fs-sm); color: var(--warn); display: flex; gap: 4px; }

/* Eingabe mit Einheit: [ 3,20 | €/lfm ] */
.ui-input-unit { display: flex; align-items: stretch; }
.ui-input-unit input { border-radius: var(--radius) 0 0 var(--radius); text-align: right; min-width: 0; }
.ui-input-unit > span { display: flex; align-items: center; padding: 0 8px; border: 1px solid var(--field-border); border-left: 0;
  border-radius: 0 var(--radius) var(--radius) 0; background: var(--rowgray); color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }

/* Gesperrtes Feld: sichtbar, nicht änderbar, mit Weg zur Änderung (Fachkonzept § 13) */
.ui-locked { display: flex; align-items: center; gap: 6px; min-height: 32px; padding: 5px 8px; border: 1px dashed var(--field-border);
  border-radius: var(--radius); background: var(--rowgray); }
.ui-locked .i { color: var(--muted); }
.ui-locked .ui-locked-action { margin-left: auto; font-size: var(--fs-sm); }

/* Label/Wert-Paare (Kopfdaten, Seitenfenster) */
.ui-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 0; }
.ui-facts dt { color: var(--muted); font-size: var(--fs-sm); padding-top: 1px; }
.ui-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- 5. Plaketten, Status, Herkunft ---------------------------- */
.badge { line-height: 16px; white-space: nowrap; }
.badge-draft { background: #fff3a8; color: var(--text); }
.badge-final { background: var(--ok-bg); color: var(--ok); }
.badge-cancelled { background: var(--err-bg); color: var(--err); }
.badge-done { background: var(--gray); color: var(--muted); }      /* erledigt ohne Folgebeleg */
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-err { background: var(--err-bg); color: var(--err); }      /* dringend, z. B. Mahnstufe 4 (ohne Durchstreichen wie storniert) */

/* Statussymbole der Belegliste (Fachkonzept § 12a.6): Gedruckt · Fakturiert · Gebucht */
.ui-status { display: inline-flex; gap: 2px; }
.ui-status > span { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  border-radius: 3px; color: var(--field-border); opacity: .55; }   /* aus: blass, aber erkennbar */
.ui-status > span.is-on, .ui-status > span.is-part, .ui-status > span.is-changed, .ui-status > span.is-locked { opacity: 1; }
.ui-status > span.is-on { color: var(--navy); }
.ui-status > span.is-part { color: var(--navy); background: var(--navy-050); }
.ui-status > span.is-changed { color: var(--warn); background: var(--warn-bg); }
.ui-status > span.is-locked { color: var(--ok); }
th.ui-status-col, td.ui-status-col { width: 28px; padding-left: 2px !important; padding-right: 2px !important; text-align: center; }

/* Herkunft eines Preises (Fachkonzept § 4.4) */
.ui-origin { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-xs); padding: 1px 6px; border-radius: 10px;
  border: 1px solid var(--line); color: var(--muted); background: var(--surface); white-space: nowrap; }
.ui-origin.is-group  { color: var(--navy); border-color: var(--navy-100); background: var(--navy-050); }
.ui-origin.is-customer { color: var(--ok); border-color: #b8d9c1; background: var(--ok-bg); }
.ui-origin.is-manual { color: var(--warn); border-color: #f0d27a; background: var(--warn-bg); font-weight: bold; }
.ui-origin.is-calc { color: var(--text); border-style: dashed; }

/* Filter-Chips / Schnellfilter */
.ui-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ui-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 3px 10px; border: 1px solid var(--field-border);
  border-radius: 14px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; text-decoration: none; }
.ui-chip:hover { background: var(--navy-050); }
.ui-chip.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.ui-chip .ui-count { font-size: var(--fs-xs); background: var(--amber); color: var(--text); border-radius: 9px; padding: 0 6px; }
.ui-chip.is-active .ui-count { background: var(--yellow); }
.ui-chip .ui-x { margin-left: 2px; opacity: .7; }

/* ---------- 6. Meldungen --------------------------------------------- */
.ui-alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid; border-left-width: 4px; margin: 0 0 var(--s3); }
.ui-alert .i { margin-top: 1px; }
.ui-alert > div { min-width: 0; flex: 1; }
.ui-alert strong { display: block; }
.ui-alert .ui-alert-actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.ui-alert.ok   { color: var(--ok);  background: var(--ok-bg);   border-color: #b8d9c1; }
.ui-alert.info { color: var(--info); background: var(--info-bg); border-color: var(--navy-100); }
.ui-alert.warn { color: var(--warn); background: var(--warn-bg); border-color: #f0d27a; }
.ui-alert.error{ color: var(--err); background: var(--err-bg);  border-color: #f2b8b2; }
.ui-alert > div, .ui-alert p { color: var(--text); }
.ui-alert strong { color: inherit; }
.ui-alert.ok strong { color: var(--ok); } .ui-alert.info strong { color: var(--info); }
.ui-alert.warn strong { color: var(--warn); } .ui-alert.error strong { color: var(--err); }

/* Toast: kurze Bestätigung, verschwindet nach 4 s, nie für Fehler */
.ui-toasts { position: fixed; right: 16px; bottom: 16px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; }
.ui-toast { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-radius: var(--radius); background: var(--text);
  color: #fff; box-shadow: var(--shadow-pop); font-size: 13px; }
.ui-toast .i { color: #8fd19e; }
.ui-toast a { color: var(--yellow); }

/* ---------- 7. Bearbeitungssperre und Speichern (Fachkonzept § 12) ----- */
.ui-lock { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--rowgray); margin-bottom: var(--s3); }
.ui-lock .ui-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center; font-weight: bold; flex: none; }
.ui-lock.is-mine { background: var(--ok-bg); border-color: #b8d9c1; }
.ui-lock.is-other { background: var(--warn-bg); border-color: #f0d27a; }
.ui-lock.is-other .ui-avatar { background: var(--warn); }
.ui-lock.is-readonly { background: var(--rowgray); }
.ui-lock.is-lost { background: var(--err-bg); border-color: #f2b8b2; }   /* eigene Sperre abgelaufen/aufgehoben */
.ui-lock .ui-lock-text { flex: 1; min-width: 200px; }
.ui-lock .ui-lock-text small { display: block; color: var(--muted); }

.ui-save { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }
.ui-save.is-saving .i { animation: ui-spin 1s linear infinite; }
.ui-save.is-saved { color: var(--ok); }
.ui-save.is-offline { color: var(--err); font-weight: bold; }
.ui-save.is-conflict { color: var(--err); font-weight: bold; }

/* ---------- 8. Seitenkopf und Belegkette ------------------------------ */
.ui-pagehead { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3); }
.ui-pagehead h1 { margin: 0; }
.ui-pagehead .ui-context { color: var(--muted); }
.ui-pagehead .ui-actions { margin-left: auto; display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }

.ui-docbar { position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: center; gap: var(--s2) var(--s3);
  flex-wrap: wrap; background: var(--surface); border-bottom: 2px solid var(--navy); padding: 8px 0; margin-bottom: var(--s3); }
.ui-docbar h1 { margin: 0; font-size: var(--fs-xl); white-space: nowrap; }
.ui-docbar .ui-back { text-decoration: none; white-space: nowrap; }
.ui-docbar .ui-partner { color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 380px; }
.ui-docbar .ui-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Belegkette: Angebot → Auftrag → Lieferschein → Rechnung */
.ui-flow { display: flex; align-items: center; gap: 0; flex-wrap: wrap; font-size: var(--fs-sm); list-style: none; margin: 0; padding: 0; }
.ui-flow li { display: flex; align-items: center; }
.ui-flow li + li::before { content: ""; width: 18px; height: 2px; background: var(--line); margin: 0 2px; }
.ui-flow a, .ui-flow span { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 12px;
  border: 1px solid var(--line); color: var(--muted); text-decoration: none; white-space: nowrap; background: var(--surface); }
.ui-flow .is-done { color: var(--navy); border-color: var(--navy-100); background: var(--navy-050); }
.ui-flow .is-current { color: #fff; background: var(--navy); border-color: var(--navy); font-weight: bold; }
.ui-flow .is-next { border-style: dashed; }

/* ---------- 9. Listen (ergänzt table.list) ---------------------------- */
.ui-table-wrap { position: relative; overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--line); border-radius: var(--radius); }
.ui-table-wrap table.list { margin: 0; }
table.list thead th { position: sticky; top: 0; z-index: 2; }
table.list.dense td { padding-top: 3px; padding-bottom: 3px; height: var(--row-dense); }
table.list th a.ui-sort { color: #fff; text-decoration: none; display: inline-flex; gap: 4px; align-items: center; }
table.list th a.ui-sort[aria-sort="ascending"]::after { content: "▲"; font-size: 9px; color: var(--yellow); }
table.list th a.ui-sort[aria-sort="descending"]::after { content: "▼"; font-size: 9px; color: var(--yellow); }
table.list tr.is-selected td { background: var(--navy-100) !important; }
table.list tr.is-draft td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
table.list tr.is-cancelled td { color: var(--muted); text-decoration: line-through; }
table.list tr.is-locked td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
table.list td.neg, .ui-neg { color: var(--err); font-weight: bold; }
table.list td .ui-sub { display: block; font-size: var(--fs-xs); color: var(--muted); }
table.list td.ui-rowmenu { width: 32px; padding: 0 2px; text-align: center; }
.ui-listinfo { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--muted); margin: 6px 0; }

/* Filterleiste */
.ui-filterbar { display: flex; gap: var(--s2) var(--s3); align-items: flex-end; flex-wrap: wrap; margin: var(--s2) 0; }
.ui-filterbar .field { min-width: 120px; }
.ui-filterbar .field.ui-search { flex: 1 1 280px; max-width: 420px; }
.ui-search-input { position: relative; }
.ui-search-input .i { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.ui-search-input input { padding-left: 30px; }
.ui-search-input kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }

/* Kontextmenü (Rechtsklick und Schaltfläche ⋯ – beides anbieten) */
.ui-menu { position: absolute; z-index: var(--z-pop); min-width: 240px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 4px 0; }
.ui-menu button, .ui-menu a { display: flex; width: 100%; gap: 8px; align-items: center; padding: 7px 12px; border: 0; background: none;
  font: inherit; color: var(--text); text-align: left; text-decoration: none; cursor: pointer; min-height: 32px; }
.ui-menu button:hover, .ui-menu a:hover { background: var(--navy-050); }
.ui-menu .ui-menu-sep { height: 1px; background: var(--line); margin: 4px 0; }
.ui-menu .ui-menu-hint { margin-left: auto; color: var(--muted); font-size: var(--fs-xs); }
.ui-menu .is-danger { color: var(--err); }
.ui-menu button[disabled], .ui-menu .is-disabled { color: var(--muted); cursor: not-allowed; }
.ui-menu .ui-menu-label { padding: 4px 12px 2px; font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
/* Ausklappmenü an einer Schaltfläche (<details class="ui-menubtn"><summary class="btn">Ausgabe ▾</summary><div class="ui-menu" role="menu">…)
   – „Ausgabe ▾“, „⋯“ (weitere Aktionen), „Kunde ▾“. Esc/Klick daneben schließt, ↑/↓ wählt (app.js). */
details.ui-menubtn { position: relative; display: inline-block; }
details.ui-menubtn > summary { list-style: none; }
details.ui-menubtn > summary::-webkit-details-marker { display: none; }
details.ui-menubtn > .ui-menu { top: calc(100% + 2px); right: 0; }
details.ui-menubtn > .ui-menu.is-left { right: auto; left: 0; }

/* Leerzustand */
.ui-empty { text-align: center; padding: var(--s6) var(--s4); color: var(--muted); }
.ui-empty .i { width: 40px; height: 40px; color: var(--lightblue); }
.ui-empty h3 { color: var(--text); margin: var(--s2) 0 var(--s1); }
.ui-empty p { margin: 0 auto var(--s3); max-width: 46ch; }

/* Laden: Skelett für Listen > 1 s, sonst nichts */
.ui-skeleton { display: block; height: 12px; border-radius: 3px; background: linear-gradient(90deg, var(--gray), var(--rowgray), var(--gray));
  background-size: 200% 100%; animation: ui-shimmer 1.2s infinite; }
@keyframes ui-shimmer { to { background-position: -200% 0; } }

/* ---------- 10. Kennzahlen und Arbeitslisten (Startseite) ------------- */
.ui-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s3); }
.ui-kpi { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); text-decoration: none; color: var(--text); position: relative; }
a.ui-kpi:hover { border-color: var(--navy); background: var(--navy-050); }
.ui-kpi .ui-kpi-label { font-size: var(--fs-sm); color: var(--muted); }
.ui-kpi .ui-kpi-value { font-size: var(--fs-kpi); font-weight: bold; color: var(--navy); font-variant-numeric: tabular-nums; line-height: 1.1; }
.ui-kpi .ui-kpi-note { font-size: var(--fs-xs); color: var(--muted); }
.ui-kpi.is-warn { border-left: 4px solid var(--amber); }
.ui-kpi.is-warn .ui-kpi-value { color: var(--warn); }
.ui-kpi.is-err { border-left: 4px solid var(--err); }
.ui-kpi.is-err .ui-kpi-value { color: var(--err); }

.ui-worklist { list-style: none; margin: 0; padding: 0; }
.ui-worklist li { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--gray); }
.ui-worklist li:last-child { border-bottom: 0; }
.ui-worklist .ui-wl-main { flex: 1; min-width: 0; }
.ui-worklist .ui-wl-main small { display: block; color: var(--muted); font-size: var(--fs-sm); }

/* ---------- 11. Bestand und Verfügbarkeit (Fachkonzept § 11a.6) ------- */
.ui-stock { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  font-size: var(--fs-sm); background: var(--surface); }
.ui-stock > span { display: flex; flex-direction: column; padding: 3px 8px; border-left: 1px solid var(--line); min-width: 74px; }
.ui-stock > span:first-child { border-left: 0; }
.ui-stock small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.ui-stock b { font-variant-numeric: tabular-nums; }
.ui-stock .is-ok b { color: var(--ok); }
.ui-stock .is-warn { background: var(--warn-bg); } .ui-stock .is-warn b { color: var(--warn); }
.ui-stock .is-err { background: var(--err-bg); }  .ui-stock .is-err b { color: var(--err); }
.ui-stock .ui-stock-link { justify-content: center; color: var(--navy); }

/* Ampelpunkt mit Text (nie Punkt allein) */
.ui-dot { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-sm); white-space: nowrap; }
.ui-dot::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.ui-dot.ok::before { background: var(--ok); } .ui-dot.warn::before { background: var(--amber); box-shadow: 0 0 0 1px var(--warn); }
.ui-dot.err::before { background: var(--err); }

/* Verfügbarkeitsverlauf */
table.ui-timeline td.ui-balance { font-weight: bold; }
table.ui-timeline tr.is-today td { background: var(--navy-050) !important; }
table.ui-timeline tr.is-uncertain td:first-child::after { content: " ca."; color: var(--warn); font-size: var(--fs-xs); }

/* ---------- 12. Positionen und Maßzeilen-Grid (Fachkonzept § 2, § 5) -- */
.ui-pos { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: var(--s2); background: var(--surface); }
.ui-pos-head { display: grid; grid-template-columns: 34px minmax(0, 2.4fr) minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr) auto;
  gap: var(--s3); align-items: center; padding: 8px 10px; }
.ui-pos-head .ui-posnr { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.ui-pos-head .ui-art b { display: block; }
.ui-pos-head .ui-art small { color: var(--muted); }
.ui-pos.is-open { border-color: var(--navy-100); box-shadow: 0 0 0 1px var(--navy-100); }
.ui-pos-body { border-top: 1px solid var(--line); padding: 10px; background: var(--rowgray); display: grid; gap: var(--s3); }
.ui-pos-raw { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; font-size: var(--fs-sm);
  padding: 6px 10px; border: 1px dashed var(--field-border); border-radius: var(--radius); background: var(--surface); }


.ui-grid-wrap { position: relative; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.ui-grid { border-collapse: collapse; width: auto; min-width: min(100%, 640px); font-variant-numeric: tabular-nums; }
table.ui-grid th { background: var(--rowgray); color: var(--muted); font-weight: normal; font-size: var(--fs-sm); text-align: right;
  padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.ui-grid th:first-child, table.ui-grid td:first-child { text-align: right; width: 36px; color: var(--muted); }
table.ui-grid th .ui-th-unit { color: var(--navy); font-weight: bold; }
table.ui-grid td { border-bottom: 1px solid var(--gray); border-right: 1px solid var(--gray); padding: 0; height: var(--row-normal); text-align: right; }
table.ui-grid td input { border: 0; border-radius: 0; height: var(--row-normal); text-align: right; background: transparent; padding: 0 8px; width: 104px; }
table.ui-grid td input:focus { box-shadow: inset 0 0 0 2px var(--navy); background: #fff; }
table.ui-grid td input::placeholder { color: var(--placeholder); font-style: italic; }   /* Vorschlagswert aus Artikel */
table.ui-grid td.is-calc { background: var(--rowgray); padding: 0 8px; color: var(--text); }  /* live berechnet, nicht änderbar */
table.ui-grid td.is-override { background: var(--amber-050); box-shadow: inset 3px 0 0 var(--amber); }  /* vom Artikel abweichend */
table.ui-grid td.is-invalid { background: var(--err-bg); box-shadow: inset 0 0 0 2px var(--err); }       /* Fehler blockiert nicht */
table.ui-grid tfoot td { position: sticky; bottom: 0; background: var(--surface); border-top: 2px solid var(--navy); font-weight: bold; padding: 0 8px; }
table.ui-grid tr.ui-grid-new td { background: #fff; }
table.ui-grid tr.ui-grid-new td:nth-child(2) input::placeholder { font-style: normal; }
.ui-grid-foot { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--muted); padding: 6px 2px 0; }

/* Tabulator-Thema (Entscheidung § 5: Tabulator 6.x). Auf .tabulator.ui-tabulator anwenden. */
.tabulator.ui-tabulator { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font: 14px var(--font); font-variant-numeric: tabular-nums; }
.tabulator.ui-tabulator .tabulator-header { background: var(--rowgray); border-bottom: 1px solid var(--line); color: var(--muted); font-weight: normal; }
.tabulator.ui-tabulator .tabulator-header .tabulator-col { background: transparent; border-right: 1px solid var(--gray); }
.tabulator.ui-tabulator .tabulator-row { min-height: var(--row-normal); }
.tabulator.ui-tabulator .tabulator-row.tabulator-row-even { background: var(--surface); }
.tabulator.ui-tabulator .tabulator-cell { border-right: 1px solid var(--gray); padding: 8px; }
.tabulator.ui-tabulator .tabulator-cell.tabulator-editing { border: 0; box-shadow: inset 0 0 0 2px var(--navy); padding: 0; }
.tabulator.ui-tabulator .tabulator-cell.ui-calc { background: var(--rowgray); }
.tabulator.ui-tabulator .tabulator-cell.ui-override { background: var(--amber-050); box-shadow: inset 3px 0 0 var(--amber); }
.tabulator.ui-tabulator .tabulator-cell.tabulator-validation-fail { background: var(--err-bg); box-shadow: inset 0 0 0 2px var(--err); border: 0; }
.tabulator.ui-tabulator .tabulator-footer { background: var(--surface); border-top: 2px solid var(--navy); font-weight: bold; }

/* ---------- 13. Preisrechner (Fachkonzept § 4) ------------------------ */
.ui-calc { display: grid; gap: var(--s3); }
.ui-calc-dims { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--s3); }
.ui-calc-dims fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px 10px; margin: 0; display: grid;
  grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: end; }
.ui-calc-dims legend { font-size: var(--fs-sm); color: var(--muted); padding: 0 4px; }
.ui-calc-dims .ui-x { padding-bottom: 8px; color: var(--muted); }
.ui-calc-prices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.ui-calc-price { border: 2px solid var(--line); border-radius: var(--radius); padding: 8px 10px; display: grid; gap: 4px; cursor: pointer; background: var(--surface); }
.ui-calc-price:has(input[type=radio]:checked) { border-color: var(--navy); background: var(--navy-050); }
.ui-calc-price .ui-calc-unit { display: flex; gap: 6px; align-items: center; font-weight: bold; color: var(--navy); }
.ui-calc-price input[type=text] { font-size: var(--fs-lg); text-align: right; font-variant-numeric: tabular-nums; }
.ui-calc-price small { color: var(--muted); font-size: var(--fs-xs); }
.ui-calc-ek { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s2) var(--s3); padding: 8px 10px;
  border-radius: var(--radius); background: var(--rowgray); border: 1px solid var(--line); }
.ui-calc-ek details { grid-column: 1 / -1; font-size: var(--fs-sm); }
.ui-calc-way { font-size: var(--fs-sm); color: var(--muted); background: var(--surface); border-left: 3px solid var(--lightblue); padding: 6px 10px; }

/* ---------- 14. Dialog, Seitenfenster -------------------------------- */
.modal.ui-dialog { padding: 0; overflow: hidden; }  /* nur Dialoge mit Kopf/Rumpf/Fuß – ältere .modal behalten ihren Innenabstand */
.ui-dialog-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.ui-dialog-head h2 { margin: 0; font-size: 17px; }
.ui-dialog-head .ui-close { margin-left: auto; }
.ui-dialog-body { padding: 14px 16px; display: grid; gap: var(--s3); max-height: 70vh; overflow-y: auto; }
.ui-dialog-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; padding: 10px 16px;
  background: var(--rowgray); border-top: 1px solid var(--line); }
.ui-dialog-foot .ui-left { margin-right: auto; font-size: var(--fs-sm); color: var(--muted); }
.modal.sm { width: min(480px, 100%); } .modal.md { width: min(680px, 100%); } .modal.lg { width: min(980px, 100%); }

.ui-sheet { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); z-index: var(--z-modal); background: var(--surface);
  box-shadow: var(--shadow-dialog); display: flex; flex-direction: column; }
.ui-sheet .ui-dialog-body { max-height: none; flex: 1; }

/* Auswahlkarten (Grund, Variante) */
.ui-choices { display: grid; gap: 8px; }
.ui-choice { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; padding: 10px 12px; border: 2px solid var(--line);
  border-radius: var(--radius); cursor: pointer; background: var(--surface); align-items: start; }
.ui-choice:has(input:checked) { border-color: var(--navy); background: var(--navy-050); }
.ui-choice input { margin-top: 3px; width: auto; }
.ui-choice small { grid-column: 2; color: var(--muted); }
.ui-choice.is-disabled { opacity: .55; cursor: not-allowed; }
.ui-reasons { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.ui-reason { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px; border: 2px solid var(--line);
  border-radius: var(--radius); background: var(--surface); cursor: pointer; font-weight: bold; text-align: center; }
.ui-reason:has(input:checked) { border-color: var(--navy); background: var(--navy); color: #fff; }
.ui-reason input { position: absolute; opacity: 0; width: 1px; }

/* ---------- 15. Halle und Lager: Touch-Ansicht (§ 5, § 11.3) ----------- */
.ui-touch { font-size: var(--fs-lg); background: var(--rowgray); min-height: 100%; }
.ui-touch .ui-touch-bar { display: flex; align-items: center; gap: var(--s3); background: var(--navy); color: #fff; padding: 10px 16px; min-height: 60px; }
.ui-touch .ui-touch-bar h1 { color: #fff; margin: 0; font-size: 20px; }
.ui-touch .ui-touch-bar .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.6); min-height: 44px; }
.ui-touch-list { display: grid; gap: var(--s3); padding: var(--s4); }
.ui-tcard { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 10px; }
.ui-tcard.is-active { border: 3px solid var(--navy); }
.ui-tcard h2 { margin: 0; font-size: 20px; color: var(--text); }
.ui-tcard .ui-tmeta { display: flex; gap: 6px 18px; flex-wrap: wrap; color: var(--muted); font-size: 15px; }
.ui-tcard .ui-tqty { font-size: 26px; font-weight: bold; color: var(--navy); font-variant-numeric: tabular-nums; }
.ui-tcard .ui-tnote { background: var(--warn-bg); color: var(--text); border-left: 4px solid var(--amber); padding: 8px 10px; border-radius: 4px; }
.ui-tactions { display: grid; grid-template-columns: 2fr 1fr; gap: var(--s3); }
.ui-tbtn { min-height: 72px; border-radius: 8px; border: 2px solid var(--navy); background: var(--surface); color: var(--navy); font: bold 18px var(--font);
  display: flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; padding: 8px 12px; text-align: center; }
.ui-tbtn.primary { background: var(--ok); border-color: var(--ok); color: #fff; }
.ui-tbtn.primary small { display: block; font-weight: normal; font-size: 13px; opacity: .9; }
.ui-tpkgs { display: grid; gap: 8px; }
.ui-tpkg { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; min-height: var(--target-touch);
  padding: 8px 12px; border: 2px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.ui-tpkg:has(input:checked) { border-color: var(--navy); background: var(--navy-050); }
.ui-tpkg input { width: 24px; height: 24px; }
.ui-tpkg b { font-size: 17px; }
.ui-tpkg small { grid-column: 2 / -1; color: var(--muted); font-size: 14px; }
@media (max-width: 640px) { .ui-tactions { grid-template-columns: 1fr; } }

/* ---------- 16. Paketetikett 150 × 100 mm (§ 7) ----------------------- */
.ui-etikett { width: 150mm; height: 100mm; box-sizing: border-box; padding: 5mm; background: #fff; color: #000; font-family: var(--font);
  display: grid; grid-template-columns: 56mm 1fr; grid-template-rows: 1fr auto; gap: 3mm 5mm; border: 0.3mm solid #000; }
.ui-etikett .ui-etikett-qr { width: 56mm; height: 56mm; align-self: start; }
.ui-etikett .ui-etikett-qr svg { width: 100%; height: 100%; display: block; }
.ui-etikett .ui-etikett-main { display: flex; flex-direction: column; gap: 2mm; min-width: 0; }
.ui-etikett .ui-etikett-nr { font-size: 15mm; line-height: 1; font-weight: bold; letter-spacing: -0.2mm; }
.ui-etikett .ui-etikett-art { font-size: 6mm; font-weight: bold; line-height: 1.15; }
.ui-etikett .ui-etikett-dims { font-size: 7.5mm; font-weight: bold; }
.ui-etikett .ui-etikett-meta { font-size: 3.6mm; line-height: 1.35; }
.ui-etikett .ui-etikett-foot { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: end; font-size: 3.2mm; border-top: 0.4mm solid #000; padding-top: 2mm; }
/* Druck nur auf der Etikettseite (Seite enthält .ui-etikett): genau eine Seite 150 × 100 mm mit dem Etikett. Andere Seiten
   drucken normal (Prüfbefund L-05: vorher galt die Regel für jede Seite – Strg+P druckte leer). Benannte Seite statt
   globalem @page, damit Listen und Belege ihr Papierformat behalten. Alles außer dem Etikett und seinen Vorfahren wird
   ausgeblendet (nicht nur unsichtbar – sonst entstehen leere Folgeseiten); der Rahmen .ui-table-wrap (relativ, mit
   Bildlauf und Höhenbegrenzung) beschnitt das Etikett im Druck – vorher war auch der Etikettdruck leer. */
@media print {
  @page etikett { size: 150mm 100mm; margin: 0; }
  body:has(.ui-etikett) { page: etikett; margin: 0; }
  body:has(.ui-etikett) *:not(:has(.ui-etikett)):not(.ui-etikett):not(.ui-etikett *) { display: none !important; }
  body:has(.ui-etikett) .ui-table-wrap { position: static; overflow: visible; max-height: none; border: 0; }
  body:has(.ui-etikett) .ui-etikett { position: absolute; left: 0; top: 0; border: 0; }
}

/* ---------- 19. Ergänzungen 23.10.2026 (Konzept docs/ui/konzept/2026-10-23-gespraech.md) ---------- */

/* Zwei-Spalten-Seite für 1920 px (E85): links Auswahl/Formular, rechts Liste/Detail; stapelt unter 1100 px */
.ui-split { display: grid; grid-template-columns: minmax(240px, var(--split-side, 340px)) minmax(0, 1fr); gap: var(--s4); align-items: start; }
.ui-split.is-wide-side { --split-side: 420px; }
.ui-split-side { position: sticky; top: var(--s2); max-height: calc(100vh - 80px); overflow: auto; display: grid; gap: var(--s3); align-content: start; min-width: 0; }
.ui-split-main { min-width: 0; display: grid; gap: var(--s3); align-content: start; }
.ui-split-side > *, .ui-split-main > * { min-width: 0; }   /* Tabellen scrollen in .ui-table-wrap statt die Spalte zu sprengen */

/* Auswahlliste links (Preisgruppen, Monate): Links, aktueller mit aria-current="page" */
.ui-navlist { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.ui-navlist li + li { border-top: 1px solid var(--gray); }
.ui-navlist a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: baseline; padding: 8px 12px; color: var(--text); text-decoration: none; }
.ui-navlist a:hover { background: var(--navy-050); }
.ui-navlist a[aria-current="page"] { background: var(--navy-050); box-shadow: inset 4px 0 0 var(--navy); }
.ui-navlist a b { color: var(--navy); min-width: 0; overflow-wrap: anywhere; }
.ui-navlist a small { color: var(--muted); font-size: var(--fs-sm); grid-column: 1 / -1; }
.ui-navlist .ui-num { font-size: var(--fs-sm); }
.ui-navlist li.ui-lvl-2 a { padding-left: 30px; }
.ui-navlist li.ui-lvl-3 a { padding-left: 48px; }

/* Baum in Listen (Warengruppen bis 3 Ebenen, Summen je Warengruppe) */
table.list.ui-tree td.ui-tree-cell { white-space: nowrap; }
table.list.ui-tree tr.ui-lvl-1 td.ui-tree-cell { font-weight: bold; }
table.list.ui-tree tr.ui-lvl-2 td.ui-tree-cell { padding-left: 30px; }
table.list.ui-tree tr.ui-lvl-3 td.ui-tree-cell { padding-left: 54px; }
.ui-tree-toggle { display: inline-flex; align-items: center; justify-content: center; width: var(--target-min); height: var(--target-min);
  margin: -2px 2px -2px -4px; padding: 0; border: 0; border-radius: 3px; background: transparent; color: var(--navy); cursor: pointer; vertical-align: middle; }
.ui-tree-toggle:hover { background: var(--navy-050); }
.ui-tree-toggle[aria-expanded="false"] .i { transform: rotate(-90deg); }
.ui-tree-leaf { display: inline-block; width: var(--target-min); margin-left: -4px; margin-right: 2px; }
table.list tr.is-sum td { font-weight: bold; background: var(--rowgray); }
table.list tfoot tr.is-sum td { border-top: 2px solid var(--navy); position: sticky; bottom: 0; }

/* Alt → neu (Massenpreise, Abweichung zum Angebot, Preise neu ermitteln) */
.ui-diff { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ui-diff .ui-diff-old { color: var(--muted); }
.ui-diff .ui-diff-arrow { color: var(--muted); }
.ui-diff .ui-diff-new { font-weight: bold; color: var(--text); }
.ui-diff .ui-diff-pct { font-size: var(--fs-xs); padding: 0 5px; border-radius: 8px; background: var(--rowgray); border: 1px solid var(--line); color: var(--text); }

/* Markierung (Plakette mit Text): geändert · neu · entfällt · unsicher · geprüft – nie Farbe allein */
.ui-mark { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-xs); font-weight: bold; line-height: 16px; padding: 0 6px;
  border: 1px solid var(--line); border-radius: 3px; white-space: nowrap; color: var(--muted); background: var(--surface); }
.ui-mark.is-changed   { color: var(--navy); background: var(--navy-050); border-color: var(--navy-100); }
.ui-mark.is-new       { color: var(--ok);   background: var(--ok-bg);    border-color: #b8d9c1; }
.ui-mark.is-removed   { color: var(--err);  background: var(--err-bg);   border-color: #f2b8b2; }
.ui-mark.is-uncertain { color: var(--warn); background: var(--warn-bg);  border-color: #f0d27a; }
.ui-mark.is-ok        { color: var(--ok);   background: var(--surface);  border-color: #b8d9c1; font-weight: normal; }
/* Streifen links an Position bzw. Listenzeile */
.ui-pos.is-mark-changed, .ui-pos.is-mark-new, .ui-pos.is-mark-removed, .ui-pos.is-mark-uncertain { border-left-width: 4px; }
.ui-pos.is-mark-changed   { border-left-color: var(--navy); }
.ui-pos.is-mark-new       { border-left-color: var(--ok); }
.ui-pos.is-mark-uncertain { border-left-color: var(--amber); }
.ui-pos.is-mark-uncertain > .ui-pos-head { background: var(--warn-bg); }
.ui-pos.is-mark-removed   { border-left-color: var(--field-border); border-style: dashed; background: var(--rowgray); }
.ui-pos.is-mark-removed > .ui-pos-head { color: var(--muted); }
.ui-pos.is-mark-removed .ui-art b { text-decoration: line-through; }
.ui-pos .ui-marks { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.ui-pos.is-moved { outline: 2px solid var(--navy); outline-offset: 1px; }   /* nach Strg+↑/↓, bis zur nächsten Eingabe; keine Animation */
/* dasselbe für Positionen als Tabellenzeilen (belege/_positionen.html): Rahmen über die Zellen, da outline an <tr> unzuverlässig ist */
table.list tr.is-moved > td { background: var(--navy-050) !important; box-shadow: inset 0 2px 0 var(--navy), inset 0 -2px 0 var(--navy); }
table.list tr.is-moved > td:first-child { box-shadow: inset 3px 0 0 var(--navy), inset 0 2px 0 var(--navy), inset 0 -2px 0 var(--navy); }
table.list tr.is-moved > td:last-child { box-shadow: inset -2px 0 0 var(--navy), inset 0 2px 0 var(--navy), inset 0 -2px 0 var(--navy); }
table.list tr.is-mark-changed td:first-child   { box-shadow: inset 3px 0 0 var(--navy); }
table.list tr.is-mark-new td:first-child       { box-shadow: inset 3px 0 0 var(--ok); }
table.list tr.is-mark-uncertain td             { background: var(--warn-bg); }
table.list tr.is-mark-uncertain td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
table.list tr.is-mark-removed td               { color: var(--muted); }
table.list tr.is-muted td                      { color: var(--muted); }
/* Maßzeilen-Grid: Zelle anders als im Angebot (neben is-override = anders als im Artikel) */
table.ui-grid td.is-diff { background: var(--navy-050); }
table.ui-grid td.is-diff input { text-decoration: underline dotted var(--navy); text-underline-offset: 3px; }
.tabulator.ui-tabulator .tabulator-cell.ui-diff-cell { background: var(--navy-050); text-decoration: underline dotted var(--navy); }

/* Preisherkunft „aus Vorlage“ (Duplizieren, § 7) – Ergänzung zu .ui-origin */
.ui-origin.is-template { color: var(--text); border-style: dotted; border-color: var(--field-border); background: var(--rowgray); }

/* Nummerierter Formularblock (Massenpreispflege, Abwertung) */
.ui-step { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px 12px; margin: 0; display: grid; gap: var(--s2);
  background: var(--surface); min-width: 0; }
.ui-step > legend { display: flex; align-items: center; gap: 8px; padding: 0 4px; font-weight: bold; }
.ui-stepnr { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; flex: none; border-radius: 50%;
  background: var(--navy); color: #fff; font-size: var(--fs-sm); font-weight: bold; }

/* Fixierte Fußleiste mit Zusammenfassung und Hauptaktion (Massenpreise, Mahnvorschlag) */
.ui-actionbar { position: sticky; bottom: 0; z-index: var(--z-sticky); display: flex; gap: var(--s2) var(--s3); align-items: center; flex-wrap: wrap;
  padding: 10px 12px; background: var(--rowgray); border: 1px solid var(--line); border-top: 2px solid var(--navy); border-radius: 0 0 var(--radius) var(--radius); }
.ui-actionbar .ui-left { margin-right: auto; font-size: var(--fs-sm); color: var(--muted); min-width: 0; }
.ui-actionbar .ui-left b { color: var(--text); }
.ui-actionbar .btn > span small { display: block; font-weight: normal; font-size: var(--fs-xs); opacity: .9; }

/* Vorschaubild (Artikelbild in Position, Artikelstamm) */
.ui-thumb { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 30px; flex: none; overflow: hidden;
  border: 1px solid var(--line); border-radius: 3px; background: var(--surface); color: var(--muted); vertical-align: middle; }
.ui-thumb img, .ui-thumb svg:not(.i) { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.ui-thumb.is-lg { width: 160px; height: 120px; }
.ui-thumb.is-off { opacity: .4; border-style: dashed; }

/* Umgebungsbanner (Spielwiese, § 25) – über der Kopfzeile, nicht schließbar */
.ui-envbar { display: flex; gap: 6px var(--s3); align-items: center; flex-wrap: wrap; padding: 6px 16px; background: var(--amber); color: var(--text);
  border-bottom: 2px solid var(--text); font-size: var(--fs-md); }
.ui-envbar b { text-transform: uppercase; letter-spacing: .04em; }
.ui-envbar a { color: var(--text); font-weight: bold; }
.ui-envbar.is-info { background: var(--navy-050); color: var(--navy); border-bottom-color: var(--navy); }
.ui-envbar.is-info a { color: var(--navy); }

/* Tablet: Kacheln (Startseite, Namenswahl) – keine Übergänge, kein Hover (Galaxy Tab A9) */
.ui-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: var(--s4); padding: var(--s4); }
.ui-tile { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 6px; min-height: 150px; padding: 16px 18px;
  border: 2px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); text-decoration: none; font: inherit; text-align: left; cursor: pointer; }
.ui-tile:active { background: var(--navy-050); border-color: var(--navy); }
.ui-tile > .i { color: var(--navy); }
.ui-tile b { font-size: 20px; color: var(--navy); }
.ui-tile small { font-size: 15px; color: var(--muted); }
.ui-tile .ui-count { position: absolute; top: 12px; right: 12px; min-width: 32px; padding: 2px 10px; border-radius: 14px; background: var(--amber);
  color: var(--text); font-size: var(--fs-lg); font-weight: bold; text-align: center; }
.ui-tile.is-disabled { opacity: .55; cursor: not-allowed; }
.ui-tile.is-wide { grid-column: 1 / -1; min-height: 80px; flex-direction: row; align-items: center; justify-content: flex-start; gap: 14px; }
.ui-tiles.is-names { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.ui-tiles.is-names .ui-tile { min-height: 88px; flex-direction: row; align-items: center; justify-content: flex-start; gap: 14px; }
.ui-tile .ui-avatar { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; flex: none; border-radius: 50%;
  background: var(--navy); color: #fff; font-size: 18px; font-weight: bold; }

/* Tablet: Stückzahl-Stepper − [ 3 ] + (Ausschuss, Inventur). Knöpfe brauchen ein Skript in app/static/js (data-tstep). */
.ui-tstepper { display: grid; grid-template-columns: 72px minmax(90px, 150px) 72px; gap: 8px; align-items: stretch; }
.ui-tstepper button { min-height: 72px; border: 2px solid var(--navy); border-radius: 8px; background: var(--surface); color: var(--navy);
  font: bold 32px var(--font); cursor: pointer; padding: 0; }
.ui-tstepper input { min-height: 72px; width: 100%; padding: 0 8px; border: 2px solid var(--field-border); border-radius: 8px;
  font: bold 32px var(--font); text-align: center; font-variant-numeric: tabular-nums; }
.ui-tstepper input[aria-invalid="true"] { border-color: var(--err); background: var(--err-bg); }
.ui-reasons.is-touch { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s3); }
.ui-reasons.is-touch .ui-reason { min-height: 72px; font-size: 18px; border-radius: 8px; }

/* Planbreite 1920 px (E85, zwei Full-HD-Monitore): Inhalt nutzt die Breite statt 1500 px aus app.css */
@media (min-width: 1700px) { .content { max-width: 1880px; } }

@media (max-width: 1100px) {
  .ui-split { grid-template-columns: 1fr; }
  .ui-split-side { position: static; max-height: none; }
}

/* ---------- 17. Kopfzeile schmal (Handy/Tablet hochkant) -------------- */
@media (max-width: 700px) {
  .topbar { gap: 15px; padding-top: 6px; }   /* Freiraum Logo ↔ Menü/Benutzerfeld = halbe Zeichenhöhe (L-02/L-03) */
  .topbar .menu { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .topbar .menu a { white-space: nowrap; }
  .topbar .userbox { margin-left: auto; }
}

/* ---------- 18. Bewegung reduzieren ---------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------- UI-R1/R2 (Rückmeldung 23.10.2026, Paket P1 „suche“) ------------------------------------------------
   Artikelsuche .ui-artsuche (Makro ui.article_search, Skript artikelsuche.js) und Zahl als Schaltfläche .ui-numlink
   (Lagerstand aus der Position). */
.ui-artsuche { position: relative; min-width: 0; }
.ui-artsuche-bar { position: relative; display: flex; gap: var(--s2); align-items: center; min-width: 0; }
.ui-artsuche-bar input { flex: 1 1 auto; min-width: 0; width: 100%; }
.ui-artsuche-bar select { flex: 0 1 220px; min-width: 110px; max-width: 240px; }
.ui-artsuche-gewaehlt:empty { display: none; }
/* volle Darstellung mind. 960 px (UX-03), nie breiter als das Fenster; ragt sie rechts hinaus, schiebt sie
   artikelsuche.js nach links */
.ui-artsuche-list { position: absolute; left: 0; top: 100%; z-index: 45; margin-top: 2px;
  min-width: max(100%, min(960px, calc(100vw - 32px))); max-width: min(1180px, calc(100vw - 16px)); }
.ui-artsuche.is-compact .ui-artsuche-list { min-width: max(100%, min(420px, 94vw)); }
.ui-artsuche-list:empty { display: none; }
.ui-artsuche-pop { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); }
.ui-artsuche-scroll { max-height: calc(var(--row-dense) * 12 + 30px); overflow-y: auto; }
table.list.ui-artsuche-table { margin: 0; width: 100%; font-size: var(--fs-sm); }
table.list.ui-artsuche-table td { cursor: pointer; }
table.list.ui-artsuche-table tr[aria-selected="true"] td { background: var(--navy-100); }
table.list.ui-artsuche-table tr[aria-selected="true"] td:first-child { box-shadow: inset 3px 0 0 var(--navy); }
table.list.ui-artsuche-table tr.is-inactive td { color: var(--muted); }
table.list.ui-artsuche-table .ui-artsuche-verf .neg { color: var(--err); }
.ui-artsuche-status { margin: 0; padding: var(--s1) var(--s2); font-size: var(--fs-xs); color: var(--muted); border-top: 1px solid var(--line); }
.ui-artsuche-pop > .ui-artsuche-status:first-child { border-top: 0; }
.ui-artsuche-status.is-error { color: var(--err); font-weight: bold; }
button.ui-artsuche-link { background: none; border: 0; padding: 0; font: inherit; color: var(--navy); text-decoration: underline; cursor: pointer; }
.ui-artsuche-status.is-empty { font-size: var(--fs-sm); color: var(--text); }
/* Listenfilter mit Artikelsuche (ui.article_filter_hint → data-artfilter) und Kundenliste: Platzhalter lesbar
   (UX-09, ≥ 400 px; auf schmalen Bildschirmen höchstens volle Breite) */
input[data-artfilter], form[action="/stammdaten/kunden"] input[type=search][name=q] { width: 400px; max-width: 100%; }

/* Zahl als Schaltfläche (UI-R2): sieht aus wie die Zahl, gepunktet unterstrichen, Ziel ≥ 24 px */
button.ui-numlink { background: none; border: 0; padding: 2px 0; min-height: var(--target-min); font: inherit; color: var(--navy);
  cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
button.ui-numlink:hover { text-decoration-style: solid; }
button.ui-numlink.neg, button.ui-numlink .neg { color: var(--err); }
/* Fenster „Lagerstand“ */
.ui-lagerstand .ui-dialog-body { gap: var(--s3); }
.ui-lagerstand .ui-lagerstand-posten { max-height: 55vh; overflow-y: auto; }
.ui-lagerstand table.list { margin: 0; }
.ui-lagerstand tr.is-this td:first-child { box-shadow: inset 3px 0 0 var(--navy); }
.ui-lagerstand .ui-dialog-foot .ui-left { display: flex; gap: var(--s3); flex-wrap: wrap; }
.ui-lagerstand-fakten { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); margin: 0; font-size: var(--fs-sm); }
.ui-lagerstand-fakten dt { color: var(--muted); }
.ui-lagerstand-fakten div { display: flex; gap: var(--s1); }
.ui-lagerstand-fakten dd { margin: 0; font-weight: bold; }
.ui-lagerstand table.list tfoot th, .ui-lagerstand table.list tfoot td { font-weight: bold; background: var(--rowgray);
  color: var(--text); text-align: left; position: static; border-top: 1px solid var(--gray); }
.ui-lagerstand table.list tfoot td.num { text-align: right; }
.ui-lagerstand table.list tfoot tr:first-child > * { border-top: 2px solid var(--navy); }

/* ---------- UI-R4/R5 (Rückmeldung Matthias 23.10.2026) ---------------- */
/* Gruppenbaum links neben Listen (UI-R4): .ui-split.is-narrow-side, nav.ui-grouptree, details.ui-grouptree-fold.
   Markup: ui.group_tree() in _ui.html, Tastatur/Aufklappen: static/js/gruppenbaum.js (ohne Skript alles offen). */
.ui-split.is-narrow-side { --split-side: 260px; }
.ui-grouptree-fold > summary { display: none; }
.ui-grouptree { display: grid; gap: var(--s2); align-content: start; }
.ui-grouptree-head { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin: 0; }
.ui-grouptree-list, .ui-grouptree-list ul { list-style: none; margin: 0; padding: 0; }
.ui-grouptree-list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.ui-grouptree-list > li + li, .ui-grouptree-list ul > li { border-top: 1px solid var(--gray); }
.ui-grouptree-row { display: flex; align-items: center; min-height: 32px; padding-left: 4px; }
.ui-grouptree-list li.ui-lvl-2 > .ui-grouptree-row { padding-left: 20px; }   /* 16 px je Ebene */
.ui-grouptree-list li.ui-lvl-3 > .ui-grouptree-row { padding-left: 36px; }
.ui-grouptree-row > a { flex: 1; min-width: 0; display: flex; gap: var(--s2); align-items: baseline; padding: 6px 10px 6px 2px;
  color: var(--text); text-decoration: none; }
.ui-grouptree-row:hover { background: var(--navy-050); }
.ui-grouptree-row > a:focus-visible { outline: 2px solid var(--amber); outline-offset: -2px; }
.ui-grouptree-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ui-grouptree-name i { color: var(--muted); }
.ui-grouptree-count { color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ui-grouptree-row.is-current { background: var(--navy-050); box-shadow: inset 4px 0 0 var(--navy); }
.ui-grouptree-row.is-current .ui-grouptree-name { color: var(--navy); font-weight: bold; }
.ui-grouptree-row.is-ancestor .ui-grouptree-name { font-weight: bold; }
/* UX-01: Knoten mit 0 sind Links → Text ≥ 4,5 : 1: --muted (5,9 : 1) statt --placeholder (3,6 : 1); Name sonst normal */
.ui-grouptree-row.is-empty .ui-grouptree-name, .ui-grouptree-row.is-empty .ui-grouptree-count { color: var(--muted); }
.ui-grouptree .ui-tree-toggle { flex: none; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  width: var(--target-min); height: var(--target-min); border-radius: var(--radius); color: var(--navy); }
.ui-grouptree .ui-tree-toggle[hidden] { display: none; }
.ui-grouptree .ui-tree-toggle:hover { background: var(--navy-100); }
.ui-grouptree .ui-tree-toggle.is-closed .i { transform: rotate(-90deg); }
.ui-grouptree .ui-tree-leaf { flex: none; width: 0; margin: 0; }   /* ohne Skript keine Pfeile → kein Platz */
.ui-grouptree.is-js .ui-tree-leaf { width: var(--target-min); }   /* mit Skript: Platz der Pfeile, Namen bündig */
.ui-grouptree ul[role="group"][hidden] { display: none; }
.ui-grouptree .ui-hint { font-size: var(--fs-sm); color: var(--muted); margin: 0; }
.ui-grouptree-headrow { display: flex; gap: var(--s2); align-items: baseline; justify-content: space-between; }
.ui-grouptree-pflege { font-size: var(--fs-sm); display: inline-flex; gap: 4px; align-items: center; }
/* Listen neben dem Baum: .ui-sr (absolut) bleibt im waagrecht scrollenden Tabellenrahmen, kein Seitenüberlauf */
.ui-split-main .table-wrap { position: relative; }
/* Filter-Chip in der Filterleiste („Warengruppe: Lärche ✕“ = alle, ui.group_chip): nur die letzte Ebene, bei Platzmangel
   gekürzt bzw. in eigener Zeile – kein waagrechter Überlauf (UX-04, Tablet 800 px) */
.ui-split.is-narrow-side .toolbar form { flex-wrap: wrap; min-width: 0; max-width: 100%; }
.ui-chip.ui-gruppenchip { text-decoration: none; color: var(--text); background: var(--navy-050); border-color: var(--navy-100);
  max-width: 100%; min-width: 0; }
.ui-gruppenchip-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-chip.ui-gruppenchip:hover { background: var(--navy-100); }
@media (max-width: 1100px) {
  .ui-grouptree-fold { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
  .ui-grouptree-fold > summary { display: flex; gap: var(--s2); align-items: center; min-height: 44px; padding: 0 var(--s3);
    cursor: pointer; color: var(--navy); }
  .ui-grouptree-fold-pfeil { margin-left: auto; display: inline-flex; }   /* UX-12: Aufklapp-Zeichen (flex entfernt den Marker) */
  .ui-grouptree-fold[open] > summary .ui-grouptree-fold-pfeil .i { transform: rotate(180deg); }
  .ui-grouptree-fold[open] > summary { border-bottom: 1px solid var(--line); }
  .ui-grouptree-fold > .ui-grouptree { padding: var(--s2); }
  .ui-grouptree-fold .ui-grouptree-head { visibility: hidden; }   /* Zusammenfassung zeigt die Auswahl; „pflegen“ bleibt */
  .ui-grouptree-row { min-height: 44px; }   /* Tablet: Ziele ≥ 44 px … */
  .ui-grouptree-row > a { align-self: stretch; align-items: center; }   /* … auch der Link selbst (Q3-07) */
}

/* Marke in der Kopfzeile: Stammbaum-Logo als Datei (Entscheidung 24.10.2026, docs/ui/marke/ „Stammbaum Logo.md“).
   Logo-Regeln: 1 Freiraum rundum die halbe Zeichenhöhe (30 px → 15 px), 4/5 nicht umfärben, nicht strecken (feste Größe
   181 × 30, flex: none). Zum Menü und Benutzerfeld: .topbar gap 16 px, bis 700 px 15 px in beide Richtungen. */
.topbar .ui-brand { display: inline-flex; align-items: center; gap: 15px; flex: none; white-space: nowrap; }
.topbar .ui-brand img { display: block; flex: none; width: 181px; height: 30px; }
/* UX-08: Bricht das Menü zweizeilig um, steht die Marke oben bündig mit der ersten Menüzeile (statt mittig dazwischen);
   Abstand = (Höhe eines Menüpunkts 47 px − Logo 30 px) / 2. */
@media (min-width: 701px) { .topbar .ui-brand { align-self: flex-start; margin-top: 8.5px; } }
.topbar .ui-brand .ui-brand-test { background: var(--amber); color: var(--text); font-size: var(--fs-xs); font-weight: bold;
  border-radius: 3px; padding: 1px 5px; letter-spacing: .5px; }
/* Anmeldeseite: Hauptlogo (mit Zeile) über „Anmelden“; im Bild sind 7 px Rand enthalten, dazu 18 px = Freiraum 25 px
   (halbe Zeichenhöhe von 50 px). Schmal: verkleinert mit Seitenverhältnis (nie gestreckt), Zeichenhöhe ≥ 28 px ab 177 px. */
.ui-login-brand { margin: 0 0 var(--s4); }
.ui-login-brand img { display: block; width: 316px; max-width: 100%; height: auto; margin: 18px 0; }
/* Text bündig mit der sichtbaren Logo-Kante: das Bild hat links 14 von 631,9 Einheiten Rand (Schatten) – Abstand in
   derselben Größe wie das Bild (316 px bzw. schmaler 100 %), das Logo selbst bleibt unverändert */
.ui-login-brand small { display: block; color: var(--muted); padding-left: calc(min(316px, 100%) * 14 / 631.9); }
.ui-login-brand .ui-brand-test { background: var(--amber); color: var(--text); font-size: var(--fs-xs); font-weight: bold;
  border-radius: 3px; padding: 1px 5px; vertical-align: middle; }

/* ---------- UI-R3. Rückfrage bei Enter (Rückmeldung 23.10.2026) ------- */
/* Natives <dialog> (showModal, oberste Ebene – liegt auch über #modal/#modal2), Aufbau wie .ui-dialog (Kopf/Rumpf/Fuß).
   Vorlage ui.enter_confirm_template(), Skript static/js/enter-rueckfrage.js. */
dialog.ui-confirm { padding: 0; border: 0; border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-dialog); width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 64px); overflow: hidden; }
dialog.ui-confirm[open] { display: flex; flex-direction: column; }
dialog.ui-confirm::backdrop { background: color-mix(in srgb, var(--navy-dark) 45%, transparent); }
dialog.ui-confirm .ui-dialog-body { overflow-y: auto; }
dialog.ui-confirm .ui-dialog-body > p { margin: 0; }
/* Tabelle der Änderungen: Feld · vorher (grau, durchgestrichen) · jetzt (fett) – Optik wie ui.diff */
table.ui-changes { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
table.ui-changes th, table.ui-changes td { text-align: left; vertical-align: top; padding: 4px 8px; border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere; }
table.ui-changes thead th { font-size: var(--fs-sm); font-weight: normal; color: var(--muted); }
table.ui-changes tbody th { font-weight: normal; color: var(--muted); width: 34%; }
table.ui-changes .ui-changes-old { color: var(--muted); text-decoration: line-through; }
table.ui-changes .ui-changes-old.is-leer { text-decoration: none; }  /* leer „–“ nur blass (UX-10) */
table.ui-changes .ui-changes-new { font-weight: bold; color: var(--text); }
.ui-changes-more { justify-self: start; }
.ui-changes-more[hidden] { display: none; }  /* .btn setzt display und würde hidden sonst aufheben */
/* „Keine Änderungen – nichts gespeichert.“ unter dem Feld (3 s, role=status) */
.ui-hint.ui-rueckfrage-keine { display: block; font-size: var(--fs-xs); color: var(--info); }
