:root {
  /* Blau/Orange-Farbschema: Blau als strukturierende Farbe (Sidebar, Kopfzeile, Überschriften),
     Orange als Aktionsfarbe (Buttons, aktive Zustände, Hervorhebungen). Der Lesebereich (Cards,
     Tabellen) bleibt durchgängig weiß, siehe --card. */
  --primary: #1b4d89;
  --primary-light: #2e6db4;
  --primary-dark: #123761;
  --accent: #f07c2e;
  --accent-dark: #d9631a;
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #dfe3ea;
  --text: #222;
  --text-muted: #666;
  --success: #2e7d32;
  --warning: #b8860b;
  --danger: #c0392b;
  --radius: 8px;
}

/* Punkt 2 (Software-Liste Runde AG): Erkennung von Browser-Autofill per CSS-Trick. Manche Browser
   (v.a. Chrome/Edge, wenn eine komplette gespeicherte Adresse auf einmal in ein leeres Formular
   eingetragen wird - z.B. beim neuen Auftrag anlegen) lösen dabei KEIN input/change-Event pro Feld
   aus, wodurch z.B. die PLZ->Ort-Automatik nie greift. Eine leere CSS-Animation, die nur bei
   :-webkit-autofill (Chrome/Edge/Safari) aktiv wird, lässt sich per "animationstart"-JS-Event
   trotzdem zuverlässig erkennen - rein technischer Trick ohne sichtbaren visuellen Effekt.
   Siehe views/projects/form.ejs und views/projects/show.ejs (PLZ-Feld). */
@keyframes vema-autofill-detect { from {} to {} }
input:-webkit-autofill { animation-name: vema-autofill-detect; animation-duration: 0.001s; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

/* ============================================================
   Layout: linke Sidebar + obere Kopfzeile mit globaler Suche
   ============================================================ */

:root {
  --sidebar-width: 230px;
  --sidebar-width-collapsed: 64px;
  --header-height: 58px;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 60;
  overflow-y: auto;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  padding: 16px 16px;
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.25;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar .brand:hover { text-decoration: none; }
.sidebar .brand-icon { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; }
.sidebar .brand-text { font-size: 1.1rem; letter-spacing: 0.02em; }
.sidenav { display: flex; flex-direction: column; padding: 10px 8px; gap: 2px; flex: 1; }
.sidenav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #c3cde0;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  white-space: nowrap;
}
.sidenav a .ic { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidenav a:hover, .sidenav a.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  text-decoration: none;
}
.sidenav a.active { background: var(--accent); color: #fff; font-weight: 600; }
.sidenav-divider { height: 1px; background: rgba(255,255,255,0.12); margin: 8px 10px; }
/* Punkt 5 (Software-Liste): Gruppen-Überschriften zwischen den Navigationsblöcken. */
.sidenav-heading {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.45);
  padding: 14px 12px 4px;
  font-weight: 600;
}
.sidenav-heading:first-child { padding-top: 4px; }
.sidenav-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidenav-footer .user-name { color: #d9dee8; font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidenav-footer-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidenav-footer-link { color: #d9dee8; font-size: 0.78rem; text-decoration: none; opacity: 0.85; }
.sidenav-footer-link:hover, .sidenav-footer-link.active { color: #fff; opacity: 1; text-decoration: underline; }
.sidenav-version { color: #8791a3; font-size: 0.7rem; margin-top: 6px; }
.btn-mini {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.8rem;
  flex-shrink: 0;
}
.btn-mini:hover { background: rgba(255,255,255,0.25); }

.topheader {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--header-height);
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-bottom: 1px solid var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  z-index: 55;
}
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: #fff;
  padding: 4px 6px;
}
.topheader-title {
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.topheader-title-link { color: inherit; text-decoration: none; }
.topheader-title-link:hover { text-decoration: underline; opacity: 0.9; }
/* Punkt 1 (Software-Liste): Suchfeld oben rechts in der Ecke statt mittig gestreckt -
   "margin-left:auto" schiebt es im Flex-Header (.topheader) ganz nach rechts, "flex:0 0 auto" statt
   des bisherigen "flex:1" verhindert das Strecken über die Restbreite. */
.topheader-search { position: relative; flex: 0 0 auto; max-width: none; margin-left: auto; }
.search-form { display: flex; align-items: center; background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.3); border-radius: 100px; padding: 0 14px; }
.search-icon { font-size: 0.85rem; opacity: 0.85; color: #fff; }
.search-form input[type="search"] {
  border: none;
  background: transparent;
  padding: 9px 8px;
  font-size: 0.88rem;
  box-shadow: none;
  color: #fff;
  width: 260px;
}
.search-form input[type="search"]::placeholder { color: rgba(255,255,255,0.75); }
.search-form input[type="search"]:focus { outline: none; }
.search-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 340px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(20,40,80,0.15);
  max-height: 420px;
  overflow-y: auto;
  padding: 6px 0;
}
.search-results.open { display: block; }
.search-group-title { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); padding: 8px 14px 4px; }
.search-results a { display: flex; flex-direction: column; padding: 7px 14px; color: var(--text); font-size: 0.88rem; }
.search-results a:hover { background: var(--bg); text-decoration: none; }
.search-results .sr-sub { font-size: 0.75rem; color: var(--text-muted); }
.search-empty { padding: 14px; color: var(--text-muted); font-size: 0.85rem; }
.sidebar-overlay { display: none; }

.container {
  /* Kein festes max-width mehr, damit sich die Anzeige immer der Bildschirmbreite anpasst
     (schmale Notebooks bis große Ultrawide-Monitore) statt in der Mitte eines breiten
     Bildschirms schmal stehen zu bleiben. WICHTIG: width muss die Sidebar-Breite abziehen,
     da margin-left sonst zusätzlich zu 100% Breite addiert und über den Bildschirmrand
     hinausragt (führte zu horizontalem Overflow).
  */
  width: calc(100% - var(--sidebar-width));
  margin-left: var(--sidebar-width);
  padding: calc(var(--header-height) + 24px) 28px 60px;
  overflow-x: auto;
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.2);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .topheader { left: 0; }
  .menu-toggle { display: inline-block; }
  .container { width: 100%; margin-left: 0; padding-left: 16px; padding-right: 16px; }
  body.sidebar-open .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10,15,30,0.45);
    z-index: 59;
  }
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}
.page-header h1 { margin: 0; font-size: 1.4rem; }
.page-header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Auftragsstatus-Stepper (siehe partials/project-status-stepper.ejs): Punkte mit verbindender
   Linie direkt unter der Bezeichnung, Klick speichert den Status sofort per AJAX. */
.status-stepper {
  display: flex;
  align-items: flex-start;
  gap: 0;
  margin: -6px 0 18px;
  overflow-x: auto;
  padding: 4px 2px 8px;
}
.status-stepper.is-saving { opacity: 0.6; pointer-events: none; }
.status-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 84px;
  position: relative;
}
.status-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 8px;
  left: calc(50% + 12px);
  right: calc(-50% + 12px);
  height: 2px;
  background: var(--border);
}
.status-step.is-past:not(:last-child)::after { background: #b9c0cc; }
.status-step-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
  cursor: pointer;
  padding: 0;
  z-index: 1;
  transition: transform 0.1s ease;
}
.status-step-dot:hover { transform: scale(1.15); }
.status-step.is-current .status-step-dot { box-shadow: 0 0 0 3px rgba(240,124,46,0.15); }
.status-step-label {
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
  padding: 0 4px;
}

/* Einstellungen-Übersicht: farbige Kategorie-Kacheln als Schnellnavigation über den eigentlichen
   (weiter unten liegenden) Detail-Karten, damit die lange Einstellungsseite übersichtlicher wirkt. */
.settings-overview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
@media (max-width: 900px) {
  .settings-overview { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .settings-overview { grid-template-columns: 1fr; }
}
.settings-cat {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 1px 2px rgba(20,30,50,0.04);
}
.settings-cat-header {
  padding: 12px 16px;
  font-weight: 700;
  font-size: 0.95rem;
}
.settings-cat-body {
  display: flex;
  flex-direction: column;
  padding: 10px 16px 14px;
}
.settings-cat-body a {
  padding: 6px 0;
  color: var(--text);
  text-decoration: none;
  font-size: 0.88rem;
  border-bottom: 1px solid #f0f1f4;
}
.settings-cat-body a:last-child { border-bottom: none; }
.settings-cat-body a:hover { color: var(--accent); text-decoration: underline; }
.settings-cat.cat-neutral .settings-cat-header { background: #f3f4f6; color: #1f2937; }
.settings-cat.cat-teal .settings-cat-header { background: #0f9b8e; color: #fff; }
.settings-cat.cat-indigo .settings-cat-header { background: #3b4cca; color: #fff; }
.settings-cat.cat-purple .settings-cat-header { background: #7c3aed; color: #fff; }
.settings-cat.cat-slate .settings-cat-header { background: #334155; color: #fff; }

/* Auftragsformular: Auto-Save-Statusanzeige (siehe views/projects/show.ejs) statt eines
   "Speichern"-Buttons. */
.autosave-status { font-size: 0.82rem; color: var(--text-muted); }
.autosave-status.is-saving { color: var(--text-muted); }
.autosave-status.is-saved { color: var(--success); font-weight: 600; }
.autosave-status.is-error { color: var(--danger); font-weight: 600; }

.import-card { max-width: 640px; }
.import-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  margin-bottom: 16px;
}
.import-result { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.92rem; }
.import-result.ok { background: #e9f7ef; border: 1px solid #a3d9b6; color: #1e6b3c; }
.import-result.error { background: #fbeaea; border: 1px solid #e3a3a3; color: #8a2323; }
.import-columns-hint { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.grid { display: grid; gap: 16px; }
/* .grid-5 (Software-Liste, "Vorname/Nachname statt einem Namensfeld"): für das Ansprechpartner-
   Formular in views/customers/show.ejs, das durch die Aufteilung von "Name" in Vorname/Nachname
   jetzt eine Spalte mehr braucht. */
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) {
  .grid-5, .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; }
}

/* Punkt 2 (Software-Liste): frei anordenbare Dashboard-Kacheln, siehe utils/dashboardWidgets.js +
   views/dashboard.ejs. 12-Spalten-Raster, jede Kachel belegt "span" Spalten (Klasse dw-span-N). */
.dashboard-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; margin-bottom: 20px; }
.dashboard-widget { min-width: 0; position: relative; }
.dashboard-widget > .card, .dashboard-widget > .stat-card { margin-bottom: 0; height: 100%; }
.dw-span-3 { grid-column: span 3; }
.dw-span-4 { grid-column: span 4; }
.dw-span-6 { grid-column: span 6; }
.dw-span-12 { grid-column: span 12; }
@media (max-width: 900px) {
  .dw-span-3, .dw-span-4, .dw-span-6, .dw-span-12 { grid-column: span 12; }
}

/* Punkt 1 (Software-Liste Runde AS): kompakter Monats-Kalender in der "Kalender"-Kachel des
   Baustellen-Dashboards, siehe views/dashboard-baustellen.ejs. */
.dashboard-mini-calendar { border-collapse: collapse; width: 100%; }
.dashboard-mini-calendar th { font-size: 0.72rem; font-weight: 600; color: var(--muted); text-align: center; padding: 4px 2px; }
.dashboard-mini-calendar td { text-align: center; padding: 1px; }
.dashboard-mini-calendar-day {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 1; border-radius: 6px; text-decoration: none; color: inherit;
  font-size: 0.78rem; position: relative;
}
.dashboard-mini-calendar-day:hover { background: rgba(20,40,80,0.06); }
.dashboard-mini-calendar-day.is-outside { color: var(--muted); opacity: 0.5; }
.dashboard-mini-calendar-day.is-today { background: var(--accent, #2f80ed); color: #fff; font-weight: 700; }
.dashboard-mini-calendar-day .day-dot {
  width: 4px; height: 4px; border-radius: 50%; background: var(--accent, #2f80ed); margin-top: 2px;
}
.dashboard-mini-calendar-day.is-today .day-dot { background: #fff; }

/* Punkt 4 (Software-Liste Runde AU): Wochen-Kalender-Kachel im Baustellen-Dashboard (ersetzt den
   bisherigen Monats-Mini-Kalender, siehe views/dashboard-baustellen.ejs) - zeigt die Verkehrs-
   sicherung-Aufträge der aktuellen Woche inkl. Kunde. "min-width: 0" auf den Spalten aus demselben
   Grund wie bei .cal-cell (siehe Bugfix Punkt 5 oben) - verhindert, dass ein langer Auftragsname
   trotz Ellipsis eine einzelne Spalte breiter zieht als die übrigen 6.
*/
.dashboard-week-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 10px; }
.dashboard-week-day {
  min-width: 0; box-sizing: border-box; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px; display: flex; flex-direction: column; gap: 6px; min-height: 130px;
}
.dashboard-week-day.is-today { background: #fff4ea; border-color: var(--accent, #2f80ed); }
.dashboard-week-day-header { display: flex; align-items: baseline; justify-content: space-between; }
.dashboard-week-day-header .weekday { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.dashboard-week-day-header .daynum { font-size: 0.85rem; font-weight: 700; }
.dashboard-week-day.is-today .daynum { color: var(--accent, #2f80ed); }
.dashboard-week-day-items { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; overflow-x: hidden; max-height: 150px; min-width: 0; }
.dashboard-week-badge {
  display: block; min-width: 0; max-width: 100%; box-sizing: border-box;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.7rem;
}
.dashboard-week-badge-kunde { opacity: 0.85; }
@media (max-width: 900px) {
  .dashboard-week-calendar { grid-template-columns: repeat(7, minmax(90px, 1fr)); overflow-x: auto; }
}
.dashboard-widget-handle {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: rgba(20,40,80,0.06);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 4px 10px;
  font-size: 0.85rem;
}
.dw-drag { cursor: grab; opacity: 0.6; }
.dw-remove { background: none; border: none; cursor: pointer; color: var(--danger); font-size: 0.85rem; padding: 2px 6px; }
.dashboard-widget.dw-editing { outline: 2px dashed var(--border); border-radius: var(--radius); }
.dashboard-widget.dw-editing[draggable="true"] { cursor: grab; }
@media (max-width: 600px) {
  .grid-5, .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .topbar-inner { gap: 8px; }
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-card .label { color: var(--text-muted); font-size: 0.85rem; }
.stat-card .value { font-size: 1.6rem; font-weight: 700; color: var(--primary); }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.02em; }
tr:hover td { background: #fafbfd; }

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  text-align: center;
}
.btn:hover { background: var(--primary-light); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-secondary:hover { background: #eef1f7; }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 0.82rem; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
/* "Kunde sperren"/"Entsperren"-Button: bewusst schwarz mit weißer Schrift, unterscheidet sich
   damit klar von den übrigen (blauen/roten) Aktions-Buttons - siehe views/customers/show.ejs. */
.btn-sperren { background: #111; color: #fff; }
.btn-sperren:hover { background: #000; }

form .form-row { margin-bottom: 14px; }
form label { display: block; margin-bottom: 5px; font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
input, select, textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-family: inherit;
  background: #fff;
}
textarea { resize: vertical; min-height: 70px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}
/* Größerer, eckiger Status-Badge speziell für Aufgaben (statt der sonst runden Pill-Badges) */
.badge.badge-task { border-radius: 4px; padding: 6px 14px; font-size: 0.9rem; font-weight: 700; }
.badge-gray { background: #e5e7eb; color: #444; }
.badge-green { background: #dcf3df; color: var(--success); }
.badge-yellow { background: #fdf1d6; color: var(--warning); }
.badge-red { background: #fbe0dd; color: var(--danger); }
.badge-blue { background: #dbe6fb; color: var(--primary-light); }
.badge-accent { background: #fde3d0; color: var(--accent-dark); }
/* "Gesperrt"/"Deaktiviert"-Hinweis: schwarz mit weißer Schrift (analog zum Sperren-Button),
   damit der Status im Kunden-/Lieferanten-Titel sofort ins Auge fällt. */
.badge-gesperrt { background: #111; color: #fff; margin-left: 6px; }

/* Item 9 (Software-Liste, "Rechnungen: Status-Badges fetter/Viereck-Stil"): kräftigerer,
   eckigerer "Chip"-Stil statt der sonst üblichen leichten Pill-Badges - bewusst eine eigene
   Modifier-Klasse (statt .badge global zu ändern), da .badge auch in vielen anderen Modulen
   (Aufträge, Angebote, Aufgaben, Antragsstatus, Gutschriften) im bisherigen Pill-Stil verwendet
   wird; wird gezielt nur bei den Rechnungs-Status-Badges eingebunden (views/invoices/list.ejs +
   show.ejs, partials/status-picker.ejs badgeClass-Parameter). Schriftgröße bleibt unverändert,
   nur Deckkraft/Sättigung des Hintergrunds, Eckenradius und Schriftgewicht ändern sich. */
.badge.badge-solid { border-radius: 4px; padding: 4px 10px; font-weight: 700; }
.badge-solid.badge-green { background: var(--success); color: #fff; }
.badge-solid.badge-yellow { background: var(--warning); color: #fff; }
.badge-solid.badge-red { background: var(--danger); color: #fff; }
.badge-solid.badge-blue { background: var(--primary-light); color: #fff; }
.badge-solid.badge-accent { background: var(--accent-dark); color: #fff; }
.badge-solid.badge-gray { background: #6b7280; color: #fff; }

/* Item 8 (Software-Liste, "Rechnungen: überfällige Zeilen komplett rot"): gesamte Zeile (nicht nur
   die Fälligkeits-Spalte) in der Rechnungsübersicht rot einfärben, wenn die Rechnung noch offen und
   bereits überfällig ist (siehe views/invoices/list.ejs <tr> + routes/invoices.js istUeberfaellig
   - bereits bezahlte/stornierte Rechnungen werden dort bewusst ausgenommen). Höhere Spezifität als
   das globale "a { color: ... }" (siehe oben), daher wirkt es auch auf verlinkte Zellen (Nr.,
   Auftrag) mit.
     Der Status-Badge selbst behält seine eigene Farbe (Badges setzen ihre Farbe inline/über eigene
   Klassen mit höherer Spezifität als diese Zeilenregel). */
tr.row-overdue td { color: var(--danger); }

/* Bugfix (echter Fehler, von Stephan gemeldet): neuer Rechnungsstatus "Ausgebucht" (siehe
   views/invoices/list.ejs <tr> + routes/invoices.js) - die Rechnung bleibt in der Liste sichtbar,
   wird aber visuell durchgestrichen und abgeblendet dargestellt (analog zu row-overdue oben).
   Letzte Spalte (Aktionen: PDF-Button/⋮-Menü) bewusst ausgenommen, damit deren Buttons nicht
   ebenfalls durchgestrichen wirken. */
tr.row-ausgebucht td:not(:last-child) { text-decoration: line-through; color: var(--text-muted); opacity: 0.75; }

/* Auftragsstatus-Farbverwaltung (Einstellungen -> Auftragsstatus): Farbpalette + Hex-Code-Feld
   neben dem nativen Farbwähler, siehe views/settings.ejs. */
.project-status-preview { white-space: nowrap; }
.color-field { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.color-field input[type="color"] { width: 34px; height: 30px; padding: 2px; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; background: none; }
.color-field input[type="text"] { font-family: monospace; }
.color-palette { display: flex; gap: 4px; flex-wrap: wrap; max-width: 190px; }
.color-swatch {
  width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.15);
  cursor: pointer; padding: 0;
}
.color-swatch:hover { transform: scale(1.15); box-shadow: 0 0 0 2px rgba(0,0,0,0.1); }

/* Status-Schnellauswahl: klickbarer Badge (details/summary), Popup mit den übrigen
   Status-Optionen zum direkten Umschalten per Klick (siehe partials/status-picker.ejs). */
.status-picker { display: inline-block; position: relative; }
.status-picker summary { list-style: none; cursor: pointer; }
.status-picker summary::-webkit-details-marker { display: none; }
.status-picker summary .badge { display: inline-flex; align-items: center; gap: 3px; }
.status-picker-caret { font-size: 0.65em; opacity: 0.7; }
.status-picker-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  min-width: 150px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
/* Bugfix (Software-Liste Runde AU, Punkt 2): das Aktionsmenü (⋮) bei Zeilen nahe dem unteren
   Fensterrand - z.B. die letzten Zeilen einer langen Tabelle in Angebote/Lieferscheine/
   Rechnungen/Eingangsrechnungen - ragte nach unten aus dem sichtbaren Fenster bzw. wurde vom
   umgebenden ".container" (overflow-x:auto, siehe oben im Layout-Abschnitt) abgeschnitten, da
   dort unterhalb der Tabelle kein Platz mehr war. Die vorherige Korrektur (Punkt 142, Runde AS)
   hatte nur das horizontale Abschneiden am rechten Rand behoben (siehe .task-menu-picker /
   .assignee-picker-menu unten), nicht dieses vertikale Problem. Die Klasse "flip-up" wird per
   JavaScript (siehe partials/nav.ejs, Status-Schnellauswahl-Skript) automatisch gesetzt, sobald
   beim Öffnen nicht genug Platz nach unten vorhanden ist - dasselbe Menü klappt dann stattdessen
   nach oben auf. Zentral hier definiert, damit alle status-picker-menu-Varianten (Aktionsmenü,
   einfache Status-Auswahl, Mitarbeiter-/Deadline-Picker) automatisch denselben Mechanismus nutzen. */
.status-picker-menu.flip-up { top: auto; bottom: calc(100% + 4px); }
.status-picker-menu form { margin: 0; }
.status-picker-menu button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 5px 6px;
  cursor: pointer;
  border-radius: 4px;
  text-align: left;
}
.status-picker-menu button:hover { background: var(--bg); }

.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.flash-error { background: #fbe0dd; color: var(--danger); }
.flash-success { background: #dcf3df; color: var(--success); }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
}
.login-box {
  background: #fff;
  padding: 36px;
  border-radius: 12px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.login-box h1 { margin-top: 0; font-size: 1.3rem; text-align: center; color: var(--primary); }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 8px; }
.login-logo { width: 64px; height: 64px; border-radius: 14px; }
.login-brand h1 { margin: 0; }

.item-table input { padding: 6px 8px; }
.item-table td { vertical-align: top; }
.remove-row { color: var(--danger); cursor: pointer; background: none; border: none; font-size: 1.1rem; }
.edit-row { color: var(--primary-light); cursor: pointer; background: none; border: none; font-size: 1rem; margin-right: 6px; }

/* Zusatztext-Live-Vorschau im "Position bearbeiten"-Popup (Angebote), siehe public/js/artikel-suche.js */
.pos-zusatztext-preview {
  margin-top: 6px; font-size: 0.82rem; color: var(--text-muted); background: var(--bg);
  border-radius: var(--radius); padding: 6px 10px; white-space: pre-wrap;
}
.pos-zusatztext-preview-label { font-weight: 700; text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.02em; }

.chat-wrap { display: flex; gap: 20px; height: 70vh; }
.chat-channels { width: 220px; border-right: 1px solid var(--border); padding-right: 16px; overflow-y: auto; }
.chat-channels a { display: block; padding: 8px 10px; border-radius: var(--radius); margin-bottom: 4px; color: var(--text); }
.chat-channels a.active, .chat-channels a:hover { background: var(--bg); text-decoration: none; }
.chat-main { flex: 1; display: flex; flex-direction: column; }
.chat-messages { flex: 1; overflow-y: auto; padding: 10px; background: var(--bg); border-radius: var(--radius); margin-bottom: 12px; }
.chat-msg { margin-bottom: 12px; }
.chat-msg .meta { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 2px; }
.chat-msg .bubble { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; display: inline-block; max-width: 80%; }
.chat-msg.own .bubble { background: var(--primary); color: #fff; border-color: var(--primary); }
.chat-form { display: flex; gap: 8px; }
/* Punkt 6 (Software-Liste Runde AU): Löschen-Icon je eigener Nachricht (bzw. jeder Nachricht für
   Nutzer mit dem Recht "loeschen"), siehe views/chat/index.ejs. */
.chat-msg-delete {
  background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.9rem;
  padding: 0 3px; margin-left: 4px; line-height: 1; vertical-align: middle;
}
.chat-msg-delete:hover { color: #ef4444; }

/* Punkt 6 (Software-Liste Runde AU): blinkender Punkt neben "Chat" in der Seitenleiste, solange der
   Mitarbeiter eine @Mention hat, die er noch nicht gesehen hat (siehe server.js
   res.locals.unreadMentionCount, db/schema.sql mention_notifications, routes/chat.js). Bewusst eine
   eigene, auffällige Animation statt eines statischen Badges, da es aktuell keine andere sichtbare
   Benachrichtigungs-Anzeige in der App gibt, die man stattdessen mitnutzen könnte. */
.chat-mention-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ef4444;
  margin-left: 6px; vertical-align: middle; animation: vema-mention-blink 1.1s ease-in-out infinite;
}
@keyframes vema-mention-blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.7); }
}

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 10px; }
.photo-grid img { width: 100%; height: 110px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }
.photo-item { position: relative; }
.photo-item form { position: absolute; top: 4px; right: 4px; margin: 0; }
.photo-item .photo-delete { background: rgba(255,255,255,0.9); }

.mobile-capture { max-width: 480px; margin: 0 auto; padding: 20px; }
.mobile-capture h1 { font-size: 1.2rem; }

/* Punkt 2 (Software-Liste Runde AF): Mini-Vorschau-Kacheln für Aufgaben-Dokumente (views/tasks/
   form.ejs) - kompakter als .photo-grid, da hier auch Nicht-Bild-Dateien (PDF etc.) mit generischem
   Symbol dargestellt werden müssen. */
.doc-mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 4px; }
.doc-mini-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; text-align: center; }
.doc-mini-thumb { display: flex; align-items: center; justify-content: center; height: 70px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-bottom: 6px; }
.doc-mini-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-mini-icon { font-size: 1.8rem; }
.doc-mini-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 4px; }
.doc-mini-actions { display: flex; align-items: center; justify-content: center; gap: 8px; }
.doc-mini-actions form { margin: 0; }
.btn-icon-sm { border: none; background: none; cursor: pointer; color: var(--danger); font-size: 0.9rem; padding: 0; }
.camera-preview { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 12px; background: #000; }

/* Sammelrechnung: Titelzeile (Auftrags-Betreff) über den Positionen eines Angebots */
.invoice-heading-row td {
  background: #dbe6f4;
  color: #14355e;
  font-weight: 700;
  font-size: 0.85rem;
}
.invoice-heading-row:hover td { background: #dbe6f4; }

.totals-box { max-width: 320px; margin-left: auto; }
.totals-box .row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 0.9rem; }
.totals-box .row.total { font-weight: 700; font-size: 1.05rem; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; }

/* Ausgaben-Übersicht (Lieferanten/Behörden-Detailseite): 3 Spalten - Gesamt / aktuelles Jahr /
   Vorjahr, siehe views/suppliers/show.ejs. */
.expenses-col { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.expenses-col-title { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.02em; }
.expenses-col-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 0.9rem; }

.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.small { font-size: 0.82rem; }

/* ============================================================
   "Auftrag für Halteverbot"-Fensteroptik, angelehnt an klassische
   Formularmasken (emis.halteverbot) – Titelleiste, hellblaue
   Kästen, Checklisten, kompakte Icon-Buttons, Korrespondenztabelle
   ============================================================ */

.hv-window {
  background: #dbe6f4;
  border: 1px solid #7f93b8;
  border-radius: 4px;
  padding: 0 0 14px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(30,50,90,0.12);
}
.hv-titlebar {
  background: linear-gradient(180deg, #4a76b8, #1f4d8f);
  color: #fff;
  padding: 8px 14px;
  border-radius: 3px 3px 0 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 600;
}
.hv-titlebar .hv-titlebar-fields {
  display: flex;
  gap: 16px;
  align-items: center;
  flex: 1;
  font-weight: 400;
  font-size: 0.78rem;
}
.hv-titlebar .hv-titlebar-fields label { color: #cfe0f7; text-transform: uppercase; font-size: 0.65rem; letter-spacing: 0.03em; display: block; margin-bottom: 2px; }
.hv-titlebar .hv-titlebar-fields input {
  background: #fff;
  border: 1px solid #14355e;
  border-radius: 2px;
  padding: 3px 6px;
  font-size: 0.8rem;
  color: #14355e;
}
.hv-body { padding: 12px 14px 0; }

.fieldset-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
  align-items: start;
}
@media (max-width: 1100px) { .fieldset-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .fieldset-grid { grid-template-columns: 1fr; } }

.fieldset-box {
  border: 1px solid #97a9c8;
  border-radius: 3px;
  background: #eef3fb;
  padding: 8px 10px 10px;
  margin: 0;
  min-width: 0;
}
.fieldset-box legend {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #1f4d8f;
  padding: 0 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.fieldset-box .form-row { margin-bottom: 6px; }
.fieldset-box label { font-size: 0.65rem; margin-bottom: 2px; color: #4c5f80; text-transform: uppercase; letter-spacing: 0.02em; }
.fieldset-box input,
.fieldset-box select,
.fieldset-box textarea {
  padding: 3px 6px;
  font-size: 0.78rem;
  border-radius: 2px;
  border: 1px solid #9fb0cc;
  background: #fff;
  box-shadow: inset 1px 1px 2px rgba(20,40,80,0.08);
}
.fieldset-box textarea { min-height: 40px; }
.fieldset-box .readonly-line { font-size: 0.78rem; margin-bottom: 6px; word-break: break-word; }
.fieldset-box .readonly-line strong { display: block; font-size: 0.82rem; }
.fieldset-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }

/* Checklisten (angehakte Arbeitsschritte je Bereich) */
.hv-checklist { list-style: none; margin: 6px 0; padding: 0; border-top: 1px solid #c7d3e8; padding-top: 6px; }
.hv-checklist li { margin-bottom: 3px; }
.hv-checklist label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  text-transform: none;
  color: #33425e;
  cursor: pointer;
}
.hv-checklist input[type="checkbox"] { width: auto; box-shadow: none; margin: 0; }

/* Kleine quadratische Icon-Buttons statt großer Textbuttons */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 3px;
  border: 1px solid #9fb0cc;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.8rem;
  text-decoration: none;
  line-height: 1;
}
.btn-icon:hover { background: var(--bg); text-decoration: none; }
.btn-icon.btn-icon-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-icon.btn-icon-danger { color: var(--danger); border-color: #f2c6bf; }

/* Gold-Buttons für PDF-Antrag / Negativlisten / Schildzettel etc. */
.btn-gold {
  display: inline-block;
  background: linear-gradient(180deg, #f6d382, #e0a83a);
  border: 1px solid #a97c22;
  color: #4a3510;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 3px;
  cursor: pointer;
  text-decoration: none;
}
.btn-gold:hover { background: linear-gradient(180deg, #f8dc9c, #eab84f); text-decoration: none; }

/* Kompakte Tabelle für die Historie ("Tabelle der Korrespondenz") */
.table-compact th, .table-compact td { padding: 5px 8px; font-size: 0.8rem; }
.table-compact td.col-betreff { font-weight: 600; }
.table-compact td.col-inhalt { color: var(--text-muted); max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.corr-table { background: #fff; border: 1px solid #b9c2d0; border-radius: 3px; overflow: hidden; }
.corr-table th { background: #eef3fb; color: #33425e; }

/* Historie / Verlauf */
.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
/* Bugfix (Software-Liste, "Erledigte Aufträge einklappbar"): eigener, per Klick auf-/zuklappbarer
   Bereich für archivierte ("erledigt") Aufträge unten in der Kundenauftragsliste. */
.customer-erledigt-details {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.customer-erledigt-summary {
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  user-select: none;
}
.customer-erledigt-summary::-webkit-details-marker { display: none; }
.customer-erledigt-summary::before {
  content: '▶';
  display: inline-block;
  margin-right: 6px;
  font-size: 0.7em;
  transition: transform 0.15s ease;
}
.customer-erledigt-details[open] .customer-erledigt-summary::before {
  transform: rotate(90deg);
}
.quick-actions details {
  position: relative;
}
.quick-actions summary {
  list-style: none;
  cursor: pointer;
}
.quick-actions summary::-webkit-details-marker { display: none; }
.quick-action-form {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  width: 340px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.timeline { display: flex; flex-direction: column; gap: 4px; }
.timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.timeline-body { flex: 1; min-width: 0; }
.timeline-meta { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.timeline-date { margin-left: auto; }
.timeline-subject { font-weight: 600; margin-top: 2px; }
.timeline-content { color: var(--text-muted); margin-top: 2px; white-space: pre-wrap; }
.timeline-item.type-system .timeline-subject,
.timeline-item.type-system .timeline-content { color: var(--text-muted); font-style: italic; }

/* ============================================================
   E-Mail-Ablage: eigenes Postfach durchsuchen und Nachrichten
   bei Aufträgen/Kunden/Lieferanten ablegen
   ============================================================ */
.mailbox-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.mailbox-tab {
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.mailbox-tab:hover { color: var(--text); }
.mailbox-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.mailbox-tab-add { color: var(--primary); opacity: 0.75; }
.mail-wrap { display: flex; gap: 16px; align-items: flex-start; }
.mail-list-pane { width: 340px; flex-shrink: 0; }
.mail-list-pane .form-row { margin-bottom: 8px; }
.mail-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  max-height: 70vh;
  overflow-y: auto;
}
.mail-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.mail-item:last-child { border-bottom: none; }
.mail-item:hover { background: var(--bg); }
.mail-item.active { background: #dbe6fb; }
.mail-item-from { font-weight: 600; font-size: 0.85rem; }
.mail-item-subject { font-size: 0.85rem; color: var(--text); margin-top: 2px; }
.mail-item-abgelegt { font-size: 0.8em; }
.mail-item-date { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.mail-preview-pane { flex: 1; min-width: 0; }
.mail-preview-pane .card { max-height: 75vh; overflow-y: auto; }
.mail-body { font-size: 0.9rem; line-height: 1.5; word-wrap: break-word; }
.mail-body img { max-width: 100%; }

/* ============================================================
   Historie-Tab-Leiste (Neue Notiz / E-Mail / Brief / Anruf / Besuch / Mehr)
   ============================================================ */
.corr-tabs {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
  background: #fff;
}
.corr-tabs-header {
  background: #f0ede8;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.corr-tabs-title { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #57534e; display: flex; align-items: center; gap: 6px; }
.corr-tabs-icons { color: #78716c; font-size: 0.9rem; display: flex; gap: 10px; }
.corr-tabs-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.corr-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 20px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #57534e;
  cursor: pointer;
  white-space: nowrap;
}
.corr-tab:hover { color: var(--primary); }
.corr-tab.active { color: var(--primary-light); border-bottom-color: var(--primary-light); }
.corr-panel { padding: 18px 20px; }
.corr-panel.hidden { display: none; }
/* !important, da diese Utility-Klasse jede andere display-Regel überstimmen soll, egal ob sie
   im Stylesheet vorher oder nachher deklariert wird (z.B. Overlays, die selbst "display: flex"
   setzen und sonst - bei gleicher CSS-Spezifität - je nach Reihenfolge im Stylesheet gewinnen
   und das Element trotz "hidden"-Klasse sichtbar lassen würden). */
.hidden { display: none !important; }
.corr-row-clickable { cursor: pointer; }
.corr-row-clickable:hover { background: var(--hover, rgba(0,0,0,0.03)); }
.mail-view-overlay {
  position: fixed; inset: 0; background: rgba(10,15,30,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.mail-view-box {
  background: var(--card); border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 640px; max-height: 80vh; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  overscroll-behavior: contain;
}
.mail-view-box .mail-view-meta { color: var(--muted, #667); font-size: 0.85rem; margin-bottom: 4px; }
.mail-view-box .mail-view-subject { font-weight: 600; font-size: 1.05rem; margin: 4px 0 14px; }
.mail-view-box .mail-view-body { white-space: pre-wrap; line-height: 1.5; border-top: 1px solid var(--border, #e2e2e2); padding-top: 14px; }

.corr-field { margin-bottom: 18px; }
.corr-field label { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.corr-field input[type="text"],
.corr-field input[type="email"],
.corr-field select,
.corr-field textarea {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 6px 2px;
  background: transparent;
  box-shadow: none;
}
.corr-field input[type="text"]:focus,
.corr-field input[type="email"]:focus,
.corr-field textarea:focus { outline: none; border-bottom-color: var(--primary-light); }
.corr-field-row { display: flex; align-items: center; gap: 10px; }
.corr-field-row .corr-field { flex: 1; margin-bottom: 0; }
.corr-links { display: flex; gap: 14px; }
.corr-links a { font-size: 0.78rem; color: var(--text-muted); cursor: pointer; }
.corr-links a:hover { color: var(--primary); text-decoration: underline; }

.corr-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.corr-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eef3fb;
  color: var(--primary);
  border-radius: 100px;
  padding: 3px 6px 3px 10px;
  font-size: 0.8rem;
}
.corr-chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1;
  padding: 2px;
}

/* Gruppen-Chip-Auswahl (Mitarbeiter -> mehrere Rollen/Gruppen, siehe views/users/form.ejs) */
.chip-toggle-wrap { display: inline-block; }
.chip-toggle {
  display: inline-flex;
  align-items: center;
  background: #eef3fb;
  color: var(--primary);
  border: 1px solid #dde6f5;
  border-radius: 100px;
  padding: 5px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
}
.chip-toggle-wrap input:checked + .chip-toggle {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.chip-toggle-group { display: flex; flex-wrap: wrap; gap: 8px; }

.override-table select { width: auto; min-width: 130px; }
.override-table td, .override-table th { padding: 6px 10px; }

.corr-editor-toolbar {
  display: flex;
  gap: 4px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.corr-editor-toolbar button {
  background: none;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 3px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.corr-editor-toolbar button:hover { background: var(--bg); color: var(--text); }
.corr-editor-body {
  min-height: 140px;
  padding: 4px 2px;
  font-size: 0.92rem;
  line-height: 1.5;
  outline: none;
}
.corr-editor-body:empty:before { content: attr(data-placeholder); color: #9ca3af; }

/* Punkt (Software-Liste): kleine Vorschau-Chips (Dokument-Icon + Dateiname) für Mail-Anhänge im
   E-Mail-Fenster (Angebot/Label/Antrag automatisch + manuell hochgeladene Dateien), siehe
   #emailAttachmentPreview in views/projects/show.ejs und views/deals/show.ejs. */
.email-attachment-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.email-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px 5px 6px;
  background: #f8f9fc;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  font-size: 0.78rem;
  color: #374151;
  max-width: 240px;
}
.email-attachment-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Bugfix (Software-Liste, "Mail-Anhang anklickbar machen"): Chip ist jetzt anklickbar und öffnet
   die PDF-Vorschau (window.openPdfViewer(), siehe partials/nav.ejs) - siehe renderAttachmentPreview()
   in views/projects/show.ejs bzw. views/deals/show.ejs. */
.email-attachment-chip.clickable { cursor: pointer; }
.email-attachment-chip.clickable:hover { background: #eef2ff; border-color: #c7d2fe; }

.corr-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}
.corr-actions-left { display: flex; gap: 10px; }
.corr-actions-right { display: flex; gap: 12px; color: var(--text-muted); font-size: 0.95rem; }

.ablegen-overlay {
  position: fixed; inset: 0; background: rgba(10,15,30,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.ablegen-box {
  background: var(--card); border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 420px; box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  max-height: 90vh; overflow-y: auto; overscroll-behavior: contain;
}

/* Punkte 1+4 (Software-Liste Runde AD): einheitliche dunkle Titelleiste für ALLE E-Mail-Ablage-
   Dialoge/Popups (Ablegen, Antworten/Schreiben in .ablegen-box, sowie der äußere iframe-Wrapper
   .modal-box in partials/email-ablage-modal.ejs) - macht das Ablage-System optisch einheitlich und
   gibt jedem dieser Dialoge einen klar sichtbaren Schließen-Button in der Titelleiste, statt ihn nur
   unten im Formular zu verstecken. Negative Margins lassen die Leiste bis an die abgerundeten Ecken
   der jeweiligen Box heranreichen (Box selbst hat padding:24px bzw. 0, siehe .ablegen-box/.modal-box).
   -mb (margin-bottom) wird pro Einsatzort passend gesetzt (siehe inline style im jeweiligen Dialog). */
.dialog-header-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--primary); color: #fff;
  padding: 14px 20px; margin: -24px -24px 18px -24px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.dialog-header-bar h3 { margin: 0; color: #fff; font-size: 1.05rem; }
.dialog-header-bar .btn-icon { color: #fff; border-color: rgba(255,255,255,0.4); }
.dialog-header-bar .btn-icon:hover { background: rgba(255,255,255,0.18); }
.dialog-header-bar .btn-sm.btn-secondary { background: rgba(255,255,255,0.15); color: #fff; border-color: rgba(255,255,255,0.4); }
.dialog-header-bar .btn-sm.btn-secondary:hover { background: rgba(255,255,255,0.28); }
.dialog-header-bar-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* Punkt 5 (Software-Liste Runde AD): Aufgaben-Übersicht mit Schnellfilter-Sidebar + Suche +
   Sortierung, angelehnt an den mitgeschickten Referenz-Screenshot. */
.aufgaben-layout { display: flex; gap: 20px; align-items: flex-start; }
.aufgaben-filter-sidebar {
  width: 230px; flex-shrink: 0; background: var(--card-bg, #fff);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
}
.aufgaben-filter-sidebar h4 { margin: 0 0 8px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.aufgaben-filter-sidebar .filter-group { margin-bottom: 16px; }
.aufgaben-filter-sidebar .filter-group:last-child { margin-bottom: 0; }
.aufgaben-filter-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px; border-radius: 6px; color: var(--text, #222); text-decoration: none; font-size: 0.92rem;
}
.aufgaben-filter-link:hover { background: var(--hover-bg, #f2f4f7); text-decoration: none; }
.aufgaben-filter-link.active { background: var(--primary); color: #fff; font-weight: 600; }
.aufgaben-filter-link .count { font-size: 0.8rem; opacity: 0.75; }
.aufgaben-filter-badge { font-size: 0.78rem; padding: 3px 9px; }
.aufgaben-main { flex: 1; min-width: 0; }
.aufgaben-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.aufgaben-toolbar input[type="search"] { flex: 1; min-width: 200px; }
.aufgaben-toolbar select { width: auto; }
@media (max-width: 800px) {
  .aufgaben-layout { flex-direction: column; }
  .aufgaben-filter-sidebar { width: 100%; }
}
@media (max-width: 900px) {
  .mail-wrap { flex-direction: column; }
  .mail-list-pane { width: 100%; }
}

/* Punkt 1 (Software-Liste Runde AC): Antworten-Dialog (siehe views/emailAblage/index.ejs
   #composeOverlay) - beim Antworten deutlich breiter (statt der schmalen 420-560px Standard-
   Dialogbreite) und zweispaltig, damit die vorangegangene E-Mail direkt daneben lesbar ist, ohne
   den Antwort-Dialog zu verlassen. Beim "Neu schreiben" (kein Bezug zu einer vorherigen Nachricht)
   bleibt die schmale, einspaltige Standardbreite bestehen (Klasse .compose-box-reply wird dafür
   nicht gesetzt, siehe JS openCompose()/openComposeReply()). */
.compose-box {
  background: var(--card); border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  /* Punkt 1 (Software-Liste Runde AE): verhindert, dass zu Ende gescrollter Dialog-Inhalt den
     Mausrad-Scroll an die Seite im Hintergrund "durchreicht" (Scroll-Chaining) - siehe ausführliche
     Erklärung bei .artikel-overlay weiter unten. */
  overscroll-behavior: contain;
}
.compose-box-reply { max-width: 1300px; width: 92vw; }
.compose-layout { display: flex; gap: 26px; align-items: flex-start; }
.compose-layout-main { flex: 1 1 55%; min-width: 0; }
.compose-layout-prev {
  flex: 1 1 45%; min-width: 0; max-height: 80vh; overflow-y: auto;
  border-left: 1px solid var(--border); padding-left: 22px;
  overscroll-behavior: contain;
}
.compose-prev-header { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.compose-prev-header h4 { margin: 0 0 4px; }
@media (max-width: 1050px) {
  .compose-layout { flex-direction: column; }
  .compose-layout-prev {
    border-left: none; border-top: 1px solid var(--border);
    padding-left: 0; padding-top: 16px; margin-top: 16px; max-height: 40vh;
  }
  .compose-box-reply { width: 96vw; }
}

/* Artikel-Suchen-Dialog (Angebotserstellung) */
.artikel-overlay {
  position: fixed; inset: 0; background: rgba(10,15,30,0.45);
  display: flex; align-items: flex-start; justify-content: center; z-index: 300;
  overflow-y: auto; padding: 40px 16px;
  /* Punkt 1 (Software-Liste Runde AE): Der Artikel-Suchen-Dialog ist bei vielen Suchergebnissen
     bzw. Warengruppen höher als der sichtbare Bereich - ohne "overscroll-behavior: contain" reicht
     der Browser das Mausrad-Scrollen, sobald der Dialog (bzw. die Artikelliste darin) sein Ende
     erreicht hat, an die Seite dahinter weiter ("Scroll-Chaining"), wodurch es so aussieht, als sei
     der Dialog selbst gar nicht scrollbar. "contain" beendet das Scrollen am Dialogrand, statt es
     an den Hintergrund weiterzugeben. Aus demselben Grund auch bei .artikel-list, .modal-overlay,
     .ablegen-box, .mail-view-box und .compose-box/.compose-layout-prev ergänzt (identisches Problem
     überall, wo ein Dialog höher als der Viewport werden kann). */
  overscroll-behavior: contain;
}
.artikel-box {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  width: 100%; max-width: 820px; box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.artikel-box-header {
  background: var(--primary, #7a1638); color: #fff; padding: 14px 20px;
  font-weight: 600; display: flex; align-items: center; gap: 10px;
}
.artikel-box-header button { background: none; border: none; color: #fff; font-size: 1.1rem; cursor: pointer; margin-left: auto; }
.artikel-box-body { padding: 18px 20px; }
.artikel-search-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border, #d8dce3);
  border-radius: 6px; font-size: 0.95rem; margin-bottom: 14px;
}
.artikel-search-layout { display: flex; gap: 24px; align-items: flex-start; }
.artikel-list-col { flex: 1; min-width: 0; }
.artikel-filter-col { width: 220px; flex-shrink: 0; }
.artikel-filter-col h4 { margin: 0 0 8px; font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); }
.artikel-filter-option {
  display: flex; align-items: center; gap: 6px; padding: 4px 0; font-size: 0.88rem; cursor: pointer;
}
.artikel-filter-option input { width: auto; }
.artikel-filter-option.disabled { color: #b7bcc6; cursor: default; }
.artikel-list { max-height: 380px; overflow-y: auto; overscroll-behavior: contain; }
.artikel-list-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 4px;
  border-bottom: 1px solid var(--border, #eee); font-size: 0.92rem; position: relative;
}
.artikel-list-item .artikel-name { flex: 1; }
.artikel-list-item .artikel-preis { color: var(--text-muted); width: 90px; text-align: right; }
.artikel-list-item .artikel-auswaehlen {
  display: none; position: absolute; right: 90px; top: 50%; transform: translateY(-50%);
}
.artikel-list-item:hover .artikel-auswaehlen { display: inline-flex; }
.artikel-list-item:hover .artikel-name { opacity: 0.35; }
.artikel-empty { color: var(--text-muted); font-size: 0.9rem; padding: 16px 4px; }
.artikel-box-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-top: 1px solid var(--border, #eee);
}
.artikel-neu-form { display: none; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border, #ddd); }
.artikel-neu-form.open { display: block; }
.artikel-neu-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }

/* Position bearbeiten (Schritt 2) */
/* Sub-Navigation über der Rechnungen-/Gutschriften-Tabelle */
.invoice-subnav {
  display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--border);
}
.invoice-subnav a {
  padding: 8px 16px; font-size: 0.86rem; font-weight: 600; color: var(--text-muted);
  border-bottom: 2px solid transparent;
}
.invoice-subnav a:hover { color: var(--primary); text-decoration: none; }
.invoice-subnav a.active { color: var(--primary); border-bottom-color: var(--accent); }

/* ============================================================
   Kalender: Monatsansicht der Aufträge
   ============================================================ */
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.cal-legend { display: flex; gap: 16px; font-size: 0.8rem; color: var(--text-muted); }
.cal-legend-item { display: flex; align-items: center; gap: 6px; }
.cal-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.cal-dot-hv { background: var(--accent); }
.cal-dot-vs { background: var(--primary-light); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-grid-weekdays {
  border-bottom: 1px solid var(--border); background: var(--bg);
}
.cal-grid-weekdays div {
  padding: 8px 10px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--text-muted);
}
.cal-cell {
  /* Bugfix (Runde AU, Punkt 5): ohne "min-width: 0" berechnet CSS Grid die automatische
     Mindestbreite einer "1fr"-Spalte u.a. aus dem intrinsischen Inhalt der Zelle (min-content) -
     ein langer, nicht umbrechender Event-Titel (siehe .cal-badge white-space: nowrap) konnte
     dadurch trotz overflow:hidden/text-ellipsis die betroffene Spalte breiter ziehen als die
     übrigen 6 Spalten in derselben Zeile, was auf Screenshots als "uneinheitliche Kachelbreiten"
     auffiel. "min-width: 0" erzwingt, dass die Spaltenbreite ausschließlich von grid-template-
     columns (repeat(7, 1fr), siehe .cal-grid) bestimmt wird, nie vom Zeileninhalt. */
  min-width: 0; max-width: 100%; box-sizing: border-box;
  min-height: 110px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 6px 6px 8px; display: flex; flex-direction: column; gap: 4px;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell-outside { background: #fafbfd; color: var(--text-muted); }
.cal-cell-outside .cal-cell-date { color: #b7bcc6; }
.cal-cell-today { background: #fff4ea; }
.cal-cell-today .cal-cell-date {
  background: var(--accent); color: #fff; border-radius: 50%;
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
}
.cal-cell-date { font-size: 0.82rem; font-weight: 600; }
/* Bugfix (Runde AU, Punkt 5): Tage mit vielen Einträgen (Aufträge+Termine+Aufgaben, je bis zu 3
   plus "+N mehr", siehe views/calendar/_month.ejs) sollen die Zeilenhöhe nicht mehr unbegrenzt
   aufblähen und dadurch die komplette Kalenderzeile uneinheitlich hoch wirken lassen - stattdessen
   scrollt eine einzelne Zelle ab einer festen Maximalhöhe intern. */
.cal-cell-items { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; overflow-x: hidden; max-height: 118px; min-width: 0; }
.cal-badge {
  display: block; font-size: 0.7rem; padding: 2px 6px; border-radius: 4px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; max-width: 100%;
  box-sizing: border-box;
}
.cal-badge:hover { opacity: 0.85; text-decoration: none; }
.cal-badge-hv { background: var(--accent); }
.cal-badge-vs { background: var(--primary-light); }
.cal-more { font-size: 0.7rem; color: var(--text-muted); padding: 0 4px; }
.cal-cell-header { display: flex; align-items: center; justify-content: space-between; }
.cal-cell-add {
  width: 18px; height: 18px; border-radius: 4px; border: 1px solid var(--border); background: #fff;
  color: var(--text-muted); cursor: pointer; font-size: 0.8rem; line-height: 1; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.cal-cell-add:hover { background: var(--bg); color: var(--primary); }
.cal-badge-termin { background: #3a3f4b; }
/* Aufgaben-Deadline im Kalender (Punkt 1, Software-Liste Runde AK). */
.cal-badge-aufgabe { background: #9333ea; }
@media (max-width: 900px) {
  .cal-cell { min-height: 70px; }
  .cal-legend { display: none; }
}

/* Kalender: Toolbar (Navigation, Ansichts-Umschalter, Mitarbeiter-Filter, Termin anlegen) */
.cal-toolbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 12px; margin-bottom: 16px;
}
.cal-toolbar-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cal-toolbar-right { display: flex; align-items: center; gap: 10px; }
.cal-toolbar-right select { width: auto; min-width: 170px; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-title { font-size: 1.15rem; font-weight: 700; color: var(--primary); min-width: 180px; }
.cal-view-switch {
  display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.cal-view-switch a {
  padding: 7px 14px; font-size: 0.85rem; color: var(--text); background: #fff; border-right: 1px solid var(--border);
}
.cal-view-switch a:last-child { border-right: none; }
.cal-view-switch a:hover { background: var(--bg); text-decoration: none; }
.cal-view-switch a.active { background: var(--primary); color: #fff; }

/* Kalender: Wochen-/Tagesansicht mit Stundenraster */
.cal-week-wrap { border: 1px solid var(--border); border-radius: var(--radius); }
.cal-week-grid { display: grid; }
.cal-week-corner, .cal-week-rowlabel, .cal-week-hourlabel {
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  font-size: 0.72rem; color: var(--text-muted); padding: 6px 8px; background: var(--bg);
}
.cal-week-daylabel {
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 8px 6px; text-align: center; background: var(--bg);
}
.cal-week-daylabel:last-child { border-right: none; }
.cal-week-dayname { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.cal-week-daynum { font-size: 1rem; font-weight: 700; }
.cal-week-daylabel.cal-cell-today .cal-week-daynum { color: var(--accent); }
.cal-week-allday, .cal-week-hourcell {
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 4px 6px; min-height: 40px; display: flex; flex-direction: column; gap: 3px;
}
.cal-week-allday:last-of-type, .cal-week-hourcell:last-of-type { border-right: none; }
.cal-week-allday.cal-cell-today, .cal-week-hourcell.cal-cell-today { background: #fff4ea; }
.cal-appt {
  background: #eef1f7; border-left: 3px solid var(--primary); border-radius: 3px;
  padding: 3px 6px; font-size: 0.75rem; display: flex; align-items: center; gap: 6px;
}
.cal-appt-time { font-weight: 700; color: var(--primary); }
.cal-appt-del {
  background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.9rem;
  margin-left: auto; padding: 0 2px; line-height: 1;
}
.cal-appt-del:hover { color: var(--danger); }

/* Kalender: Jahresansicht (Mini-Monate) */
.cal-year-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1100px) { .cal-year-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) { .cal-year-grid { grid-template-columns: repeat(2, 1fr); } }
.cal-year-month { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.cal-year-month-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 6px; text-align: center; }
.cal-year-month-title a { color: var(--primary); }
.cal-year-weekdays, .cal-year-days { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-year-weekdays div { font-size: 0.62rem; color: var(--text-muted); text-align: center; padding: 2px 0; }
.cal-year-day {
  font-size: 0.68rem; text-align: center; padding: 3px 0; color: var(--text); border-radius: 3px; position: relative;
}
.cal-year-day:hover { background: var(--bg); text-decoration: none; }
.cal-year-day.outside { color: #c6cad2; }
.cal-year-day.today { background: var(--accent); color: #fff; font-weight: 700; }
.cal-year-day.has-entries::after {
  content: ''; position: absolute; bottom: 1px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--primary-light);
}
.cal-year-day.today.has-entries::after { background: #fff; }

/* Kalender: Termin-Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,30,50,0.45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
  overscroll-behavior: contain;
}
.modal-box {
  background: var(--card); border-radius: var(--radius); padding: 22px; width: 100%; max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }

/* Bugfix (echter Fehler, von Stephan gemeldet, Screenshot mit rot/grün markiertem Fenster): siehe
   ausführlicher Kommentar in views/partials/email-ablage-modal.ejs - blendet beim "Per E-Mail
   senden" aus Rechnung/Angebot/Gutschrift (composePrefill-Modus) die äußere Modal-Chrome komplett
   aus, damit einzig das innere Compose-Fenster (mit eigener Titelleiste) sichtbar bleibt. Der
   dunkle Hintergrund-Tint kommt dann allein vom inneren Compose-Overlay (.ablegen-overlay in der
   eingebetteten Seite) - ohne diese Regel gäbe es zwei übereinanderliegende, sichtbar
   unterschiedliche Rahmen/Titelleisten. */
#emailAblageModalOverlay.email-ablage-bare { background: transparent; padding: 0; align-items: stretch; }
#emailAblageModalOverlay.email-ablage-bare .modal-box.email-ablage-bare {
  max-width: none; width: 100%; height: 100vh; box-shadow: none; border-radius: 0; background: transparent;
}
#emailAblageModalOverlay.email-ablage-bare .modal-box.email-ablage-bare #emailAblageModalHeaderBar { display: none; }
#emailAblageModalOverlay.email-ablage-bare .modal-box.email-ablage-bare iframe { height: 100vh; }
.cal-type-filter { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 4px; }
.cal-type-option { display: flex; align-items: center; gap: 5px; font-size: 0.85rem; font-weight: 400; text-transform: none; color: var(--text); }
.cal-type-option input { width: auto; }
.cal-employee-checks { display: flex; flex-direction: column; gap: 6px; max-height: 160px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; }
.cal-employee-check { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; font-weight: 400; text-transform: none; color: var(--text); }
.cal-employee-check input { width: auto; }

.position-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 14px; align-items: end; margin-bottom: 14px; }
.position-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: end; margin-bottom: 14px; }
.position-calc-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.position-gewinn { font-weight: 600; }
.position-gewinn.negativ { color: #b3261e; }
.position-gewinn.positiv { color: #1a7f37; }

/* Größerer runder Icon-Button (z.B. "+ Neue Aufgabe" oben rechts in der Aufgabenübersicht) */
.btn-icon-lg { width: 38px; height: 38px; border-radius: 50%; font-size: 1.3rem; }

/* Aufgaben: flache Liste (siehe partials/aufgaben-liste.ejs + partials/aufgabe-zeile.ejs).
   Kein overflow:hidden hier (würde die Status-/Zuweisen-/Deadline-Popups, die als Dropdown unter
   der jeweiligen Zeile aufklappen, abschneiden und unsichtbar machen). */
.task-list { border: 1px solid var(--border); border-radius: var(--radius); }
.task-row {
  display: flex; align-items: center; gap: 14px; padding: 15px 18px;
  border-top: 1px solid var(--border); font-size: 1.02rem;
}
.task-list .task-row:first-child { border-top: none; }
.task-bullet {
  width: 12px; height: 12px; border-radius: 50%; flex: none;
  border: 2px solid #b7c0d1; background: transparent;
}
.task-bullet.done { border-color: #1a7f37; background: #1a7f37; }
.task-title { color: var(--text); text-decoration: none; flex: 1; min-width: 0; font-weight: 600; }
.task-title:hover { text-decoration: underline; }
.task-title.done { text-decoration: line-through; color: var(--text-muted); }
.task-row-right { display: flex; align-items: center; gap: 16px; flex: none; }
.task-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; color: #fff; font-size: 0.85rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.task-deadline { font-size: 0.82rem; color: var(--text-muted); text-align: right; line-height: 1.3; min-width: 64px; cursor: pointer; }
.task-deadline.overdue { color: var(--danger); font-weight: 700; }
.task-avatar-empty { background: #d7dce4; color: #6b7280; font-size: 1rem; }
.task-row .btn-icon { width: 30px; height: 30px; font-size: 1rem; }

/* Aufgaben: Mitarbeiter-/Deadline-Schnellauswahl-Popups (siehe partials/aufgabe-zeile.ejs) - auf
   Basis des .status-picker-Popup-Musters (Details/Summary), damit Öffnen/Schließen/Klick-außerhalb
   automatisch über die bestehende globale Steuerung in partials/nav.ejs mitläuft. */
.assignee-picker summary, .deadline-picker summary { list-style: none; cursor: pointer; }
.assignee-picker summary::-webkit-details-marker, .deadline-picker summary::-webkit-details-marker { display: none; }
/* Bugfix (Software-Liste Runde AS, Punkt 2): der Mitarbeiter-Filter sitzt praktisch überall rechts
   im Toolbar/Header (page-header-actions, Kalender-Toolbar usw.) - mit dem geerbten "left:0" von
   .status-picker-menu ragte das Menü rechts über den Fensterrand hinaus. right:0 lässt das Menü
   stattdessen nach links aufklappen (analog zur bereits bestehenden .task-menu-picker-Regel unten). */
.assignee-picker-menu { left: auto; right: 0; min-width: 200px; max-height: 260px; overflow-y: auto; padding: 4px; }
.assignee-picker-menu form { margin: 0; }
.assignee-picker-option {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 6px 10px; border: none; background: none; border-radius: var(--radius); cursor: pointer; font-size: 0.85rem;
  color: var(--text);
}
.assignee-picker-option:hover { background: var(--bg); text-decoration: none; }
.assignee-picker-option.active { background: #eef3fb; font-weight: 600; }
.deadline-picker-menu { padding: 12px; }
.deadline-picker-form { display: flex; flex-direction: column; gap: 8px; }

/* Aufgaben-Zeile: ⋮-Aktionsmenü (Öffnen/Bearbeiten/Verschieben/Duplizieren/Löschen), ersetzt den
   früheren einzelnen Löschen-Button. Öffnet nach rechts (right:0) statt nach links, da es das
   letzte/rechteste Element der Zeile ist und sonst über den Seitenrand hinausragen könnte. */
.task-menu-picker summary { list-style: none; cursor: pointer; }
.task-menu-picker summary::-webkit-details-marker { display: none; }
.task-menu-picker .status-picker-menu { left: auto; right: 0; min-width: 170px; }

/* Bugfix (Software-Liste): "Aufgaben aus Vorlage anlegen"-Dropdown (📋-Button neben "+" im
   Aufgaben-Kartenkopf, views/projects/show.ejs) sitzt wie das ⋮-Aktionsmenü oben ganz rechts im
   Kartenkopf - mit dem geerbten "left:0" von .status-picker-menu ragte es über den rechten
   Fensterrand hinaus und war dadurch teilweise unsichtbar/nicht klickbar. Gleiche Lösung wie bei
   .task-menu-picker/.assignee-picker-menu oben: rechtsbündig aufklappen. */
.task-vorlage-picker .status-picker-menu { left: auto; right: 0; min-width: 220px; }
.task-menu a, .task-menu button {
  display: block; width: 100%; text-align: left; padding: 6px 10px; border: none; background: none;
  border-radius: 4px; cursor: pointer; font-size: 0.85rem; color: var(--text); text-decoration: none;
}
.task-menu form { margin: 0; }
.task-menu a:hover, .task-menu button:hover { background: var(--bg); }
.task-menu-danger { color: var(--danger) !important; }

/* Historie als Feed mit Vorschau (siehe partials/historie-eintragen.ejs + views/tasks/form.ejs) -
   im Unterschied zur kompakten Korrespondenz-Tabelle auf der Auftragsseite: größer, mit Avatar,
   Betreff/Absender in einer Kopfzeile. Der Inhalt ist standardmäßig auf 3 Zeilen begrenzt
   (-webkit-line-clamp) und klappt per Klick auf den Text bzw. den "Mehr anzeigen"-Link auf/zu
   (siehe partials/historie-feed.ejs). */
.hist-feed { display: flex; flex-direction: column; gap: 10px; }
.hist-feed-item {
  display: flex; gap: 12px; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.hist-feed-avatar {
  position: relative; flex: none; width: 38px; height: 38px; border-radius: 50%; color: #fff;
  font-size: 0.75rem; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.hist-feed-icon {
  position: absolute; bottom: -3px; right: -3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 1px solid var(--border); font-size: 0.65rem; line-height: 16px; text-align: center;
}
.hist-feed-body { flex: 1; min-width: 0; }
.hist-feed-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.hist-feed-summary { font-size: 0.9rem; color: var(--text); }
.hist-feed-summary b { font-weight: 700; }
.hist-feed-summary a { color: var(--primary-light); }
.hist-feed-time { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.hist-feed-preview-wrap { margin-top: 6px; }
.hist-feed-preview {
  font-size: 0.85rem; color: var(--text); white-space: pre-wrap; line-height: 1.5; cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hist-feed-preview.expanded { -webkit-line-clamp: unset; display: block; overflow: visible; }
.hist-feed-toggle { display: none; margin-top: 4px; font-size: 0.75rem; color: var(--primary-light); text-decoration: none; }
.hist-feed-toggle.visible { display: inline-block; }
.hist-feed-toggle:hover { text-decoration: underline; }
.hist-feed-attachment { margin-top: 8px; font-size: 0.8rem; color: var(--text-muted); }
.hist-feed-actions { display: flex; gap: 14px; margin-top: 8px; }
.hist-feed-action { font-size: 0.78rem; color: var(--primary-light); text-decoration: none; }
.hist-feed-action:hover { text-decoration: underline; }
.hist-feed-empty { color: var(--text-muted); font-size: 0.85rem; padding: 10px 0; }

/* PDF-Vorschau-Popup (siehe partials/nav.ejs, openPdfViewer) - großes Modal fast über die ganze
   Seite, damit im eingebetteten (nativen) Browser-PDF-Viewer noch genug Platz zum Lesen/Zoomen bleibt. */
.pdf-viewer-box { max-width: 1100px; width: 96%; padding: 0; overflow: hidden; display: flex; flex-direction: column; height: 92vh; }
.pdf-viewer-header { padding: 12px 18px; border-bottom: 1px solid var(--border); margin-bottom: 0; flex: none; }
.pdf-viewer-header h3 { margin: 0; font-size: 0.95rem; }
.pdf-viewer-frame { flex: 1; width: 100%; border: 0; display: block; }

/* Bugfix (Software-Liste, "sauberes Mail-Popup"): die kleine <details>-Dropdown-Box zum Versenden
   von Angeboten/Rechnungen/Gutschriften (siehe views/quotes|invoices|creditNotes/show.ejs) war zu
   schmal, ließ sich nicht schließen und zeigte keinen Anhang - jetzt ein richtiges, breites Modal
   (siehe partials/email-modal.ejs), analog zum bestehenden Muster von .pdf-viewer-box oben. */
.email-modal-box { max-width: 680px; width: 96%; max-height: 92vh; overflow-y: auto; }
.email-modal-box textarea#emailModalBody { min-height: 220px; resize: vertical; }
.email-modal-toggle-row { display: flex; gap: 14px; margin: -6px 0 14px; }
.email-modal-toggle-row button {
  border: none; background: none; padding: 0; color: var(--primary); font-size: 0.82rem;
  cursor: pointer; text-decoration: underline;
}

/* Bugfix (Software-Liste, "Aufgabenvorlagen: Mitarbeiter-Auswahl") - Checkbox-Liste mit
   Mitarbeiter-Avataren, siehe views/taskTemplates/form.ejs. */
.employee-avatar-picker { display: flex; flex-wrap: wrap; gap: 10px; }
.employee-avatar-check {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px;
  border: 1px solid var(--border); border-radius: 20px; cursor: pointer; font-weight: 400;
  text-transform: none; font-size: 0.85rem; color: var(--text); background: #fff;
}
.employee-avatar-check:has(input:checked) { border-color: var(--primary); background: #eef2ff; }
.employee-avatar-check input { width: auto; margin: 0; }
.employee-avatar-circle {
  width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: #fff; font-size: 0.62rem; font-weight: 700; flex: none;
}

/* @Mention-Autocomplete (siehe partials/nav.ejs, initMentionTextarea) - fest positioniertes
   Dropdown direkt unter der Cursor-Position im Textfeld. */
.mention-dropdown {
  position: fixed;
  z-index: 3000;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  min-width: 160px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
}
.mention-dropdown-item { padding: 7px 14px; font-size: 0.88rem; cursor: pointer; }
.mention-dropdown-item:hover { background: var(--bg-hover, #f0f2f5); }

/* E-Mail-Empfänger-Dropdown (siehe partials/nav.ejs, initRecipientPicker) - Kontaktbuch/
   Ansprechpartner-Auswahl mit Avatar-Kürzel/Gebäude-Icon statt der schlichten Browser-Datalist. */
.recipient-dropdown {
  position: fixed;
  z-index: 3000;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  max-height: 300px;
  overflow-y: auto;
  padding: 4px 0;
}
.recipient-dropdown-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; }
.recipient-dropdown-item:hover { background: var(--bg-hover, #f0f2f5); }
.recipient-avatar {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.recipient-avatar.recipient-avatar-firma { background: #6b7280; border-radius: 7px; font-size: 0.95rem; }
.recipient-info { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.recipient-name { font-size: 0.86rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recipient-sub { font-size: 0.74rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Rechte-System (siehe middleware/auth.js + partials/nav.ejs): Sachbearbeiter sehen keine
   Löschen-Buttons/-Icons - serverseitig ist das Löschen ohnehin über requireNotSachbearbeiter
   gesperrt, dies blendet die dafür nutzlosen Buttons zusätzlich aus der Oberfläche aus. */
html.role-sachbearbeiter .btn-danger,
html.role-sachbearbeiter .btn-icon-danger,
html.role-sachbearbeiter .task-menu-danger,
html.role-sachbearbeiter .cal-appt-del {
  display: none !important;
}

/* Behörden-Antrag Feld-Designer (siehe views/authorityTemplates/designer.ejs) */
.designer-layout { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.designer-canvas-wrap { flex: 1; min-width: 320px; overflow-x: auto; }
.designer-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.designer-toolbar select, .designer-toolbar input[type="text"] { width: auto; }
.designer-fields-list { width: 280px; flex: none; }
.designer-fields-ul { list-style: none; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: var(--radius); max-height: 500px; overflow-y: auto; }
.designer-fields-ul li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--border); font-size: 0.85rem; }
.designer-fields-ul li:first-child { border-top: none; }

/* Aufträge: Ansichts-Umschalter (Spaltenansicht/Pipeline) + Pipeline-Kanban-Board
   (siehe views/projects/list.ejs, routes/projects.js) */
.view-toggle { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.spalten-anpassen { position: relative; }
.spalten-anpassen summary { list-style: none; cursor: pointer; }
.spalten-anpassen summary::-webkit-details-marker { display: none; }
.spalten-anpassen-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 180px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 4px 14px rgba(0,0,0,0.14);
}
.spalten-anpassen-menu label { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 400; }
.spalten-anpassen-menu input[type="checkbox"] { width: auto; }

.pipeline-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.pipeline-column {
  flex: 0 0 260px; width: 260px; background: #f5f7fb; border-radius: var(--radius);
  display: flex; flex-direction: column; max-height: calc(100vh - 260px);
}
.pipeline-column-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-top: 3px solid #8a94a6; border-radius: var(--radius) var(--radius) 0 0;
  background: #fff;
}
.pipeline-column-title { font-weight: 700; font-size: 0.88rem; }
.pipeline-column-count {
  background: #e3e7ee; color: var(--text-muted); border-radius: 10px; padding: 1px 8px; font-size: 0.78rem; font-weight: 700;
}
.pipeline-column-sum { padding: 4px 12px; background: #fff; }
.pipeline-column-body {
  flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 60px;
}
.pipeline-column-body.drag-over { background: #e9edf7; outline: 2px dashed var(--primary, #3b5bdb); outline-offset: -2px; }
.pipeline-card {
  display: block; background: #fff; border-radius: var(--radius); padding: 10px 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08); text-decoration: none; color: var(--text); cursor: grab;
  border: 1px solid var(--border);
}
.pipeline-card:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.12); }
.pipeline-card.dragging { opacity: 0.4; }
.pipeline-card-title { font-weight: 700; font-size: 0.88rem; margin-bottom: 2px; }
.pipeline-card-sub { line-height: 1.4; }
.pipeline-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.pipeline-card-amount { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); }
