:root {
  /* Platzhalter-Farbschema (warm) – wird später durch das Hasenzähnchen-Branding ersetzt */
  --bg: #f6f1ea;
  --surface: #ffffff;
  --surface-2: #faf6f0;
  --border: #e9e0d5;
  --text: #2b2320;
  --text-2: #6b5f57;
  --text-3: #a3968c;
  --primary: #e8734a;
  --primary-hover: #d5613a;
  --primary-soft: #fde9df;
  --danger: #d23f3f;
  --danger-soft: #fde4e4;
  --success: #3a9d5d;
  --warning: #d98a1a;
  --sidebar-bg: #2b2320;
  --sidebar-text: #e9dfd6;
  --sidebar-muted: #9c8e84;
  --sidebar-active: rgba(232, 115, 74, .22);
  --shadow: 0 1px 3px rgba(43, 35, 32, .08), 0 1px 2px rgba(43, 35, 32, .04);
  --shadow-lg: 0 10px 30px rgba(43, 35, 32, .2);
  --radius: 12px;
  --topbar-h: 56px;
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 68px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120f;
    --surface: #211a16;
    --surface-2: #2a221d;
    --border: #3a2f29;
    --text: #f0e8e1;
    --text-2: #b8aca2;
    --text-3: #7d7067;
    --primary: #f08657;
    --primary-hover: #f79b74;
    --primary-soft: #4a2a1c;
    --danger-soft: #4a1d1d;
    --sidebar-bg: #100c0a;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }

/* ---------- Layout: Sidebar + Inhalt ---------- */
.layout { min-height: 100%; display: flex; }
#sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh;
  transition: width .15s ease; z-index: 30;
}
.sb-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 10px 16px; padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; font-weight: 700; font-size: 1rem; min-width: 0; flex: 1; }
.brand-mark { display: inline-flex; width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: #fff; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-collapse { margin-left: auto; color: var(--sidebar-text); opacity: .7; width: 32px; min-height: 32px; font-size: 18px; }
.sb-collapse:hover { background: rgba(255,255,255,.08); color: var(--sidebar-text); }
.sb-nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.sb-section { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--sidebar-muted); padding: 14px 8px 6px; white-space: nowrap; overflow: hidden; }
.sb-nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 10px; color: var(--sidebar-text);
  font-weight: 500; margin-bottom: 2px; white-space: nowrap; overflow: hidden;
}
.sb-nav a .ico { font-size: 21px; width: 26px; display: inline-flex; justify-content: center; flex-shrink: 0; color: var(--sidebar-muted); }
.sb-nav a.active .ico, .sb-nav a:hover .ico { color: #fff; }
.ico svg { display: block; }
.btn .ico { display: inline-flex; font-size: 18px; }
.sb-nav a:hover { background: rgba(255,255,255,.07); }
.sb-nav a.active { background: var(--sidebar-active); color: #fff; }
.sb-foot { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-top: 1px solid rgba(255,255,255,.08); }
.sb-user { display: flex; align-items: center; gap: 10px; color: inherit; flex: 1; min-width: 0; line-height: 1.2; }
.sb-user .lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user small { color: var(--sidebar-muted); }
#sb-logout { color: var(--sidebar-muted); }
#sb-logout:hover { color: #fff; background: rgba(255,255,255,.08); }

/* eingeklappte Sidebar (Desktop) */
body.sb-collapsed #sidebar { width: var(--sidebar-w-collapsed); }
body.sb-collapsed .brand-name, body.sb-collapsed .sb-nav .lbl, body.sb-collapsed .sb-user .lbl, body.sb-collapsed .sb-section { display: none; }
body.sb-collapsed .sb-head { flex-direction: column; padding: 12px 8px; }
body.sb-collapsed .sb-collapse { margin: 6px 0 0; transform: rotate(180deg); }
.perm-title { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; }
.perm-title .ico { font-size: 18px; display: inline-flex; color: var(--text-2); }
body.sb-collapsed .sb-nav a { justify-content: center; padding: 10px 0; }
body.sb-collapsed .sb-foot { flex-direction: column; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
#topbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)); /* Statusleiste (Uhr/Akku) bleibt frei */
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; padding: 0 16px; padding-top: env(safe-area-inset-top, 0px);
}
.topbar-title { font-weight: 700; font-size: 1.1rem; flex: 1; }
#menu-btn { display: none; }
main#view { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 16px; padding-bottom: calc(24px + var(--safe-bottom)); }
main#view.full-bleed { max-width: none; padding: 0; display: flex; flex-direction: column; }
main#view.breit { max-width: none; padding: 10px 10px 10px 14px; }   /* Module mit breit: true (E-Mail) – volle Breite, schmaler Rand */

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 700; flex-shrink: 0;
  text-transform: uppercase;
}
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--safe-bottom) + 8px); z-index: 21;
  width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--primary); color: #fff;
  font-size: 30px; line-height: 1; box-shadow: var(--shadow-lg); cursor: pointer;
}
.sb-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 29; }

/* Die Kopfzeile nur als schmale Leiste: am Rechner 32 px, auf dem Telefon 40 px (dort sitzt der Menüknopf) */
@media (min-width: 768px) {
  :root { --topbar-h: 32px; }
  #topbar { padding: 0 16px; }
  .topbar-title { font-size: 13px; font-weight: 600; color: var(--text-2); }
}
@media (max-width: 767px) {
  #sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; width: min(300px, 85vw) !important; }
  body.drawer-open #sidebar { transform: none; }
  body.sb-collapsed .brand-name, body.sb-collapsed .sb-nav .lbl, body.sb-collapsed .sb-user .lbl, body.sb-collapsed .sb-section { display: initial; }
  body.sb-collapsed .sb-nav a { justify-content: flex-start; padding: 10px; }
  body.sb-collapsed .sb-head { flex-direction: row; }
  body.sb-collapsed .sb-foot { flex-direction: row; }
  .sb-collapse { display: none; }
  :root { --topbar-h: 40px; }
  #topbar { padding-left: 6px; padding-right: 12px; gap: 4px; }
  .topbar-title { font-size: 15px; }
  #menu-btn { display: inline-flex; width: 40px; height: 40px; }
  #btn-new { display: none !important; }
  main#view { padding: 12px; padding-bottom: calc(var(--safe-bottom) + 84px); }
  main#view.full-bleed { padding-bottom: var(--safe-bottom); }
}
@media (min-width: 768px) {
  .fab, .sb-backdrop { display: none !important; }
}

/* ---------- KI-Assistent (iframe) ---------- */
/* ---------- Warenwirtschaft: Artikel ---------- */

.chip.quiet { opacity: .8; font-variant-numeric: tabular-nums; }

.feld-paar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .feld-paar { grid-template-columns: 1fr; } }

.bom-zeile { display: flex; align-items: center; gap: 10px; padding: 7px 2px;
  border-bottom: 1px solid var(--border); }
.bom-zeile:last-child { border-bottom: none; }
.bom-zeile.still { opacity: .55; }

/* Nummernkreise: ein Kreis je Zeile. Schmal untereinander, breit nebeneinander. */
.nk-zeile { display: grid; gap: 8px 12px; align-items: end;
  padding: 12px 2px; border-bottom: 1px solid var(--border); }
.nk-zeile:last-child { border-bottom: none; }
.nk-was { display: flex; flex-direction: column; gap: 1px; }
.nk-zeile .tb-field { width: auto; }
.nk-beispiel { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.nk-beispiel code { font-weight: 600; }
.nk-beispiel code.fehler { color: var(--danger, #c0392b); font-weight: 400; }
@media (min-width: 900px) {
  .nk-zeile { grid-template-columns: minmax(150px, 1fr) minmax(160px, 1.4fr) 92px 150px minmax(120px, 1fr) auto; }
  .nk-was { align-self: center; }
  .nk-beispiel { align-self: center; }
}
.hint.warn { color: var(--danger, #c0392b); }

/* ---------- Warenwirtschaft: Lager ---------- */

.chip.warn { background: #fef3c7; color: #92400e; }
@media (prefers-color-scheme: dark) { .chip.warn { background: #4a3410; color: #fde68a; } }

.wawi-tabelle { width: 100%; border-collapse: collapse; font-size: 14px; }
.wawi-tabelle th, .wawi-tabelle td { border-bottom: 1px solid var(--border); padding: 7px 8px;
  text-align: left; vertical-align: top; }
.wawi-tabelle th { background: var(--surface-2); font-size: 12px; color: var(--text-2); position: sticky; top: 0; }
.wawi-tabelle tr.set-kopf td { background: var(--surface-2); }
.wawi-tabelle tr.im-set td:first-child { padding-left: 22px; }

/* Zu- und Abgänge, Fehlmengen – in jeder Tabelle grün bzw. rot */
:is(.wawi-tabelle, .sortier-tabelle) .plus:not(.chip) { color: var(--success); font-variant-numeric: tabular-nums; }
:is(.wawi-tabelle, .sortier-tabelle) .minus:not(.chip) { color: var(--danger); font-variant-numeric: tabular-nums; }
.zaehl-feld { width: 92px; font-size: 16px; padding: 4px 8px; text-align: right; }

/* top/left ausdrücklich: Das umgebende .field ist ein Flex-Container, und darin
   landet ein absolut positioniertes Kind sonst oben links – also über dem Feld. */
.artikel-treffer { position: fixed; z-index: 70;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow-lg); overflow-y: auto;
  display: flex; flex-direction: column; }
.artikel-treffer button { border: none; background: none; text-align: left; padding: 8px 12px;
  cursor: pointer; color: var(--text); font: inherit; }
.artikel-treffer button:hover, .artikel-treffer button.markiert { background: var(--surface-2); }
.artikel-leer { padding: 10px 12px; color: var(--text-3); font-size: 14px; }
/* Der kleine Pfeil macht aus dem Textfeld sichtbar ein Auswahlfeld. */
input.mit-auswahl { background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
  linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) calc(50% + 2px), calc(100% - 10px) calc(50% + 2px);
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.modal .field, .toolbar .tb-field { position: relative; }

.fefo-vorschau { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; }
.fefo-zeile { padding: 3px 0; font-size: 14px; }
.fefo-zeile.fehlt { color: var(--danger); font-weight: 600; }
/* Pflichtfeld, das noch fehlt (Wareneingang: Menge, Charge, MHD) */
input.feld-fehlt { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); background: var(--danger-soft); }

/* ---------- Warenwirtschaft: Einkauf ---------- */
.bestell-kopf { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.bestell-kopf > .muted { white-space: nowrap; }
.vorschlag-gruppe { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; }
.vorschlag-kopf { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; margin-bottom: 6px; }
.chip.plus { font-weight: 600; }

/* ---------- Verkauf: Lieferschein, Angebot, Rechnung ---------- */
.lieferschein .ls-kopf, .beleg .ls-kopf { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.lieferschein .ls-empfaenger, .beleg .ls-empfaenger { text-align: right; line-height: 1.5; }
.lieferschein h3, .beleg h3 { margin: 0 0 2px; }
.beleg .beleg-absender { line-height: 1.5; }
.beleg-daten { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 6px 0 16px; font-size: 14px; }
.beleg-daten div { display: flex; gap: 6px; }
.beleg-daten span { color: var(--text-2); }
.beleg-summen { margin: 14px 0 0; margin-left: auto; max-width: 360px; font-size: 14px; }
.beleg-summen div { display: flex; justify-content: space-between; gap: 20px; padding: 3px 0; }
.beleg-summen b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.beleg-brutto { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 6px !important; font-size: 16px; }
/* Die Tabelle für alle Listen (shared/tabelle.js): weiße Karte auf dem
   beigen Grund, ruhiger Kopf, feine Linien zwischen den Zeilen. */
.sortier-tabelle { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.sortier-tabelle th { text-align: left; padding: 0; background: var(--surface-2);
  border-bottom: 1px solid var(--border); }
.sortier-tabelle th button, .sortier-tabelle th > span { width: 100%; display: flex; align-items: center;
  gap: 4px; background: none; border: 0; padding: 10px 14px; font: inherit; font-size: 12.5px;
  font-weight: 600; letter-spacing: .02em; color: var(--text-2); text-align: left; white-space: nowrap; }
.sortier-tabelle th button { cursor: pointer; }
.sortier-tabelle th.rechts button, .sortier-tabelle th.rechts > span { justify-content: flex-end; }
.sortier-tabelle th button:hover { color: var(--text); }
.sortier-tabelle th[aria-sort="ascending"] button,
.sortier-tabelle th[aria-sort="descending"] button { color: var(--primary); }
.sortier-tabelle th button:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.sortier-tabelle .pfeil { font-size: 10px; }
.sortier-tabelle td { padding: 10px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle; white-space: nowrap; background: var(--surface); }
.sortier-tabelle tbody tr:last-child td { border-bottom: 0; }
/* Die eine breite Spalte nimmt den Rest – alles andere bleibt in einer Zeile */
.sortier-tabelle th.breit, .sortier-tabelle td.breit { white-space: normal; width: 100%; min-width: 11em; }
.sortier-tabelle td.rechts, .sortier-tabelle th.rechts { text-align: right;
  font-variant-numeric: tabular-nums; }
.sortier-tabelle tbody tr { cursor: pointer; }
.sortier-tabelle tbody tr:hover td { background: var(--primary-soft); }
.sortier-tabelle tbody tr:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.sortier-tabelle.nur-lesen tbody tr { cursor: default; }
.sortier-tabelle.nur-lesen tbody tr:hover td { background: var(--surface); }
.sortier-tabelle tr.still td { color: var(--text-3); }
.sortier-tabelle tr.warn td:first-child { box-shadow: inset 3px 0 var(--danger); }
/* Gruppen (die Positionen eines Sets): Kopfzeile „Teil von …“, darunter eingerückt */
.sortier-tabelle tbody tr.gruppen-kopf { cursor: default; }
.sortier-tabelle tbody tr.gruppen-kopf td, .sortier-tabelle tbody tr.gruppen-kopf:hover td {
  background: var(--surface-2); padding-top: 7px; padding-bottom: 7px; }
.sortier-tabelle tr.in-gruppe td:first-child { padding-left: 30px; }
/* Ganze Zeile hinterlegt: rot = Frist oder dringend, rot-stark = überfällig, gelb = hoch */
.sortier-tabelle tbody tr.rot td { background: #fff1f0; }
.sortier-tabelle tbody tr.rot td.breit b { color: #991b1b; }
.sortier-tabelle tbody tr.rot-stark td { background: #ffe1de; }
.sortier-tabelle tbody tr.rot-stark td.breit b { color: #991b1b; }
.sortier-tabelle tr:is(.rot, .rot-stark) td:first-child { box-shadow: inset 4px 0 var(--danger); }
.sortier-tabelle tbody tr.gelb td { background: #fff8db; }
.sortier-tabelle tbody tr.gelb td:first-child { box-shadow: inset 4px 0 var(--warning); }
.sortier-tabelle tbody tr:is(.rot, .rot-stark, .gelb):hover td { filter: brightness(.97); }
@media (prefers-color-scheme: dark) {
  .sortier-tabelle tbody tr.rot td { background: #2a1414; }
  .sortier-tabelle tbody tr.rot-stark td { background: #3a1616; }
  .sortier-tabelle tr:is(.rot, .rot-stark) td.breit b { color: #fecaca; }
  .sortier-tabelle tbody tr.gelb td { background: #2e2610; }
}
.tabelle-anzahl { display: flex; align-items: center; gap: 8px; min-height: 32px; margin-bottom: 8px; }
.tabelle-anzahl .filter-knopf { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.tabelle-anzahl .filter-knopf svg { width: 16px; height: 16px; }
.tabelle-anzahl .filter-knopf.aktiv { color: var(--primary); font-weight: 600; }
.tabelle-anzahl .filter-knopf[aria-expanded="true"] { background: var(--surface); box-shadow: var(--shadow); }
/* Filter unter den Überschriften – zugeklappt, bis man „Filter“ drückt; ein
   gesetzter Filter ist farbig umrandet. Die Felder bleiben in ihrer Spalte. */
.sortier-tabelle thead tr:has(+ .filter-zeile:not([hidden])) th { border-bottom: 0; }
.sortier-tabelle .filter-zeile th { padding: 3px 6px 8px; }
.sortier-tabelle .filter-zeile :is(select, input) { display: block; box-sizing: border-box; width: 100%;
  min-width: 0; max-width: 100%; min-height: 30px; padding: 3px 6px; font-size: 13px; font-weight: 400;
  border: 1px solid var(--border); border-radius: 8px; background-color: var(--surface); color: var(--text);
  text-overflow: ellipsis; }
/* Platz für den Pfeil, den das allgemeine select-CSS als Hintergrundbild setzt */
.sortier-tabelle .filter-zeile select { padding-right: 24px; background-position: right 6px center; }
.sortier-tabelle .filter-zeile :is(select, input).aktiv { border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary); }
.sortier-tabelle .filter-zeile th:has(select, input) { min-width: 7.5em; }
.sortier-tabelle tr.tabelle-leer td { padding: 24px; text-align: center; color: var(--text-3); cursor: default; }
.sortier-tabelle tbody tr.tabelle-leer:hover td { background: var(--surface); }
/* iOS zoomt in Felder unter 16px hinein */
@media (max-width: 768px) { .sortier-tabelle .filter-zeile :is(select, input) { font-size: 16px; } }
.sortier-tabelle .overdue { color: var(--danger); font-weight: 700; }
.sortier-tabelle .today { color: var(--warning); font-weight: 700; }
.sortier-tabelle .chip { margin-left: 6px; }

/* Auf dem Telefon rollt die Positionstabelle seitlich, statt abgeschnitten zu werden. */
.tabelle-rollt { overflow-x: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); }
.tabelle-rollt table { min-width: 100%; }
@media print { .tabelle-rollt { overflow-x: visible; } }
/* Preislisten: Staffeln als Reihe von Plaketten, Preise rechtsbündig */
.staffeln { display: flex; flex-wrap: wrap; gap: 6px; }
.staffel { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px;
  border: 1px solid var(--border); border-radius: 6px; font-size: 13px; white-space: nowrap; }
.staffel .btn { padding: 0 4px; min-height: 0; line-height: 1.2; }
/* Ein Preis, der gerade nicht gilt – alte oder künftige Laufzeit */
.staffel.alt { opacity: .5; border-style: dashed; }

/* Kategorie an der Aufgabe – die Farbe gehört der Kategorie, nicht der Person */
.chip.kategorie { border-color: var(--kat); color: var(--kat); font-weight: 600; }
.chip.kategorie::before { content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--kat); display: inline-block; margin-right: 5px; }
.wawi-tabelle .rechts { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.preisliste th.rechts { text-align: right; }
.wawi-tabelle tr.still { opacity: .55; }
.beleg-text { margin: 16px 0 0; font-size: 14px; }
.beleg-fuss { margin-top: 22px; padding-top: 8px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-2); }
@media (max-width: 560px) {
  .beleg .ls-kopf { flex-direction: column; }
  .beleg .ls-empfaenger { text-align: left; }
  .beleg-summen { max-width: none; }
}
/* Beim Drucken bleibt nur der Lieferschein stehen. */
@media print {
  body.druckt-lieferschein #sidebar, body.druckt-lieferschein #topbar,
  body.druckt-lieferschein .modal-head, body.druckt-lieferschein .modal-foot,
  body.druckt-lieferschein .toast-root, body.druckt-lieferschein main#view { display: none !important; }
  body.druckt-lieferschein .modal-backdrop { position: static; background: none; padding: 0; display: block; }
  body.druckt-lieferschein .modal { max-width: none; max-height: none; box-shadow: none; border-radius: 0; }
  body.druckt-lieferschein .modal-body { overflow: visible; padding: 0; }
}

/* ---------- KI-Assistent: Wissen durchsehen ---------- */

.wissen-daten { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0 0 14px; font-size: 14px; }
.wissen-daten dt { color: var(--text-2); }
.wissen-daten dd { margin: 0; overflow-wrap: anywhere; }
.wissen-abschnitt { border-top: 1px solid var(--border); padding: 6px 0; }
.wissen-abschnitt summary { cursor: pointer; color: var(--text-2); font-size: 13px; }
.wissen-text { margin-top: 6px; font-size: 14px; max-height: 320px; overflow-y: auto; }
.wissen-text table { border-collapse: collapse; }
.wissen-text th, .wissen-text td { border: 1px solid var(--border); padding: 4px 8px; }

/* ---------- KI-Assistent (Chat) ---------- */
/* Genau fensterhoch – NICHT flex: 1: das setzt die Höhe außer Kraft, der Chat wüchse mit seinem
   Inhalt, und statt des Verlaufs scrollte die ganze Seite (Mausrad im Chat ohne Wirkung). */
.ki-chat { flex: 0 0 auto; display: flex; min-height: 0;
  height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top, 0px)); }
.ki-haupt { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
/* Die Chats links – wie bei Claude; auf schmalen Geräten über den Knopf „Chats“ */
.ki-chats { width: 250px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; padding: 12px;
  border-right: 1px solid var(--border); background: var(--surface); overflow-y: auto; }
.ki-chatliste { display: flex; flex-direction: column; gap: 2px; }
.ki-chat-eintrag { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%;
  padding: 8px 10px; border: none; border-radius: 8px; background: none; color: inherit; font: inherit;
  text-align: left; cursor: pointer; }
.ki-chat-eintrag .t { font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.ki-chat-eintrag:hover { background: var(--surface-2); }
.ki-chat-eintrag.aktiv { background: var(--primary-soft); font-weight: 600; }
.ki-titel { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Mit Vorrang vor .btn, das weiter unten steht */
.ki-kopf .ki-chats-knopf { display: none; }
@media (max-width: 899px) {
  .ki-chats { display: none; }
  .ki-kopf .ki-chats-knopf { display: inline-flex; }
}
.ki-komprimiert { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 8px 10px;
  border-radius: 8px; background: var(--surface-2); border-left: 3px solid var(--warning); color: var(--text); font-size: 13px; line-height: 1.35; }
.ki-komprimiert svg { flex-shrink: 0; width: 16px; height: 16px; }
.ki-komprimiert span { flex: 1; }
.ki-komprimiert[hidden] { display: none; }
.ki-kopf { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; padding: 6px 12px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.ki-hinweis { flex-basis: 100%; display: flex; align-items: center; gap: 6px; min-width: 0;
  color: var(--text-3); font-size: 12px; line-height: 1.3; }
.ki-hinweis svg { flex-shrink: 0; }
.ki-kopf-aktionen { display: flex; gap: 4px; flex-shrink: 0; margin-left: auto; }
.ki-verlauf { flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 12px 8px; display: flex; flex-direction: column; gap: 14px; }
.ki-leer { max-width: 560px; margin: auto; text-align: center; color: var(--text-2); }
.ki-leer p { margin: 0 0 8px; }

.ki-nachricht { display: flex; }
.ki-nachricht.user { justify-content: flex-end; }
.ki-blase { max-width: min(760px, 88%); padding: 10px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  overflow-wrap: anywhere; }
.ki-nachricht.user .ki-blase { background: var(--primary-soft); border-color: transparent; box-shadow: none; }
.ki-blase > :first-child { margin-top: 0; }
.ki-blase > :last-child { margin-bottom: 0; }
.ki-blase p { margin: 0 0 .6em; }
.ki-blase .wiki-h { margin: .8em 0 .4em; font-size: 1.05em; }
.ki-blase pre { background: var(--surface-2); padding: 8px 10px; border-radius: 8px; overflow-x: auto; }
.ki-blase table { border-collapse: collapse; font-size: 14px; }
.ki-blase th, .ki-blase td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
/* Die Blase bricht lange Wörter überall um – in einer Tabelle quetschte das jede Spalte auf
   wenige Buchstaben. Dort bleiben Wörter ganz, und .wiki-tabelle scrollt seitlich. */
.ki-blase .wiki-tabelle { max-width: 100%; }
.ki-blase .wiki-tabelle td, .ki-blase .wiki-tabelle th { overflow-wrap: normal; word-break: normal; }
.ki-blase .wiki-tabelle th { white-space: nowrap; }

.ki-bild { max-width: 100%; border-radius: 8px; margin-top: 8px; display: block; }
.ki-video { max-width: 100%; border-radius: 8px; margin-top: 8px; display: block; }
.ki-mitgeschickt { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.ki-quellen { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 6px; }
.ki-quellen summary { cursor: pointer; color: var(--text-2); font-size: 13px; font-weight: 500; }
.ki-quelle { margin-top: 8px; }
.ki-quelle-kopf { color: var(--text-2); font-size: 12px; }
.ki-quelle-text { margin: 2px 0 0; padding: 6px 8px; background: var(--surface-2); border-radius: 6px;
  font-size: 12px; white-space: pre-wrap; max-height: 160px; overflow-y: auto; }

.ki-status { width: min(760px, 88%); }
.ki-status-kopf { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.ki-status-zeilen { margin-top: 6px; font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.ki-status-ergebnis { color: var(--text-2); font-size: 12px; padding-left: 10px; }
.ki-nicht-warten { margin-top: 8px; }
.ki-nicht-warten[hidden] { display: none; }
/* Nur für Vorleseprogramme: Status und Antwort werden hier angesagt, nicht der ganze Verlauf */
.ki-ansage { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.ki-spinner { width: 14px; height: 14px; flex-shrink: 0; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--primary); animation: ki-dreh .8s linear infinite; }
@keyframes ki-dreh { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ki-spinner { animation-duration: 3s; } }

.ki-fuss { border-top: 1px solid var(--border); background: var(--surface);
  padding: 8px 12px calc(8px + var(--safe-bottom)); }
.ki-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ki-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 3px 8px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border); font-size: 12px; overflow-wrap: anywhere; }
.ki-chip .ki-spinner { width: 12px; height: 12px; }
/* Sichtbar klein, zum Tippen groß genug: die unsichtbare Fläche reicht auf 44px Höhe */
.ki-chip-weg { position: relative; border: none; background: none; color: var(--text-2); cursor: pointer;
  padding: 2px 4px; font: inherit; font-size: 12px; font-weight: 600; line-height: 1.2; text-decoration: underline; }
.ki-chip-weg::after { content: ''; position: absolute; inset: -14px -4px; }
.ki-chip-weg:hover { color: var(--danger); }
.ki-zeile { display: flex; align-items: flex-end; gap: 8px; }
.ki-zeile textarea { flex: 1; resize: none; height: 42px; min-height: 42px; max-height: 160px;
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 21px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px; line-height: 1.5; }
.ki-zeile textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.ki-zeile .btn-icon { flex-shrink: 0; border-radius: 50%; width: 42px; height: 42px; padding: 0; }
/* Spracheingabe: während der Aufnahme rot mit laufender Zeit, beim Abschreiben mit Kreisel */
.ki-zeile .ki-mikro.ki-mikro-breit { width: auto; min-width: 42px; padding: 0 12px; border-radius: 21px;
  gap: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ki-zeile .ki-mikro.ki-mikro-an { background: var(--danger); border-color: var(--danger); color: #fff; }
.ki-mikro-punkt { animation: ki-blinken 1s steps(2, start) infinite; }
@keyframes ki-blinken { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .ki-mikro-punkt { animation: none; } }
@media (max-width: 480px) { .ki-mikro-text { display: none; } }
@media (max-width: 480px) {
  /* Auf dem Telefon nimmt der Hinweis die ganze Breite, sonst drängt ihn der
     Knopf auf fünf Zeilen zusammen. */
  .ki-hinweis { font-size: 11px; }
}

/* ---------- Buttons & Forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn-icon { width: 40px; padding: 0; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); }
.input, input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]):not([type=range]), select, textarea {
  width: 100%; min-height: 42px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 16px; /* 16px verhindert Zoom auf iOS */
}
textarea { min-height: 90px; resize: vertical; }
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236b5f57' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 12px 8px;
}
select:disabled { opacity: .6; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
input[type=color] { width: 48px; height: 42px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; font-weight: 500; }
.check input { width: 20px; height: 20px; flex: 0 0 20px; margin: 0; accent-color: var(--primary); }
.weekday-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.weekday-picker label {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); cursor: pointer; font-weight: 600; font-size: 13px; user-select: none;
}
.weekday-picker input { display: none; }
.weekday-picker input:checked + span { color: #fff; }
.weekday-picker label:has(input:checked) { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Cards, chips, misc ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar select, .toolbar input { min-height: 40px; font-size: 14px; width: auto; }
/* Unter 16px zoomt iOS beim Antippen in die Seite */
@media (max-width: 767px) { .toolbar select, .toolbar input { font-size: 16px; } }
.toolbar .grow { flex: 1; min-width: 140px; }
/* Der Anlegen-Knopf sitzt am Ende der Werkzeugleiste, auf Höhe der Felder */
.toolbar .tb-aktion { margin-left: auto; align-self: flex-end; }
@media (max-width: 560px) { .toolbar .tb-aktion { grid-column: 1 / -1; margin-left: 0; } }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.empty { text-align: center; color: var(--text-3); padding: 40px 16px; }
.stack > * + * { margin-top: 8px; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.segmented button { border: none; background: transparent; padding: 8px 12px; min-height: 38px; cursor: pointer; color: var(--text-2); font-weight: 500; }
.segmented button.active { background: var(--primary); color: #fff; }
.pill-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; overflow-x: auto; }
.pill-tabs button { border: none; background: none; padding: 10px 12px; cursor: pointer; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.pill-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Task list ---------- */




.prio { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 4px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.prio-1 { background: #e2e8f0; color: #475569; }
.prio-2 { background: #dbeafe; color: #1d4ed8; }
.prio-3 { background: #fef3c7; color: #b45309; }
.prio-4 { background: #fee2e2; color: #b91c1c; }
@media (prefers-color-scheme: dark) {

  

  
  .prio-1 { background: #253248; color: #a9b7cc; }
  .prio-2 { background: #1e3a8a; color: #bfdbfe; }
  .prio-3 { background: #78350f; color: #fde68a; }
  .prio-4 { background: #7f1d1d; color: #fecaca; }
}

/* ---------- Startseite „Dashboard“ ---------- */
.heute-kopf h1 { margin: 0; font-size: 1.4rem; }
.heute-raster { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; align-items: start; }
.heute-karte h2 { margin: 0 0 10px; font-size: 1.05rem; }
@media (max-width: 767px) { .heute-raster { grid-template-columns: 1fr; } }
.heute-status { margin: 0 0 10px; }
.heute-knoepfe { display: flex; gap: 8px; flex-wrap: wrap; }
.heute-liste { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.heute-liste a { color: inherit; text-decoration: none; display: flex; gap: 10px; align-items: baseline; }
.heute-liste a:hover { color: var(--primary); }
.heute-zahl { font-size: 1.3rem; min-width: 2ch; text-align: right; }
.heute-hinweis { margin: 8px 0; }

/* ---------- Calendar ---------- */
.cal-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
/* „+ Neuer Termin" rechts, damit es nicht zwischen den Blätter-Pfeilen klebt */
.cal-toolbar #neuer-termin { margin-left: auto; }
.cal-toolbar .cal-title { font-weight: 700; font-size: 1.1rem; flex: 1; min-width: 150px; text-transform: capitalize; }
.cal-filter { position: relative; }
.cal-filter-panel {
  position: absolute; right: 0; top: 44px; z-index: 15; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 12px; min-width: 240px;
}
.cal-filter-panel .check { min-height: 36px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-left: 1px solid var(--border); border-top: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.cal-head { padding: 6px 4px; text-align: center; font-size: 12px; font-weight: 700; color: var(--text-2); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal-day { min-height: 110px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.cal-day.other { background: var(--surface-2); color: var(--text-3); }
.cal-day.today .daynum { background: var(--primary); color: #fff; }
.cal-day.weekend { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.cal-day .daynum { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.cal-day .more { font-size: 11px; color: var(--text-2); padding: 0 4px; }
.ev {
  font-size: 12px; padding: 2px 6px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: #fff; cursor: pointer; line-height: 1.35; border-left: 3px solid transparent;
}
.ev.foreign { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left-width: 4px; }
.ev.task-ev { background: transparent; color: var(--text); border: 1px dashed var(--text-3); }
.ev.task-ev.done { text-decoration: line-through; opacity: .6; }
.ev .t { opacity: .85; font-weight: 600; margin-right: 3px; }
.ev.cont { border-top-left-radius: 0; border-bottom-left-radius: 0; opacity: .85; }
.cal-dots { display: flex; gap: 2px; flex-wrap: wrap; }
.cal-dots .dot { width: 6px; height: 6px; }
@media (max-width: 767px) {
  .cal-day { min-height: 64px; padding: 2px; }
  .cal-day .ev { display: none; }
  .cal-day .more { display: none; }
}
@media (min-width: 768px) { .cal-dots { display: none; } }

.agenda-day { margin-bottom: 14px; }
.agenda-day h3 { display: flex; align-items: baseline; gap: 8px; font-size: .95rem; margin: 0 0 6px; }
.agenda-day h3 .muted { font-weight: 500; }
.agenda-day.today h3 { color: var(--primary); }
.agenda-ev { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; margin-bottom: 6px; }
.agenda-ev .bar { width: 5px; border-radius: 3px; align-self: stretch; flex-shrink: 0; }
.agenda-ev .time { width: 82px; font-size: 13px; color: var(--text-2); flex-shrink: 0; }
.agenda-ev .name { font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.agenda-ev .who { font-size: 12px; color: var(--text-2); }
.agenda-ev.done .name { text-decoration: line-through; color: var(--text-3); }

.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; min-height: 200px; }
.week-col h4 { margin: 0 0 6px; font-size: 13px; text-align: center; }
.week-col.today h4 { color: var(--primary); }
.week-col .ev { white-space: normal; margin-bottom: 4px; }
@media (max-width: 767px) { .week-grid { grid-template-columns: 1fr !important; } .week-col { min-height: auto; } }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 640px; max-height: calc(100vh - 32px);
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
}
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { flex: 1; margin: 0; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; }
.modal-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-foot .spacer, .toolbar .spacer { flex: 1; }
.modal.sm { max-width: 420px; }
.modal.lg { max-width: 860px; }
.modal.xl { max-width: 1100px; }
@media (max-width: 767px) {
  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal { max-width: none; max-height: none; border-radius: 0; height: 100%; }
  .modal-head { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .modal-body { padding: 14px; }
  .modal-foot { padding-bottom: calc(12px + var(--safe-bottom)); }
  /* kleine Dialoge (Auswahl, Bestätigung) als Bottom-Sheet – Tippen daneben schließt */
  .modal-backdrop:has(.modal.sm) { align-items: flex-end; }
  .modal.sm { height: auto; max-height: 85vh; border-radius: 16px 16px 0 0; }
  .modal.sm .modal-head { padding-top: 14px; }
  .modal.sm .modal-foot { padding-bottom: calc(12px + var(--safe-bottom)); }
  .sb-foot { padding-bottom: calc(10px + var(--safe-bottom)); }
}

/* ---------- Comments & history ---------- */
.comment { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.comment .c-body { flex: 1; min-width: 0; }
.comment .c-head { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.comment .c-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.hist { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; display: flex; gap: 10px; }
.hist .when { color: var(--text-3); width: 120px; flex-shrink: 0; }
.hist .what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.hist .what b { font-weight: 600; }
.hist .val { background: var(--surface-2); padding: 0 4px; border-radius: 3px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-bottom) + 76px); z-index: 100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
@media (min-width: 768px) { #toast-root { bottom: 24px; } }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); font-weight: 500; animation: toast-in .2s ease; max-width: min(90vw, 460px); line-height: 1.45; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { justify-content: center; margin-bottom: 16px; font-size: 1.4rem; }

/* ---------- Admin tables ---------- */
.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row .grow { flex: 1; min-width: 0; }

/* Sortierbare Liste: zwei Pfeile, dazu Ziehen mit der Maus */
.sort-knoepfe { display: flex; flex-direction: column; gap: 2px; flex: none; }
.sort-knoepfe .btn { padding: 0 6px; line-height: 1.3; min-height: 0; font-size: 13px; }
.sort-knoepfe .btn:disabled { opacity: .25; cursor: default; }
.sortierbar { cursor: grab; }
.sortierbar:active { cursor: grabbing; }
.sortierbar.zieht { opacity: .4; }
.sortierbar.ueber { background: var(--surface-2); }
.rang-nr { flex: none; width: 22px; text-align: right; color: var(--text-2);
  font-variant-numeric: tabular-nums; font-size: 13px; }
/* Auf dem Telefon zieht sich schlecht – da bleiben die Pfeile der Weg */
@media (hover: none) { .sortierbar { cursor: default; } }
.list-row .sub { font-size: 12px; color: var(--text-3); }

.badge { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; background: var(--primary-soft); color: var(--primary); text-transform: uppercase; }

/* ---------- Abhängigkeiten & Anhänge ---------- */
.dep-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; min-height: 24px; }
.dep-chip { background: var(--danger-soft); color: var(--danger); padding-right: 4px; }
.dep-chip.done { background: var(--surface-2); color: var(--text-2); }
.dep-chip button { border: none; background: transparent; color: inherit; cursor: pointer; padding: 0 4px; font-size: 12px; min-height: 22px; }

.blocked-chip { background: var(--danger-soft); color: var(--danger); white-space: normal; }

/* ---------- Rechte-Matrix ---------- */
.perm-matrix { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.perm-module { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; background: var(--surface-2); }
.perm-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.perm-module .perm { min-height: 34px; align-items: flex-start; padding: 4px 0; }
.perm-module .perm input { margin-top: 3px; }
.perm-module .perm small { font-weight: 400; }
.cal-toolbar select { width: auto; min-height: 40px; font-size: 14px; max-width: 240px; }
@media (max-width: 767px) { .cal-toolbar select { font-size: 16px; } }
.cal-toolbar .check.small { font-size: 13px; }

/* ---------- Schnellzugriff: laufende Termine ---------- */
#now-banner:not(:empty) { margin-bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.now-item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--warning); border-radius: var(--radius); }
.now-item.running { border-left-color: var(--success); }
.now-state { font-size: 12px; font-weight: 700; color: var(--warning); white-space: nowrap; }
.now-item.running .now-state { color: var(--success); }
.now-title { flex: 1; min-width: 140px; font-weight: 600; cursor: pointer; }

/* ---------- Beschriftete Filterleiste ---------- */
.toolbar { align-items: flex-end; }
.tb-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tb-field > span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); padding-left: 2px; }
.tb-field select, .tb-field input { width: 100%; }
.toolbar .tb-field.grow { flex: 1 1 200px; }
@media (max-width: 767px) {
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar .tb-field.grow { grid-column: 1 / -1; }
}

/* ---------- Skripte ---------- */

.script-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.run-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); cursor: pointer; margin-bottom: 6px; }
.run-line:hover { filter: brightness(.97); }
.run-badge { font-weight: 700; font-size: 13px; white-space: nowrap; }
.run-running .run-badge { color: var(--warning); }
.run-success .run-badge { color: var(--success); }
.run-failed .run-badge { color: var(--danger); }
.run-cancelled .run-badge { color: var(--text-2); }
.run-status { font-weight: 600; margin: 8px 0 4px; }
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin: 6px 0; }
.progress > div { height: 100%; background: var(--primary); transition: width .4s ease; }
.progress.big { height: 10px; border-radius: 5px; }
pre.log { background: #1b1613; color: #e9dfd6; padding: 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.45; max-height: 50vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 12px 0 0; min-height: 120px; }
.result-box { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.result-table { border-collapse: collapse; margin-top: 4px; font-size: 14px; }
.result-table th { text-align: left; padding: 2px 12px 2px 0; font-weight: 600; color: var(--text-2); vertical-align: top; }
.result-table td { padding: 2px 0; }
.hint-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin-top: 4px; }
.hint-box summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.hint-box pre { background: var(--surface); padding: 8px; border-radius: 6px; overflow-x: auto; }
@media (max-width: 767px) { pre.log { max-height: 45vh; } }

/* ---------- Hinweise / PWA ---------- */
.notice { padding: 10px 12px; border-radius: 8px; background: var(--primary-soft); color: var(--text); margin-bottom: 10px; font-size: 14px; }
.notice.ok { background: #dcfce7; color: #166534; }
@media (prefers-color-scheme: dark) { .notice.ok { background: #14532d; color: #bbf7d0; } }
/* Als installierte App: Statusleiste oben respektieren */

/* ---------- iOS Safari: Datums-/Zeitfelder respektieren sonst keine Breite ---------- */
input[type=date], input[type=time], input[type=datetime-local] {
  -webkit-appearance: none; appearance: none;
  min-width: 0; max-width: 100%; display: block;
  -webkit-min-logical-width: 0;
}
input[type=date]::-webkit-date-and-time-value, input[type=time]::-webkit-date-and-time-value { text-align: left; min-height: 1.4em; }
.row > .field { min-width: 0; }
.field input, .field select, .field textarea { max-width: 100%; }
.modal { overflow: hidden; }
.modal-body { overflow-x: hidden; }
.weekday-picker { max-width: 100%; }
@media (max-width: 767px) { html, body { overflow-x: hidden; } }

/* ======================= Animationen ======================= */
:root {
  --ease-out: cubic-bezier(.22, 1, .36, 1);        /* weiches Auslaufen (iOS-typisch) */
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);   /* leichtes Überschwingen */
  --dur-fast: .18s; --dur: .28s; --dur-slow: .42s;
}

/* Seitenwechsel: Inhalt gleitet sanft herein */
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
/* Der Seitenbehälter (app.js) erzeugt keinen eigenen Kasten – Layout und Abstände bleiben wie ohne ihn */
main#view > .seite { display: contents; }
main#view.view-enter > .seite > * { animation: view-in var(--dur-slow) var(--ease-out) both; }

/* Listen: Einträge erscheinen leicht versetzt */
@keyframes row-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.agenda-ev, .list-row, .week-col { animation: row-in var(--dur) var(--ease-out) both; }
.agenda-ev:nth-child(2) { animation-delay: .03s; }
.agenda-ev:nth-child(3) { animation-delay: .06s; }
.agenda-ev:nth-child(4) { animation-delay: .09s; }
.agenda-ev:nth-child(5) { animation-delay: .12s; }
.agenda-ev:nth-child(n+6) { animation-delay: .15s; }

/* Karten & Chips reagieren auf Berührung */
.agenda-ev, .ev, .run-line, .stat { transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), opacity var(--dur); }
.agenda-ev:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.agenda-ev:active, .run-line:active { transform: scale(.985); box-shadow: none; }
.ev:hover { transform: translateY(-1px); filter: brightness(1.05); }

/* Knöpfe: kurzes Eindrücken */
.btn, .fab, .sb-nav a { transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast), color var(--dur-fast), opacity var(--dur-fast), box-shadow var(--dur-fast); }
.btn:active:not(:disabled) { transform: scale(.96); }
.fab:active { transform: scale(.92); }
.fab:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(43,35,32,.28); }

/* Dialoge: Desktop skaliert aus der Mitte, Handy schiebt von rechts bzw. Bottom-Sheet von unten */
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes modal-out { to { opacity: 0; transform: translateY(10px) scale(.97); } }
.modal-backdrop { animation: backdrop-in var(--dur) ease both; }
.modal { animation: modal-in var(--dur-slow) var(--ease-out) both; transform-origin: center; }
.modal-backdrop.closing { animation: backdrop-in var(--dur-fast) ease reverse forwards; }
.modal-backdrop.closing .modal { animation: modal-out var(--dur-fast) ease-in forwards; }
@media (max-width: 767px) {
  @keyframes modal-in-right { from { transform: translateX(100%); } to { transform: none; } }
  @keyframes modal-out-right { to { transform: translateX(100%); } }
  @keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
  @keyframes sheet-out { to { transform: translateY(100%); } }
  .modal { animation: modal-in-right var(--dur-slow) var(--ease-out) both; }
  .modal-backdrop.closing .modal { animation: modal-out-right var(--dur) ease-in forwards; }
  .modal.sm { animation: sheet-in var(--dur-slow) var(--ease-out) both; }
  .modal-backdrop.closing .modal.sm { animation: sheet-out var(--dur) ease-in forwards; }
}

/* Drawer-Hintergrund weich einblenden */
.sb-backdrop { animation: backdrop-in var(--dur) ease both; }

/* Toasts gleiten herein und wieder hinaus */
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.96); } }
.toast { animation: toast-in var(--dur) var(--ease-spring) both; }
.toast.hide { animation: toast-out var(--dur-fast) ease-in forwards; }

/* Tabs, Fortschritt, Kalender-Navigation */
.pill-tabs button { transition: color var(--dur-fast), border-color var(--dur-fast); }
.progress > div { transition: width .6s var(--ease-out); }
@keyframes cal-in { from { opacity: 0; transform: translateX(var(--cal-dir, 12px)); } to { opacity: 1; transform: none; } }
#cal-body.cal-enter > * { animation: cal-in var(--dur) var(--ease-out) both; }
.now-item { animation: row-in var(--dur-slow) var(--ease-out) both; }
.check input { transition: transform var(--dur-fast) var(--ease-spring); }
.check input:active { transform: scale(.85); }
.weekday-picker label { transition: background var(--dur-fast), color var(--dur-fast), transform var(--dur-fast) var(--ease-spring); }
.weekday-picker label:active { transform: scale(.9); }

/* Nach dem Ablauf wird die Animation per JS entfernt (siehe app.js), damit Safari Text wieder scharf zeichnet */
.anim-done { animation: none !important; }

/* Wer Bewegung reduziert haben möchte, bekommt keine */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}

/* ---------- Dienstplan ---------- */
.wochen-nav { display: inline-flex; gap: 4px; }
.wochen-nav .btn { min-height: 42px; }
.w-titel { display: inline-flex; align-items: center; min-height: 42px; font-weight: 700; }
.plan-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.plan-grid {
  display: grid; grid-template-columns: minmax(160px, 1.4fr) repeat(7, minmax(78px, 1fr)) minmax(70px, .7fr);
  min-width: 760px;
  border-left: 1px solid var(--border); border-top: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; background: var(--surface);
}
.plan-zelle { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 5px; min-height: 62px; display: flex; flex-direction: column; gap: 4px; }
.plan-kopf { background: var(--surface-2); font-weight: 700; font-size: 12px; min-height: 0; padding: 7px 5px; align-items: center; justify-content: center; text-align: center; }
.plan-kopf.heute { color: var(--primary); }
/* Namen linksbündig, damit ein umbrechender Name nicht aus der Spalte rutscht */
.plan-name { justify-content: flex-start; font-weight: 600; font-size: 14px; flex-direction: row; align-items: center; gap: 7px; background: var(--surface-2); }
.plan-name .avatar { flex: 0 0 auto; }
.plan-name .nm { min-width: 0; line-height: 1.25; overflow-wrap: break-word; }
.plan-name.offen { color: var(--text-2); }
.plan-summe { justify-content: center; align-items: center; text-align: center; font-size: 13px; background: var(--surface-2); }
.plan-zelle.heute { background: color-mix(in srgb, var(--primary-soft) 30%, transparent); }
.plan-zelle[data-tag]:hover { background: color-mix(in srgb, var(--primary-soft) 55%, transparent); cursor: pointer; }
.plan-zelle.verf-nicht_verfuegbar { background: repeating-linear-gradient(45deg, transparent, transparent 5px, var(--border) 5px, var(--border) 7px); }
.plan-zelle.verf-bevorzugt { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--success) 45%, transparent); }
.schicht {
  background: var(--f); color: #fff; border-radius: 7px; padding: 3px 6px; font-size: 11.5px; line-height: 1.3;
  cursor: pointer; display: flex; flex-direction: column; position: relative;
}
.schicht .z { font-weight: 700; white-space: nowrap; }
.schicht .t { opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schicht.entwurf { background: transparent; color: var(--text); border: 1px dashed var(--f); }
.schicht.offen { background: transparent; color: var(--text); border: 2px dashed var(--primary); }
.schicht .tausch { position: absolute; top: 2px; right: 3px; font-size: 12px; display: inline-flex; }
.verf-chip.nicht_verfuegbar { background: var(--danger-soft); color: var(--danger); }
.verf-chip.bevorzugt { background: #dcfce7; color: #166534; }
@media (prefers-color-scheme: dark) { .verf-chip.bevorzugt { background: #14532d; color: #bbf7d0; } }
@media (max-width: 1000px) and (min-width: 768px) { .plan-grid { font-size: 12px; } .plan-zelle { padding: 3px; } .schicht { font-size: 11px; padding: 2px 4px; } }

/* ---------- Zeiterfassung ---------- */
.stempel-karte { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 14px 16px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--text-3); border-radius: var(--radius); box-shadow: var(--shadow); }
.stempel-karte.laeuft { border-left-color: var(--success); }
.stempel-karte.pause { border-left-color: var(--warning); }
.stempel-info { flex: 1; min-width: 180px; }
.stempel-status { font-weight: 700; font-size: 13px; color: var(--text-2); }
.stempel-karte.laeuft .stempel-status { color: var(--success); }
.stempel-karte.pause .stempel-status { color: var(--warning); }
.stempel-uhr { font-size: 2rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stempel-knoepfe { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-stempel { min-height: 52px; padding: 0 22px; font-size: 16px; font-weight: 700; }

.chip.plus { background: #dcfce7; color: #166534; }
.chip.minus { background: var(--danger-soft); color: var(--danger); }
@media (prefers-color-scheme: dark) { .chip.plus { background: #14532d; color: #bbf7d0; } }
.status-chip.erfasst { background: #fef3c7; color: #b45309; }
.status-chip.genehmigt { background: #dcfce7; color: #166534; }
.status-chip.abgelehnt { background: var(--danger-soft); color: var(--danger); }
.status-chip.laufend { background: var(--primary-soft); color: var(--primary); }
@media (prefers-color-scheme: dark) { .status-chip.genehmigt { background: #14532d; color: #bbf7d0; } .status-chip.erfasst { background: #78350f; color: #fde68a; } }

.kiosk { text-align: center; }
.kiosk-anzeige { font-size: 17px; font-weight: 600; min-height: 56px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); border-radius: 10px; padding: 8px; }
.kiosk-anzeige.ok { background: #dcfce7; color: #166534; }
.kiosk-anzeige.fehler { background: var(--danger-soft); color: var(--danger); }
.kiosk-pin { font-size: 28px; letter-spacing: 8px; min-height: 40px; font-weight: 700; }
.kiosk-tasten { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 280px; margin: 0 auto 12px; }
.kiosk-tasten .btn { min-height: 56px; font-size: 20px; font-weight: 700; }

/* ---------- Abwesenheit ---------- */
.urlaub-karte .card-body { padding: 14px 16px; }
.urlaub-rest { font-size: 1.15rem; color: var(--primary); }
.urlaub-werte { display: flex; gap: 20px; margin-top: 8px; }
.abw-grid .plan-zelle { min-height: 34px; padding: 2px; }
.abw-grid .plan-kopf { font-size: 10px; line-height: 1.1; padding: 3px 1px; }
.abw-grid .plan-kopf.weekend, .abw-tag.weekend { background: var(--surface-2); }
.abw-grid .plan-kopf.feiertag { background: var(--primary-soft); color: var(--primary); }
.abw-tag.hat-abw { background: var(--f); cursor: pointer; }
.abw-tag.hat-abw.beantragt { background: repeating-linear-gradient(45deg, var(--f), var(--f) 4px, transparent 4px, transparent 8px); }
.abw-tag.hat-abw.abgelehnt { background: none; }

/* ---------- Dienstplan: Abwesenheit, Warnungen, Kosten ---------- */
.plan-zelle.hat-abwesenheit { background: color-mix(in srgb, var(--abw) 14%, transparent); }
.abw-marke { font-size: 10px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.abw-marke.beantragt { opacity: .6; font-style: italic; }
.schicht .warnung { position: absolute; bottom: 1px; right: 3px; font-size: 11px; color: #b45309; }
.schicht:not(.entwurf):not(.offen) .warnung { color: #fde68a; }
.plan-summe .kosten { font-size: 12px; font-weight: 700; color: var(--text-2); }
.notice.warnung-box { background: #fef3c7; color: #78350f; }
@media (prefers-color-scheme: dark) { .notice.warnung-box { background: #78350f; color: #fde68a; } }
.plan-kopf.feiertag { background: var(--primary-soft); color: var(--primary); }
.plan-kopf.sonntag { color: var(--danger); }
.plan-kopf .fei-name { font-size: 9px; font-weight: 600; display: block; line-height: 1.1; }
.plan-zelle.ist-feiertag { background: color-mix(in srgb, var(--primary-soft) 40%, transparent); }
.warn-chip { background: #fef3c7; color: #b45309; }
@media (prefers-color-scheme: dark) { .warn-chip { background: #78350f; color: #fde68a; } }

/* ---------- Personalakte ---------- */
.akte-zeile { display: flex; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.akte-zeile > span:first-child { flex: 0 0 150px; }
.akte-zeile > span:last-child { flex: 1; overflow-wrap: anywhere; }
@media (max-width: 767px) { .akte-zeile { flex-direction: column; gap: 0; } .akte-zeile > span:first-child { flex: none; font-size: 12px; } }
.ev.abwesend-ev { background: color-mix(in srgb, var(--f) 22%, transparent); color: var(--text); border: 1px solid var(--f); border-left-width: 4px; }
.ev.abwesend-ev.beantragt { background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--f) 20%, transparent), color-mix(in srgb, var(--f) 20%, transparent) 4px, transparent 4px, transparent 8px); font-style: italic; }
.ev.privat-ev { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 5px, var(--border) 5px, var(--border) 7px); color: var(--text-2); border: 1px solid var(--border); border-left-width: 4px; }
.rsvp-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; background: var(--primary-soft); border-radius: 8px; margin-bottom: 12px; font-weight: 600; font-size: 14px; }
.ev.google-ev { background: var(--surface-2); color: var(--text-2); border: 1px dashed var(--border); border-left: 3px solid var(--f, #94a3b8); }
.profil-kopf { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }

/* Passwort-Richtlinie: Live-Hinweise unter dem Feld */
.pw-checks { list-style: none; padding: 0; margin: 6px 0 0; font-size: 13px; }
.pw-checks li { padding: 1px 0; }
.pw-checks li.ok { color: #16a34a; }
.pw-checks li.bad { color: #dc2626; }

/* ---------- Wiki ---------- */
.wiki-layout { display: grid; grid-template-columns: 250px 1fr; gap: 18px; align-items: start; }
.wiki-seitenleiste { position: sticky; top: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.wiki-baum { max-height: 55vh; overflow: auto; margin: 6px 0 10px; font-size: 14px; }
.wiki-zweig { }
.wiki-knoten { display: flex; align-items: center; gap: 2px; padding-left: calc(var(--t) * 12px); border-radius: 6px; }
.wiki-knoten:hover { background: var(--surface-2); }
.wiki-knoten.aktiv { background: var(--primary-soft); }
.wiki-knoten a, .wiki-nurordner { padding: 4px 4px; overflow-wrap: anywhere; }
.wiki-nurordner { color: var(--text-3); }
.wiki-klapp { width: 18px; height: 18px; flex: 0 0 18px; border: 0; background: transparent; color: var(--text-3); cursor: pointer; padding: 0; font-size: 11px; }
.wiki-klapp.leer { cursor: default; }
.wiki-werkzeuge { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border); padding-top: 10px; }
.wiki-treffer { display: block; padding: 7px 6px; border-radius: 7px; }
.wiki-treffer:hover { background: var(--surface-2); }
.wiki-treffer span { display: block; }
.wiki-inhalt { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px 24px; }
.wiki-kopf { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.wiki-pfad { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.wiki-trenner { color: var(--text-3); }
.wiki-aktionen { display: flex; gap: 6px; flex-wrap: wrap; }
.wiki-titel { margin: 4px 0 2px; font-size: 26px; }
.wiki-meta { margin-bottom: 12px; }
.wiki-toc { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 16px; font-size: 14px; }
.wiki-toc ol { list-style: none; margin: 6px 0 0; padding: 0; }
.wiki-toc li.s2 { padding-left: 14px; }
.wiki-toc li.s3 { padding-left: 28px; }
.wiki-toc li.s4 { padding-left: 42px; }
.wiki-toc a { display: block; padding: 2px 0; }

.wiki-text { line-height: 1.65; overflow-wrap: anywhere; }
.wiki-text h2, .wiki-text h3, .wiki-text h4, .wiki-text h5 { margin: 22px 0 8px; line-height: 1.3; }
.wiki-text h2 { font-size: 22px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.wiki-text h3 { font-size: 18px; }
.wiki-text h4, .wiki-text h5 { font-size: 16px; }
.wiki-text p { margin: 10px 0; }
.wiki-text ul, .wiki-text ol { margin: 8px 0 8px 22px; }
.wiki-text li { margin: 3px 0; }
.wiki-text blockquote { margin: 12px 0; padding: 6px 14px; border-left: 3px solid var(--primary); background: var(--surface-2); border-radius: 0 7px 7px 0; }
.wiki-text pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; overflow-x: auto; }
.wiki-text code { background: var(--surface-2); border-radius: 4px; padding: 1px 5px; font-size: 13px; }
.wiki-text pre code { background: transparent; padding: 0; }
.wiki-text hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.wiki-anker { opacity: 0; margin-left: 8px; color: var(--text-3); font-size: 14px; text-decoration: none; }
.wiki-h:hover .wiki-anker { opacity: 1; }
.wiki-text a.wiki-neu { color: var(--danger); border-bottom: 1px dotted var(--danger); }
.wiki-fehlt { color: var(--danger); font-size: 13px; }
.wiki-box { display: inline-block; width: 15px; height: 15px; border: 2px solid var(--text-3); border-radius: 4px; vertical-align: -2px; text-align: center; line-height: 12px; font-size: 11px; }
.wiki-box.an { background: var(--success); border-color: var(--success); color: #fff; }
.wiki-tabelle { overflow-x: auto; margin: 12px 0; }
.wiki-tabelle table { border-collapse: collapse; min-width: 320px; }
.wiki-tabelle th, .wiki-tabelle td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.wiki-tabelle th { background: var(--surface-2); }
.wiki-bild { margin: 14px 0; }
.wiki-bild img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.wiki-bild figcaption { font-size: 13px; color: var(--text-2); margin-top: 4px; }

.wiki-dateien, .wiki-hierher { margin-top: 26px; border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.wiki-dateien h3, .wiki-hierher h3 { width: 100%; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); margin: 0; }
.wiki-datei-bild img { height: 84px; width: auto; border-radius: 7px; border: 1px solid var(--border); }

.wiki-editor-leiste { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.wiki-editor-flaeche { display: grid; grid-template-columns: 1fr; gap: 12px; }
.wiki-editor-flaeche.geteilt { grid-template-columns: 1fr 1fr; }
.wiki-editor textarea { width: 100%; min-height: 55vh; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; line-height: 1.55; resize: vertical; }
@media (max-width: 767px) { .wiki-editor textarea { font-size: 16px; } }
.wiki-vorschau { border: 1px dashed var(--border); border-radius: var(--radius); padding: 10px 14px; overflow: auto; max-height: 60vh; }
.wiki-anhaenge { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.wiki-anhaenge .chip button { border: 0; background: transparent; cursor: pointer; color: var(--primary); font-weight: 700; margin-left: 4px; }

.wiki-diff-kopf { display: flex; justify-content: space-between; margin-bottom: 8px; }
.wiki-diff { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; max-height: 60vh; }
.wiki-diff > div { padding: 1px 10px; white-space: pre-wrap; }
.wiki-diff .d-weg { background: var(--danger-soft); color: var(--danger); }
.wiki-diff .d-neu { background: #dcfce7; color: #166534; }
@media (prefers-color-scheme: dark) { .wiki-diff .d-neu { background: #14532d; color: #bbf7d0; } }
@media (max-width: 900px) {
  .wiki-layout { grid-template-columns: 1fr; }
  .wiki-seitenleiste { position: static; }
  .wiki-baum { max-height: 240px; }
  .wiki-inhalt { padding: 14px; }
  .wiki-editor-flaeche.geteilt { grid-template-columns: 1fr; }
}

/* ---------- Aufklappbare Abschnitte in Einstellungen und Verwaltung ---------- */
.einst-block { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 12px; overflow: hidden; }
.einst-block > summary {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; cursor: pointer; list-style: none;
  padding: 13px 16px; font-weight: 700; font-size: 16px; background: var(--surface-2);
  transition: background var(--dur-fast);
}
.einst-block > summary::-webkit-details-marker { display: none; }
.einst-block > summary::after {
  content: '▸'; margin-left: auto; color: var(--text-3); font-size: 13px; transition: transform var(--dur-fast) var(--ease-out);
}
.einst-block[open] > summary::after { transform: rotate(90deg); }
.einst-block > summary:hover { background: color-mix(in srgb, var(--primary-soft) 40%, var(--surface-2)); }
.einst-block > summary .h { font-weight: 400; font-size: 13px; color: var(--text-2); }
.einst-inhalt { padding: 14px 16px 18px; border-top: 1px solid var(--border); }
.einst-inhalt > :first-child { margin-top: 0; }
.einst-inhalt > p.small { margin-top: 0; }
@media (max-width: 600px) {
  .einst-block > summary { padding: 12px 13px; font-size: 15px; }
  .einst-inhalt { padding: 12px 13px 16px; }
}

/* Untermenüpunkte im Seitenmenü */
.sb-unter { display: flex; flex-direction: column; margin: 2px 0 6px; }
.sb-unter a {
  display: block; padding: 7px 10px 7px 46px; font-size: 14px; color: var(--sidebar-muted);
  border-radius: 9px; margin: 0 8px; position: relative;
}
.sb-unter a::before {
  content: ''; position: absolute; left: 30px; top: 0; bottom: 0; width: 1px; background: rgba(255,255,255,.16);
}
.sb-unter a:hover { color: #fff; background: rgba(255,255,255,.06); }
.sb-unter a.active { color: #fff; background: rgba(255,255,255,.12); font-weight: 600; }
body.sb-collapsed .sb-unter { display: none; }

/* Tastaturbedienung: Wer mit Tabulator navigiert, muss sehen, wo er ist */
.run-line:focus-visible, .cal-day:focus-visible, .week-col h4:focus-visible, .now-title:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}

/* Auswahl in Tabellen (shared/tabelle.js, `aktionen`) */
.sortier-tabelle th.wahl, .sortier-tabelle td.wahl { width: 1%; padding: 0; text-align: center; }
/* Kopf und Zeilen gleich gebaut: das Kästchen mittig in einer 40er-Fläche, damit beide Häkchen übereinanderstehen */
.sortier-tabelle .wahl label { display: flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; cursor: pointer; }
.sortier-tabelle .wahl input { width: 18px; height: 18px; margin: 0; cursor: pointer; }
.tabelle-aktionen { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tabelle-aktionen[hidden] { display: none; }

/* KI: gespeicherte Prompts im Chat */
.ki-prompt-liste { display: flex; flex-direction: column; gap: 6px; }
.ki-prompt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--card, #fff); cursor: pointer; font: inherit; color: inherit; }
.ki-prompt:hover, .ki-prompt:focus-visible { border-color: var(--primary); }

/* ---------- Umfragen: Auswertung ---------- */
.umf-balken { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; align-items: center; gap: 8px; font-size: 14px; }
.umf-label { overflow-wrap: anywhere; }
.umf-spur { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.umf-spur > span { display: block; height: 100%; background: var(--primary); border-radius: 5px; }
.umf-zahl { color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.umf-zitate { margin: 0; padding-left: 18px; }
.umf-zitate li { margin: 2px 0; }
.umf-abschnitt { border-top: 1px solid var(--border); padding-top: 8px; }
.umf-abschnitt > summary { cursor: pointer; font-weight: 600; }
.logik-box { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--surface-2); }
.umf-option { flex-wrap: wrap; }
.umf-quiz { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
/* Umfrage-Bericht drucken bzw. als PDF speichern: nur Kennzahlen und Zusammenfassung */
@media print {
  body.druckt-umfrage #sidebar, body.druckt-umfrage #topbar, body.druckt-umfrage .toast-root,
  body.druckt-umfrage [data-reiter], body.druckt-umfrage [data-aktionen], body.druckt-umfrage [data-alle-antworten],
  body.druckt-umfrage .umf-drucken, body.druckt-umfrage details > summary::marker { display: none !important; }
  body.druckt-umfrage .card { break-inside: avoid; box-shadow: none; }
  body.druckt-umfrage .layout, body.druckt-umfrage .content, body.druckt-umfrage main#view { display: block; padding: 0; margin: 0; max-width: none; }
  body.druckt-umfrage details { display: block; }
  body.druckt-umfrage details > *:not(summary) { display: block !important; }
}

/* Umfragen: Übersetzungstafel – links der Text, rechts die Übersetzung */
.uebersetzung { display: grid; gap: 10px; }
.uebersetzung-zeile { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; padding-top: 10px; border-top: 1px solid var(--border); }
.uebersetzung-zeile:first-child { border-top: 0; padding-top: 0; }
.uebersetzung-quelle { white-space: pre-wrap; }
.uebersetzung-zeile input, .uebersetzung-zeile textarea { width: 100%; font-size: 16px; }
.uebersetzung-zeile .vorgeschlagen { border-color: var(--primary); background: var(--primary-soft); }
@media (max-width: 640px) { .uebersetzung-zeile { grid-template-columns: 1fr; gap: 4px; } }

/* E-Mail: Ordner links, Liste rechts; auf dem Handy eine Auswahl statt der Ordnerleiste */
.mail-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 14px; align-items: start; }
.mail-leiste { flex-wrap: wrap; }
.mail-leiste-rechts { display: flex; gap: 4px; align-items: center; margin-left: auto; }
.mail-leiste { gap: 6px; }
.mail-leiste .segmented button { padding: 6px 10px; min-height: 36px; font-size: 14px; }
.mail-leiste [data-suche] { min-width: 160px !important; }
/* Wird es eng, rücken die Knöpfe neben die Suche und nur die Filter in die zweite Reihe – zwei Reihen statt drei */
@media (max-width: 1250px) {
  .mail-leiste-rechts { order: 1; }
  .mail-leiste .segmented { order: 2; }
}
.mail-ordner { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 8px; }
.mail-konto { margin-top: 10px; }
.mail-konto-name { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); padding: 4px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-ordner-link { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; color: var(--text); text-decoration: none; }
.mail-ordner-link:hover { background: var(--surface-2, var(--primary-soft)); }
.mail-ordner-link.aktiv { background: var(--primary-soft); font-weight: 600; }
.mail-zahl { font-size: 12px; color: var(--primary); }
.mail-ordner-wahl { display: none; }
.mail-neu { font-weight: 700; }
.mail-stern { color: #d97706; }
.mail-inhalt { width: 100%; min-height: 200px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.mail-anhaenge { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mail-anhaenge .chip a { margin-left: 6px; }
.mail-unterhaltung { display: block; padding: 6px 0; border-top: 1px solid var(--border); color: var(--text); text-decoration: none; }
.mail-editor { min-height: 220px; max-height: 55vh; overflow: auto; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 16px; line-height: 1.5; }
.mail-editor:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.mail-editor blockquote { margin: 0 0 0 6px; padding-left: 10px; border-left: 3px solid var(--border); color: var(--text-2); }
.mail-editor-leiste { display: flex; flex-wrap: wrap; gap: 2px; }
@media (max-width: 760px) {
  .mail-layout { grid-template-columns: 1fr; }
  .mail-ordner { display: none; }
  .mail-ordner-wahl { display: block; width: 100%; font-size: 16px; }
}
.mail-adressfeld { position: relative; }
.mail-vorschlaege { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.12); overflow: hidden; }
.mail-vorschlaege button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; color: var(--text); cursor: pointer; font: inherit; }
.mail-vorschlaege button:hover { background: var(--primary-soft); }
.mail-lesen { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 12px; align-items: start; }
.mail-lesen-seite:empty { display: none; }
@media (max-width: 960px) { .mail-lesen { grid-template-columns: 1fr; } }
/* Ohne Seitenspalte (die Mail selbst – dort steht der Absender im Info-Overlay) oder mit leerer: eine Spalte */
.mail-lesen:has(.mail-lesen-seite:empty), .mail-lesen:not(:has(.mail-lesen-seite)) { grid-template-columns: 1fr; }
.ticket-entwurf { white-space: pre-wrap; padding: 10px 12px; border-radius: 8px; background: var(--primary-soft); font-size: 15px; }
.ticket-mail { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.ticket-mail.eigene { background: var(--primary-soft); border-color: transparent; }
.ticket-mail [data-vorschau] { cursor: pointer; margin-top: 4px; }
.ticket-zeile { display: grid; grid-template-columns: 140px 1fr 32px; gap: 8px; align-items: center; margin: 4px 0; }
.ticket-balken { display: block; height: 10px; border-radius: 5px; background: var(--primary); }
.kpi-reihe { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.text-danger { color: var(--danger); font-weight: 600; }
.crm-mail-zeile { display: grid; grid-template-columns: 170px minmax(0, 1.3fr) minmax(0, 1fr) auto auto; gap: 6px; align-items: center; }
@media (max-width: 640px) { .crm-mail-zeile { grid-template-columns: 1fr 1fr; } }

/* E-Mail: Ordner und Liste so hoch wie der Bildschirm – beide scrollen für sich */
@media (min-width: 761px) {
  /* Höhe bis zum unteren Rand der Seite (10 px Innenabstand) – sonst rollt die ganze Seite, und die Bildlaufleiste frisst Breite */
  .mail-layout { height: calc(100dvh - var(--mail-oben, 150px) - 10px); min-height: 480px; grid-template-rows: minmax(0, 1fr); align-items: stretch; }
  .mail-ordner { position: static; height: 100%; overflow-y: auto; padding-right: 4px; }
  .mail-liste { display: flex; flex-direction: column; min-height: 0; height: 100%; }
  .mail-liste > .mail-tabelle { flex: 1; min-height: 0; }
}
/* Die Liste: Kopf fest und niedrig, nie seitlich scrollen, jede Mail in einer Zeile */
.mail-tabelle { display: flex; flex-direction: column; min-height: 0; }
.mail-tabelle .tabelle-anzahl { flex: none; min-height: 28px; margin: 0; padding: 2px 8px; }
.mail-tabelle .tabelle-rollt { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; }
.mail-tabelle .sortier-tabelle { table-layout: fixed; width: 100%; }
.mail-tabelle .sortier-tabelle thead { position: sticky; top: 0; z-index: 2; }
.mail-tabelle .sortier-tabelle th { background: var(--surface-2); }
.mail-tabelle .sortier-tabelle th button, .mail-tabelle .sortier-tabelle th > span { padding: 5px 10px; font-size: 12px; }
.mail-tabelle .sortier-tabelle th.wahl, .mail-tabelle .sortier-tabelle td.wahl { width: 36px; }
.mail-tabelle .sortier-tabelle .wahl label { min-height: 30px; min-width: 36px; }
.mail-tabelle .sortier-tabelle .mail-sp-von { width: 190px; }
.mail-tabelle .sortier-tabelle .mail-sp-ordner { width: 110px; }
.mail-tabelle .sortier-tabelle .mail-sp-datum { width: 64px; text-align: right; }
.mail-tabelle .sortier-tabelle td { padding: 6px 10px; overflow: hidden; text-overflow: ellipsis; }
.mail-tabelle .sortier-tabelle tbody tr { cursor: pointer; }
.mail-tabelle .sortier-tabelle tbody tr.mail-zeile-neu td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.mail-tabelle .sortier-tabelle tbody tr.mail-aktiv td { background: var(--primary-soft); }
.mail-kuerzen { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-zeile-inhalt { display: flex; align-items: center; gap: 6px; min-width: 0; }
.mail-zeile-inhalt > .mail-kuerzen { flex: 1; }
.mail-zeile-vorschau { color: var(--text-2); font-weight: 400; }
.mail-symbol { flex: none; color: var(--text-2); display: inline-flex; }
.mail-symbol svg { width: 14px; height: 14px; }
@media (max-width: 640px) { .mail-tabelle .sortier-tabelle .mail-sp-von { width: 110px; } }

/* E-Mail: geteilte Ansicht – oben die Liste, unten die geöffnete Mail */
.mail-split { flex: 1; display: grid; grid-template-rows: var(--oben, 38%) 9px minmax(0, 1fr); min-height: 0;
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.mail-split-oben { overflow: hidden; min-height: 0; }
.mail-split-oben .tabelle-rollt { border: 0; border-radius: 0; box-shadow: none; }
.mail-trenner { cursor: row-resize; background: var(--surface-2, var(--bg)); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; touch-action: none; }
.mail-trenner::before { content: ''; width: 44px; height: 3px; border-radius: 2px; background: var(--border); }
.mail-trenner:hover::before, .mail-trenner:focus-visible::before { background: var(--primary); }
.mail-split-unten { overflow: auto; min-height: 0; padding: 0 20px 20px; }
.mail-split-unten.laedt { opacity: .55; transition: opacity .15s; }
.mail-leer { height: 100%; min-height: 160px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--text-2); }
.mail-leer svg { width: 40px; height: 40px; opacity: .4; }

/* Eine geöffnete Mail – modern: großer Betreff, Werkzeugleiste oben fest, Absender mit Kreis */
.mail-ansicht { display: flex; flex-direction: column; gap: 10px; }
.mail-betreff { margin: 16px 0 0; font-size: 21px; line-height: 1.3; }
.mail-werkzeuge { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.mail-ansicht.eingebettet .mail-werkzeuge { position: sticky; top: 0; z-index: 2; background: var(--surface); }
.mail-werkzeuge select { max-width: 170px; min-height: 32px; }
.mail-werkzeuge-trenner { width: 1px; align-self: stretch; background: var(--border); margin: 2px 4px; }
.mail-ansicht .mail-kopf { display: flex; gap: 12px; align-items: center; margin-bottom: 4px; }
.mail-kopf-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.mail-kopf-datum { white-space: nowrap; align-self: flex-start; }
.mail-avatar { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%; color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 15px; }
.mail-ansicht .mail-inhalt { border: 0; border-radius: 10px; box-shadow: 0 0 0 1px var(--border); }
.mail-anhaenge { display: flex; flex-wrap: wrap; gap: 8px; }
.mail-anhang { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; min-width: 220px; background: var(--surface); }
.mail-anhang a { font-size: 13px; }
.mail-unterhaltungen h3 { margin: 6px 0 4px; font-size: 15px; }
.mail-unterhaltung { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-top: 1px solid var(--border); background: none; color: var(--text); cursor: pointer; font: inherit; }
.mail-unterhaltung:hover { background: var(--primary-soft); }
/* Die Zeile über der Mail-Tabelle nur zeigen, wenn etwas darin steht (Filter-Knopf, Auswahl) */
.mail-tabelle .tabelle-anzahl:not(:has(.filter-knopf, .tabelle-aktionen:not([hidden]))) { display: none; }
/* Punktemenü (shared/menue.js) */
.menue { position: fixed; z-index: 1000; min-width: 220px; max-width: 320px; max-height: 70vh; overflow-y: auto; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.16); }
.menue-eintrag { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.menue-eintrag:hover, .menue-eintrag:focus-visible { background: var(--primary-soft); outline: none; }
.menue-eintrag.gefahr { color: var(--danger); }
.menue-eintrag:disabled { opacity: .5; cursor: default; }
.menue-trenner { height: 1px; background: var(--border); margin: 4px 6px; }
.menue-titel { padding: 6px 10px 2px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.menue-gruppe .menue-eintrag { padding-left: 18px; }
.menue-inhalt { width: 300px; max-width: calc(100vw - 16px); padding: 0; }
.menue-inhalt > .card { border: 0; box-shadow: none; background: transparent; }
.menue-titel { overflow-wrap: anywhere; }
.menue-inhalt .anhang-alle { margin: 10px 10px 4px; display: flex; justify-content: center; }
.anhang-liste { list-style: none; margin: 0; padding: 4px 6px 8px; max-height: 60vh; overflow-y: auto; }
.anhang-liste li { display: flex; align-items: center; gap: 6px; padding: 6px 4px; border-top: 1px solid var(--border); }
.anhang-liste li:first-child { border-top: 0; }
.anhang-liste .grow { min-width: 0; display: flex; flex-direction: column; }
.anhang-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.menue-inhalt:has(.anhang-liste) { width: 380px; }
/* Vorschau von Anhängen: Fenster fast bildschirmhoch, PDF und Office im Rahmen, Bilder eingepasst */
.modal.vorschau-modal { height: calc(100vh - 32px); }
.vorschau-modal .modal-body { display: flex; flex-direction: column; min-height: 0; }
.vorschau { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.vorschau-rahmen { flex: 1; width: 100%; min-height: 60vh; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.vorschau-bild { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; background: var(--surface-2, var(--bg)); border-radius: 8px; }
.vorschau-bild img { max-width: 100%; max-height: calc(100vh - 200px); object-fit: contain; }
.vorschau-video { width: 100%; max-height: calc(100vh - 200px); background: #000; border-radius: 8px; }
.vorschau-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.vorschau-tabelle { overflow: auto; }
.vorschau-tabelle table { border-collapse: collapse; font-size: 13px; }
.vorschau-tabelle th, .vorschau-tabelle td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; vertical-align: top; }
.vorschau-tabelle thead th { position: sticky; top: 0; background: var(--surface); }
.vorschau-hinweis { margin: auto; text-align: center; padding: 32px 16px; }
.vorschau-mail h3 { margin: 0 0 4px; }
.vorschau-mail .vorschau-text { margin-top: 12px; }
@media (max-width: 767px) { .modal.vorschau-modal { height: 100%; } }
/* Tooltip für Symbol-Knöpfe (shared/tooltip.js) */
.tooltip { position: fixed; z-index: 2000; max-width: 280px; padding: 4px 8px; border-radius: 6px; pointer-events: none;
  background: #1f2937; color: #fff; font-size: 12px; line-height: 1.35; box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.tooltip[hidden] { display: none; }
/* Knopf, dessen Symbol sich dreht, solange er arbeitet (Abgleichen) */
.dreht svg { animation: ki-dreh 1s linear infinite; }
/* Mail-Liste: zwei Zeilen je Mail (Betreff, darunter die Vorschau); Häkchen-Spalte ohne Innenabstand */
.mail-tabelle .sortier-tabelle td.wahl, .mail-tabelle .sortier-tabelle th.wahl { padding: 0; }
.mail-tabelle .sortier-tabelle .wahl label { min-width: 0; width: 100%; }
.mail-tabelle .sortier-tabelle td { vertical-align: top; }
.mail-tabelle .sortier-tabelle td.mail-sp-datum { white-space: nowrap; }
.mail-tabelle .mail-zeile-vorschau { display: block; margin-top: 1px; font-size: 12.5px; }
.mail-symbolknopf { min-width: 34px; justify-content: center; font-size: 16px; }
.mail-symbolknopf svg { width: 16px; height: 16px; }
.mail-knopf-zahl { font-size: 12px; margin-left: 2px; }
