/* ==========================================================================
   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:         48px;
  --w-nav:         216px;
  --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: 26px;
}
.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: 20px; width: auto; max-width: 190px; display: block; }
[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; }

.topnav { display: flex; align-items: center; gap: 1px;
  min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  padding: 5px 10px; border-radius: var(--r);
  color: var(--text-2); font-weight: 500; white-space: nowrap;
}
.topnav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.topnav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }

.topbar .spacer { flex: 1; }

.search-wrap { position: relative; width: 300px; }
.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: 10px 8px 24px;
}
.nav-group { margin-bottom: 16px; }
.nav-title {
  font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); padding: 0 8px 5px;
}
.nav a {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: var(--r);
  color: var(--text-2); font-size: 12.5px; line-height: 18px;
}
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.nav a .n { margin-left: auto; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav a.active .n { color: var(--accent); }
.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; }

.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); }

/* 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); }

/* 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: 2px solid transparent;
  color: var(--text); cursor: pointer;
}
.mail-row:hover { background: var(--surface-2); text-decoration: none; }
.mail-row.active { background: var(--accent-soft); border-left-color: var(--accent); }
.mail-row.unread { background: var(--surface); }
.mail-row.unread .r1 .from { font-weight: 650; }
.mail-row.unread .subj { font-weight: 600; color: var(--text); }
.mail-row .r1 { display: flex; align-items: center; gap: 7px; margin-bottom: 2px; }
.mail-row .r1 .from { flex: 1; 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;
  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; }
}
