/* ── Reset & Variables ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Icons (inline outline SVG, replaces emoji glyphs) ── */
.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.125em; flex: none; }
button .icon, a .icon { pointer-events: none; }

:root {
  --bg: #f0f1f3;
  --surface: #ffffff;
  --column-bg: #e4e6ea;
  --card-bg: #ffffff;
  /* Die Kopfleiste hat ein eigenes Merkmal: sie soll neutral bleiben, auch
     wenn --primary sich aendert. */
  --topbar-bg: #38393d;
  --primary: #1f4daa;
  --primary-hover: #193e88;
  /* Fuer die Aufhellungen weiter unten (rgba). Muss zu --primary passen. */
  --primary-rgb: 31, 77, 170;
  --text: #172b4d;
  --text-muted: #6b778c;
  --border: #dfe1e6;
  /* Trennlinien duerfen zart sein. Ein Rahmen, der ein BEDIENELEMENT kenntlich
     macht (Eingabefeld, Auswahl, Editor), braucht 3:1 gegen seinen Hintergrund
     — sonst ist nicht zu erkennen, wo man klicken kann. --border misst 1,31:1
     auf Weiss und reicht dafuer nicht. Gemessen: 3,83:1 auf Weiss, 3,39:1 auf
     --bg. */
  --border-control: #788396;
  --danger: #de350b;
  --danger-hover: #bf2600;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.1);
  --shadow-modal: 0 8px 32px rgba(0,0,0,.2);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

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

/* ── Topbar ── */
.topbar {
  background: var(--topbar-bg);
  color: #fff;
  padding: 0 20px;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}
.topbar-title { font-weight: 700; font-size: 16px; color: inherit; text-decoration: none; }
/* Board-Ansicht: kein Platz für den App-Namen (Board-Name, Layout-/Mitglieder-Buttons, Suche). Logo bleibt. */
.board-wrap .topbar-title { display: none; }
.topbar-logo-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: #fff; opacity: 1; flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  transition: transform .15s;
}
.topbar-logo-link:hover { opacity: 1; transform: scale(1.05); }
.topbar-logo { width: 28px; height: 28px; display: block; }
#btn-toggle-layout, #btn-manage-members { color: #fff; opacity: .85; }
#btn-toggle-layout:hover, #btn-manage-members:hover { opacity: 1; background: rgba(255,255,255,.2); color: #fff; }
.topbar a { color: #fff; opacity: .85; }
.topbar a:hover { opacity: 1; text-decoration: none; }
.topbar a:not(.topbar-logo-link) { padding: 5px 8px; border-radius: 4px; }
.topbar a:not(.topbar-logo-link):hover { background: rgba(255,255,255,.12); }
.topbar a.active { opacity: 1; font-weight: 600; background: rgba(255,255,255,.2); }
.topbar a.active:hover { background: rgba(255,255,255,.28); }
.topbar-spacer { flex: 1; }

/* ── Navigation: in der Leiste, auf schmalen Schirmen als Schublade ──
   Ein Behaelter, zwei Erscheinungsformen. Auf breiten Schirmen liegt die
   Navigation in der Leiste wie bisher; unter 900px wird derselbe Behaelter zur
   Schublade am rechten Rand. Kein zweiter Satz Links, der auseinanderlaufen
   koennte. */
.topbar-nav { display: contents; }
.topbar-burger {
  display: none;
  background: none; border: none; padding: 6px; margin: 0;
  color: #fff; opacity: .85; cursor: pointer; border-radius: 4px;
}
.topbar-burger:hover { opacity: 1; background: rgba(255,255,255,.12); }
.topbar-burger .icon { width: 22px; height: 22px; }
.offcanvas-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 1090;
}
.offcanvas-backdrop.hidden { display: none; }

@media (max-width: 900px) {
  .topbar-burger { display: inline-flex; }
  .topbar-nav {
    display: flex;
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 260px; max-width: 82vw;
    flex-direction: column; align-items: stretch; gap: 4px;
    padding: 16px 12px;
    background: var(--topbar-bg);
    box-shadow: 0 15px 35px rgba(0,0,0,.35);
    transform: translateX(100%);
    /* visibility, nicht nur transform: die verschobene Schublade stand sonst
       rechts NEBEN der Seite und machte das Dokument breiter als den Schirm.
       Nebenbei ist sie so auch fuer die Tastatur unerreichbar, solange sie zu
       ist. */
    visibility: hidden;
    transition: transform .2s ease, visibility .2s;
    z-index: 1100;
    overflow-y: auto;
  }
  .topbar-nav.open { transform: none; visibility: visible; }

  /* Die geschlossene Schublade steht rechts NEBEN der Seite und machte das
     Dokument dadurch breiter als den Schirm — auf index.php 563 statt 386. */
  html, body { overflow-x: hidden; }


  /* Tabellen, die sich nicht kuerzen lassen (Feld-Editor der Administration),
     scrollen wenigstens sauber innerhalb ihres Bereichs, statt die Seite
     breiter zu machen. */
  .ticket-table { font-size: 13px; }

  /* Seitenkopf und seine Bedienelemente duerfen umbrechen. Auf „Meine Boards"
     lagen Sortierung, Filter, Suche und zwei Knoepfe in EINER Reihe ohne
     Umbruch — zusammen 508px auf einem 390px-Schirm, also nicht bedienbar.
     Betrifft alle Seiten mit .page-header gleichermassen. */
  .page-header { flex-wrap: wrap; gap: 12px; }
  .page-header-actions { flex-wrap: wrap; width: 100%; gap: 8px; }
  .board-sort-wrap { flex-wrap: wrap; width: 100%; }
  /* Die Suche darf die Zeile fuellen, statt neben zwei Klapplisten zu
     verhungern. */
  .board-sort-wrap input[type=text] { flex: 1; min-width: 160px; }

  /* Die Leiste wird eng: 16px Abstand mal acht Elemente sind allein 112px. */
  .topbar { gap: 8px; padding: 0 12px; }
  /* Die Board-Knoepfe zeigen nur noch ihr Sinnbild — „Horizontal" und
     „Optionen" belegten zusammen 187px von 386. */
  #btn-toggle-layout span, #btn-manage-members span { display: none; }
  #board-name-display { display: none; }
  /* In der Schublade sind die Eintraege Zeilen, keine Knoepfe nebeneinander. */
  .topbar-nav a:not(.topbar-logo-link) { padding: 12px; border-radius: 6px; font-size: 15px; }
  .topbar-user { border-bottom: 1px solid rgba(255,255,255,.2); margin-bottom: 8px; padding-bottom: 12px !important; }
  /* Der App-Name weicht dem Platz — das Logo bleibt als Weg zur Uebersicht. */
  .topbar-title { display: none; }
}

/* ── Search ── */
/* Suche: kollabiert zu kleiner Lupen-Pille, bei Fokus (oder solange Text drin ist)
   breit + weiß, überlagert per absoluter Position die Menüelemente rechts. */
.search-wrap { position: relative; width: 36px; height: 32px; flex-shrink: 0; }
.search-wrap .search-icon {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  display: inline-flex; color: #fff; opacity: .9;
  pointer-events: none; z-index: 2; transition: color .2s ease;
}
.search-wrap .search-icon .icon { width: 16px; height: 16px; }
/* Der Selektor nennt die Leiste mit, weil die allgemeine Formularregel weiter
   unten (input[type="text"] …) sonst spezifischer waere und die Pille weiss
   uebermalt — sie soll eingeklappt aber durchscheinend sein. */
.topbar .search-input {
  position: absolute; left: 0; top: 0; height: 32px; box-sizing: border-box;
  width: 36px; padding: 6px 12px 6px 32px;
  border: none; border-radius: 20px;
  font-size: 13px; background: rgba(255,255,255,.2); color: #fff;
  cursor: pointer; transition: width .2s ease, background .2s ease, color .2s ease, box-shadow .2s ease;
}
.search-input::placeholder { color: rgba(255,255,255,.7); }
.search-input:focus, .search-input:not(:placeholder-shown) {
  outline: none; width: 320px; cursor: text; z-index: 20;
  background: #fff; color: var(--text); box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.search-input:focus::placeholder, .search-input:not(:placeholder-shown)::placeholder { color: var(--text-muted); }
.search-input:focus ~ .search-icon,
.search-input:not(:placeholder-shown) ~ .search-icon { color: var(--text-muted); opacity: 1; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--column-bg); color: var(--text); }
.btn-secondary:hover { background: #d0d3d8; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 4px 8px; }
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
/* Ein Icon erbt sonst die Schriftgroesse — in einem btn-sm waeren das 12 px,
   und ein Knopf, der NUR aus diesem Icon besteht, ist dann kaum zu treffen.
   Die Beschriftung darf klein bleiben, das Sinnbild nicht. */
.btn-sm .icon { width: 16px; height: 16px; }

/* ── Forms ── */
/* Datumsfelder gehoerten nie dazu und trugen deshalb den Browser-Rahmen —
   neben den uebrigen Feldern sah das aus wie ein Fehler. */
input[type=text], input[type=email], input[type=password], input[type=date],
textarea, select {
  width: 100%;
  padding: 8px 10px;
  /* 1px statt 2px: die Farbe muss bei 3:1 bleiben (der Rahmen ist das Einzige,
     was das Feld kenntlich macht), also nimmt man das Gewicht ueber die Staerke
     zurueck statt ueber den Ton. */
  border: 1px solid var(--border-control);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
}
input[type=text]:focus, input[type=email]:focus, input[type=password]:focus,
input[type=date]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  /* Mit dem duenneren Rahmen traegt der Farbwechsel allein den Fokus nicht mehr.
     Der Ring liegt aussen und verschiebt nichts. */
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .25);
}
/* Einzeilige Bedienelemente auf EINE Hoehe zwingen. Ohne das rechnet jeder
   Typ seine eigene: gemessen 36,5px beim Textfeld gegen 38,5px bei Auswahl und
   Datum — nebeneinander in einer Zeile sieht das nach Fehler aus. line-height
   hilft nicht, die Hoehe einer <select> bestimmt der Browser.
   38px ist kein gegriffener Wert: 14px Schrift + 2x8 Innenabstand + 2x2 Rahmen.
   textarea ist bewusst ausgenommen — die soll mehrzeilig wachsen. */
input[type=text], input[type=email], input[type=password], input[type=date], select {
  height: 38px;
}

/* 16px auf Beruehrungsgeraeten — und zwar auf ALLEN Eingabefeldern.
 *
 * iOS Safari zoomt beim Fokussieren automatisch hinein, sobald das Feld
 * kleiner als 16px setzt, und zoomt danach NICHT von selbst zurueck. Beim
 * Oeffnen eines Tickets bekommt der Titel den Fokus — die Seite blieb also
 * vergroessert stehen, der Menueknopf war nur noch angeschnitten zu sehen und
 * man musste jedes Mal von Hand herauszoomen.
 *
 * Gemessen waren ALLE 36 Felder darunter: 13, 13,33 und 14px. Die Bedingung
 * haengt bewusst an der Bedienart, nicht an der Fensterbreite: ein iPad im
 * Querformat ist breit und hat dasselbe Verhalten. Die Feldhoehe von 38px
 * traegt 16px Schrift muehelos (16 + 2x8 Innenabstand + 2x1 Rahmen = 34). */
@media (hover: none) and (pointer: coarse) {
  /* NUR Texteingaben. <select> loest keinen Zoom aus — dort oeffnet iOS ein
     Auswahlrad statt einer Tastatur. Sie mitzuvergroessern machte die Filter
     groesser als die Ticket-Titel daneben und stellte die Rangfolge auf den
     Kopf: Werkzeug lauter als Inhalt.
     !important, weil ein Dutzend Stellen eigene Groessen setzt (Ticketfelder
     14px, Werkzeugleisten 13px) und die Zoomfalle schon bei EINEM Feld greift,
     das durchrutscht. */
  input, textarea { font-size: 16px !important; }
}
/* Die Werkzeugleiste des Editors traegt bewusst kleine Bedienelemente. */
.editor-toolbar select { height: auto; }

/* iOS Safari gibt input[type=date] eine EIGENE Hoehe und einen eigenen
   Innenabstand und ignoriert die Angaben oben — das Feld steht dort hoeher als
   die Felder daneben. Mit appearance:none uebernimmt es die normale
   Feldgestaltung. Das Kalendersymbol bleibt: es haengt an
   ::-webkit-calendar-picker-indicator, nicht am Aussehen des Feldes. */
input[type=date] {
  -webkit-appearance: none;
  appearance: none;
  /* min-height statt height allein: iOS setzt sonst eine eigene intrinsische
     Hoehe durch, sobald ein Wert drinsteht. */
  min-height: 38px;
  /* Ohne das schiebt iOS den Text nach oben und die Grundlinien laufen
     auseinander. */
  line-height: normal;
}

/* Eigenes Chevron statt des Browser-Pfeils: dasselbe Zeichen wie icon('chevron-down'),
   damit die Auswahl zur uebrigen Bildsprache passt, und mit festem Abstand zum Rand
   statt der Vorgabe des Systems. Es bleibt RECHTS — bei einem Feld voller Breite
   gehoert es dorthin; neben den Wert gerutscht saehe es bei langen Werten falsch aus.
   Der rechte Innenabstand haelt lange Werte vom Zeichen fern. */
select {
  appearance: none;
  -webkit-appearance: none;
  /* Einfache Anfuehrungszeichen im SVG, damit sie die url("…") nicht sprengen;
     %23 ist die Raute der Farbangabe. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23788396' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
  padding-right: 34px;
}
/* Ohne Pfeil in der schmalen Werkzeugleiste — dort ist kein Platz dafuer. */
.editor-toolbar select { background-image: none; padding-right: 6px; }

textarea { resize: vertical; min-height: 80px; }

/* ── Rich-text editor ── */
.editor-toolbar {
  /* flex-wrap: neun Knoepfe, eine Auswahlliste und vier Trenner passen in einer
     schmalen Spalte nicht in eine Zeile — und liefen bisher einfach hinaus. */
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px 8px;
  background: var(--column-bg); border: 1px solid var(--border);
  border-bottom: none; border-radius: var(--radius) var(--radius) 0 0;
}
.editor-toolbar button {
  background: none; border: 1px solid transparent; padding: 4px 8px;
  cursor: pointer; border-radius: 3px; font-size: 13px; color: var(--text);
}
.editor-toolbar button:hover { background: var(--surface); border-color: var(--border); }
.editor-toolbar select {
  width: auto; padding: 3px 6px; font-size: 13px; border: 1px solid var(--border-control);
  border-radius: 3px; background: var(--surface);
}
.toolbar-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.editor-content {
  min-height: 250px; padding: 10px 12px; border: 1px solid var(--border-control);
  border-radius: 0 0 var(--radius) var(--radius); background: var(--surface);
  font-size: 14px; line-height: 1.6; color: var(--text); overflow-y: auto;
  overflow-wrap: break-word; /* Fallback für ältere Safari */
  overflow-wrap: anywhere;
}
.editor-content:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .25);
}
.editor-content:empty::before {
  content: attr(data-placeholder); color: var(--text-muted); pointer-events: none;
}
.editor-content h1, .editor-content h2, .editor-content h3, .editor-content h4 { margin: 8px 0 4px; }
.editor-content ul, .editor-content ol { padding-left: 24px; margin: 4px 0; }
.editor-content li { margin-bottom: 2px; }
.editor-raw {
  min-height: 250px; padding: 10px 12px; border: 1px solid var(--border-control);
  border-radius: 0 0 var(--radius) var(--radius); background: #1e1e1e;
  font-family: monospace; font-size: 13px; line-height: 1.5; color: #d4d4d4;
  resize: vertical; width: 100%;
}
.editor-toolbar button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Code formatting inside the description editor + comment bodies ── */
.editor-content code, .comment-text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--column-bg);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}
.editor-content pre, .comment-text pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--column-bg);
  padding: 10px 12px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.9em;
  line-height: 1.5;
}
.editor-content pre code, .comment-text pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 1em;
}

/* ── Comment rich-text editor (add + edit forms) ── */
.comment-editor-toolbar { padding: 4px 6px; }
.comment-editor.editor-content { min-height: 60px; font-size: 13px; line-height: 1.5; }
.comment-edit-form .editor-content { border-radius: 0 0 var(--radius) var(--radius); }
label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── Index: Board Grid ── */
.page-header {
  padding: 24px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.page-header h1 { font-size: 20px; }

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.board-sort-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.board-sort-wrap label {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}
.board-sort-wrap select {
  width: auto;
  padding: 6px 10px;
  font-size: 13px;
}
.board-sort-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.boards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding: 24px;
}

.board-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
  position: relative;
}
.board-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.15); transform: translateY(-1px); }
.board-card-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.board-card-meta { font-size: 12px; color: var(--text-muted); }
/* Der Abkuerzungs-Bereich unter den Boards: gleiches Raster, aber ohne den
   oberen Innenabstand — sonst klaffte eine doppelte Luecke zu den Boards. */
.boards-extra { padding-top: 0; }
/* Das Adressbuch ist ein <a> im Zuschnitt einer Board-Kachel: dieselbe Flaeche,
   aber ohne die Knoepfe oben rechts (es gibt nichts umzubenennen oder zu
   loeschen) und in ruhigerer Farbe — es ist eine Abkuerzung, kein Board. */
.board-card-link { display: block; color: inherit; text-decoration: none; background: none;
                   box-shadow: none; border: 1px dashed var(--border-control); }
.board-card-link:hover { background: var(--surface); box-shadow: var(--shadow); border-style: solid; }
.board-card-link .board-card-name { display: flex; align-items: center; gap: 8px; color: var(--primary); }
.board-card-link .icon { width: 16px; height: 16px; }

.board-card-actions { position: absolute; top: 10px; right: 10px; display: none; gap: 4px; }
.board-card:hover .board-card-actions { display: flex; }

/* Listenansicht der Boards: Grid-Layout aufheben, Tabelle füllt die Breite. */
.boards-grid.boards-list-mode { display: block; }
.board-list-row { cursor: pointer; transition: background .12s; }
.board-list-row:hover { background: rgba(var(--primary-rgb),.06); }

.board-card-draggable { cursor: move; }
.board-card-dragging { opacity: .5; }
.boards-grid.drag-over { background: rgba(var(--primary-rgb),.06); border-radius: var(--radius); }

/* ── Filter bar ── */
/* Die Zeile ueber dem Board: links der Filter-Knopf, daneben die Summen.
   Sie traegt Hintergrund und Trennlinie — die Summen darin nicht mehr. */
.board-topline {
  display: flex; flex-wrap: wrap; align-items: center; gap: 20px;
  padding: 8px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
/* min-width: 0 ist Pflicht: als Flex-Kind duerfte .price-totals sonst auf
   Inhaltsbreite wachsen (403px in 390px) statt umzubrechen — „Seiten 1 1/6"
   hing am Telefon rechts aus dem Schirm. */
/* display: contents — die Summen werden direkte Geschwister des Knopfes. Als
   eigener Behaelter brachen sie sonst als GANZES unter den Knopf (drei Zeilen
   bei 400px: Filter, Seiten, Anzeigensumme). So steht „Seiten" neben dem Knopf
   und nur die lange Anzeigensumme rueckt in die zweite Zeile. .hidden gewinnt
   weiterhin: display: none !important schlaegt contents. */
.board-topline .price-totals { display: contents; }
/* Und jede Summe darf in sich umbrechen: Beschriftung oben, Zahlen darunter. */
.board-topline .price-total { flex-wrap: wrap; row-gap: 0; }
/* Der Umschalter fuer die Filterleiste — auf jeder Breite. */
.filter-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
  cursor: pointer; flex: none;
}
.filter-toggle:hover { background: var(--border); }
.filter-toggle[aria-expanded="true"] { border-color: var(--primary); color: var(--primary); }
.filter-bar.zu { display: none; }
.filter-toggle-zahl {
  min-width: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--primary); color: #fff; font-size: 12px; font-weight: 600;
}
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.filter-bar select {
  width: auto;
  /* Rechts MUSS Platz fuer das eigene Chevron bleiben (siehe die select-Regel
     weiter oben): die Kurzschreibweise „5px 8px" hat den dort gesetzten
     Innenabstand von 34px ueberschrieben, das Zeichen wurde aber weiter
     gezeichnet — der Text lief darunter hindurch. Mit 13px Schrift fiel das
     kaum auf, auf Beruehrungsgeraeten mit 16px sofort. */
  padding: 5px 34px 5px 8px;
  border: 1px solid var(--border);
  font-size: 13px;
  /* width:auto laesst das Feld mit seinem laengsten Eintrag wachsen — ein Feld
     mit langem Namen ragte damit ueber den Schirmrand und war abgeschnitten. */
  max-width: 100%;
}

/* ── Board Layout ── */
.board-wrap {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  /* Breite der angedockten Ticketspalte. Wird vom Ziehgriff gesetzt und je
     Nutzer gemerkt; hier steht nur die Vorgabe. */
  --dock-w: 480px;
}
/* Die waagerechte Ebene unter Kopf-, Filter- und Summenleiste: links das Board,
   rechts das angedockte Ticket. */
.board-main {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
}
.board-canvas {
  display: flex;
  gap: 12px;
  padding: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

/* min-width:0 ist die halbe Miete: ohne sie waechst ein Flex-Kind an seinem
   Inhalt und die Ticketspalte wuerde aus dem Fenster geschoben. */
.board-canvas { min-width: 0; }

/* ── Angedockte Ticketspalte ── */
.ticket-dock {
  position: relative;
  width: var(--dock-w);
  flex: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 6px rgba(0,0,0,.06);
}
.ticket-dock.hidden { display: none; }

/* Der Ziehgriff liegt ueber der Trennlinie, nicht daneben: er soll die Spalte
   nicht schmaler machen, sondern nur greifbar sein. */
.dock-resizer {
  position: absolute;
  left: -3px; top: 0; bottom: 0;
  width: 7px;
  cursor: col-resize;
  z-index: 2;
  display: flex; align-items: center; justify-content: center;
}
.dock-resizer:hover, .dock-resizer.is-dragging { background: rgba(var(--primary-rgb), .35); }

/* Ein unsichtbarer Streifen sagt niemandem, dass man ziehen kann. Der Griff
   steht deshalb dauerhaft da — leise, aber sichtbar — und wird beim
   Darueberfahren deutlich. */
.dock-grip {
  display: flex; align-items: center; justify-content: center;
  width: 14px; height: 44px;
  margin-left: -4px;                 /* ueber der Trennlinie, nicht daneben */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  pointer-events: none;              /* das Ziehen gehoert dem Streifen */
  transition: color .12s, border-color .12s;
}
.dock-grip .icon { width: 14px; height: 14px; }
.dock-resizer:hover .dock-grip,
.dock-resizer.is-dragging .dock-grip { color: var(--primary); border-color: var(--primary); }
/* Waehrend des Ziehens darf nichts markiert werden, sonst faerbt sich das halbe
   Board blau. */
body.dock-resizing { user-select: none; cursor: col-resize; }

.dock-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px 0 12px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.dock-tabs { display: flex; gap: 2px; margin-right: auto; }
.dock-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 12px;
  margin-bottom: -1px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.dock-tab:hover:not(:disabled) { color: var(--text); }
.dock-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.dock-tab:disabled { opacity: .45; cursor: default; }

.dock-body { flex: 1; min-height: 0; overflow-y: auto; }

/* Im Dock ist die Ticketkarte kein Dialog mehr: keine Begrenzung, kein Rand,
   kein Schatten — und das × sitzt oben im Dock-Kopf. */
/* Messbezug fuer die @container-Regeln weiter unten. Steht am Panel selbst und
   gilt damit in BEIDEN Behausungen — im Dock ist es schmal, im Overlay breit. */
#ticket-panel { container: ticket / inline-size; }

.ticket-dock .modal {
  max-width: none;
  width: 100%;
  border-radius: 0;
  box-shadow: none;
  padding: 16px;
}
.ticket-dock .modal-close { display: none; }
/* „Schliessen" im Fuss bleibt auch angedockt: wer bis unten gescrollt hat,
   soll nicht erst wieder hoch zum × muessen — im schwebenden Fenster gibt es
   ebenfalls beides. */
/* Umgekehrt: der Andocken-Knopf gehoert nur ins Overlay. */
.ticket-dock #btn-dock-back { display: none; }
/* Unter 900px gilt zwangsweise das Overlay — dann taete der Andocken-Knopf
   sichtbar nichts, also weg damit. */
@media (max-width: 900px) { #btn-dock-back { display: none; } }

/* Reiter „Kunde": eine Lese-Ansicht, kein zweiter Editor. */
/* Der Bearbeiten-Link sitzt in der Abschnittsueberschrift des Kundenfeldes.
   Bewusst NUR dort auf flex umgestellt — die uebrigen Abschnittsueberschriften
   sind reiner Text und sollen es bleiben. */
#ticket-customer-wrap > .modal-section-title { display: flex; align-items: center; gap: 8px; }
.cust-edit-link { color: var(--text-muted); display: inline-flex; }
.cust-edit-link:hover { color: var(--primary); }
.cust-edit-link .icon { width: 14px; height: 14px; }
.cust-edit-link.hidden { display: none; }

.dock-customer { padding: 16px; }
.dock-customer.hidden { display: none; }
.dock-kunde-kopf {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.dock-kunde-kopf > :first-child { margin-right: auto; min-width: 0; }
.dock-kunde-name { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
/* Bezeichnung und Wert nebeneinander, die Bezeichnung in fester Spalte —
   so stehen die Werte untereinander und lassen sich ueberfliegen. */
.dock-kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 12px; margin-bottom: 8px; font-size: 13px; }
.dock-kv-k { color: var(--text-muted); }
.dock-kv span:last-child { overflow-wrap: anywhere; }
.dock-abschnitt { margin-top: 20px; }
.dock-notizen { font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ── Columns ── */
.column {
  background: var(--column-bg);
  border-radius: var(--radius);
  width: 272px;
  min-width: 272px;
  display: flex;
  flex-direction: column;
}
.column-header {
  padding: 10px 12px;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.column-header-name { flex: 1; cursor: text; }
.column-header-name-input {
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 13px;
  font-weight: 700;
}
.column-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
  min-height: 48px;
}
.column-body.drag-over { background: rgba(var(--primary-rgb),.08); border-radius: 4px; }
.column-footer { padding: 4px 8px 8px; flex-shrink: 0; }
.col-scroll-top { display: block; margin-left: auto; opacity: .5; font-size: 14px; }
.col-scroll-top:hover { opacity: 1; }

/* ── Ticket Cards ── */
.ticket-card {
  background: var(--card-bg);
  border: 2px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: box-shadow .1s;
  position: relative;
}
.ticket-drag-handle {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  color: #6b7280;
  background: rgba(255,255,255,.85);
  border-radius: 4px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  opacity: .35;
  transition: opacity .15s, background .15s;
  z-index: 2;
}
.ticket-card:hover .ticket-drag-handle { opacity: .85; }
.ticket-drag-handle:hover  { opacity: 1 !important; background: #eef0f3; }
.ticket-drag-handle:active { cursor: grabbing; }
@media (hover: none) and (pointer: coarse) {
  .ticket-drag-handle { opacity: .85; }
}
.ticket-card.ticket-color-red    { border-color: #b85c5c; }
.ticket-card.ticket-color-yellow { border-color: #c4a452; }
.ticket-card.ticket-color-green  { border-color: #6f9c6f; }
.ticket-card.ticket-color-blue   { border-color: #6889a8; }
.ticket-card.ticket-color-purple { border-color: #8a6fa0; }

/* Color picker swatches in ticket modal */
.color-picker { display: inline-flex; gap: 4px; align-items: center; }
.color-swatch {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.2);
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: transform .1s, box-shadow .1s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active {
  box-shadow: 0 0 0 2px var(--card-bg), 0 0 0 4px var(--text);
}
.color-swatch-none {
  background: linear-gradient(135deg, transparent 45%, #b0b0b0 45%, #b0b0b0 55%, transparent 55%);
}
.color-swatch.color-red    { background: #b85c5c; border-color: #b85c5c; }
.color-swatch.color-yellow { background: #c4a452; border-color: #c4a452; }
.color-swatch.color-green  { background: #6f9c6f; border-color: #6f9c6f; }
.color-swatch.color-blue   { background: #6889a8; border-color: #6889a8; }
.color-swatch.color-purple { background: #8a6fa0; border-color: #8a6fa0; }
.ticket-card:hover { box-shadow: 0 4px 10px rgba(0,0,0,.15); }
.ticket-card.dragging { opacity: .5; }
.ticket-card.search-hidden { display: none; }
.list-row.search-hidden { display: none; }
.ticket-card.ticket-heading {
  background: transparent;
  box-shadow: none;
  padding: 8px 4px 2px;
  border-bottom: 2px solid var(--text);
  border-radius: 0;
}
.ticket-card.ticket-heading .ticket-card-title {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #172b4d;
}
.ticket-card.ticket-heading:hover { box-shadow: none; background: rgba(0,0,0,.03); }
/* Der Ueberschriften-Modus wird jetzt je Abschnitt entschieden (applyTicketBlocks
   in app.js), nicht mehr ueber die Position im Dokument — die Abschnitte sind
   umsortierbar geworden. */
.col-drag-handle {
  display: inline-block;
  padding: 0 6px;
  cursor: grab;
  color: #5e6c84;
  user-select: none;
  font-size: 16px;
  line-height: 1;
}
.col-drag-handle:active { cursor: grabbing; }
.column.col-dragging { opacity: .5; }
.column.blurred .column-header-name,
.column.blurred .column-body,
.column.blurred .column-footer {
  filter: blur(7px);
  user-select: none;
  pointer-events: none;
  transition: filter .15s;
}
.col-blur-toggle.active { opacity: 1; }
.ticket-card-preview {
  display: block;
  width: calc(100% + 24px);
  margin: -10px -12px 10px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius) var(--radius) 0 0;
}
.ticket-card-title { font-weight: 500; font-size: 14px; line-height: 1.4; padding-right: 28px; }
.ticket-card-customer { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.ticket-card-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; display: flex; gap: 8px; }

/* ── Add Column Button ── */
.add-column-btn {
  background: rgba(255,255,255,.25);
  border: none;
  border-radius: var(--radius);
  width: 272px;
  min-width: 272px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  transition: background .15s;
  flex-shrink: 0;
}
.add-column-btn:hover { background: rgba(255,255,255,.5); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  z-index: 1000;
  overflow-y: auto;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 680px;
  padding: 24px;
  position: relative;
}
/* Der Ticket-Dialog traegt deutlich mehr als die uebrigen: mehrere schmale Felder
   nebeneinander, Beschreibung, Kommentare. Die anderen Dialoge (Einladung,
   Board-Optionen) bleiben bei 680px, sonst wirken sie verloren. */
#modal-ticket .modal { max-width: 880px; }

.modal-close {
  position: absolute;
  top: 25px;
  right: 12px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--border); color: var(--text); }

/* Der Platz fuer das × ist KONSTANT, also darf er nicht prozentual bemessen
   sein: mit width:95% blieben auf einem 390px-Schirm nur 18px frei, der Knopf
   braucht aber 44 — der Titel lief 24px unter ihn hindurch. Jetzt volle Breite
   und ein fester Innenabstand rechts.
   Die ID muss mit in den Selektor: input[type=text] (0,1,1) schlaegt sonst
   .modal-title (0,1,0) und setzt padding-right auf 10px zurueck. */
input#ticket-title.modal-title {
  /* calc statt Prozent: abgezogen wird die BREITE DES KNOPFES, und die ist
     fest. Mit padding-right allein reichte der Fokusrahmen des Feldes bis
     unter das × — beim Oeffnen ist der Titel fokussiert, und das sah aus, als
     wuerde der Knopf das Feld leeren statt den Dialog zu schliessen. */
  width: calc(100% - 48px);
}
/* Angedockt gibt es kein × — dort gehoert die ganze Breite dem Titel. */
.ticket-dock input#ticket-title.modal-title { width: 100%; }
.modal-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-right: 32px;
  border: none;
  width: 100%;
  font-family: inherit;
  color: var(--text);
}
.modal-title:focus { outline: 2px solid var(--primary); border-radius: 4px; }

.modal-section { margin-bottom: 20px; }
/* Abschnitte des Ticket-Dialogs. Kleine Felder liegen zu mehreren in einer Zeile,
   breite fuellen sie allein. .block-off gehoert dem Ueberschriften-Modus,
   .hidden der Sichtbarkeitseinstellung — beide blenden aus. */
.ticket-block-row { display: flex; gap: 12px; flex-wrap: wrap; }
.ticket-block-row > .ticket-block { flex: 1; min-width: 160px; }
.block-off { display: none !important; }
.modal-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Ticket modal action bar */
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.modal-actions-primary {
  margin-left: auto;
  display: flex;
  gap: 12px;
  align-items: center;
}
.heading-toggle {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .modal { padding: 16px; }
  .modal-actions { gap: 10px; }
  .modal-actions > #btn-delete-ticket,
  .modal-actions > #btn-duplicate-ticket {
    flex: 1;
    justify-content: center;
    padding: 8px 12px;
    font-size: 14px;
  }
  .color-picker { width: 100%; justify-content: flex-start; gap: 10px; }
  .color-swatch { width: 24px; height: 24px; }
  .modal-actions-primary {
    margin-left: 0;
    width: 100%;
    flex-wrap: wrap;
    gap: 10px;
  }
  .heading-toggle { width: 100%; order: -1; font-size: 14px; }
  .modal-actions-primary .btn {
    flex: 1;
    justify-content: center;
    padding: 10px 12px;
  }
}

/* Gegenstueck zum Breakpoint oben, gemessen an der Karte statt am Fenster —
   siehe die Begruendung bei .custom-fields. */
@container ticket (max-width: 560px) {
  .modal-actions { gap: 10px; }
  .modal-actions > #btn-delete-ticket,
  .modal-actions > #btn-duplicate-ticket { flex: 1; justify-content: center; }
  .color-picker { width: 100%; justify-content: flex-start; gap: 10px; }
  .modal-actions-primary { margin-left: 0; width: 100%; flex-wrap: wrap; gap: 10px; }
  .heading-toggle { width: 100%; order: -1; }
  .modal-actions-primary .btn { flex: 1; justify-content: center; }
}

/* ── Image Gallery ── */
.image-gallery { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.image-thumb {
  position: relative;
  width: 100px;
  height: 80px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.image-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-thumb {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--surface-alt, var(--border));
  color: var(--text-muted);
}
.file-thumb .icon { width: 28px; height: 28px; }
.file-thumb-ext {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.image-thumb-delete {
  position: absolute;
  top: 3px;
  right: 3px;
  background: rgba(0,0,0,.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}
.image-thumb:hover .image-thumb-delete,
.image-thumb:hover .image-thumb-open { display: flex; }
.image-thumb-open {
  position: absolute;
  top: 3px;
  right: 28px;
  background: rgba(0,0,0,.6);
  color: #fff;
  text-decoration: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

/* ── Lightbox ── */
#lightbox {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.88); align-items: center; justify-content: center;
}
#lightbox.active { display: flex; }
#lightbox #lb-img {
  max-width: calc(100vw - 120px); max-height: calc(100vh - 80px);
  object-fit: contain; border-radius: var(--radius); box-shadow: var(--shadow-modal);
}
#lb-close {
  position: fixed; top: 16px; right: 20px;
  background: none; border: none; color: #fff; font-size: 28px; cursor: pointer; line-height: 1;
}
#lb-download {
  position: fixed; top: 18px; right: 56px;
  color: #fff; font-size: 24px; line-height: 1; text-decoration: none;
}
#lb-download:hover { color: rgba(255,255,255,.7); }
#lb-prev, #lb-next {
  position: fixed; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.15); border: none; color: #fff;
  font-size: 36px; padding: 12px 16px; cursor: pointer; border-radius: var(--radius);
  line-height: 1;
}
#lb-prev { left: 12px; }
#lb-next { right: 12px; }
#lb-prev:hover, #lb-next:hover { background: rgba(255,255,255,.3); }
#lb-counter {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,.7); font-size: 13px;
}

/* ── Links ── */
.links-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.link-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.link-item a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-add-form { display: flex; gap: 8px; flex-wrap: wrap; }
.link-add-form input { flex: 1; min-width: 140px; }

/* ── Comments ── */
.comments-list { display: flex; flex-direction: column; gap: 16px; }
.comment-item {
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.comment-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
/* pre-wrap bricht nur an Leerzeichen — lange URLs ohne Leerzeichen sind EIN Wort und
   schieben sonst den Kommentar über den Viewport. `anywhere` bricht notfalls mitten drin
   und verhindert zusätzlich, dass die Mindestbreite des Containers mitwächst. */
.comment-text {
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: break-word; /* Fallback für ältere Safari */
  overflow-wrap: anywhere;
  min-width: 0;
}
.comment-text a { overflow-wrap: anywhere; }
.comment-actions { display: flex; gap: 2px; }
.comment-edit, .comment-delete { padding: 0 6px; opacity: .5; }
.comment-edit:hover, .comment-delete:hover { opacity: 1; }
.comment-edited { font-style: italic; opacity: .7; }
.comment-edit-form { display: flex; flex-direction: column; gap: 6px; }
.comment-edit-form textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  min-height: 60px;
  box-sizing: border-box;
}
.comment-edit-actions { display: flex; gap: 6px; }
.comment-add-form { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.comment-add-form textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  box-sizing: border-box;
}
.comment-add-form button { align-self: flex-start; }

/* ── Inline add ticket form ── */
.inline-add-form {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow);
}
.inline-add-form textarea { min-height: 60px; margin-bottom: 8px; }
.inline-add-form-actions { display: flex; gap: 6px; align-items: center; }

/* ── Utility ── */
.hidden { display: none !important; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.mt-8 { margin-top: 8px; }
.ml-auto { margin-left: auto; }

/* ─── Horizontales Raster-Board ─────────────────────────────── */
:root { --lane-label-w: 140px; --grid-cell-w: 200px; }
.board-grid {
  display: grid;
  gap: 6px;
  padding: 12px;
  align-items: start;
  align-content: start;      /* Zeilen oben kompakt halten, nicht über die Höhe strecken */
  grid-auto-rows: min-content;
  align-self: start;
  width: max-content;
  overflow-y: auto;
}
.grid-lane-label {
  position: sticky; left: 0; z-index: 2;
  display: flex; align-items: center; gap: 4px;
  padding: 6px 8px; font-weight: 600; font-size: 13px;
  background: var(--bg, #f4f5f7);
  border-right: 2px solid rgba(0,0,0,.08);
}
.grid-lane-label span { flex: 1; cursor: text; }
.grid-cell {
  min-height: 70px;
  border: 1px dashed transparent;
  border-radius: 6px;
}
.grid-cell.empty { border-color: rgba(0,0,0,.08); cursor: pointer; }
.grid-cell.empty:hover { background: rgba(var(--primary-rgb),.05); border-color: rgba(var(--primary-rgb),.35); }
.grid-cell.drag-over { background: rgba(var(--primary-rgb),.12); border-color: var(--primary); }
.grid-cell.filtered-out { border-color: rgba(0,0,0,.04); }
.board-grid .ticket-card { width: 100%; margin: 0; }
/* Horizontal-Modus: Canvas stapelt Grid + "Lane hinzufügen" untereinander,
   damit der Button als Zeile unter den Lanes erscheint (nicht als Spalte rechts). */
.board-canvas.grid-mode { flex-direction: column; align-items: flex-start; }
.add-lane-btn {
  margin: 0 12px 12px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  background: rgba(255,255,255,.35);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
}
.add-lane-btn:hover { background: rgba(255,255,255,.6); }

/* ─── List-Layout (Tabellen-Ansicht aller Tickets) ─────────────────── */
.board-canvas.list-mode {
  display: block;
  overflow-y: auto;
  overflow-x: auto;
  align-items: initial;
}
/* Die Tabelle darf den Canvas ueberragen, statt sich hineinzuquetschen — er
   scrollt sie dann (siehe .tabelle-breit, gleiche Begruendung). Einen EIGENEN
   Wrapper bekommt sie hier nicht: zwei verschachtelte Scroll-Behaelter fangen
   die Wischgeste gegenseitig ab. Gilt bei JEDER Fensterbreite: ob eine Tabelle
   scrollen muss, haengt daran, ob sie in ihren Platz passt — nicht daran, wie
   breit der Schirm ist. */
.board-canvas.list-mode > .ticket-table { width: auto; min-width: 100%; overflow: visible; }
.ticket-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.ticket-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
  background: var(--column-bg);
  border-bottom: 2px solid var(--border);
}
.ticket-table tbody td {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.ticket-table tbody tr:last-child td { border-bottom: none; }
.list-row { cursor: pointer; transition: background .12s; }
.list-row:hover { background: rgba(var(--primary-rgb),.06); }
.list-cell-title { font-weight: 600; }
.list-row-heading td {
  padding: 8px 14px;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  background: var(--column-bg);
}
.list-row-empty td {
  padding: 28px 14px;
  text-align: center;
  color: var(--text-muted);
}
/* Das Flex gehoert in eine Huelle INNERHALB der Zelle. Ein <td> mit
   display:flex ist keine Tabellenzelle mehr — der Browser baut eine
   Ersatzzelle drumherum, und die Spalte verrutscht, sobald Inhalt da ist. */
.list-cell-tags { max-width:260px; }
.list-tags { display:flex; flex-wrap:wrap; gap:4px; }
/* Auch hier gehoert das Flex in eine Huelle, nicht in die Zelle selbst. */
.list-cell-indicators { color:var(--text-muted); }
.list-indicators { display:flex; flex-wrap:wrap; align-items:center; gap:4px 10px; }
.list-indicator { display:inline-flex; align-items:center; gap:3px; font-size:12px; color:var(--text-muted); }
.list-indicator + .list-indicator { margin-left:10px; }
/* Favoriten-Stern im Adressbuch (Toggle) */

.ticket-meta { display:flex; gap:6px; align-items:center; flex-wrap:wrap; margin-top:6px; }
.prio-badge { font-size:11px; font-weight:600; padding:2px 6px; border-radius:4px; color:#fff; }
/* Die Farbe kommt seit der Administration je Prioritaet als inline-style. */
/* Wiedervorlage in der Liste: die ganze Zelle ist der Schalter, damit sie an
   einem Akquise-Tag mit einem Klick zu treffen ist. */
/* Name und Firma in der Liste oeffnen den Kundendialog. Als <button>, damit
   die Tastatur sie erreicht — aussehen sollen sie wie der Text, der sie sind. */
.cust-open {
  background: none; border: none; padding: 0; margin: 0;
  font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.cust-open:hover { color: var(--primary); text-decoration: underline; }

/* Verknuepfte Tickets im Kundendialog */
.cust-tickets { max-height: 220px; overflow-y: auto; border: 1px solid var(--border);
                border-radius: var(--radius); padding: 4px; }
.cust-ticket-row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 6px 8px; border-radius: 4px; font-size: 13px;
  color: var(--text); text-decoration: none;
}
.cust-ticket-row:hover { background: rgba(var(--primary-rgb), .10); }
.cust-ticket-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cust-ticket-meta { color: var(--text-muted); font-size: 12px; margin-left: auto; flex: none; }

/* Kunden-Tags in der Liste: die ganze Zelle ist der Schalter, wie bei der
   Wiedervorlage. Das automatische Kennzeichen ist anders eingefaerbt — es ist
   kein vergebenes Tag, sondern eine Feststellung, und nicht entfernbar. */
.cust-tag-cell { cursor: pointer; }
.cust-tag-cell:hover { background: rgba(var(--primary-rgb), .06); }
.cust-tag-cell .tag-badge { cursor: pointer; }
.cust-tag-input { width: 100%; min-width: 140px; height: 30px; font-size: 12px; padding: 2px 6px; }
/* Es IST ein Tag — es sieht nur etwas ruhiger aus, weil es sich nicht setzen
   und nicht entfernen laesst. Keine Kursivschrift: das schrie mehr Ausnahme,
   als der Sache angemessen ist. */
.tag-auto {
  background: rgba(var(--primary-rgb), .10);
  border-color: rgba(var(--primary-rgb), .35);
  color: var(--primary);
}

.cust-wv-cell { cursor: pointer; }
.cust-wv-cell:hover { background: rgba(var(--primary-rgb), .06); }
.cust-wv-leer { font-size: 11px; color: var(--text-muted); font-style: italic; }
.cust-wv-input { width: 100%; min-width: 130px; height: 30px; font-size: 12px; padding: 2px 6px; }
.ticket-deadline { font-size:11px; color:#4b5563; }
.ticket-deadline.overdue { color:#e5484d; font-weight:600; }
.ticket-assignee { width:22px; height:22px; border-radius:50%; background:#334155; color:#fff;
  font-size:10px; font-weight:600; display:inline-flex; align-items:center; justify-content:center; margin-left:auto; }
.ticket-assignee-img { width:22px; height:22px; border-radius:50%; object-fit:cover; margin-left:auto; flex-shrink:0; }
.topbar-avatar { width:28px; height:28px; border-radius:50%; object-fit:cover; margin-right:-8px; border:1px solid rgba(255,255,255,.5); }

/* ── Tags: card badges (clickable filter) + modal chip editor ── */
.ticket-card-tags { display:flex; flex-wrap:wrap; gap:4px; margin-top:4px; }
.tag-badge {
  display:inline-flex; align-items:center;
  font-size:11px; font-weight:600; line-height:1.4;
  padding:2px 8px; border-radius:999px;
  background: var(--bg); color: var(--primary);
  border: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
.tag-badge:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.tag-chip-list { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:8px; }
.tag-chip {
  display:inline-flex; align-items:center; gap:4px;
  font-size:12px; font-weight:600;
  padding:3px 4px 3px 10px; border-radius:999px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border);
}
.tag-chip-remove {
  display:inline-flex; align-items:center; justify-content:center;
  width:16px; height:16px; padding:0; border:none; border-radius:50%;
  background:transparent; color: var(--text-muted); cursor:pointer;
}
.tag-chip-remove:hover { background: var(--danger); color:#fff; }
.tag-chip-remove .icon { width:11px; height:11px; }

/* Vorschlagsliste fuer Tags — Ersatz fuer <datalist>, die Safari auf dem
   iPhone nicht als Liste unter dem Feld zeigt. Bauart wie .combo-list. */
.tag-suggest {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 240px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 4px 6px rgba(0,0,0,.2);
}
.tag-suggest.hidden { display: none; }
.tag-suggest-item { padding: 10px 12px; cursor: pointer; font-size: 13px; }
.tag-suggest-item.active, .tag-suggest-item:hover { background: rgba(var(--primary-rgb), .10); }

/* ── @-Erwähnungen ── */
[data-mention] {
  background: rgba(var(--primary-rgb),.12);
  color: var(--primary);
  border-radius: 4px;
  padding: 0 4px;
  font-weight: 600;
  white-space: nowrap;
}
.mention-popup {
  position: absolute;
  z-index: 1200;
  min-width: 200px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  padding: 4px;
}
.mention-item { padding: 6px 10px; font-size: 13px; border-radius: 4px; cursor: pointer; }
.mention-item:hover { background: var(--column-bg); }
.mention-item.active { background: var(--primary); color: #fff; }

/* ── Inbox / Notifications ── */
.inbox-wrap { position: relative; display: flex; align-items: center; }
.inbox-bell { position: relative; font-size: 16px; line-height: 1; color: #fff; }
.inbox-bell:hover { background: rgba(255,255,255,.2); color: #fff; }
.inbox-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
  box-shadow: 0 0 0 2px var(--primary);
}
.inbox-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 320px; max-height: 420px; overflow-y: auto;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-modal); z-index: 100;
}
.inbox-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 600;
}
.inbox-list { display: flex; flex-direction: column; }
.inbox-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.inbox-item:last-child { border-bottom: none; }
.inbox-item:hover { background: var(--bg); }
.inbox-item.unread { background: rgba(var(--primary-rgb), .10); }
.inbox-item.unread:hover { background: rgba(var(--primary-rgb), .16); }
.inbox-item-text { font-size: 13px; }
.inbox-item.unread .inbox-item-text { font-weight: 600; }
.inbox-item-date { font-size: 11px; color: var(--text-muted); }
.inbox-empty { padding: 20px 12px; color: var(--text-muted); text-align: center; font-size: 13px; }
/* Anmeldekarte im goldenen Schnitt (Kai, 17.09.2026: „das anmeldefeld weiter hoch,
   vielleicht mit goldener schnitt proportion"): freier Raum oben : unten = 1 : 1,618,
   unabhaengig von der Kartenhoehe — zwei unsichtbare Federn mit 382 : 618. */
.auth-wrap { min-height:100vh; display:flex; flex-direction:column; align-items:center; padding:0 16px; }
.auth-wrap::before { content:''; flex:382 0 0; }
.auth-wrap::after  { content:''; flex:618 0 0; }
.auth-wrap > .auth-card { flex:none; }
.auth-card { background:#fff; padding:32px; border-radius:10px; box-shadow:0 4px 24px rgba(0,0,0,.1);
  width:340px; display:flex; flex-direction:column; gap:8px; }
.auth-appname { font-weight:700; font-size:18px; color:var(--primary); margin-bottom:4px; }
.auth-card h1 { font-size:20px; margin-bottom:8px; }
.auth-card input, .auth-card button { width:100%; }
.auth-error { background:#fde8e8; color:#c81e1e; padding:8px 12px; border-radius:6px; font-size:13px; }
.auth-info  { background:#e6f4ea; color:#1e6b3a; padding:8px 12px; border-radius:6px; font-size:13px; }
.auth-card p { font-size:13px; color:var(--text-muted); margin:0 0 12px; }
.auth-links { text-align:center; margin:12px 0 0 !important; }
.auth-links a { color:var(--text-muted); text-decoration:underline; }
.auth-links a:hover { color:var(--primary); }
.user-list { padding:0 24px; }
/* Ohne Umbruch quetschten sich Name, Rolle und die beiden Knoepfe auf schmalen
   Schirmen ineinander — „Deaktivieren" lag ueber der Rolle. Die Knopfgruppe
   schrumpft nicht mit, sie rueckt bei Enge in die naechste Zeile. */
.user-row {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid #eee;
}
.user-row > .flex { flex-shrink: 0; }
.invite-result { margin:12px 24px; padding:10px 14px; background:#eef6ff; border-radius:6px; font-size:13px; word-break:break-all; }
.topbar-user { color:#fff; opacity:.85; margin-right:12px; }
.member-list { margin-bottom:12px; }
.member-row { display:flex; justify-content:space-between; align-items:center; padding:6px 0; border-bottom:1px solid var(--border); font-size:14px; }
.member-row:last-child { border-bottom:none; }

/* ── Profile page ── */
/* Abstaende ausschliesslich aus der Reihe 4 · 8 · 12 · 16 · 24. */
.profile-wrap { max-width:480px; margin:0 auto; padding:24px; display:flex; flex-direction:column; gap:16px; }
.profile-section { background:var(--surface); border-radius:var(--radius); box-shadow:var(--shadow); padding:24px; }
.profile-section h2 { font-size:16px; margin-bottom:16px; }
.profile-section label { margin-top:16px; }
.profile-section label:first-of-type { margin-top:0; }
.profile-hint { font-size:12px; color:var(--text-muted); margin:0 0 12px; line-height:1.5; }

/* Checkbox + Satz nebeneinander. Die globale label-Regel macht Versalien,
   Fettung und Sperrung — fuer ganze Saetze ist das unlesbar, also zurueck
   auf normalen Fliesstext. */
.profile-section label.checkbox-row {
  display:flex; align-items:flex-start; gap:8px;
  margin:0 0 8px; font-size:13px; line-height:1.5;
  font-weight:400; text-transform:none; letter-spacing:0;
  color:var(--text); cursor:pointer;
}
.profile-section label.checkbox-row:last-child { margin-bottom:0; }
/* Groesse regelt die allgemeine Kaestchen-Regel am Dateiende; hier nur der
   Versatz, damit das Kaestchen zur ersten Textzeile passt. */
.profile-section label.checkbox-row input[type="checkbox"] { margin-top:2px; align-self:flex-start; }

/* Der Hauptschalter regiert alle anderen — eigene Zeile, Trennlinie darunter. */
.notify-master { padding-bottom:16px; border-bottom:1px solid var(--border); }

/* Mehr Abstand um eine Gruppe als zwischen ihren Zeilen (8px innen, 24px aussen). */
.notify-group { margin-top:24px; }
.notify-group-title {
  font-size:12px; font-weight:600; color:var(--text-muted);
  text-transform:uppercase; letter-spacing:.05em; margin-bottom:4px;
}
/* Einzelschalter bei aktivem „alles aus" sichtbar wirkungslos */
#notify-detail.is-disabled { opacity:.45; pointer-events:none; }

.profile-avatar-row { display:flex; align-items:center; gap:16px; }
.profile-avatar-preview, .profile-avatar-placeholder {
  width:72px; height:72px; border-radius:50%; flex-shrink:0;
}
.profile-avatar-preview { object-fit:cover; }
.profile-avatar-placeholder {
  background:var(--text); color:#fff; font-size:24px; font-weight:600;
  display:flex; align-items:center; justify-content:center;
}
.profile-avatar-actions { display:flex; flex-direction:column; align-items:flex-start; gap:8px; }
/* Datei-Auswahl sieht aus wie ein Knopf, ist aber ein <label> — und erbt damit
   Versalien, Sperrung und die Label-Groesse. Zurueck auf Knopf-Beschriftung. */
.btn-file {
  cursor:pointer; display:inline-flex; width:auto;
  text-transform:none; letter-spacing:0; font-size:12px; color:inherit;
}
.profile-success { background:#e6f4ea; color:#1e7e34; padding:8px 12px; border-radius:6px; font-size:13px; }

/* ── lexoffice sync badge (customers list) ── */
.lexoffice-badge {
  display:inline-flex; align-items:center; margin-left:6px;
  font-size:10px; font-weight:600; line-height:1.4; letter-spacing:.02em;
  padding:1px 7px; border-radius:999px;
  background:#fff3d6; color:#8a5a00; border:1px solid #f0d28f;
}
/* Gleiche Form wie das lexoffice-Badge, andere Farbe: ein Angebot ist ein
   Zustand des Kunden, keine Herkunft. */
.cust-modal-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: -10px 0 14px; }
#ticket-customer-quote { margin: 6px 0 0; }
.dock-kunde-kopf .quote-badge { margin-left: 0; }
.cust-modal-badges .lexoffice-badge, .cust-modal-badges .quote-badge, .cust-modal-badges .apollo-badge { margin-left: 0; }
/* Herkunft wie lexoffice, eigene Farbe: Angaben aus Apollo.io. */
.apollo-badge {
  display:inline-flex; align-items:center; margin-left:6px;
  font-size:10px; font-weight:600; line-height:1.4; letter-spacing:.02em;
  padding:1px 7px; border-radius:999px;
  background:#e8f0fe; color:#1a4fa3; border:1px solid #b9cdf3;
}
.cust-card-badges .apollo-badge { margin-left: 0; }
/* Apollo-Dialog: Kopf mit Kosten und Abruf-Knopf, darunter Zeilen Feld | bisher | Apollo. */
.apollo-kopf { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.apollo-kopf .btn { margin-left: auto; flex: none; }
.apollo-zeile { display: grid; grid-template-columns: 20px 1.1fr 1.4fr 1.4fr; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--border); font-size: 13px; cursor: pointer; }
.apollo-zeile input { margin: 0; }
.apollo-kopfzeile { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); border-top: none; cursor: default; }
.apollo-feld { font-weight: 600; }
.apollo-alt { color: var(--text-muted); overflow-wrap: anywhere; }
.apollo-neu { overflow-wrap: anywhere; }
.apollo-kontakt { margin-top: 12px; }
.apollo-kontakt-name { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; padding: 6px 0 2px; }
.apollo-kontakt-name .icon { width: 14px; height: 14px; }
.apollo-warn { color: #8a5a00; font-weight: 400; }
@media (max-width: 640px) { .apollo-zeile { grid-template-columns: 20px 1fr; } .apollo-alt { display: none; } }
/* Apollo-Suche */
.apollo-suche-form { max-width: 900px; }
.apollo-bereiche { display: flex; flex-wrap: wrap; gap: 4px 12px; padding-top: 6px; }
.apollo-bereich { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; text-transform: none; letter-spacing: 0; font-weight: 400; margin: 0; }
.apollo-wartet { color: #8a5a00; }
.cust-email-member { margin: 4px 0 0; color: #8a5a00; font-size: 12px; }
.dup-merkmale { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.apollo-ps { margin-top: 20px; }
.apollo-ps-form { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; align-items: center; }
.apollo-ps-form input { margin: 0; }
.apollo-bereich input { margin: 0; }
.apollo-bekannt a { font-weight: 600; }
.apollo-personen-zeile td { background: var(--bg-muted, #f6f7f9); padding: 8px 12px 12px; }
.apollo-person { display: grid; grid-template-columns: 20px 1.2fr 1.6fr .8fr; gap: 8px; align-items: center; padding: 4px 0; font-size: 13px; cursor: pointer; }
.apollo-person input { margin: 0; }
.apollo-person-name { font-weight: 600; }
.apollo-person-titel, .apollo-person-hat { color: var(--text-muted); }
.quote-badge {
  display:inline-flex; align-items:center; margin-left:6px;
  font-size:10px; font-weight:600; line-height:1.4; letter-spacing:.02em;
  padding:1px 7px; border-radius:999px;
  background:#e3f1ff; color:#0b4f8a; border:1px solid #a9d0f5;
}

/* Admin: Ticket-Felder */
#tf-body input[type="text"], #tf-body select { width: 100%; }
#tf-body td { vertical-align: middle; }
#tf-body input[disabled], #tf-body select[disabled] { opacity: .45; }
/* Feldnamen sind Fliesstext. Ohne das Zuruecksetzen erbt jedes <label> die
   Versalien der globalen label-Regel weiter oben. */
.tf-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; white-space: nowrap;
  text-transform: none; font-weight: 400; letter-spacing: 0; color: var(--text);
}

/* Frei definierte Ticket-Felder */
/* Drei Spalten: die meisten Felder nehmen sich alle drei, ein Ja/Nein-Feld nur
   eine — mehr braucht ein Haken nicht, und drei davon stehen so nebeneinander. */
/* Sechs Spalten, damit Drittel UND Haelften aufgehen. Die Breite je Feld
   kommt aus der Administration. */
.custom-fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px 16px; }
.cf-row {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: 160px 1fr; align-items: center; gap: 12px;
}
.cf-w-third     { grid-column: span 2; grid-template-columns: 1fr auto; }
.cf-w-half      { grid-column: span 3; grid-template-columns: 1fr auto; }
/* Beim Kaestchen zuerst das Bedienelement, dann die Bezeichnung — gilt in
   jeder Breite und ueberschreibt deshalb die Spaltenaufteilung oben. */
.cf-row-check { grid-template-columns: auto 1fr; }
.cf-row-check > label { cursor: pointer; }
.cf-w-twothirds { grid-column: span 4; grid-template-columns: 140px 1fr; }
.cf-w-full      { grid-column: 1 / -1; }
/* Lange Bezeichnungen kuerzen statt umbrechen; der volle Text steht im title. */
.cf-row > label {
  font-size: 13px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.cf-row input, .cf-row select, .cf-row textarea { width: 100%; }
.cf-price { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cf-price > input { text-align: right; width: 120px; }
.cf-discount { display: inline-flex; align-items: center; gap: 6px; margin-left: 12px; }
.cf-discount input { width: 90px; text-align: right; }
.cf-discount span { font-size: 12px; color: var(--text-muted); }
/* Preisverantwortliches Mitglied: schmaler als die uebrigen Auswahllisten und
   in Grau — es ist ein Beiwert des Betrags, nicht die Hauptangabe der Zeile. */
.cf-member { display: inline-flex; align-items: center; gap: 6px; margin-left: 12px; }
.cf-member select { width: 150px; font-size: 13px; color: var(--text-muted); }
.cf-member > span { font-size: 12px; color: var(--text-muted); }
.cf-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.cf-price input.cf-invalid, .cf-discount input.cf-invalid {
  border-color: var(--danger);
  background: #fff5f5;
}
@media (max-width: 640px) {
  .custom-fields { grid-template-columns: 1fr; }
  .cf-row { grid-column: 1 / -1 !important; grid-template-columns: 1fr; gap: 4px; }
  /* Ein Kaestchen und seine Beschriftung gehoeren NEBENeinander, auch wenn
     alles andere untereinander rutscht — sonst schwebt das Haekchen ueber
     seinem eigenen Text und man weiss nicht mehr, wozu es gehoert. */
  .cf-row-check { grid-template-columns: auto 1fr; gap: 8px; align-items: center; }
}
/* Dasselbe noch einmal, aber an der Breite der TICKETKARTE statt der des
   Fensters: angedockt ist die Karte schmal, das Fenster aber weit — die
   @media-Regel oben greift dort nie. Sie bleibt trotzdem stehen, denn im
   Overlay auf dem Telefon ist das Fenster das richtige Mass. */
@container ticket (max-width: 640px) {
  .custom-fields { grid-template-columns: 1fr; }
  .cf-row { grid-column: 1 / -1 !important; grid-template-columns: 1fr; gap: 4px; }
  .cf-row-check { grid-template-columns: auto 1fr; gap: 8px; align-items: center; }
}

/* Summe der Preisfelder */
.price-totals {
  display: flex; flex-wrap: wrap; align-items: center; gap: 20px;
  padding: 8px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 13px;
}
.price-total { display: inline-flex; align-items: baseline; gap: 8px; }
.price-total-label { color: var(--text-muted); }
.price-total-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.price-total-detail { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.price-total-hint { color: var(--text-muted); font-style: italic; }
/* Der eigene Anteil steht bewusst leiser als die Gesamtsumme daneben. */
.price-total-mine {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  border-left: 1px solid var(--border);
  padding-left: 8px;
}

/* Admin: Einstellungen (Weg zu den Unterseiten) */
.admin-settings { padding: 12px 24px 4px; }
.admin-settings .profile-hint { margin: 8px 0 0; max-width: 620px; }

/* ── Admin-Seite (refactoring-ui, 05.09.2026) ──
   Vorher standen acht Abschnitte mit gleich schweren Ueberschriften direkt
   auf dem Seitengrund, Ueberschrift und Inhalt gleich weit voneinander wie
   die Abschnitte untereinander — nichts fuehrte das Auge. Jetzt: ein Seitentitel
   (20 px), Abschnittstitel als Beschriftung (16 px/600), jeder Abschnitt eine
   weisse Karte, mehr Raum ZWISCHEN den Abschnitten (32 px) als IN ihnen (12–16 px). */
.seite-admin .page-header { padding: 32px 24px 0; max-width: 1008px; }   /* 960 + 2×24: Knoepfe enden mit der Karte */
.seite-admin .page-header:first-of-type { padding-top: 24px; }
.seite-admin .page-header h2 { font-size: 16px; font-weight: 600; margin: 0; }
.seite-admin .admin-settings,
.seite-admin .user-list {
  margin: 12px 24px 0; padding: 16px 20px 20px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  max-width: 960px;
}
.seite-admin .admin-settings .profile-hint { margin: 0 0 12px; }
.seite-admin .admin-settings .profile-hint + .profile-hint { margin-top: -4px; }
.seite-admin .admin-settings label[for="branding-name"] { margin-top: 0; }
.seite-admin .admin-settings textarea,
.seite-admin .dup-merkmale,
.seite-admin .apollo-credits { margin: 4px 0 12px; }
.seite-admin .dup-merkmale + .profile-hint { margin-top: 20px; }
.seite-admin .user-list .user-row:last-child { border-bottom: 0; }
.seite-admin .user-list:empty { display: none; }
.seite-admin .invite-result { margin: 12px 24px 0; max-width: 960px; }
/* Luft nach dem letzten Abschnitt — sonst klebt „Offene Einladungen" am Fensterrand. */
.seite-admin #invite-list { margin-bottom: 48px; }
/* Der Abschnitt „Erscheinungsbild" traegt sein Feld direkt in der Karte. */
.seite-admin .admin-settings > label { margin-top: 0; }

/* Ticket-Feld-Uebersicht auf der Admin-Seite: was existiert, ohne Klick. */
.admin-fields { list-style: none; margin: 12px 0 0; padding: 0; max-width: 620px; }
.admin-fields li {
  display: flex; align-items: baseline; gap: 12px;
  padding: 8px 0; border-top: 1px solid var(--border);
}
.admin-fields li:first-child { border-top: 0; }
.admin-field-label { font-weight: 600; }
.admin-field-meta  { font-size: 12px; color: var(--text-muted); }
.admin-field-off   { font-size: 12px; color: var(--danger); margin-left: auto; }
.admin-fields-empty { font-size: 13px; color: var(--text-muted); margin: 12px 0 0; }

/* Feste Ticket-Felder im Feld-Editor: eine Reihe Schalter statt einer Tabelle. */
.tf-heading { font-size: 16px; margin: 24px 0 8px; }
#tf-wrap .profile-hint { margin: 0 0 12px; max-width: 720px; }
#tf-wrap .ticket-table { margin-bottom: 8px; }
#tf-wrap > .tf-heading ~ .tf-heading { margin-top: 36px; }

/* Offene Einladungen: gleiche Zeilenform wie die Benutzerliste. */
.invite-who { font-weight: 600; }
.invite-who-none { color: var(--text-muted); font-style: italic; }

/* ── Erscheinungsbild (Admin) ── */
/* Der Hinweis darueber hat keinen Abstand nach unten — sonst klebt die
   Beschriftung daran. */
.admin-settings label[for="branding-name"] { margin-top: 16px; }
.branding-logo-row {
  display: flex; align-items: flex-start; gap: 16px;
  margin-top: 20px; max-width: 620px;
}
.branding-logo-preview {
  width: 64px; height: 64px; object-fit: contain; flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px;
}
.branding-logo-text { flex: 1; min-width: 0; }
.branding-logo-text .profile-hint { margin: 4px 0 0; }
#branding-name { max-width: 320px; }
#branding-msg { margin-top: 12px; max-width: 620px; }

/* Logo auf der Anmeldekarte — der App-Name steht direkt darunter als Text. */
.auth-logo { width: 48px; height: 48px; object-fit: contain; display: block; margin: 0 auto 10px; }

/* ── Prioritäten (Admin) ── */
.prio-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; max-width: 720px; }
.prio-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 10px;
}
.prio-row .prio-label { flex: 1; min-width: 0; margin: 0; }
.prio-row .tf-drag-handle { flex-shrink: 0; }
.prio-row[draggable] { cursor: grab; }
.prio-row[draggable]:active { cursor: grabbing; }
.prio-row input, .prio-row button { cursor: auto; }
.prio-row button { cursor: pointer; }
.prio-row .prio-color { width: 40px; height: 32px; padding: 2px; flex-shrink: 0; cursor: pointer; }
.prio-usage { font-size: 12px; color: var(--text-muted); white-space: nowrap; min-width: 76px; text-align: right; }
/* Gleiche Sprache wie die Favoriten im Adressbuch: Umriss = nicht gesetzt, gefüllt = gesetzt. */
.prio-star {
  background: none; border: none; cursor: pointer; padding: 0; flex-shrink: 0;
  color: var(--text-muted); display: inline-flex;
}
.prio-star .icon { width: 18px; height: 18px; }
.prio-star:hover { color: #f5a623; }
.prio-star.is-fallback { color: #f5a623; }
.prio-star.is-fallback .icon { fill: currentColor; }
#prio-msg { margin-top: 12px; max-width: 720px; }

/* ── Aufbau des Tickets (Feld-Editor) ── */
.tf-blocks { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; max-width: 720px; }
.tf-block-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 10px;
}
.tf-block-row .tf-drag-handle { flex-shrink: 0; }
/* min-width: 0 laesst die Bezeichnung schrumpfen — ohne overflow lief ihr Text
   dann sichtbar ueber „schmal" und „immer da" hinweg, statt sich zu kuerzen. */
.tf-block-label { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tf-block-size,
.tf-block-always { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.tf-block-size { min-width: 84px; }
.tf-block-always { min-width: 92px; }
.tf-block-row .tf-toggle { min-width: 92px; }
/* Ja/Nein-Felder in der Übersicht. Offene stehen blasser da als gesetzte —
   man soll auf einen Blick sehen, was noch aussteht, ohne dass es sich vordrängt.
   Mit „ohne Text" bleibt nur das Zeichen, die Bezeichnung steht im title. */
.cf-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; color: var(--text-muted); cursor: help;
  opacity: .45;
}
.cf-badge.is-set { opacity: 1; color: var(--text); }
.cf-badge .icon { width: 13px; height: 13px; flex: none; }
/* Zwischen zwei Abzeichen braucht es Luft — auf der Karte stehen sie als eine
   Zeichenkette in EINEM Flex-Kind, dort greift die Luecke des Elters nicht. */
.cf-badge + .cf-badge { margin-left: 8px; }
/* Lange Feldnamen duerfen die Spalte nicht sprengen. */
.cf-badge > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }

/* „ohne Rechnung": die Board-Summe zählt solche Tickets weiter mit — sie zeigt
   den Aufwand, nicht den Rechnungsbetrag. Deshalb muss man sie sehen können. */
.no-invoice-badge {
  font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 4px;
  background: var(--bg); color: var(--text-muted); border: 1px solid var(--border);
  white-space: nowrap;
}

/* ── Protokoll (Admin) ── */
.log-controls { display: flex; align-items: center; gap: 8px; margin: 16px 0 8px; flex-wrap: wrap; }
.log-controls #log-search { flex: 1; min-width: 200px; max-width: 360px; margin: 0; }
/* Die allgemeine Formularregel gibt select/input volle Breite — in einer Leiste
   mit mehreren Bedienelementen ist das falsch. */
.log-controls select { margin: 0; width: auto; min-width: 160px; }
#log-mail-result { margin-bottom: 12px; max-width: 720px; }
.log-list {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow-x: auto;
}
.log-row {
  display: grid; grid-template-columns: 190px 84px 1fr; gap: 10px;
  padding: 6px 12px; border-bottom: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  line-height: 1.5;
}
.log-row:last-child { border-bottom: none; }
.log-time { color: var(--text-muted); white-space: nowrap; }
.log-level { font-weight: 600; white-space: nowrap; }
/* Die Meldung darf umbrechen — Pfade und JSON-Kontexte werden lang. */
.log-text { overflow-wrap: anywhere; }
.log-error .log-level,
.log-fatal .log-level,
.log-exception .log-level { color: var(--danger); }
.log-warning .log-level { color: #8a5a00; }
.log-info .log-level { color: var(--text-muted); }
@media (max-width: 700px) {
  .log-row { grid-template-columns: 1fr; gap: 2px; }
}

/* ── Sortieren per Ziehen (Feld-Editor) ── */
.tf-block-row[draggable], #tf-body tr[draggable] { cursor: grab; }
.tf-block-row[draggable]:active, #tf-body tr[draggable]:active { cursor: grabbing; }
/* Eingaben bleiben bedienbar: der Zeiger gehört dort dem Feld, nicht dem Ziehen. */
.tf-block-row input, .tf-block-row select, .tf-block-row button,
#tf-body input, #tf-body select, #tf-body button { cursor: auto; }
#tf-body button, .tf-block-row button { cursor: pointer; }
.row-dragging { opacity: .45; }
/* Wohin es fällt: eine Linie oberhalb der Zielzeile. */
.row-drop-before { box-shadow: 0 -2px 0 0 var(--primary); }
.tf-drag-handle { color: var(--text-muted); display: inline-flex; vertical-align: middle; margin-right: 2px; }
.tf-drag-handle .icon { width: 14px; height: 14px; }

/* ── Kontrollkästchen ──
   Safari gibt einem Kästchen als direktem Raster- oder Flex-Element keine
   verlässliche Eigengröße: es fällt auf null zusammen und man sieht nur die
   Beschriftung daneben. Chrome setzt dort still seine Standardgröße ein,
   deshalb fiel es dort nicht auf. Also überall ausdrücklich messen — und
   nicht mitwachsen oder -schrumpfen lassen. */
input[type="checkbox"], input[type="radio"] {
  -webkit-appearance: checkbox;
  appearance: auto;
  width: 15px;
  height: 15px;
  flex: none;
  align-self: center;
  justify-self: start;
  margin: 0;
}
input[type="radio"] { -webkit-appearance: radio; border-radius: 50%; }


/* ── Adressbuch: Bedienleiste und Karten-Ansicht ── */
/* Der Kopf der Seite atmet: 16 zwischen Titel und Filterleiste — vorher klebten
   sie mit 0 aneinander. Und kein weisser Kasten mehr hinter der Leiste: sie
   stand als Block auf grauem Grund und endete abrupt, ohne dass die Kante etwas
   bedeutet haette. Auf dem Grau heben sich die cards von selbst ab. */
.cust-bar {
  padding: 0;
  margin-top: 16px;
  background: none;
  border-bottom: none;
  align-items: center;
}
/* Derselbe Rahmen wie beim Suchfeld daneben. Vorher 1,31:1 — die Richtlinie
   verlangt 3:1 fuer alles, was ein Bedienelement erkennbar macht. */
.cust-bar select {
  width: auto; min-width: 170px; margin: 0;
  border-color: var(--border-control);
}
/* Alle Bedienelemente der Leiste auf eine Hoehe — „Als Liste" war 24px hoch
   neben vier Feldern mit 38. */
.cust-bar .btn { height: 38px; }

/* Segment-Umschalter: eine Gruppe Knoepfe, genau einer aktiv. */
.seg { display: inline-flex; border: 1px solid var(--border-control); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg > button {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px;
  border: 0; border-left: 1px solid var(--border); background: transparent; color: var(--text);
  font: inherit; font-size: 13px; cursor: pointer;
}
.seg > button:first-child { border-left: 0; }
.seg > button .icon { width: 14px; height: 14px; }
.seg > button.aktiv { background: var(--primary); color: #fff; }
.seg > button:not(.aktiv):hover { background: rgba(var(--primary-rgb), .06); }
.seg-sm > button { height: 28px; padding: 0 10px; font-size: 12px; }
.cust-bar .seg { height: 38px; }
.cust-bar .seg > button { height: 36px; }

/* ── Kalender-Ansicht (Wiedervorlagen) ── */
.cust-cal { margin-top: 4px; }
.cal-kopf { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.cal-titel { font-size: 16px; font-weight: 600; min-width: 180px; text-align: center; }
.cal-stand { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text-muted); }
.cal-ueberfaellig { color: #e5484d; font-weight: 600; }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px;
}
.cal-wochentag { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); padding: 0 8px 4px; }
.cal-day {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  min-height: 96px; padding: 6px 8px 28px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.cal-week .cal-day { min-height: 320px; }
.cal-day.fremd { background: transparent; }
.cal-day.fremd .cal-datum { color: var(--text-muted); }
.cal-datum { font-size: 12px; font-weight: 600; }
.cal-day.heute .cal-datum { color: #fff; background: var(--primary); border-radius: 999px; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
.cal-day.overdue .cal-datum { color: #e5484d; }
.cal-day.overdue { border-color: #f3b3b6; }
.cal-day.drag-over { background: rgba(var(--primary-rgb), .12); border-color: var(--primary); }
.cal-chips { display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.cal-chip {
  font-size: 12px; font-weight: 600; line-height: 1.3; padding: 4px 6px; border-radius: 4px;
  background: rgba(var(--primary-rgb), .08); color: var(--text); cursor: grab;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-chip:hover { background: rgba(var(--primary-rgb), .16); }
.cal-chip.dragging { opacity: .4; }
/* Einfuegemarke beim Sortieren innerhalb eines Tags (Kai, 17.09.2026). */
.cal-chip.drop-before { box-shadow: 0 -2px 0 0 var(--primary); }
.cal-chip.drop-after  { box-shadow: 0 2px 0 0 var(--primary); }
.cal-chip-firma { display: block; font-weight: 400; color: var(--text-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.cal-day.overdue .cal-chip { background: rgba(229, 72, 77, .10); }
.cal-add-btn {
  position: absolute; right: 6px; bottom: 6px; width: 22px; height: 22px; line-height: 20px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-muted);
  font-size: 15px; cursor: pointer; opacity: 0; transition: opacity .12s;
}
.cal-day:hover .cal-add-btn, .cal-add-btn:focus { opacity: 1; }
.cal-add {
  position: absolute; z-index: 5; left: 4px; right: 4px; top: 28px;
  display: flex; flex-direction: column; gap: 8px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border-control); border-radius: var(--radius);
  box-shadow: var(--shadow-modal); font-size: 12px;
}
.cal-add-kopf { display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
.cal-add-kopf .modal-close { position: static; width: 22px; height: 22px; }
.cal-add .combo-input { width: 100%; height: 30px; font-size: 12px; }
.cal-add .combo-list { max-height: 180px; }
@media (max-width: 720px) {
  .cal-grid { gap: 2px; }
  .cal-day { min-height: 64px; padding: 4px 4px 24px; }
  .cal-chip-firma { display: none; }
  .seg > button span { display: none; }
}

/* Trefferzahl und die selten gebrauchten Werkzeuge. */
.cust-meta {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 16px;
  margin: 12px 0 16px;
  font-size: 12px; color: var(--text-muted);
}
.cust-werkzeuge { margin-left: auto; display: flex; align-items: baseline; gap: 8px; }
.cust-werkzeug-trenner { color: var(--border-control); }
/* Tertiaere Aktionen sehen aus wie Links, nicht wie Knoepfe — sie sollen da
   sein, ohne mit „+ Neuer Kunde" um Aufmerksamkeit zu ringen. */
.linkbtn {
  background: none; border: none; padding: 0; margin: 0;
  font: inherit; color: var(--primary); cursor: pointer;
}
.linkbtn:hover { text-decoration: underline; }
.linkbtn:disabled { color: var(--text-muted); cursor: default; text-decoration: none; }
/* Die Breite muss der Wichtigkeit folgen: der Name stand vorher mit 85px als
   schmalste von neun Spalten da und brach um. Gilt auf jedem Schirm — auf
   schmalen scrollt die Tabelle in sich, statt Spalten zusammenzuquetschen. */
#customers-table th:nth-child(1), #customers-table td:nth-child(1) { min-width: 190px; }
#customers-table th:nth-child(2), #customers-table td:nth-child(2) { min-width: 120px; }
/* Die Aktionsspalte braucht nur ihren Inhalt. */
#customers-table th:nth-child(5), #customers-table td:nth-child(5) { width: 1%; }
.cust-page { padding: 0 24px 24px; }
/* Steht ausserhalb von .cust-page, muss ihren seitlichen Rand aber teilen. */
.cust-randnachricht { margin: 0 24px 16px; }
/* Die Suche ist das Hauptwerkzeug und darf entsprechend Platz nehmen. */
.cust-bar #cust-search { flex: 1; min-width: 220px; max-width: 420px; margin: 0; }
.cust-cards {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  /* Alle cards einer Reihe auf die Hoehe der laengsten — so gewuenscht: die
     Reihe bleibt als Reihe lesbar, statt dass die Unterkanten ausfransen. */
  align-items: stretch;
}
.cust-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; cursor: pointer;
  box-shadow: var(--shadow); transition: box-shadow .12s;
}
.cust-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.14); }
.cust-card-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
/* Der Name darf umbrechen: er ist die Kennung der Karte, nicht ihr Schmuck. */
.cust-card-name { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.cust-card-badges { display: flex; flex-wrap: wrap; gap: 4px; margin: -2px 0 6px; }
.cust-card-badges .lexoffice-badge, .cust-card-badges .quote-badge { margin-left: 0; }
/* Knoepfe am rechten Rand des Kartenkopfs — sie duerfen den Namen nicht kuerzen. */
.cust-card-tools { margin-left: auto; flex: none; }
.cust-card-line { font-size: 12px; color: var(--text-muted); line-height: 1.6; overflow-wrap: anywhere; }
/* Der einzige Eingriff an den cards: Luft ZWISCHEN den Gruppen, keine
   innerhalb. Genau daraus entsteht, dass man Zusammengehoeriges sieht —
   Schriftgroesse, Farbe und Reihenfolge bleiben unangetastet. */
.cust-card-group { margin-top: 12px; }

/* ── Dublettenprüfung ── */
.warn-box {
  background: #fff3d6; color: #8a5a00; border: 1px solid #f0d28f;
  border-radius: var(--radius); padding: 10px 12px; font-size: 13px;
}
.dupe-hits { margin: 6px 0 0 18px; }
.dupe-reason { color: var(--text-muted); font-size: 12px; }
.dupe-group {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 10px;
}
.dupe-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 6px 0; border-top: 1px solid var(--border);
}
.dupe-group .dupe-row:first-of-type { border-top: none; }
.dupe-name { flex: 1; min-width: 160px; font-weight: 600; }
.dupe-target { width: auto; min-width: 190px; margin: 0; }

/* ── Ansprechpartner je Kunde ── */
.cust-contacts { display: flex; flex-direction: column; gap: 12px; }
/* Zwei Zeilen je Person: Name + Position (+ Entfernen), darunter Telefon, E-Mail, LinkedIn. */
.cust-contact-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cust-contact-row input { margin: 0; min-width: 0; }
.cust-contact-row .cc-anrede   { flex: 0 0 96px; }   /* „Frau", „Herr", „Dr." — der Platzhalter „Anrede" muss ganz lesbar sein */
.cust-contact-row .cc-name     { flex: 1 1 calc(45% - 70px); }
.cust-contact-row .cc-title    { flex: 1 1 calc(45% - 70px); }
.cust-contact-row .cc-phone    { flex: 1 1 28%; }
.cust-contact-row .cc-email    { flex: 1 1 34%; }
.cust-contact-row .cc-linkedin { flex: 1 1 28%; }
.cust-contact-row .cc-newsletter-wrap { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-muted); cursor: pointer; }
.cust-contact-row .cc-newsletter-wrap input { width: auto; }
.cust-contact-titel { color: var(--text-muted, inherit); }
.cust-card-line.cust-contact { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; }
/* Name, Telefon und E-Mail bleiben je fuer sich zusammen — umbrochen wird
   zwischen ihnen, nicht in ihnen. */
.cust-contact-teil { display: inline-flex; align-items: center; gap: 4px; }
.cust-card-line.cust-contact .icon { width: 12px; height: 12px; flex: none; }

/* ── Verlauf und Anrufe ── */
.cust-history {
  max-height: 220px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px;
}
.hist-row {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12px; line-height: 1.6; padding: 3px 0;
}
.hist-row + .hist-row { border-top: 1px solid var(--border); }
.hist-icon { color: var(--text-muted); display: inline-flex; flex: none; margin-top: 2px; }
.hist-icon .icon { width: 13px; height: 13px; }
/* Eine Zeile Freitext unter dem Verlauf — Eingabe und Knopf in einer Reihe. */
.hist-note { display: flex; gap: 8px; margin-top: 8px; }
.hist-note input { flex: 1; min-width: 0; }
.hist-row > span:nth-child(2) { flex: 1; overflow-wrap: anywhere; }
.hist-when { color: var(--text-muted); white-space: nowrap; }
/* Zuruecknehmen — immer sichtbar, nicht erst beim Ueberfahren: am Telefon gibt
   es kein Ueberfahren. Die Trefferflaeche ist groesser als das Zeichen. */
.hist-revert {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 24px; margin: -4px -6px -4px 0;
  border: none; border-radius: 4px; background: none;
  color: var(--text-muted); cursor: pointer;
}
.hist-revert .icon { width: 13px; height: 13px; }
.hist-revert:hover { color: var(--primary); background: rgba(var(--primary-rgb),.08); }
.hist-revert:disabled { opacity: .4; cursor: default; }
.cust-call { display: inline-flex; align-items: center; color: var(--primary); margin-left: 6px; }
.cust-call .icon { width: 14px; height: 14px; }
.cust-phone-cell { white-space: nowrap; }

/* ── Formular-Dialoge: Gruppen, Zeilen, Rangfolge ──
   Gemessen am Kundendialog: dort standen 4px zwischen Beschriftung und Feld,
   aber 0px zwischen einem Feld und der nächsten Beschriftung. Der Abstand
   INNERHALB einer Gruppe war größer als der ZWISCHEN den Gruppen — jede
   Beschriftung klebte optisch am falschen Feld. Werte aus der Abstandsskala:
   8 innerhalb eines Feldes, 20 zwischen Feldern, 32 zwischen Gruppen. */
.modal-form h2 { margin-bottom: 24px; }
.form-group + .form-group { margin-top: 32px; }
/* NUR direkte Kinder: ohne das ">" trifft die Regel auch zwei .field
   NEBENEINANDER in einer .form-row und schiebt das zweite nach unten —
   die Felder einer Zeile stehen dann nicht mehr auf einer Linie. */
.form-group > .field + .field,
.form-group > .field + .form-row,
.form-group > .form-row + .field,
.form-group > .form-row + .form-row { margin-top: 16px; }

.field > label { margin-bottom: 8px; }
.field > input, .field > select, .field > textarea { margin: 0; }

/* Ein Gruppentitel ist eine Beschriftung, keine Überschrift: gleiche Größe wie
   die Feldnamen, aber dunkler — das trennt ihn von ihnen, ohne laut zu werden.
   Die Linie übernimmt die Trennung, die sonst Abstand allein leisten müsste. */
.form-group-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text); padding-bottom: 8px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

/* Zwei Felder nebeneinander — kurze Angaben brauchen keine ganze Zeile. */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.form-row-adresse { grid-template-columns: 2fr 96px 1.4fr; }

/* Der Name ist die Identität des Datensatzes, nicht ein Feld unter vielen. */
.field-lead { font-size: 16px; font-weight: 600; }

.modal-form-actions { margin-top: 32px; }
.modal-form textarea { width: 100%; }

@media (max-width: 560px) {
  .form-row, .form-row-adresse { grid-template-columns: 1fr; }
}

/* Verlauf-Umschalter: die jüngste Zeile steht da, der Rest auf Klick. */
.hist-toggle {
  display: flex; align-items: baseline; gap: 12px; width: 100%;
  background: none; border: none; padding: 0; cursor: pointer; text-align: left;
  font: inherit; color: inherit;
}
.hist-summary { flex: 1; font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.hist-toggle-more { font-size: 12px; color: var(--primary); white-space: nowrap; }
.hist-toggle:hover .hist-toggle-more { text-decoration: underline; }
#customer-history { margin-top: 12px; }

/* ── Kundenauswahl mit Suche ──
   Eine Klappliste mit 1500 Einträgen ist nicht bedienbar. Suchzeile plus
   gefilterte Treffer, gefiltert im Browser über die schlank geladene Liste. */
/* Preis aus den Tags: lesbar, aber sichtbar nicht zum Tippen. */
.cf-price input[readonly] { background: var(--bg); color: var(--text-muted); cursor: default; }

.tf-block-title { width: 180px; height: 30px; padding: 4px 8px; font-size: 13px; }

.combo { position: relative; }
/* Mit Element UND Klasse, sonst verliert die Regel gegen `input[type=text]`
   der allgemeinen Formularregel — und das × stand ueber dem Text (Kai, 04.09.). */
.combo input.combo-input { padding-right: 34px; }
.combo-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; line-height: 1; padding: 0;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 16px;
}
.combo-clear:hover { color: var(--danger); }
.combo-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 280px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 4px 6px rgba(0,0,0,.2);
}
.combo-item {
  display: flex; align-items: baseline; gap: 8px;
  padding: 7px 12px; cursor: pointer; font-size: 13px;
}
.combo-item.active, .combo-item:hover { background: rgba(var(--primary-rgb), .10); }
.combo-name { font-weight: 600; }
/* Die Firma steht als Zweitangabe daneben — zum Unterscheiden gleichnamiger Kunden. */
.combo-firma { color: var(--text-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Ein Ansprechpartner steht eingerueckt unter seiner Firma — dieselbe Zeile
   traegt links die Person, rechts den Kunden, zu dem sie gehoert. */
.combo-item-kontakt { padding-left: 28px; }
.combo-item-kontakt .combo-name { font-weight: 500; }
.combo-person { color: var(--text-muted); display: inline-flex; flex: none; }
.combo-person .icon { width: 13px; height: 13px; }
.combo-fav { color: #f5a623; display: inline-flex; flex: none; }
.combo-fav .icon { width: 12px; height: 12px; fill: currentColor; }
.combo-leer { padding: 10px 12px; font-size: 13px; color: var(--text-muted); }

/* ── Schmale Schirme: Adressbuch und Feld-Editor ─────────────────────────────
   Dieser Block steht am DATEIENDE, hinter den Grundregeln, die er zuruecknimmt.
   Stuende er weiter oben, gewaenne bei gleicher Spezifitaet die spaetere
   Grundregel — und man muesste jede Zeile mit !important erzwingen. */
@media (max-width: 900px) {
  /* 24px hohe Knoepfe trifft man am Finger nicht. Hoehe kostet in einer engen
     Tabelle nichts — anders als Breite. */
  .ticket-table .btn-sm { min-height: 40px; }
  .hist-revert { width: 36px; height: 32px; margin: -8px -8px -8px 0; }
  /* 24px links und rechts nehmen dem Inhalt ein Achtel des Schirms. */
  .cust-page { padding: 0 12px 24px; }
  .cust-randnachricht { margin: 0 12px 16px; }


  /* Griff, zwei Pfeile und zwei Angaben liessen der Bezeichnung auf 390px genau
     0px — sie stand quer ueber ihren Nachbarn. Hier bekommt der Name die erste
     Zeile, Breite und Sichtbarkeit ruecken darunter. */
  .tf-block-row { flex-wrap: wrap; }
  .tf-block-label { flex: 1 0 120px; overflow: visible; white-space: normal; }
  .tf-block-size { min-width: 0; }

  /* Am Telefon enger: Seiten neben dem Knopf, die Anzeigensumme darunter —
     ohne die Luft einer Desktop-Zeile. */
  .board-topline { gap: 4px 14px; padding: 6px 12px; }
}

/* ── Waagerecht scrollende Listen ────────────────────────────────────────────
   Gilt bei JEDER Fensterbreite, nicht nur auf schmalen Schirmen: ob eine
   Tabelle scrollen muss, haengt daran, ob sie in ihren Platz passt. Eine Liste
   mit vielen eigenen Feldern sprengt auch ein 1000px breites Fenster.

   width:auto statt der geerbten 100%: die Tabelle nimmt ihre natuerliche Breite
   und darf den Behaelter ueberragen. min-width:100% haelt sie umgekehrt auf
   voller Breite, wenn sie schmaler waere. (min-width:max-content ist hier
   falsch — es verbietet JEDER Zelle den Umbruch und blies die Adressliste auf
   14368px auf.) */
.tabelle-breit { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabelle-breit > .ticket-table {
  width: auto; min-width: 100%;
  /* Der abgerundete Rahmen schnitte sonst die scrollenden Spalten ab. */
  overflow: visible;
}

/* ── Der Griff muss sichtbar sein ────────────────────────────────────────────
   macOS blendet Scrollbalken aus, bis gescrollt wird — und mit einer
   gewoehnlichen Maus laesst sich waagerecht ueberhaupt nicht scrollen. Ein
   Scroll-Behaelter ohne sichtbaren Griff ist dort schlicht unbedienbar.
   Deshalb ein dauerhaft sichtbarer, schlanker Balken. */
/* KEIN scrollbar-width hier: ist es gesetzt, ignoriert Chrome die
   ::-webkit-scrollbar-Regeln darunter, und der Balken bleibt das unsichtbare
   Overlay, das er vorher war. Firefox kennt nur scrollbar-width und bekommt
   seine Fassung im @supports-Block am Ende. */
.tabelle-breit::-webkit-scrollbar,
.board-canvas.list-mode::-webkit-scrollbar { height: 10px; }
.tabelle-breit::-webkit-scrollbar-track,
.board-canvas.list-mode::-webkit-scrollbar-track {
  background: rgba(0,0,0,.04); border-radius: 5px;
}
.tabelle-breit::-webkit-scrollbar-thumb,
.board-canvas.list-mode::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.28); border-radius: 5px;
}
.tabelle-breit::-webkit-scrollbar-thumb:hover,
.board-canvas.list-mode::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.45); }

/* Firefox kennt ::-webkit-scrollbar nicht; dort ist scrollbar-width der Weg.
   Der Test greift nur in Firefox, Chrome faellt nicht hinein. */
@supports (scrollbar-width: thin) and (not selector(::-webkit-scrollbar)) {
  .tabelle-breit,
  .board-canvas.list-mode {
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,.28) rgba(0,0,0,.04);
  }
}

/* ── Das Ticket am Telefon: ganzer Schirm ────────────────────────────────────
   Ein schwebendes Blatt mit Schatten und Rand ringsum ist eine Desktop-Geste —
   sie zeigt, dass darunter etwas weiterlebt. Am Telefon kostet sie nur Platz:
   der Dialog IST dort die Ansicht, nicht ein Fenster darueber.

   700px, nicht die 900px der uebrigen Mobilregeln: bei 880px sitzt man vor
   einem schmalen Desktop-Fenster, und dort soll der Dialog ein Dialog bleiben. */
@media (max-width: 700px) {
  #modal-ticket.modal-overlay {
    padding: 0;
    /* flex-start, NICHT stretch: stretch macht den Dialog so hoch wie das
       Overlay (den Schirm), nicht wie seinen Inhalt. Alles unterhalb der ersten
       Schirmhoehe lag dann auf dem halbdurchsichtigen Overlay — hinter der
       Beschreibung schien das Board durch. */
    align-items: flex-start;
    /* Und das Overlay selbst deckend: es ist hier die Seite, kein Schleier. */
    background: var(--surface);
  }
  #modal-ticket .modal {
    max-width: none;
    min-height: 100%;
    border-radius: 0;
    box-shadow: none;
    /* Innen bleibt Abstand — sonst klebt jedes Feld am Schirmrand. */
    padding: 16px;
  }
}


/* ── lexoffice: Ueberfaelligkeit und Rechnungsknopf ──────────────────────────
   Das Zeichen ist rot UND ein Symbol mit Beschriftung im title — Farbe allein
   traegt die Botschaft nicht. */
.cust-overdue { display: inline-flex; align-items: center; color: var(--danger); margin-left: 4px; vertical-align: middle; }
.cust-overdue .icon { width: 14px; height: 14px; }
/* Der Knopf steht IN der Titelzeile und darf sie nicht hoeher machen — sonst
   rutscht das Kundenfeld unter das Prioritaetsfeld (Kai, 04.09.). Die Zeile
   ist 14 px hoch, der Knopf 18: der Rest geht in negative Raender. */
.cust-invoice-btn { margin: -5px 0 -5px auto; padding: 2px 8px; }
.cust-invoice-btn .icon { width: 14px; height: 14px; }
.cust-invoice-btn:disabled { opacity: .5; cursor: default; }
/* Haengender Vorgang: Antwort von lexoffice fehlt, ein Mensch muss nachsehen. */
.cust-invoice-btn.ist-offen { color: var(--danger); }
/* Abgerechnet: gedaempft, aber klickbar — zum Loesen nach einem Storno. */
.cust-invoice-btn.ist-abgerechnet { color: var(--text-muted, inherit); }
.hist-lex { display: inline-flex; align-items: center; color: var(--text-muted, inherit); margin-left: 4px; }
.hist-lex .icon { width: 13px; height: 13px; }
.hist-lex:hover { color: var(--primary); }
/* Checkbox + ganzer Satz: die globale label-Regel (Versalien, Sperrung, fett,
   gedaempft) ist fuer Feldbeschriftungen gedacht — ein Satz wird damit unlesbar. */
.lex-schalter {
  display: flex; align-items: center; gap: 8px; margin: 0;
  font-size: 14px; font-weight: 400; color: var(--text);
  text-transform: none; letter-spacing: 0; cursor: pointer;
}
.lex-schalter input { margin: 0; flex: none; }
.lex-ergebnis { margin-top: 12px; font-size: 13px; }
.lex-ergebnis ul { margin: 4px 0 8px 18px; }
.lex-ergebnis summary { cursor: pointer; color: var(--primary); }
.apollo-credits { font-size: 13px; color: var(--text); margin-top: 12px; }

/* Karten im Adressbuch: Wiedervorlage und Tags sind anklickbar — wie in der
   liste. Der Zeiger sagt es, die leere Angabe („Datum setzen") ebenso. */
.cust-card .cust-wv-cell, .cust-card .cust-tag-cell { cursor: text; }
.cust-card .cust-wv-cell:hover, .cust-card .cust-tag-cell:hover { background: rgba(var(--primary-rgb), .05); border-radius: 4px; }
.cust-card .cust-wv-input, .cust-card .cust-tag-input { width: 100%; }

/* ── Zeitleiste im Ticket: Kommentare, Dateien, Aenderungen ─────────────────
   Eine Liste, aelteste oben, Eingabe unten. Kommentare behalten ihre Karte,
   Dateien zeigen ihr Bild, Aenderungen ihre Verlaufszeile. */
.timeline-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.timeline-switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-muted); cursor: pointer; }
.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline .hist-row { padding: 4px 0; border-top: none; }
.timeline-file { display: flex; gap: 12px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.timeline-thumb { width: 64px; height: 64px; flex: none; object-fit: cover; border-radius: 4px; }
.timeline-thumb.file-thumb { display: flex; }
.timeline-file-text { flex: 1; min-width: 0; font-size: 13px; overflow-wrap: anywhere; }
.timeline-file-text .comment-meta { margin: 2px 0 0; }
#btn-timeline-more { margin-bottom: 8px; }
.timeline-add { margin-top: 12px; }
.timeline-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.timeline-drop-hint { font-size: 12px; color: var(--text-muted); }
/* Ablage sichtbar machen, solange eine Datei ueber dem Ticket schwebt. */
#ticket-panel.drop-aktiv { outline: 2px dashed var(--primary); outline-offset: -6px; }
#ticket-panel.drop-aktiv .timeline-drop-hint { color: var(--primary); font-weight: 600; }
