/* ==========================================================================
   BCS — Business Communication System
   Ein Farbton, ein Raster, eine Typografie. Keine Verläufe, keine Schatten
   ausser bei schwebenden Elementen, keine Animation ohne Funktion.
   ========================================================================== */

:root {
  /* Flächen */
  --bg:            #f6f7f8;
  --surface:       #ffffff;
  --surface-2:     #fafbfc;
  --surface-3:     #f1f3f5;
  --sidebar:       #f8f9fa;

  /* Linien */
  --line:          #e3e6e9;
  --line-strong:   #d2d7dc;

  /* Text */
  --text:          #16191d;
  --text-2:        #4d545c;
  --text-3:        #767d86;
  --text-inv:      #ffffff;

  /* Akzent — ein einziges gedämpftes Blau */
  --accent:        #2c5c86;
  --accent-hover:  #244c6f;
  --accent-soft:   #eaeff4;
  --accent-line:   #b9cbdb;

  /* Statusfarben — entsättigt, nie leuchtend */
  --tone-blue:     #2c5c86;   --tone-blue-bg:   #e9eff5;
  --tone-amber:    #8a6014;   --tone-amber-bg:  #f6f0e2;
  --tone-green:    #2f6a45;   --tone-green-bg:  #e8f0eb;
  --tone-red:      #94382f;   --tone-red-bg:    #f6eae9;
  --tone-violet:   #5a4a86;   --tone-violet-bg: #eeecf5;
  --tone-muted:    #6b727a;   --tone-muted-bg:  #eef0f2;

  /* Metrik */
  --r:             4px;
  --r-lg:          6px;
  --h-top:         60px;
  --w-nav:         232px;
  --w-list:        400px;
  --shadow-pop:    0 4px 16px rgba(16, 21, 26, .12), 0 0 0 1px rgba(16, 21, 26, .06);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  --bg:            #14171a;
  --surface:       #1b1f23;
  --surface-2:     #202529;
  --surface-3:     #262c31;
  --sidebar:       #171b1e;
  --line:          #2b3136;
  --line-strong:   #3a4147;
  --text:          #e7eaed;
  --text-2:        #a8b0b8;
  --text-3:        #79828b;
  --accent:        #6b9dc9;
  --accent-hover:  #83b0d8;
  --accent-soft:   #1e2933;
  --accent-line:   #34495c;
  --tone-blue:     #7aa8ce;   --tone-blue-bg:   #1c2731;
  --tone-amber:    #cba55f;   --tone-amber-bg:  #2b261a;
  --tone-green:    #74b48d;   --tone-green-bg:  #1a2721;
  --tone-red:      #cf8279;   --tone-red-bg:    #2c1f1d;
  --tone-violet:   #9b8fca;   --tone-violet-bg: #23202e;
  --tone-muted:    #8a929a;   --tone-muted-bg:  #23282c;
  --shadow-pop:    0 4px 20px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .07);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #14171a;  --surface:      #1b1f23;  --surface-2: #202529;
    --surface-3:     #262c31;  --sidebar:      #171b1e;  --line:      #2b3136;
    --line-strong:   #3a4147;  --text:         #e7eaed;  --text-2:    #a8b0b8;
    --text-3:        #79828b;  --accent:       #6b9dc9;  --accent-hover: #83b0d8;
    --accent-soft:   #1e2933;  --accent-line:  #34495c;
    --tone-blue:     #7aa8ce;  --tone-blue-bg:   #1c2731;
    --tone-amber:    #cba55f;  --tone-amber-bg:  #2b261a;
    --tone-green:    #74b48d;  --tone-green-bg:  #1a2721;
    --tone-red:      #cf8279;  --tone-red-bg:    #2c1f1d;
    --tone-violet:   #9b8fca;  --tone-violet-bg: #23202e;
    --tone-muted:    #8a929a;  --tone-muted-bg:  #23282c;
    --shadow-pop:    0 4px 20px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.07);
  }
}

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 17px; }
h2 { font-size: 14px; }
h3 { font-size: 13px; }

p { margin: 0 0 10px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

::selection { background: var(--accent-soft); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: 2px;
}

/* Schlanke, unaufdringliche Scrollbalken */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border: 3px solid transparent;
  background-clip: content-box; border-radius: 6px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------------ Gerüst */
.app { display: grid; grid-template-rows: var(--h-top) 1fr; height: 100vh; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 40;
}

.brandmark {
  display: flex; align-items: center; gap: 8px;
  font-weight: 650; font-size: 13px; letter-spacing: .02em;
  color: var(--text); white-space: nowrap;
  padding-right: 12px; margin-right: 2px;
  border-right: 1px solid var(--line);
  height: 48px;
}
.brandmark .mark {
  width: 20px; height: 20px; border-radius: 3px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: 0;
}
.brandmark:hover { text-decoration: none; }

/* Systemlogo. Die Vorlage ist dunkle Zeichnung auf Durchsichtigem; im dunklen
   Erscheinungsbild wird sie umgekehrt, damit sie weiß erscheint. */
.brandmark.has-logo { padding-right: 14px; }
.brandlogo { height: 42px; width: auto; max-width: 260px; display: block; }
/* Logohöhe und Leistenhöhe gehören zusammen: die Leiste ist 60px (--h-top),
   das Logo 42px, bleiben oben und unten je 9px Luft. Wer das Logo weiter
   vergrößert, muss --h-top mitziehen — sonst klebt es an der Trennlinie.
   Alles andere in der Leiste ist mittig ausgerichtet und wächst mit. */
[data-theme="dark"] .brandlogo,
[data-theme="dark"] .auth-logo,
[data-theme="dark"] .logo-preview img { filter: invert(1) brightness(1.9); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brandlogo,
  :root:not([data-theme="light"]) .auth-logo,
  :root:not([data-theme="light"]) .logo-preview img { filter: invert(1) brightness(1.9); }
}

.auth-logo { max-width: 220px; max-height: 54px; width: auto; height: auto;
  display: block; margin: 0 auto 18px; }

.logo-preview { border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface-2); padding: 12px 14px; display: inline-flex;
  align-items: center; justify-content: center; min-width: 200px; min-height: 62px; }
.logo-preview img { max-width: 240px; max-height: 54px; width: auto; height: auto; display: block; }
.logo-preview.empty { color: var(--text-3); font-size: 12px; }

.topbar .spacer { flex: 1; }

.search-wrap { position: relative; width: 100%; max-width: 460px; }
.search-wrap input {
  width: 100%; height: 28px;
  padding: 0 10px 0 28px;
  font-size: 12.5px;
  background: var(--surface-3);
  border: 1px solid transparent;
  border-radius: var(--r);
  color: var(--text);
}
.search-wrap input:focus { background: var(--surface); border-color: var(--accent-line); outline: none; }
.search-wrap .ico { position: absolute; left: 8px; top: 6px; color: var(--text-3); pointer-events: none; }
.search-wrap kbd {
  position: absolute; right: 7px; top: 6px;
  font: 500 10px var(--font); color: var(--text-3);
  border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; background: var(--surface);
}
.search-wrap input:focus ~ kbd { display: none; }

.quick-results {
  position: absolute; top: 32px; left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  max-height: 400px; overflow: auto; z-index: 60; padding: 4px;
}
.quick-results a {
  display: flex; align-items: baseline; gap: 8px;
  padding: 6px 8px; border-radius: var(--r); color: var(--text);
}
.quick-results a:hover, .quick-results a.sel { background: var(--surface-3); text-decoration: none; }
.quick-results .t { font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-3); min-width: 52px; }
.quick-results .l { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-results .s { color: var(--text-3); font-size: 11.5px; }

.body { display: flex; min-height: 0; overflow: hidden; }

.nav {
  width: var(--w-nav); flex: 0 0 var(--w-nav);
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 12px 10px 20px;
  display: flex; flex-direction: column;
}

/* Gruppen tragen die Ordnung. Ohne Überschriften wäre die Leiste eine Liste
   von zwanzig Wörtern, in der man liest statt sieht. */
.nav-group { margin-bottom: 4px; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-title {
  font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-3); padding: 0 9px 6px;
}

.nav a {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 9px; margin-bottom: 1px;
  border-radius: 5px;
  font-size: 13px; line-height: 1.4;
  color: var(--text-2); text-decoration: none;
  white-space: nowrap;
}
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }

/* Der aktive Punkt ist der einzige mit Fläche — damit sticht er heraus, ohne
   dass die halbe Leiste bunt wird. */
.nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav a .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav a .dot { width: 6px; height: 6px; border-radius: 2px; flex: none; }

/* Zahlen sind **Auskunft, kein Alarm**.
   Der erste Entwurf gab jeder Zahl einen gefüllten blauen Kreis — zehn davon
   untereinander, und die Leiste sah aus wie ein Weihnachtsbaum. Wenn alles
   ruft, hört man nichts. Also: schlicht und grau, in derselben Zeile mitlaufend.
   Farbe bekommt genau **eine** Stelle — der Arbeitskorb, denn dort steht, was
   ohne einen Menschen nicht weitergeht. */
.nav a .n {
  flex: none;
  font-size: 11px; font-weight: 550;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  padding: 0 1px;
}
.nav a:hover .n { color: var(--text-2); }
.nav a.active .n { color: var(--accent); font-weight: 650; }

/* Die eine Ausnahme. */
.nav a[data-alarm] .n {
  color: var(--text-inv); background: var(--tone-amber);
  border-radius: 9px; padding: 1px 6px; font-weight: 650;
}
.nav a[data-alarm].active .n { background: var(--accent); color: var(--text-inv); }

/* Unterpunkte: eingerückt, mit Führungslinie — man sieht, wozu sie gehören. */
.nav-sub {
  margin: 2px 0 6px 9px;
  padding-left: 10px;
  border-left: 1px solid var(--line-strong);
}
.nav-sub a { font-size: 12.5px; padding: 5px 8px; }

/* Verwaltung am Fuß: da, aber leise. */
.nav-admin { margin-top: auto; padding-top: 14px; }
.nav-admin > summary {
  list-style: none; cursor: pointer;
  font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-3); padding: 6px 9px;
  border-top: 1px solid var(--line);
}
.nav-admin > summary::-webkit-details-marker { display: none; }
.nav-admin > summary::after { content: ' ▾'; opacity: .5; }
.nav-admin[open] > summary::after { content: ' ▴'; }
.nav-admin > summary:hover { color: var(--text-2); }

/* „Hier liegt Arbeit" — abgesetzt von den Ordnerzählern daneben, die nur
   Bestand zeigen. Eine Null wird gar nicht erst ausgegeben. */
.nav a .n.todo {
  min-width: 18px; text-align: center; padding: 1px 6px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 10.5px;
}
.nav a.active .n.todo { background: var(--surface); }
.nav a .dot { width: 7px; height: 7px; border-radius: 2px; flex: 0 0 7px; }
.nav a .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

.page { flex: 1; overflow-y: auto; overflow-x: auto; padding: 18px 22px 40px; }
.page.tight { padding: 0; }

/* Umbruch statt Abschneiden: die Knöpfe rechts müssen auch in einem schmalen
   Fenster erreichbar bleiben, notfalls in einer zweiten Zeile. */
.pagehead {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding-bottom: 14px; margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.pagehead h1 { flex: none; }
.pagehead .sub { color: var(--text-3); font-size: 12px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pagehead .btn { flex: none; }
.pagehead .spacer { flex: 1 1 0; min-width: 0; }

/* ---------------------------------------------------------------- Elemente */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.card > header {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 13px; border-bottom: 1px solid var(--line);
  font-weight: 600; font-size: 12.5px;
}
.card > header .spacer { flex: 1; }
.card-body { padding: 13px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.c6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid.main-side { grid-template-columns: minmax(0, 1fr) 320px; }

/* Rasterkinder dürfen schmaler werden als ihr Inhalt. Ohne das schiebt eine
   breite Tabelle die eigene Spalte auf und legt sich über die Nachbarspalte —
   genau so überlappte das Dashboard in der Mitte. */
.grid > * { min-width: 0; }

/* Und der Inhalt, der trotzdem breiter ist, rollt in seiner Karte statt die
   Seite aufzuziehen. Betrifft die Tabellen: die stehen immer in „flush". */
.card-body.flush { overflow-x: auto; }

.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 11px 13px; display: block; color: inherit;
}
.stat:hover { border-color: var(--line-strong); text-decoration: none; }
.stat .k { font-size: 11.5px; color: var(--text-3); margin-bottom: 3px; }
.stat .v { font-size: 21px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .v.warn { color: var(--tone-red); }

/* Dieselbe Kennzahlenoptik innerhalb einer Karte — dort trägt die Karte schon
   Rahmen und Fläche, deshalb nur Beschriftung und Zahl. */
.kpi-label { font-size: 11.5px; color: var(--text-3); margin-bottom: 3px; }
.kpi-value { font-size: 21px; font-weight: 600; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; }

/* Rechenfeld im Ausgabenformular */
.calc-box { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface-2); padding: 8px 10px; font-size: 12.5px; }
.calc-box > div { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.calc-box > div span { color: var(--text-3); }
.calc-box > div strong { font-variant-numeric: tabular-nums; }
.calc-box > div:last-child { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 5px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 28px; padding: 0 11px;
  font: 500 12.5px var(--font); color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r); cursor: pointer; white-space: nowrap;
  transition: background .1s, border-color .1s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { background: var(--line); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.quiet:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--tone-red); border-color: var(--line-strong); }
.btn.danger:hover { background: var(--tone-red-bg); }
.btn.sm { height: 24px; padding: 0 8px; font-size: 12px; }
.btn.block { width: 100%; }

.btn-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Formulare */
label { display: block; font-size: 12px; font-weight: 550; color: var(--text-2); margin-bottom: 4px; }
.field { margin-bottom: 13px; }
.field .hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=search], input[type=url],
input[type=tel], select, textarea {
  width: 100%; padding: 5px 8px; min-height: 28px;
  font: 13px var(--font); color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r);
}
textarea { min-height: 80px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft);
}
input[type=color] { padding: 2px; height: 28px; width: 44px; min-height: 0; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); margin: 0; }
select { appearance: none; padding-right: 24px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
                    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 13px) 12px, calc(100% - 9px) 12px;
  background-size: 4px 4px, 4px 4px; background-repeat: no-repeat; }

.check { display: flex; align-items: center; gap: 7px; font-size: 12.5px;
  color: var(--text); font-weight: 400; margin-bottom: 0; }
.check input { flex: none; }

fieldset { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 13px; margin: 0 0 14px; }
legend { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); padding: 0 5px; }

.checklist { max-height: 220px; overflow-y: auto; border: 1px solid var(--line);
  border-radius: var(--r); padding: 6px; background: var(--surface-2); }
.checklist label { display: flex; align-items: center; gap: 7px; padding: 3px 5px;
  font-weight: 400; font-size: 12.5px; color: var(--text); margin: 0; border-radius: 3px; }
.checklist label:hover { background: var(--surface-3); }

/* Tabellen */
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tbl th {
  text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-3);
  padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
  background: var(--surface-2); position: sticky; top: 0; z-index: 1;
}
table.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--surface-2); }
/* Zahlenspalten: Kopf und Wert müssen auf derselben Kante stehen. Die Regel
   galt nur für td — dadurch klebte jeder Spaltenkopf links, während die Beträge
   rechts standen. */
table.tbl th.num, table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.nowrap, table.tbl th.nowrap { white-space: nowrap; }
table.tbl .muted { color: var(--text-3); }

/* Marken / Status / Prioritäten */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 18px; padding: 0 6px; border-radius: 3px;
  font-size: 11px; font-weight: 550; letter-spacing: .01em; white-space: nowrap;
  background: var(--tone-muted-bg); color: var(--tone-muted);
}
.badge.blue   { background: var(--tone-blue-bg);   color: var(--tone-blue); }
.badge.amber  { background: var(--tone-amber-bg);  color: var(--tone-amber); }
.badge.green  { background: var(--tone-green-bg);  color: var(--tone-green); }
.badge.red    { background: var(--tone-red-bg);    color: var(--tone-red); }
.badge.violet { background: var(--tone-violet-bg); color: var(--tone-violet); }
.badge.outline { background: transparent; border: 1px solid var(--line-strong); color: var(--text-2); }

.tag { display: inline-flex; align-items: center; gap: 4px; height: 18px; padding: 0 6px 0 5px;
  border-radius: 3px; font-size: 11px; background: var(--surface-3); color: var(--text-2); }
.tag .sw { width: 6px; height: 6px; border-radius: 2px; }

.prio { display: inline-block; width: 3px; height: 14px; border-radius: 2px; background: var(--line-strong); }
.prio.p3 { background: var(--tone-amber); }
.prio.p4 { background: var(--tone-red); }

.avatar {
  width: 22px; height: 22px; flex: none; border-radius: 3px;
  display: grid; place-items: center;
  font-size: 9.5px; font-weight: 650; letter-spacing: .02em;
  color: #fff; background: var(--tone-muted);
}
.avatar.lg { width: 30px; height: 30px; font-size: 11.5px; border-radius: 4px; }

.muted { color: var(--text-3); }
.small { font-size: 11.5px; }
.mono  { font-family: var(--mono); font-size: 11.5px; }
.nowrap{ white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabnum { font-variant-numeric: tabular-nums; }

.empty { padding: 44px 20px; text-align: center; color: var(--text-3); }
.empty strong { display: block; color: var(--text-2); font-size: 13px; margin-bottom: 4px; font-weight: 550; }

/* Hinweise */
.flash-stack { position: fixed; top: 58px; right: 18px; z-index: 200; display: flex;
  flex-direction: column; gap: 8px; max-width: 400px; }
.flash {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 9px 12px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-pop); font-size: 12.5px;
}
.flash.success { border-left: 3px solid var(--tone-green); }
.flash.error   { border-left: 3px solid var(--tone-red); }
.flash.info    { border-left: 3px solid var(--accent); }
.flash .x { margin-left: auto; cursor: pointer; color: var(--text-3); background: none; border: 0; }

.notice { padding: 9px 12px; border-radius: var(--r); font-size: 12.5px;
  background: var(--surface-3); border-left: 3px solid var(--line-strong); margin-bottom: 14px; }
.notice.warn { background: var(--tone-amber-bg); border-left-color: var(--tone-amber); color: var(--tone-amber); }
.notice.error{ background: var(--tone-red-bg);   border-left-color: var(--tone-red);   color: var(--tone-red); }
.notice.info { background: var(--accent-soft);   border-left-color: var(--accent); }
.notice.ok   { background: var(--tone-green-bg); border-left-color: var(--tone-green); color: var(--tone-green); }

/* Menüs */
.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 4px); right: 0; min-width: 180px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  padding: 4px; z-index: 100; display: none;
}
.menu.open { display: block; }
.menu.left { right: auto; left: 0; }
.menu a, .menu button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 5px 9px; border-radius: var(--r); border: 0; background: none;
  font: 12.5px var(--font); color: var(--text); text-align: left; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--surface-3); text-decoration: none; }
.menu .sep { height: 1px; background: var(--line); margin: 4px 0; }
.menu .head { padding: 5px 9px 3px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-3); font-weight: 600; }

/* Segmentierte Filter */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r);
  overflow: hidden; background: var(--surface); }
.seg a, .seg button {
  padding: 4px 10px; font-size: 12px; color: var(--text-2); border: 0;
  border-right: 1px solid var(--line); background: none; cursor: pointer; font-family: var(--font);
}
.seg a:last-child, .seg button:last-child { border-right: 0; }
.seg a:hover, .seg button:hover { background: var(--surface-3); text-decoration: none; }
.seg a.active, .seg button.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }

.filters { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters select, .filters input { height: 28px; width: auto; min-width: 120px; font-size: 12.5px; }

.pager { display: flex; gap: 5px; align-items: center; justify-content: center;
  padding: 14px 0 4px; color: var(--text-3); font-size: 12px; }
.pager a { padding: 3px 9px; border: 1px solid var(--line-strong); border-radius: var(--r); color: var(--text-2); }
.pager a:hover { background: var(--surface-3); text-decoration: none; }

/* ===================================================== E-Mail: Drei-Spalten */
.mail-layout { display: flex; min-width: 0; flex: 1; overflow: hidden; }

.mail-list {
  width: var(--w-list); flex: 0 0 var(--w-list);
  border-right: 1px solid var(--line);
  background: var(--surface); display: flex; flex-direction: column; min-height: 0;
}
.mail-list-head {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 11px; border-bottom: 1px solid var(--line); min-height: 40px;
  background: var(--surface);
}
.mail-list-head .title { font-weight: 600; font-size: 12.5px; }
.mail-list-head .spacer { flex: 1; }
.mail-list-scroll { overflow-y: auto; flex: 1; }

.mail-row {
  display: block; padding: 9px 11px 9px 9px;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
  padding-left: 8px;
  color: var(--text); cursor: pointer;
}
/* Was gelesen und erledigt ist, tritt zurück — sonst konkurriert alles um
   dieselbe Aufmerksamkeit und am Ende sticht nichts mehr heraus. */
.mail-row:not(.unread) .r1 .from { color: var(--text-2); }
.mail-row:hover { background: var(--surface-2); text-decoration: none; }
.mail-row.active { background: var(--accent-soft); border-left-color: var(--accent); }
/* Ungelesen muss man **sehen**, nicht suchen.
   Vorher unterschied sich eine ungelesene Zeile nur durch einen Hauch
   Schriftstärke — bei zwei Nachrichten desselben Absenders war damit nicht
   erkennbar, welche die neue ist. Jetzt tragen drei Dinge zusammen: ein
   farbiger Balken am Rand, kräftige Schrift und das Wort „neu". Farbe allein
   genügt nicht — wer sie nicht unterscheiden kann, sieht sonst gar nichts. */
.mail-row.unread {
  /* **Nicht `--surface`** — das ist die Farbe der Liste selbst, der Zustand war
     damit optisch nicht vorhanden. `--accent-soft` ist in beiden Erscheinungs-
     bildern definiert und hebt die Zeile ab, ohne zu schreien. */
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding-left: 8px;   /* die zwei zusätzlichen Pixel des Balkens ausgleichen */
}
.mail-row.unread .r1 .from { font-weight: 700; color: var(--text); }
.mail-row.unread .subj { font-weight: 650; color: var(--text); }
.mail-row.unread .r1 .time { color: var(--accent); font-weight: 600; }

.mail-row .r1 .neu {
  flex: none;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-inv);
  background: var(--accent);
  border-radius: 8px;
  padding: 1px 6px 2px;
  line-height: 1.4;
}
.mail-row .r1 .cnt {
  flex: none;
  font-size: 10px;
  color: var(--text-3);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 5px;
  line-height: 1.5;
}
.mail-row .r1 { display: flex; align-items: center; gap: 7px; margin-bottom: 2px; }
.mail-row .r1 .from { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 12.5px; }
.mail-row .r1 .time { font-size: 11px; color: var(--text-3); white-space: nowrap;
  margin-left: auto;
  font-variant-numeric: tabular-nums; }
.mail-row .subj { font-size: 12.5px; color: var(--text-2); margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row .snip { font-size: 11.5px; color: var(--text-3); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mail-row .r3 { display: flex; align-items: center; gap: 5px; margin-top: 5px; flex-wrap: wrap; }
.mail-row .dot { width: 6px; height: 6px; border-radius: 2px; flex: none; }
.mail-row .cb { flex: none; }

.mail-reader { flex: 1; min-width: 0; display: flex; flex-direction: column;
  background: var(--surface); overflow: hidden; }
.reader-head { padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.reader-head h1 { font-size: 15px; line-height: 1.35; margin-bottom: 7px; }
.reader-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-3); }
.reader-actions { display: flex; align-items: center; gap: 6px; padding: 7px 18px;
  border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.reader-body { flex: 1; overflow-y: auto; padding: 0 18px 40px; }

.lockbar {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 18px; font-size: 12.5px;
  background: var(--tone-amber-bg); color: var(--tone-amber);
  border-bottom: 1px solid var(--line);
}
.lockbar.mine { background: var(--tone-green-bg); color: var(--tone-green); }
.lockbar .spacer { flex: 1; }
.lockbar .btn { height: 22px; font-size: 11.5px; background: transparent;
  border-color: currentColor; color: inherit; }

.msg { border-bottom: 1px solid var(--line); padding: 14px 0; }
.msg:last-child { border-bottom: 0; }
.msg-head { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 9px; }
.msg-head .who { flex: 1; min-width: 0; }
.msg-head .name { font-weight: 600; font-size: 12.5px; }
.msg-head .addr { color: var(--text-3); font-size: 11.5px; }
.msg-head .time { color: var(--text-3); font-size: 11.5px; white-space: nowrap; }
.msg.out .msg-head .name::after {
  content: "Gesendet"; margin-left: 7px; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--tone-green);
  background: var(--tone-green-bg); padding: 1px 5px; border-radius: 3px;
}
.msg.failed { background: var(--tone-red-bg); border-radius: var(--r); padding-left: 10px; padding-right: 10px; }
/* Der Nachrichtentext liegt wie ein Blatt Papier im Verlauf — im dunklen
   Erscheinungsbild mit feinem Rahmen, damit die weiße Fläche gewollt wirkt. */
.msg-frame { width: 100%; min-height: 40px; border: 0; display: block;
  background: #fff; border-radius: var(--r); overflow: hidden; }
[data-theme="dark"] .msg-frame { border: 1px solid var(--line); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .msg-frame { border: 1px solid var(--line); }
}

/* Lesegröße im Nachrichtentext */
.text-size { display: inline-flex; align-items: center; gap: 1px;
  border: 1px solid var(--line); border-radius: var(--r); padding: 1px; }
.text-size .btn { padding: 0 7px; height: 20px; font-variant-numeric: tabular-nums; }
.text-size .btn.active { background: var(--accent-soft); color: var(--accent); }
.msg-atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.att {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 9px; border: 1px solid var(--line-strong); border-radius: var(--r);
  font-size: 12px; color: var(--text-2); background: var(--surface-2); max-width: 260px;
}
.att:hover { background: var(--surface-3); text-decoration: none; }
.att .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .sz { color: var(--text-3); font-size: 11px; white-space: nowrap; }

/* Antwortbereich */
.composer { border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  margin: 14px 0 24px; background: var(--surface); }
.composer-head { display: flex; gap: 7px; align-items: center; padding: 8px 11px;
  border-bottom: 1px solid var(--line); font-weight: 600; font-size: 12.5px; }
.composer-fields { padding: 9px 11px; border-bottom: 1px solid var(--line); display: grid; gap: 7px; }
.composer-fields .row { display: flex; align-items: center; gap: 8px; }
.composer-fields .row label { width: 54px; margin: 0; flex: none; font-size: 11.5px; }
.editor { min-height: 180px; padding: 11px; font-size: 13px; line-height: 1.6; outline: none;
  overflow-y: auto; max-height: 460px; }
.editor:empty::before { content: attr(data-placeholder); color: var(--text-3); }
.composer-foot { display: flex; align-items: center; gap: 8px; padding: 9px 11px;
  border-top: 1px solid var(--line); background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg); flex-wrap: wrap; }
.composer-foot .spacer { flex: 1; }
.att-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 11px 9px; }
.att-chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 7px;
  background: var(--surface-3); border-radius: var(--r); font-size: 11.5px; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--text-3); padding: 0; }

/* Interne Kommunikation */
.internal { background: var(--tone-amber-bg); border: 1px solid var(--line);
  border-left: 3px solid var(--tone-amber); border-radius: var(--r-lg); margin: 16px 0; }
.internal > header { display: flex; align-items: center; gap: 7px; padding: 8px 12px;
  border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .05em; color: var(--tone-amber); }
.internal > header .spacer { flex: 1; }
.internal .list { padding: 4px 12px; }
.comment { display: flex; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: 0; }
.comment .c { flex: 1; min-width: 0; }
.comment .meta { display: flex; align-items: baseline; gap: 7px; margin-bottom: 2px; }
.comment .meta .nm { font-weight: 600; font-size: 12.5px; }
.comment .meta .tm { font-size: 11px; color: var(--text-3); }
.comment .txt { font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.comment .del { margin-left: auto; opacity: 0; border: 0; background: none;
  cursor: pointer; color: var(--text-3); font-size: 11px; }
.comment:hover .del { opacity: 1; }
.comment-form { padding: 9px 12px; border-top: 1px solid var(--line); }
.comment-form textarea { min-height: 54px; background: var(--surface); font-size: 12.5px; }

/* Kontextspalte */
.context {
  width: 300px; flex: 0 0 300px; border-left: 1px solid var(--line);
  background: var(--surface-2); overflow-y: auto; padding: 0 0 40px;
}
.ctx-block { border-bottom: 1px solid var(--line); padding: 12px 14px; }
.ctx-block > h3 { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); margin-bottom: 9px; display: flex; align-items: center; gap: 6px; }
.ctx-block > h3 .spacer { flex: 1; }
.kv { display: grid; grid-template-columns: 88px 1fr; gap: 3px 10px; font-size: 12px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.ctx-list { display: flex; flex-direction: column; gap: 7px; }
.ctx-item { font-size: 12px; line-height: 1.45; }
.ctx-item .t { color: var(--text); display: block; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.ctx-item .m { color: var(--text-3); font-size: 11px; }

/* Aufgabenliste kompakt */
.task-line { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0;
  border-bottom: 1px solid var(--line); font-size: 12.5px; }
.task-line:last-child { border-bottom: 0; }
.task-line .t { flex: 1; min-width: 0; }
.task-line .t .ttl { display: block; }
.task-line.done .ttl { text-decoration: line-through; color: var(--text-3); }
.task-line .m { font-size: 11px; color: var(--text-3); }
.task-line .due.over { color: var(--tone-red); font-weight: 550; }

/* KI-Bereich */
.ai-panel { border: 1px solid var(--accent-line); background: var(--accent-soft);
  border-radius: var(--r-lg); padding: 12px; margin: 14px 0; }
.ai-panel h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--accent); margin-bottom: 9px; }
.ai-out { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 11px; font-size: 12.5px; line-height: 1.6; white-space: pre-wrap;
  max-height: 380px; overflow-y: auto; margin-top: 9px; }

/* Aktivitätsprotokoll */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--line);
  font-size: 12.5px; align-items: flex-start; }
.feed-item:last-child { border-bottom: 0; }
.feed-item .c { flex: 1; min-width: 0; }
.feed-item .tm { color: var(--text-3); font-size: 11px; white-space: nowrap; }
.feed-item .act { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-3); }

/* Kalender */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.cal .dow { padding: 7px 9px; font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-3); background: var(--surface-2);
  border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
.cal .dow:nth-child(7n) { border-right: 0; }
.cal .day { min-height: 108px; padding: 6px; border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line); }
.cal .day:nth-child(7n) { border-right: 0; }
.cal .day.out { background: var(--surface-2); }
.cal .day.today .num { background: var(--accent); color: #fff; }
.cal .num { display: inline-grid; place-items: center; width: 19px; height: 19px;
  border-radius: 3px; font-size: 11.5px; font-weight: 600; margin-bottom: 4px;
  color: var(--text-2); font-variant-numeric: tabular-nums; }
.cal .ev { display: block; font-size: 11px; line-height: 1.35; padding: 2px 4px;
  border-radius: 3px; margin-bottom: 2px; background: var(--surface-3); color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-left: 2px solid var(--line-strong); }
.cal .ev:hover { text-decoration: none; background: var(--line); }
.cal .ev.task { border-left-color: var(--accent); }
.cal .ev.snooze { border-left-color: var(--tone-violet); }
.cal .ev.done { opacity: .5; text-decoration: line-through; }

/* Sparkline */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 40px; }
.spark i { flex: 1; background: var(--accent-line); border-radius: 1px 1px 0 0; min-height: 2px; display: block; }
.spark i.hi { background: var(--accent); }

/* Anmeldung */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: var(--bg); }
.auth-card { width: 100%; max-width: 348px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 26px; }
.auth-card .brandmark { border: 0; justify-content: center; margin-bottom: 4px; padding: 0; height: auto; }
.auth-card h1 { text-align: center; font-size: 15px; margin-bottom: 3px; }
.auth-card .sub { text-align: center; color: var(--text-3); font-size: 12px; margin-bottom: 20px; }
.auth-foot { text-align: center; color: var(--text-3); font-size: 11px; margin-top: 18px; }

/* Installer */
.setup-wrap { max-width: 620px; margin: 40px auto; padding: 0 20px 60px; }
.step-list { counter-reset: s; margin: 0 0 20px; padding: 0; list-style: none; }
.step-list li { counter-increment: s; position: relative; padding: 0 0 12px 26px;
  font-size: 12.5px; color: var(--text-2); }
.step-list li::before { content: counter(s); position: absolute; left: 0; top: 1px;
  width: 17px; height: 17px; border-radius: 3px; background: var(--surface-3);
  color: var(--text-2); display: grid; place-items: center; font-size: 10px; font-weight: 700; }
.step-list li.ok::before { content: "✓"; background: var(--tone-green-bg); color: var(--tone-green); }
.step-list li.bad::before { content: "!"; background: var(--tone-red-bg); color: var(--tone-red); }

/* Tastaturhilfe */
.kbd-help { position: fixed; inset: 0; background: rgba(10, 13, 16, .5); z-index: 300;
  display: none; place-items: center; padding: 24px; }
.kbd-help.open { display: grid; }
.kbd-help .panel { background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: var(--shadow-pop); width: 100%; max-width: 460px; padding: 18px; }
.kbd-help dl { display: grid; grid-template-columns: 84px 1fr; gap: 7px 12px;
  font-size: 12.5px; margin: 14px 0 0; }
.kbd-help dt { text-align: right; }
.kbd-help dd { margin: 0; color: var(--text-2); }
kbd { display: inline-block; padding: 1px 5px; font: 500 11px var(--mono);
  border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 3px; background: var(--surface-2); color: var(--text-2); }

/* ================================================ Interne Kommunikation */
.presence { width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--line-strong); display: inline-block; }
.presence.on   { background: var(--tone-green); }
.presence.idle { background: var(--tone-amber); }
.presence.off  { background: var(--line-strong); }

.chat-stream {
  flex: 1; overflow-y: auto; padding: 14px 18px 20px;
  display: flex; flex-direction: column; gap: 2px;
}

.chat-daysep { display: flex; align-items: center; gap: 10px; margin: 14px 0 8px; }
.chat-daysep::before, .chat-daysep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.chat-daysep span { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.chat-system {
  align-self: center; margin: 6px 0;
  font-size: 11.5px; color: var(--text-3);
  background: var(--surface-3); border-radius: 10px; padding: 3px 10px;
}

.chat-msg { display: flex; gap: 9px; padding: 4px 0; align-items: flex-start; }
.chat-msg .c { flex: 1; min-width: 0; }
.chat-msg .meta { display: flex; align-items: baseline; gap: 7px; margin-bottom: 1px; }
.chat-msg .meta .nm { font-weight: 600; font-size: 12.5px; }
.chat-msg .meta .tm { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.chat-msg .txt {
  font-size: 13px; line-height: 1.55; word-break: break-word;
  background: var(--surface-3); border-radius: var(--r-lg);
  padding: 7px 10px; display: inline-block; max-width: 100%;
}
.chat-msg.mine .txt { background: var(--accent-soft); }
.chat-msg .txt a { text-decoration: underline; }

/* Aufeinanderfolgende Nachrichten derselben Person rücken zusammen. */
.chat-msg.cont { padding-top: 0; }
.chat-msg.cont .avatar { visibility: hidden; height: 0; }
.chat-msg.cont .meta { display: none; }

.chat-ref {
  display: flex; align-items: center; gap: 7px; margin-top: 5px;
  padding: 5px 9px; border: 1px solid var(--line-strong); border-left: 2px solid var(--accent);
  border-radius: var(--r); background: var(--surface); font-size: 12px; max-width: 420px;
}
.chat-ref:hover { background: var(--surface-3); text-decoration: none; }

.chat-composer { border-top: 1px solid var(--line); background: var(--surface); padding: 9px 18px 10px; }
.chat-input-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-input-row textarea {
  flex: 1; min-height: 34px; max-height: 190px; resize: none;
  padding: 7px 10px; line-height: 1.5; overflow-y: auto;
}
.chat-hint { margin-top: 5px; font-size: 11px; }

.chat-msg .msg-atts { margin-top: 6px; }

/* ============================================================ Lead-Pipeline */
.board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr);
  gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: start;
}
.board-col {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-lg); min-width: 0; display: flex; flex-direction: column;
}
.board-col > header {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.board-col > header .spacer { flex: 1; }
.board-drop { padding: 8px; display: flex; flex-direction: column; gap: 7px;
  min-height: 90px; max-height: calc(100vh - 260px); overflow-y: auto; }
.board-col.over { border-color: var(--accent); }
.board-col.over .board-drop { background: var(--accent-soft); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.board-empty { color: var(--text-3); font-size: 11.5px; text-align: center; padding: 10px 0; }

.lead-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 8px 9px; cursor: grab;
}
.lead-card:hover { border-color: var(--line-strong); }
.lead-card.dragging { opacity: .45; }
.lead-card .t { display: block; font-weight: 600; font-size: 12.5px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-card .t:hover { text-decoration: none; color: var(--accent); }
.lead-card .s { font-size: 11.5px; color: var(--text-2); margin-top: 2px; }
.lead-card .m { display: flex; align-items: center; gap: 6px; margin-top: 7px;
  font-size: 11px; color: var(--text-3); }
.lead-card .m .spacer { flex: 1; }
.lead-card .m .dot { width: 7px; height: 7px; border-radius: 2px; flex: none; }
.lead-card .na { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--text-2); }
.lead-card .na.due { color: var(--tone-red); font-weight: 550; }
.lead-card .na.none { color: var(--text-3); font-style: italic; }

/* Bewertung: kalt / warm / heiß */
.rating { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--line-strong); }
.rating.r1 { background: var(--tone-blue); }
.rating.r2 { background: var(--tone-amber); }
.rating.r3 { background: var(--tone-red); }

@media (max-width: 980px) {
  .board { grid-auto-columns: minmax(210px, 78vw); }
}

/* -------------------------------------------------------------- Responsive */
@media (max-width: 1400px) { :root { --w-list: 340px; } .context { width: 264px; flex-basis: 264px; } }

@media (max-width: 1180px) {
  .context { display: none; }
  .context.show { display: block; position: fixed; right: 0; top: var(--h-top); bottom: 0;
    width: 320px; z-index: 90; box-shadow: var(--shadow-pop); }
  .grid.main-side { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 980px) {
  :root { --w-nav: 0px; }
  .nav { position: fixed; left: 0; top: var(--h-top); bottom: 0; width: 236px;
    z-index: 95; transform: translateX(-100%); transition: transform .16s ease; }
  .nav.show { transform: none; box-shadow: var(--shadow-pop); }
  .nav-toggle { display: inline-flex !important; }
  .topnav { display: none; }
  .search-wrap { width: 180px; }
  .grid.c4, .grid.c6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.c3 { grid-template-columns: minmax(0, 1fr); }
  .mail-list { width: 100%; flex-basis: 100%; }
  .mail-layout.reading .mail-list { display: none; }
  .mail-layout:not(.reading) .mail-reader { display: none; }
  [data-back] { display: inline-flex !important; }
}

@media (max-width: 620px) {
  .page { padding: 14px; }
  .grid.c2, .grid.c4, .grid.c6 { grid-template-columns: minmax(0, 1fr); }
  .search-wrap { width: 130px; }
  .brandmark span:not(.mark) { display: none; }
}

.nav-toggle { display: none; }

/* Belege: Positionen, interne Notiz, Druckansicht */
.hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }

.note-internal {
  background: var(--tone-amber-bg); border: 1px solid var(--line);
  border-radius: var(--r); padding: 8px 10px; font-size: 12.5px;
}

table.items-table td { padding: 4px 5px; }
table.items-table th { padding: 6px 5px; }
table.items-table tbody tr:hover { background: transparent; }
table.items-table input, table.items-table select {
  width: 100%; height: 26px; padding: 0 6px; font-size: 12.5px;
}
table.items-table input.num { text-align: right; font-variant-numeric: tabular-nums; }
table.items-table td.pos { text-align: right; padding-right: 2px; }
table.items-table tfoot td { border-bottom: 0; padding: 3px 10px 3px 5px; }
table.items-table tfoot tr:first-child td { border-top: 1px solid var(--line); padding-top: 8px; }
.items-table .it-remove { padding: 0 6px; color: var(--text-3); }
.items-table .it-remove:hover { color: var(--tone-red); }

/* ------------------------------------------------ Geschäftsdokumente
   Aufbau in Anlehnung an DIN 5008 Form B: Briefkopf, Anschriftfeld links,
   Informationsblock rechts, Betreff, Positionen, Pflichtangaben im Fuß.
   Maße in Millimetern, damit der Ausdruck auf A4 sitzt. */
.doc-letter { max-width: 880px; }
.doc-sheet.letter { padding: 0; overflow: hidden; position: relative; }

.lt-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 24px;
  padding: 16mm 20mm 8mm;
  border-bottom: 2px solid var(--doc-accent, var(--accent));
}
.lt-logo { max-height: 22mm; max-width: 70mm; display: block; }
.lt-wordmark { font-size: 19px; font-weight: 700; letter-spacing: .01em;
  color: var(--doc-accent, var(--accent)); }
.lt-contact { text-align: right; font-size: 10.5px; line-height: 1.55; color: var(--text-2); }
.lt-contact .strong { font-weight: 650; color: var(--text); }

.lt-body { display: flex; gap: 14mm; padding: 10mm 20mm 0; align-items: flex-start; }
.lt-address { flex: 1; min-height: 40mm; }
.lt-sender { font-size: 9px; color: var(--text-3); padding-bottom: 2mm;
  border-bottom: .3mm solid var(--line); margin-bottom: 4mm; }
.lt-recipient { font-size: 12.5px; line-height: 1.6; }
.lt-recipient-vat { font-size: 10.5px; color: var(--text-2); margin-top: 2mm; }

.lt-info { width: 68mm; flex: none; }
.lt-info dl { display: grid; grid-template-columns: auto auto; gap: 1mm 5mm;
  font-size: 10.5px; margin: 0; }
.lt-info dt { color: var(--text-3); white-space: nowrap; }
.lt-info dd { margin: 0; text-align: right; }
.lt-info dd.strong { font-weight: 650; }

.lt-title { font-size: 15px; font-weight: 650; margin: 8mm 20mm 1mm; }
.lt-void-tag { color: var(--tone-red); font-weight: 500; }
.lt-subject { margin: 0 20mm 4mm; color: var(--text-2); font-size: 12.5px; }
.lt-text { margin: 0 20mm 3mm; font-size: 12px; line-height: 1.6; }
.lt-legal { color: var(--text-2); font-size: 11px; }

.lt-items { margin: 5mm 0 4mm; }
.lt-items th, .lt-items td { padding-left: 20mm; }
.lt-items th + th, .lt-items td + td { padding-left: 8px; }
.lt-items th:last-child, .lt-items td:last-child { padding-right: 20mm; }

.doc-sheet.letter .doc-sums { margin: 0 20mm 5mm auto; }

.lt-sign { width: calc(100% - 40mm); margin: 12mm 20mm 4mm; font-size: 10.5px;
  color: var(--text-3); border-collapse: collapse; }
.lt-sign td { padding-top: 12mm; border-top: .3mm solid var(--line); width: 45%; }
.lt-sign td.gap { border-top: 0; width: 10%; }

.lt-foot {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8mm;
  margin: 10mm 0 0; padding: 5mm 20mm 12mm;
  border-top: .3mm solid var(--line);
  font-size: 9px; line-height: 1.5; color: var(--text-3);
}
.lt-foot .strong { font-weight: 650; color: var(--text-2); }
.lt-foot-note { padding: 0 20mm 10mm; font-size: 9px; color: var(--text-3); }

/* ------------------------------------------------------- Team und Anwesenheit */
.team-strip { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.team-head { display: flex; align-items: center; gap: 8px;
  padding: 8px 12px 5px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-3); font-weight: 600; }
.team-head .team-count { margin-left: auto; text-transform: none; letter-spacing: 0;
  font-weight: 500; color: var(--text-3); }
.team-list { max-height: 168px; overflow-y: auto; padding-bottom: 5px; }
.team-row-form { margin: 0; }
.team-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 4px 12px; background: none; border: 0; cursor: pointer;
  font: inherit; font-size: 12.5px; color: var(--text); text-align: left;
}
.team-row:hover { background: var(--surface-3); }
.team-row.me { cursor: default; }
.team-row.me:hover { background: none; }
.team-row .nm { flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.team-row .nm .muted { margin-left: 4px; }
.team-row .presence { margin-left: auto; }

/* Verknüpfung im Verlauf: Suche und Trefferliste über dem Eingabefeld */
.link-pick { border-top: 1px solid var(--line); background: var(--surface-2);
  padding: 8px 12px; }
.link-pick input[type="search"] { width: 100%; height: 28px; font-size: 12.5px; }
.link-results { max-height: 190px; overflow-y: auto; margin-top: 6px; }
.link-results button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 5px 7px; background: none; border: 0; border-radius: var(--r);
  cursor: pointer; font: inherit; font-size: 12.5px; color: var(--text); text-align: left;
}
.link-results button:hover, .link-results button.sel { background: var(--surface-3); }
.link-results .k { flex: none; font-size: 10.5px; color: var(--text-3);
  border: 1px solid var(--line-strong); border-radius: 3px; padding: 0 4px; }
.link-results .v { flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.link-results .none { padding: 6px 7px; font-size: 12px; color: var(--text-3); }

.chip-row { padding: 6px 12px 0; }
.chip-row .chip { display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 3px; padding: 3px 5px 3px 7px; font-size: 12px; max-width: 100%; }
.chip-row .chip .k { font-size: 10.5px; opacity: .8; }
.chip-row .chip .v { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-row .chip .x { background: none; border: 0; cursor: pointer;
  color: inherit; font-size: 11px; padding: 0 2px; }

/* Leiste über der Vorschau — gehört nicht zum Dokument und wird nicht gedruckt. */
.preview-bar { position: sticky; top: 0; z-index: 50;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.preview-bar .filters { padding: 9px 14px 6px; }
@media print { .preview-bar { display: none !important; } }

/* Stornovermerk quer über das Blatt — im Ausdruck sofort erkennbar. */
.doc-void.neutral { color: var(--text-3); opacity: .12; }
.doc-void {
  position: absolute; top: 42%; left: 50%;
  transform: translate(-50%, -50%) rotate(-22deg);
  font-size: 62px; font-weight: 700; letter-spacing: .06em;
  color: var(--tone-red); opacity: .14; pointer-events: none;
  text-transform: uppercase; white-space: nowrap; z-index: 2;
}

@media print {
  .doc-letter { max-width: none; }
  .doc-sheet.letter { border: 0; }
  .lt-head { padding-top: 8mm; }
  .lt-foot { position: running(footer); }
  .doc-void { opacity: .2; }
}

@media (max-width: 760px) {
  .lt-head, .lt-body { flex-direction: column; }
  .lt-contact { text-align: left; }
  .lt-info { width: 100%; }
  .lt-foot { grid-template-columns: minmax(0, 1fr); }
}

/* Sammelauswahl von Artikeln für eine Bestellung */
.picker { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.picker-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 12px; border-bottom: 1px solid var(--line); }
.picker-head .spacer { flex: 1; }
.picker-list { max-height: 320px; overflow-y: auto; }
.picker-row {
  display: grid; grid-template-columns: 18px 1fr 130px 90px 80px;
  align-items: center; gap: 10px;
  padding: 5px 12px; font-size: 12.5px; font-weight: 400;
  border-bottom: 1px solid var(--line); margin: 0; cursor: pointer;
}
.picker-row:last-child { border-bottom: 0; }
.picker-row:hover { background: var(--surface-3); }
.picker-row input[type="checkbox"] { margin: 0; }
.picker-row .pick-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-row .pick-price { text-align: right; }
.picker-row .pick-qty { height: 24px; padding: 0 6px; font-size: 12.5px; text-align: right; }

@media (max-width: 760px) {
  .picker-row { grid-template-columns: 18px 1fr 70px; }
  .picker-row .pick-sku, .picker-row .pick-price { display: none; }
}

/* Artikelstamm: Vorschaubilder und Abschnittsüberschriften */
.sub-head { font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-3); font-weight: 600; margin: 0 0 7px; }

.thumb { width: 34px; height: 34px; border-radius: 3px; object-fit: cover;
  border: 1px solid var(--line); display: block; background: var(--surface-2); }
.empty-thumb { background: repeating-linear-gradient(45deg,
  var(--surface-2), var(--surface-2) 4px, var(--surface-3) 4px, var(--surface-3) 8px); }

.img-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.shot { width: 132px; height: 132px; object-fit: cover; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface-2); display: block; }
.shot-box { margin: 0; }
.shot-box figcaption { display: flex; align-items: center; gap: 5px; margin-top: 4px;
  min-height: 22px; }
.shot-box figcaption form { margin: 0; }

/* Druckbeleg — bewusst nüchtern, ohne Rahmen und Farbflächen. */
.doc { max-width: 820px; margin: 0 auto; padding: 24px 20px 60px; }
.doc-actions { display: flex; gap: 8px; margin-bottom: 18px; }
.doc-sheet { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 42px 46px; font-size: 12.5px; line-height: 1.55; }
.doc-head { display: flex; justify-content: space-between; gap: 30px; margin-bottom: 34px; }
.doc-sender { font-weight: 650; font-size: 14px; }
.doc-sender-sub { color: var(--text-2); margin-top: 3px; }
.doc-meta { display: grid; gap: 2px; text-align: right; min-width: 210px; }
.doc-meta div { display: flex; justify-content: space-between; gap: 14px; }
.doc-meta span { color: var(--text-3); }
.doc-address { margin-bottom: 30px; min-height: 60px; }
.doc-title { font-size: 17px; font-weight: 650; margin: 0 0 3px; }
.doc-subject { color: var(--text-2); margin-bottom: 18px; }
table.doc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-bottom: 16px; }
table.doc-table th { text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-3); padding: 6px 8px;
  border-bottom: 1px solid var(--line-strong); background: transparent; position: static; }
table.doc-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.doc-table th.num, table.doc-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.doc-sku { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.doc-desc { color: var(--text-2); font-size: 11.5px; margin-top: 2px; }
table.doc-sums { margin-left: auto; min-width: 300px; border-collapse: collapse; font-size: 12.5px; }
table.doc-sums td { padding: 4px 0 4px 20px; }
table.doc-sums td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.doc-sums tr.total td { border-top: 1px solid var(--line-strong); font-weight: 650; padding-top: 7px; }
.doc-notes { margin-top: 20px; color: var(--text-2); }

@media print {
  .topbar, .nav, .context, .reader-actions, .composer, .internal { display: none !important; }
  .page, .reader-body { overflow: visible; }
  body { background: #fff; }
  .doc-actions { display: none !important; }
  .doc { max-width: none; padding: 0; }
  .doc-sheet { border: 0; border-radius: 0; padding: 0; background: #fff; }
}

/* --- Auslastung des Teams: wer trägt gerade wie viel ------------------- */
.workload { display: flex; flex-wrap: wrap; gap: 6px; }
.workload .wl {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text); text-decoration: none; font-size: 12.5px;
}
.workload .wl:hover { border-color: var(--accent); }
.workload .wl.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.workload .wl .nm { font-weight: 550; }
.workload .wl .n {
  min-width: 20px; text-align: center; padding: 0 5px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 11.5px;
}
.workload .wl .od { color: var(--tone-red); font-size: 11px; }
.workload .wl[data-empty] .n { background: var(--line); color: var(--text-3); }

/* Pfandzeile im Belegformular: gehört zur Ware darüber, wird nicht getippt. */
.items-table tr.deposit-row td { background: var(--bg-soft, #fafafa); }
.items-table tr.deposit-row input { border-color: transparent; background: transparent; color: var(--muted, #6b7280); }

/* Schmale Seite für unterwegs: ein Stopp auf dem Telefon, nichts daneben. */
.page.narrow { max-width: 640px; }
.page.narrow .btn.block { padding: 12px; font-size: 15px; }
.page.narrow input[type="text"] { font-size: 16px; }  /* iOS zoomt sonst beim Tippen */

/* hidden ist eine Zusage: was so ausgezeichnet ist, wird nicht gezeigt.
   Ohne diese Regel gewinnt jedes spätere display:grid oder display:block —
   und der Abschluss stand da, obwohl er versteckt sein sollte. */
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ Packtisch
   Bedient wird mit dem Finger, oft im Stehen, manchmal mit Handschuh. Große
   Flächen, kräftige Kontraste, keine Ziele unter 44 Pixeln.

   Ausschließlich Themenfarben: der Packschirm läuft auf fremden Geräten, und
   ein fest verdrahtetes Weiß wird im dunklen Erscheinungsbild zu weißem Text
   auf weißem Grund. */

.kiosk { background: var(--bg); color: var(--text); }
.kiosk-bar { display: flex; align-items: center; gap: 14px; padding: 10px 20px;
             background: var(--surface); border-bottom: 1px solid var(--line);
             position: sticky; top: 0; z-index: 20; }
.kiosk-bar .kb-home { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.kiosk-bar .kb-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--accent);
                      color: var(--text-inv); display: flex; align-items: center;
                      justify-content: center; font-weight: 700; }
.kiosk-bar .kb-title { font-size: 18px; font-weight: 600; color: var(--text); }
.kiosk-bar .kb-clock { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.kiosk-bar .kb-user { font-size: 15px; color: var(--tone-muted); }
.kiosk-bar .kb-out { display: inline; }
.kiosk-main { padding: 18px 20px 24px; }
.kiosk .page { max-width: none; padding: 0; }

.btn.xl { font-size: 22px; padding: 18px 32px; border-radius: 10px; }

.pq-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
           margin-bottom: 18px; flex-wrap: wrap; }
.pq-head h1 { font-size: 30px; margin: 0; }
.pq-sub { font-size: 16px; color: var(--tone-muted); }

.pack-queue { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.pack-card { position: relative; display: block; padding: 20px 22px 18px; border-radius: 10px;
             border: 1px solid var(--line); border-left: 8px solid var(--accent);
             background: var(--surface); color: var(--text); text-decoration: none;
             transition: transform .06s ease; }
.pack-card:active { transform: scale(.985); }
.pack-card.first { box-shadow: 0 0 0 2px var(--accent); }
.pack-card .pq-next { position: absolute; top: 14px; right: 18px; font-size: 11px; font-weight: 600;
                      text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.pack-card .pq-name { font-size: 22px; font-weight: 650; line-height: 1.25; margin-bottom: 6px;
                      padding-right: 90px; color: var(--text); }
.pack-card .pq-no { font-size: 14px; color: var(--tone-muted); display: flex; gap: 8px;
                    align-items: center; flex-wrap: wrap; }
.pack-card .pq-brand { padding: 2px 8px; border-radius: 999px; background: var(--tone-muted-bg); }
.pack-card .pq-foot { display: flex; align-items: baseline; gap: 12px; margin-top: 14px; }
.pack-card .pq-count { font-size: 28px; font-weight: 700; line-height: 1; color: var(--text); }
.pack-card .pq-count .u { font-size: 13px; font-weight: 500; color: var(--tone-muted); margin-left: 5px; }
.pack-card .pq-age { font-size: 14px; color: var(--tone-muted); }
.pack-card .pq-age.warn { color: var(--tone-amber); font-weight: 600; }
.pack-card .pq-age.late { color: var(--tone-red); font-weight: 700; }
.pack-card .pq-bar { height: 8px; border-radius: 999px; background: var(--tone-muted-bg);
                     margin-top: 14px; overflow: hidden; }
.pack-card .pq-bar span { display: block; height: 100%; background: var(--tone-green); }
.pack-card .pq-bar-text { font-size: 13px; color: var(--tone-muted); margin-top: 5px; }

.pq-empty { text-align: center; padding: 70px 20px; }
.pq-empty-mark { width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 50%;
                 background: var(--tone-green-bg); color: var(--tone-green); font-size: 44px;
                 display: flex; align-items: center; justify-content: center; }
.pq-empty-title { font-size: 26px; font-weight: 650; }
.pq-empty-sub { font-size: 16px; color: var(--tone-muted); margin-top: 4px; }

/* --- Der Auftrag am Tisch ------------------------------------------------ */
.page.pack .pagehead h1 { font-size: 26px; }
.page.pack .pack-progress { font-size: 24px; font-weight: 600; padding: 4px 14px; border-radius: 999px;
                            background: var(--tone-muted-bg); color: var(--text); }
.page.pack .pack-progress.full { background: var(--tone-green-bg); color: var(--tone-green); }

.pack-list { display: grid; gap: 8px; margin: 12px 0 16px; }
.pack-row { display: grid; grid-template-columns: 60px 104px 1fr auto; align-items: center; gap: 14px;
            min-height: 88px; padding: 10px 16px; border: 2px solid var(--line); border-radius: 10px;
            background: var(--surface); color: var(--text); cursor: pointer; user-select: none; }
.pack-row .pk-check { width: 44px; height: 44px; border-radius: 8px; border: 2px solid var(--line-strong);
                      display: flex; align-items: center; justify-content: center;
                      font-size: 24px; color: transparent; }
.pack-row.done { border-color: var(--tone-green); background: var(--tone-green-bg); }
.pack-row.done .pk-check { background: var(--tone-green); border-color: var(--tone-green); color: var(--text-inv); }
/* Abgehakt heißt erledigt, nicht unlesbar: nur ein Haken und ein grüner
   Rahmen. Durchgestrichener, blasser Text war auf dem Tisch nicht mehr zu
   entziffern — und genau dann will jemand nachsehen, was er schon eingepackt hat. */
.pack-row.done .pk-title { color: var(--text); }
.pack-row .pk-qty { font-size: 34px; font-weight: 700; line-height: 1; color: var(--text); }
.pack-row .pk-qty .u { font-size: 13px; font-weight: 500; color: var(--tone-muted); margin-left: 4px; }
.pack-row .pk-title { font-size: 20px; font-weight: 600; color: var(--text); }
.pack-row .pk-meta { font-size: 13px; color: var(--tone-muted); }
.pack-row .pk-bin { font-size: 22px; font-weight: 700; padding: 6px 14px; border-radius: 8px;
                    background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pack-row.aside { opacity: .6; cursor: default; }

/* Fehlmenge: rot, weil es eine Nachricht an den Kunden auslöst. */
.pack-row.short { border-color: var(--tone-red); background: var(--tone-red-bg); }
.pack-row.short .pk-title { text-decoration: line-through; }
.pack-row.short .pk-check { border-style: dashed; }
.pk-short { font-size: 15px; font-weight: 600; padding: 12px 16px; min-height: 48px;
            border: 1px solid var(--line-strong); border-radius: 8px;
            background: var(--surface); color: var(--tone-muted); cursor: pointer; white-space: nowrap; }
.pack-row.short .pk-short { border-color: var(--tone-red); color: var(--tone-red);
                            background: var(--surface); }
.pack-row { grid-template-columns: 60px 104px 1fr auto auto; }

.pack-waiting { margin-top: 12px; padding: 20px; border: 2px dashed var(--line-strong);
                border-radius: 10px; text-align: center; font-size: 18px; color: var(--tone-muted); }
.pack-waiting .pack-tools { justify-content: center; }

/* --- Abschluss: Zahlenfeld und ein großer Knopf -------------------------- */
.pack-overlay { position: fixed; inset: 0; z-index: 60; display: flex;
                align-items: center; justify-content: center; padding: 20px;
                background: rgba(8, 11, 14, .72); }
.pack-sheet { width: min(940px, 100%); max-height: calc(100vh - 40px); overflow: auto;
              background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
              box-shadow: var(--shadow-pop); padding: 20px; }
.ps-head { display: flex; align-items: flex-start; justify-content: space-between;
           gap: 16px; margin-bottom: 16px; }
.ps-title { font-size: 22px; font-weight: 650; color: var(--text); }
.ps-sub { font-size: 14px; color: var(--tone-muted); margin-top: 2px; }
.ps-back { font-size: 15px; padding: 12px 16px; min-height: 48px; border-radius: 8px;
           border: 1px solid var(--line-strong); background: var(--bg); color: var(--text);
           cursor: pointer; white-space: nowrap; }

.pack-foot { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
@media (max-width: 780px) { .pack-foot { grid-template-columns: 1fr; } }

.pf-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pf-pad button { font-size: 26px; font-weight: 600; padding: 14px 0; border-radius: 8px;
                 border: 1px solid var(--line-strong); background: var(--bg); color: var(--text);
                 cursor: pointer; }
.pf-pad button:active { background: var(--accent-soft); }
.pf-pad button.wide { grid-column: span 2; }

.pf-side { display: grid; gap: 14px; align-content: start; }
.pf-display { display: flex; align-items: baseline; justify-content: flex-end; gap: 10px;
              padding: 14px 20px; border: 2px solid var(--line-strong); border-radius: 10px;
              background: var(--bg); }
.pf-display .v { font-size: 46px; font-weight: 700; font-variant-numeric: tabular-nums;
                 line-height: 1; color: var(--text); }
.pf-display .v.empty { color: var(--tone-muted); }
.pf-display .u { font-size: 20px; color: var(--tone-muted); }
.pf-label { font-size: 14px; color: var(--tone-muted); }

.pf-go { display: block; width: 100%; font-size: 26px; font-weight: 650; padding: 24px 20px;
         border: 0; border-radius: 10px; background: var(--tone-green); color: #fff; cursor: pointer; }
.pf-go:active { filter: brightness(.94); }
.pf-hint { padding: 24px 20px; border: 2px dashed var(--line-strong); border-radius: 10px;
           text-align: center; font-size: 17px; color: var(--tone-muted); }

.pack-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.pack-tools form { display: inline; }

/* Unterschriftsfeld: groß genug für einen Finger, mit sichtbarer Linie —
   ein leeres Rechteck lädt niemanden zum Unterschreiben ein. */
.sig-wrap { position: relative; }
.sig-pad { display: block; width: 100%; height: 190px; background: #fff;
           border: 2px dashed var(--line-strong); border-radius: 10px; touch-action: none; }
.sig-hint { position: absolute; left: 0; right: 0; bottom: 26px; text-align: center;
            font-size: 15px; color: #9aa1a9; pointer-events: none; }
.sig-wrap::after { content: ''; position: absolute; left: 24px; right: 24px; bottom: 22px;
                   border-bottom: 1px solid #d2d7dc; pointer-events: none; }

/* Die Fahrer-App scrollt als ganze Seite.
   Das Bürolayout setzt `html, body { height: 100% }` — dort ist das richtig,
   weil Postfach und Liste eigene Bildlaufbereiche haben. In der App wäre die
   Seite damit exakt bildschirmhoch: alles darunter bleibt unerreichbar, und
   beim Wischen federt es zurück. Genau das war der Grund, warum der letzte
   Knopf nicht zu treffen war — nicht der Abstand. */
html.drv-html, html.drv-html body {
  height: auto;
  min-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* ------------------------------------------------------------ Fahrer-App
   Eine eigene Oberfläche, kein verkleinerter Schreibtisch. Alles ab 56 px,
   damit es im Stehen, in Eile und mit Handschuh bedienbar bleibt. Die
   sicheren Abstände (env safe-area) sind Pflicht, nicht Kosmetik: ohne sie
   liegt die untere Leiste auf einem iPhone unter dem Systembalken. */
/* Die untere Leiste ist 64 px hoch, der runde Knopf ragt 18 px darüber
   hinaus. Wer nur 64 px freihält, legt den letzten Knopf der Seite darunter —
   sichtbar, aber nicht mehr zu treffen. Deshalb großzügig: 104 px plus die
   sichere Zone des Geräts. */
body.drv { background: var(--bg); color: var(--text);
           padding-bottom: calc(104px + env(safe-area-inset-bottom));
           -webkit-tap-highlight-color: transparent; }

.drv-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
           padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
           background: var(--surface); border-bottom: 1px solid var(--line); }
.drv-back { font-size: 30px; line-height: 1; text-decoration: none; color: var(--text);
            width: 34px; margin: -6px 0; }
.drv-title { font-size: 18px; font-weight: 650; }
.drv-net { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
           padding: 4px 9px; border-radius: 999px; background: var(--tone-amber-bg); color: var(--tone-amber); }
.drv-main { padding: 14px 14px 20px; display: grid; gap: 12px; align-content: start; }

.drv-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
            display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
            background: var(--surface); border-top: 1px solid var(--line);
            padding-bottom: env(safe-area-inset-bottom); }
.drv-tab { display: flex; flex-direction: column; align-items: center; gap: 3px;
           padding: 9px 0 7px; text-decoration: none; color: var(--tone-muted); font-size: 11px; }
.drv-tab svg { width: 24px; height: 24px; }
.drv-tab.on { color: var(--drv-accent); font-weight: 650; }
.drv-plus { background: var(--drv-accent); color: #fff; width: 54px; height: 54px;
            border-radius: 50%; justify-self: center; align-items: center; justify-content: center;
            padding: 0; margin-top: -18px; box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.drv-plus svg { width: 28px; height: 28px; }

/* Karten und Knöpfe der App */
.drv-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
            padding: 16px; }
.drv-hello { font-size: 15px; color: var(--tone-muted); }
.drv-h1 { font-size: 26px; font-weight: 700; margin: 2px 0 10px; }
.drv-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.drv-kpi { text-align: center; padding: 10px 2px; border-radius: 10px; background: var(--bg);
           min-width: 0; }
/* Kleiner als im Entwurf: „12/12" bei vier Spalten sprengt auf einem schmalen
   Telefon sonst die Kachel und wird abgeschnitten. */
.drv-kpi b { display: block; font-size: 19px; line-height: 1.15;
             overflow-wrap: anywhere; }
.drv-kpi span { font-size: 10.5px; color: var(--tone-muted); }
.drv-main > form:last-child .drv-big:last-child,
.drv-main > .drv-big:last-child { margin-bottom: 6px; }
.drv-big { display: block; width: 100%; text-align: center; font-size: 19px; font-weight: 700;
           padding: 20px; border: 0; border-radius: 12px; background: var(--drv-accent);
           color: #fff; text-decoration: none; cursor: pointer; }
.drv-big.ghost { background: var(--surface); color: var(--text); border: 2px solid var(--line-strong); }
.drv-big.warn { background: var(--tone-amber); }
.drv-big.danger { background: var(--tone-red); }
.drv-list { display: grid; gap: 10px; }
.drv-row { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 14px 16px;
           background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
           text-decoration: none; color: var(--text); font-size: 16px; }
.drv-row .n { margin-left: auto; color: var(--tone-muted); font-size: 14px; }

/* Stoppkarte */
.drv-stop { background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--drv-accent);
            border-radius: 12px; padding: 16px; }
.drv-stop.done { border-left-color: var(--tone-green); background: var(--tone-green-bg); }
.drv-stop.failed { border-left-color: var(--tone-red); background: var(--tone-red-bg); }
.drv-stop .no { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
                color: var(--tone-muted); }
.drv-stop .who { font-size: 20px; font-weight: 650; margin: 2px 0 4px; }
.drv-stop .adr { font-size: 15px; color: var(--tone-muted); }
.drv-stop .task { font-size: 15px; margin-top: 8px; }
.drv-stop .acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.drv-stop .acts a, .drv-stop .acts button { display: block; text-align: center; padding: 14px 8px;
            border-radius: 10px; font-size: 15px; font-weight: 600; text-decoration: none;
            border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); }
.drv-stop .acts .go { grid-column: 1 / -1; background: var(--drv-accent); color: #fff; border: 0; }

/* Zähler mit Daumen bedienbar */
.drv-step { display: grid; grid-template-columns: 64px 1fr 64px; gap: 8px; align-items: center; }
.drv-step button { height: 60px; font-size: 30px; font-weight: 700; border-radius: 10px;
                   border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); }
.drv-step input { height: 60px; font-size: 26px; text-align: center; font-weight: 700; }

.drv-flash { position: fixed; left: 12px; right: 12px; bottom: calc(96px + env(safe-area-inset-bottom));
             z-index: 40; display: grid; gap: 8px; }
/* Meldungen verschwinden von selbst: auf dem Telefon liegen sie über dem
   Inhalt, und wer beide Hände voll hat, tippt kein Kreuzchen. */
.drv-flash .flash { animation: drvFade 0s linear 9s forwards; }
@keyframes drvFade { to { opacity: 0; visibility: hidden; } }

/* Einrichtungsliste der Fahrer-App */
.drv-setup .drv-todo { display: flex; gap: 12px; align-items: flex-start;
                       padding: 12px 0; border-top: 1px solid var(--line); }
.drv-setup .drv-todo:first-of-type { border-top: 0; }
.drv-setup .mark { width: 30px; height: 30px; border-radius: 50%; flex: 0 0 30px;
                   background: var(--bg); border: 2px solid var(--line-strong);
                   display: flex; align-items: center; justify-content: center;
                   font-weight: 700; font-size: 14px; }
.drv-setup .drv-todo.done .mark { background: var(--tone-green); border-color: var(--tone-green);
                                  color: #fff; font-size: 0; }
.drv-setup .drv-todo.done .mark::after { content: '✓'; font-size: 17px; }
.drv-setup .drv-todo.done strong { color: var(--tone-muted); }
.drv-setup .btn.sm { margin-top: 8px; min-height: 44px; padding: 10px 16px; font-size: 15px; }

/* Stoppmaske der Fahrer-App */
.drv-item { padding: 12px 0; border-top: 1px solid var(--line); }
.drv-item:first-of-type { border-top: 0; padding-top: 0; }
.drv-item .ttl { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.drv-item .ttl .drv-hello { display: block; font-size: 13px; font-weight: 400; }
.drv-sub { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.drv-sub label { font-size: 14px; color: var(--tone-muted); flex: 1; }
.drv-sub input { width: 96px; height: 48px; text-align: center; font-size: 17px; }
.drv-balance { margin-top: 12px; padding: 12px; border-radius: 10px;
               background: var(--accent-soft); color: var(--accent);
               font-size: 16px; text-align: center; }
.drv-balance strong { font-size: 22px; }

/* Große Kästchen: mit dem Finger getroffen wird die ganze Zeile, nicht das
   Kästchen — 20 Pixel Ziel wären auf einem Rütteltisch unbedienbar. */
.drv-check { display: flex; align-items: center; gap: 12px; padding: 12px 4px;
             border-bottom: 1px solid var(--line); font-size: 16px; cursor: pointer; }
.drv-check input { width: 28px; height: 28px; flex: 0 0 28px; }
.drv-check input:checked + span { color: var(--tone-green); font-weight: 600; }

.drv .field label { font-size: 14px; color: var(--tone-muted); }
.drv .field input, .drv .field textarea, .drv .field select { font-size: 16px; }
.drv .sig-pad { height: 170px; }

/* ============================================================================
   BCS 3.0 — Reiter, Vorgangsketten, Zeitleiste, Arbeitskorb

   Alles hier folgt derselben Regel wie der Rest des Stylesheets: Flächen aus
   `--surface`, Linien aus `--line`, Farbe nur dort, wo sie etwas bedeutet.
   ========================================================================= */

/* --- Reiter in der Kundenakte ------------------------------------------- */
.tabbar {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }
.tabbar a {
  padding: 8px 13px 9px;
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tabbar a:hover { color: var(--text); background: var(--surface-3); }
.tabbar a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 550;
}
.tabbar a .n {
  font-size: 11px;
  color: var(--text-3);
  background: var(--surface-3);
  border-radius: 8px;
  padding: 0 6px;
}

/* --- Kopfzahlen der Akte ------------------------------------------------- */
.factline {
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
  align-items: flex-start;
}
.factline .fact { display: flex; flex-direction: column; gap: 1px; min-width: 96px; }
.factline .fact .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-3);
}
.factline .fact .v { font-size: 17px; font-weight: 600; line-height: 1.25; }
.factline .fact .v.danger { color: var(--tone-red); }
.factline .fact .s { font-size: 11px; color: var(--text-3); }
.factline .fact .s.danger { color: var(--tone-red); }

/* --- Vorgangskette ------------------------------------------------------- */
.chain {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.chain:last-child { border-bottom: 0; }
.chain .arrow { align-self: center; color: var(--text-3); font-size: 13px; }
.chain .glied {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 132px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  text-decoration: none;
  color: var(--text);
}
.chain .glied:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.chain .glied .lb {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-3);
}
.chain .glied .tt { font-size: 13px; font-weight: 550; }
.chain .glied .dt { font-size: 11px; color: var(--text-3); }
.chain .glied .badge { align-self: flex-start; margin-top: 2px; }

/* --- Zeitleiste ---------------------------------------------------------- */
.tl { list-style: none; margin: 0; padding: 0; }
.tl .tl-day {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-3);
  padding: 14px 0 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}
.tl .tl-day:first-child { padding-top: 0; }
.tl .tl-item {
  display: grid;
  grid-template-columns: 22px 44px 1fr;
  gap: 8px;
  padding: 6px 0;
  align-items: baseline;
}
.tl .tl-item .ic {
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
  line-height: 18px;
}
.tl .tl-item .tm {
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.tl .tl-item .bd { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tl .tl-item .ttl { font-size: 13px; }
.tl .tl-item .dt { font-size: 12px; color: var(--text-2); }
.tl .tl-item .who { font-size: 11px; color: var(--text-3); }

/* --- Pfad über dem Inhalt ------------------------------------------------ */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 10px;
}
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs .sep { color: var(--line-strong); }
.crumbs .now { color: var(--text); font-weight: 550; }

/* --- Zurückstellen im Arbeitskorb ---------------------------------------- */
.inline-menu { position: relative; display: inline-block; }
.inline-menu > summary { list-style: none; cursor: pointer; }
.inline-menu > summary::-webkit-details-marker { display: none; }
.inline-menu .pop {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  width: 240px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 12px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

/* --- Beleg einlesen (Buchhaltung) ---------------------------------------- */
.scan-band { border-color: var(--accent-line); background: var(--accent-soft); }
.scan-band .card-body { padding: 13px 15px; }
.scan-result {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
}
.scan-result .hd { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.scan-result.ok   { border-left: 3px solid var(--tone-green); }
.scan-result.warn { border-left: 3px solid var(--tone-amber); }
.scan-seen {
  margin: 8px 0 0;
  padding: 9px 11px;
  max-height: 260px;
  overflow: auto;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--r);
}

/* --- Belegvorschau und Lieferantenvorschläge ----------------------------- */
.doc-view { margin-bottom: 14px; }
.doc-frame {
  display: block;
  width: 100%;
  height: 520px;
  border: 0;
  background: var(--surface-3);
}
img.doc-frame { height: auto; max-height: 720px; object-fit: contain; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  font: inherit;
  font-size: 12px;
  line-height: 1.3;
  padding: 4px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 550; }

/* Auf breiten Schirmen Beleg und Maske nebeneinander — Abtippen ohne
   Fensterwechsel ist der halbe Zweck der Sache. */
@media (min-width: 1500px) {
  .with-doc { display: grid; grid-template-columns: minmax(0, 1fr) 520px; gap: 14px; align-items: start; }
  .with-doc > .scan-band { grid-column: 1 / -1; }
  .with-doc > .doc-view { grid-column: 2; grid-row: 2 / span 3; position: sticky; top: 14px; }
  .with-doc > .doc-view .doc-frame { height: calc(100vh - 190px); }
  .with-doc > .grid, .with-doc > .btn-row { grid-column: 1; }
}

/* --- Sammelaktion in Listen ---------------------------------------------- */
.bulk-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 14px; margin-top: 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--r);
}
.bulk-bar label { display: flex; align-items: center; gap: 6px; color: var(--text-2); }


/* --- Kopfzeile: wo bin ich ------------------------------------------------ */
.topwhere {
  display: flex; align-items: center; gap: 7px;
  min-width: 0; font-size: 13px;
}
.topwhere .grp { color: var(--text-3); }
.topwhere .sep { color: var(--line-strong); }
.topwhere .now {
  font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 900px) { .topwhere .grp, .topwhere .sep { display: none; } }
