@font-face {
  font-family: 'Jost';
  src: url('fonts/Jost-Book.woff2') format('woff2'), url('fonts/Jost-Book.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Jost';
  src: url('fonts/Jost-Medium.woff2') format('woff2'), url('fonts/Jost-Medium.woff') format('woff');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Jost';
  src: url('fonts/Jost-Semi.woff2') format('woff2'), url('fonts/Jost-Semi.woff') format('woff');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Jost';
  src: url('fonts/Jost-Bold.woff2') format('woff2'), url('fonts/Jost-Bold.woff') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Elbnetz-Markenfarben (Brand Manual):
   Schwarz #15222B · Nachtblau #112640 · Dunkelblau #0059A5 / #218AE0 · Hellblau #24CFF7
   Orange #fb6149 / #fcb818 / #FDDC11 · Gold #C5AD84 · Grau #95a0a6 / #DDE7EC / #F2F8FB */
:root {
  color-scheme: light;
  --bg: #F2F8FB;
  --panel: #ffffff;
  --border: #DDE7EC;
  --text: #15222B;
  --muted: #5E6F79;
  --accent: #0059A5;
  --accent-hover: #004881;
  --accent-soft: #DCEEFB;
  --highlight: #24CFF7;
  --danger: #D8432A;
  --warn: #8F6400;
  --warn-soft: #FFF3D0;
  --sidebar: #15222B;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(17, 38, 64, 0.08);
  --input-bg: #ffffff;
  --hover: #F7FAFC;
  --btn-hover: #EAF2F7;
  --label: #39414e;
  --badge-bg: #E8EEF2;
  --badge-text: #3D4F5A;
  --badge-green-bg: #D8F5FE;
  --badge-green-text: #0A7396;
  --badge-red-bg: #FEE9E4;
  --badge-blue-bg: #E2ECF7;
  --act-note: #FFF7DC;
  --act-call: #E3F0FB;
  --act-email: #EEF1F4;
  --act-meeting: #F0EAFA;
}

/* Dark-Modus: aktiv per html.dark — Umschalter am Menü-Ende, folgt standardmäßig dem System */
html.dark {
  color-scheme: dark;
  --bg: #0E171E;
  --panel: #17232C;
  --border: #2A3944;
  --text: #DFE9EF;
  --muted: #93A5B0;
  --accent: #4DA6EC;
  --accent-hover: #6FB8F0;
  --accent-soft: #12314A;
  --danger: #F07B66;
  --warn: #E5B84C;
  --warn-soft: #3A3010;
  --sidebar: #0A1218;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  --input-bg: #101B23;
  --hover: #1D2B35;
  --btn-hover: #22323D;
  --label: #A9B8C2;
  --badge-bg: #263540;
  --badge-text: #AEC0CA;
  --badge-green-bg: #0E3B4A;
  --badge-green-text: #55C3E8;
  --badge-red-bg: #47231D;
  --badge-blue-bg: #143050;
  --act-note: #37301A;
  --act-call: #16293C;
  --act-email: #232E36;
  --act-meeting: #2B2340;
}
html.dark .login-logo { filter: brightness(0) invert(0.92); }
html.dark .toast { background: #263540; border: 1px solid var(--border); }
html.dark .toast.error { background: #47231D; border-color: var(--danger); }
html.dark .swatch.none { background: var(--input-bg); }

body {
  font-family: 'Jost', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}
input, select, textarea, button { font-family: inherit; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13px; margin: 6px 0; }

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

/* ---------- Login ---------- */
#login {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 36px; width: 360px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-logo { width: 210px; align-self: center; margin-bottom: 4px; }
.login-card p { margin-top: -8px; text-align: center; }

/* ---------- Layout ---------- */
#shell { display: flex; min-height: 100vh; }

aside {
  width: 220px; flex-shrink: 0; background: var(--sidebar); color: #C6D2DA;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 20px 18px 16px; }
.brand img { width: 150px; display: block; }
aside nav { display: flex; flex-direction: column; padding: 4px 10px; gap: 2px; flex: 1; }
aside nav a {
  color: #9FB0BB; padding: 9px 14px; border-radius: 8px; font-weight: 500;
}
aside nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
/* Roter Zähler im Menü (offene Tickets/Aufgaben, Leads) */
.nav-count {
  float: right; min-width: 18px; height: 18px; padding: 0 5px; margin-top: 1px; margin-left: 10px;
  border-radius: 9px; background: #E5484D; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
/* Dezenter Dark-Modus-Umschalter am Menü-Ende */
aside nav a.theme-toggle {
  margin-top: auto; font-size: 12.5px; font-weight: 400; color: #5E6F79;
}
aside nav a.theme-toggle:hover { color: #C6D2DA; background: rgba(255,255,255,0.06); }
aside nav a.active { background: rgba(255,255,255,0.10); color: #fff; }
.sidebar-footer {
  padding: 14px 18px; border-top: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px;
}

/* min-width: 0 — sonst spreizen breite Tabellen das Flex-Item auf und die
   Seite scrollt horizontal, statt dass die Tabelle intern scrollt */
main { flex: 1; min-width: 0; padding: 28px 32px 60px; max-width: 1560px; }

/* Bleibt beim Scrollen oben sichtbar (Titel + Filter der Übersichten).
   Negative Ränder + Innenabstand füllen die Polsterung von <main>, damit
   beim Andocken keine Inhalte oberhalb/seitlich durchscheinen. */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px 16px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 30;
  background: var(--bg);
  margin: -28px -32px 16px; padding: 28px 32px 12px;
  border-bottom: 1px solid var(--border);
}
.page-head h1 { font-size: 22px; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; flex: 1; justify-content: flex-end; }

h2.section { font-size: 15px; margin: 26px 0 10px; display: flex; align-items: center; justify-content: space-between; }

/* ---------- Komponenten ---------- */
.btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 8px; padding: 8px 14px; font-size: 14px; cursor: pointer; font-weight: 500;
}
a.btn { display: inline-block; }
a.btn:hover { text-decoration: none; }
.btn:hover { background: var(--btn-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: #F3CFC7; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,0.25); color: #dbe5e0; }
.btn.ghost:hover { background: rgba(255,255,255,0.1); }

input, select, textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-size: 14px; font-family: inherit; background: var(--input-bg); color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
/* Kompaktes Zuständigkeits-Dropdown in Tabellenzeilen und Detail-Kopf */
.assign-select { width: auto; max-width: 160px; padding: 4px 8px; font-size: 13px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--label); }
label input, label select, label textarea { font-weight: 400; }
.checkbox-label { flex-direction: row; align-items: center; gap: 8px; }
.checkbox-label input { width: auto; }
/* Checkboxen vom generischen Input-Styling ausnehmen — Safari verliert sonst
   das native Aussehen und rendert sie unsichtbar (Chrome ignoriert das) */
input[type="checkbox"] {
  -webkit-appearance: checkbox;
  appearance: auto;
  width: 16px; height: 16px;
  padding: 0; border: none; background: none;
  accent-color: var(--accent);
}

.search-input { max-width: 280px; }
/* Dropdowns im Seitenkopf (Sortierung, Filter) nur so breit wie nötig,
   statt sich wie das Suchfeld auf 280px aufzuspannen */
select.search-input { width: auto; min-width: 140px; max-width: 200px; }

/* ---------- Durchsuchbare Auswahl (Combobox) ---------- */
.combo { position: relative; }
.combo-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 60;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(17, 38, 64, 0.18); max-height: 240px; overflow-y: auto;
}
.combo-item { padding: 7px 10px; cursor: pointer; font-weight: 400; font-size: 14px; }
.combo-item:hover, .combo-item.active { background: var(--accent-soft); }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}

/* border-collapse: separate + overflow: clip statt collapse/hidden — beides nötig,
   damit die sticky Kopfzeile funktioniert (hidden erzeugt einen Scroll-Container,
   collapse lässt Zellränder beim Andocken verschwinden). Optik bleibt identisch. */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: clip; box-shadow: var(--shadow); }
table { display: table; }
.table-wrap { border-radius: var(--radius); }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
/* Normaler Text bricht nur zwischen Wörtern um — so bekommen Namens-/Textspalten
   ihre nötige Breite. Nur lange URLs/E-Mail-Adressen (externe Links) dürfen
   notfalls mitten im Wort brechen, sonst drücken sie die Tabelle über die
   Fensterbreite hinaus. Telefonnummern bleiben immer in einer Zeile. */
td { overflow-wrap: break-word; }
td a[href^="http"], td a[href^="mailto:"] { overflow-wrap: anywhere; }
td a[href^="tel:"] { white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--hover); white-space: nowrap; }
/* Spaltenüberschriften docken beim Scrollen unter dem Seitenkopf an;
   --page-head-h wird in app.js per ResizeObserver gepflegt */
thead th { position: sticky; top: var(--page-head-h, 58px); z-index: 20; }
/* Schmale Fenster: Tabellen scrollen wie bisher intern horizontal.
   Die Spaltenzeile muss hier wieder normal fließen (position: static) —
   sticky würde sie innerhalb des Scroll-Containers um --page-head-h nach
   unten schieben und mitten in der Tabelle schweben lassen. */
@media (max-width: 1100px) {
  .table-wrap { overflow-x: auto; }
  thead th { position: static; }
}
/* Schmalere Fenster: kompakteres Zellen-Padding, damit die Textspalten
   (Namen, URLs, E-Mails) möglichst ohne Umbruch auskommen */
@media (max-width: 1400px) {
  th, td { padding: 10px 10px; }
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--hover); }
tr.clickable { cursor: pointer; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: var(--badge-bg); color: var(--badge-text); white-space: nowrap;
}
.badge.green { background: var(--badge-green-bg); color: var(--badge-green-text); }
.badge.red { background: var(--badge-red-bg); color: var(--danger); }
.badge.yellow { background: var(--warn-soft); color: var(--warn); }
.badge.blue { background: var(--badge-blue-bg); color: var(--accent); }
.badge.gray { background: var(--badge-bg); color: var(--muted); }

.due-overdue { color: var(--danger); font-weight: 600; }
.due-today { color: var(--warn); font-weight: 600; }

/* ---------- Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { display: block; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
a.stat { color: inherit; text-decoration: none; transition: border-color .12s, box-shadow .12s, transform .12s; }
a.stat:hover { border-color: var(--accent, #218AE0); box-shadow: 0 4px 14px rgba(0,0,0,.10); transform: translateY(-1px); }
.stat .num { font-size: 26px; font-weight: 700; }
.stat .lbl { font-size: 13px; color: var(--muted); }
a.stat:hover .lbl { color: var(--accent, #218AE0); }
.pager { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 20px 0 4px; }
.pager-info { font-size: 13px; color: var(--muted); }
/* minmax(0,1fr) statt 1fr — sonst schrumpfen die Spalten nicht unter die
   Breite langer unumbrechbarer Zeilen (E-Mail-Signaturen in den Aktivitäten)
   und die Seite wird auf dem Handy breiter als der Viewport (Zoom-out) */
.dash-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: minmax(0,1fr); } }

.list-plain { list-style: none; display: flex; flex-direction: column; }
.list-plain li { padding: 9px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.list-plain li:last-child { border-bottom: none; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(6, minmax(180px, 1fr)); gap: 12px; overflow-x: auto; align-items: start; }
.kanban-col { background: var(--badge-bg); border-radius: var(--radius); padding: 10px; min-height: 220px; }
.kanban-col.drag-over { outline: 2px dashed var(--accent); }
.kanban-col h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--badge-text); padding: 2px 4px 8px; }
.deal-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow);
}
.deal-card:active { cursor: grabbing; }
.deal-card .title { font-weight: 600; margin-bottom: 2px; }
.deal-card .meta { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }

/* ---------- Aufgabenliste ---------- */
/* Ampel: Dringlichkeit nach Fälligkeit (rot = dringend, gelb = bald fällig, grün = im Plan) */
.light { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; position: relative; top: -1px; }
.light.red { background: var(--danger); }
.light.yellow { background: #F0A800; }
.light.green { background: #2E9E5B; }
.light.gray { background: var(--border); }
.light.off { background: transparent; }
.task-row { display: flex; align-items: baseline; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.task-row:last-child { border-bottom: none; }
.task-row input[type="checkbox"] { width: 16px; height: 16px; flex-shrink: 0; position: relative; top: 2px; }
.task-row .t-title { font-weight: 500; }
.task-row.done .t-title { text-decoration: line-through; color: var(--muted); }
.task-row .t-meta { font-size: 12.5px; color: var(--muted); }
.task-row .spacer { flex: 1; }

/* ---------- Aktivitäten ---------- */
.activity { padding: 10px 0; border-bottom: 1px solid var(--border); }
.activity:last-child { border-bottom: none; }
.activity .a-head { font-size: 12.5px; color: var(--muted); margin-bottom: 3px; display: flex; gap: 8px; align-items: baseline; }
.activity .a-content { overflow-wrap: break-word; }
/* Aufklappbare Aktivitäten: Vorschauzeile mit Pfeil, Rest ein-/ausblendbar */
.a-preview { display: flex; gap: 7px; align-items: baseline; cursor: pointer; }
.a-preview > div { min-width: 0; }
.a-preview .acc-arrow {
  color: var(--muted); font-size: 11px; flex-shrink: 0;
  display: inline-block; transition: transform 0.15s ease;
}
.a-preview.open .acc-arrow { transform: rotate(90deg); }
.a-preview:hover .acc-arrow { color: var(--text); }
.a-more { margin-top: 6px; padding-left: 18px; }
.a-content ul, .tl-content ul, dl.kv dd ul { margin: 2px 0 2px 18px; }
.a-content a { word-break: break-all; }
/* Überschriften aus fmtText (# / ## / ###) — bewusst kompakt, damit Beiträge ruhig bleiben */
h1.fmt-h { font-size: 17px; margin: 10px 0 4px; }
h2.fmt-h { font-size: 15px; margin: 8px 0 3px; }
h3.fmt-h { font-size: 13.5px; margin: 6px 0 2px; }
.fmt-h:first-child { margin-top: 0; }
.activity.internal { background: var(--warn-soft); border-radius: 8px; padding: 10px 12px; margin: 4px 0; border-bottom: none; }
.activity.act-note, .activity.act-call, .activity.act-email, .activity.act-meeting {
  border-radius: 8px; padding: 10px 12px; margin: 4px 0; border-bottom: none;
}
.activity.act-note { background: var(--act-note); }
.activity.act-call { background: var(--act-call); }
.activity.act-email { background: var(--act-email); }
.activity.act-meeting { background: var(--act-meeting); }

/* ---------- Detailseiten ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; margin-bottom: 8px; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { word-break: break-word; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 22, 30, 0.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50;
  overflow-y: auto;
}
.modal {
  background: var(--panel); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  width: 520px; max-width: 100%; padding: 22px;
}
.modal h2 { font-size: 17px; margin-bottom: 16px; }
.modal form { display: flex; flex-direction: column; gap: 12px; }
.modal .modal-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }
.modal .modal-actions .right { display: flex; gap: 8px; margin-left: auto; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

/* Plugin-Lizenzen (Widget auf der Firmen-Detailseite) */
.plugin-license { padding: 10px 0; border-top: 1px solid var(--border); font-size: 14px; display: flex; flex-direction: column; gap: 3px; }
.plugin-license:first-of-type { border-top: none; padding-top: 0; }
.pl-head { display: flex; align-items: center; gap: 8px; }
.pl-head a { margin-left: auto; color: var(--muted); }
.pl-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; color: var(--muted); word-break: break-all; }

/* MainWP-Block im Wartung-Widget */
.mwp-site { padding: 10px 0 4px; border-top: 1px solid var(--border); margin-top: 10px; font-size: 14px; }
.mwp-items { list-style: none; margin: 8px 0 4px; display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.mwp-items li { display: flex; justify-content: space-between; gap: 10px; }
.mwp-items li.muted span { color: var(--muted); }

/* Inline-Bearbeitung direkt in einer Karte (Stammdaten/Wartung, ohne Popup) */
.inline-form { display: flex; flex-direction: column; gap: 12px; }
.inline-form .modal-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }
.inline-form .modal-actions .right { display: flex; gap: 8px; margin-left: auto; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: #15222B; color: #fff; padding: 11px 16px; border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25); font-size: 14px; max-width: 340px;
  animation: toast-in 0.18s ease-out;
}
.toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Timeline ----------
   Echter Zeitstrahl: mittige Linie, Beiträge chronologisch abwechselnd
   links/rechts versetzt, Datums-Badge über jedem Beitrag zur Linie hin. */
.timeline { position: relative; display: flex; gap: 56px; align-items: flex-start; }
.timeline::before {
  content: ''; position: absolute; left: 50%; top: 4px; bottom: 4px; width: 4px;
  transform: translateX(-50%); background: var(--border); border-radius: 2px;
}
.tl-col { flex: 1 1 0; min-width: 0; }
.tl-item { margin-bottom: 32px; }
.tl-badge-row { margin-bottom: 10px; }
.tl-col.tl-left .tl-badge-row { text-align: right; }
.tl-badge {
  display: inline-block; background: var(--sidebar); color: #F2F8FB;
  padding: 4px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
html.dark .tl-badge { background: var(--badge-bg); color: var(--text); }
@media (max-width: 1000px) {
  .timeline { display: block; }
  .timeline::before { display: none; }
  .tl-col.tl-left .tl-badge-row { text-align: left; }
}
.tl-post {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.tl-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.tl-author { font-weight: 600; }
.tl-date { font-size: 12.5px; color: var(--muted); }
.tl-del { margin-left: auto; color: var(--muted); align-self: flex-start; }
.tl-content { overflow-wrap: break-word; }
.tl-content p { margin-bottom: 8px; }
.tl-content ul, .tl-content ol { margin: 4px 0 8px 20px; }
.tl-content hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.tl-content a { word-break: break-all; }
.tl-replies { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.tl-reply { border: none; box-shadow: none; padding: 8px 0 4px; margin-bottom: 0; background: transparent; }
.tl-reply .tl-content { font-size: 14px; }
.tl-reply-form { display: flex; gap: 8px; margin-top: 8px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
}
.tl-reply .avatar { width: 28px; height: 28px; font-size: 11px; }

/* ---------- Projektphasen (Stepper) ---------- */
.phases { display: flex; overflow-x: auto; padding-bottom: 2px; }
.phase {
  flex: 1; min-width: 92px; background: none; border: none; cursor: pointer;
  text-align: center; position: relative; padding: 4px 4px 0; font-family: inherit;
}
.phase::before {
  content: ''; position: absolute; top: 17px; left: -50%; width: 100%; height: 3px;
  background: var(--border); z-index: 0;
}
.phase:first-child::before { display: none; }
.phase.done::before, .phase.current::before { background: var(--accent); }
.ph-dot {
  position: relative; z-index: 1; display: inline-flex; width: 30px; height: 30px;
  border-radius: 50%; align-items: center; justify-content: center;
  background: var(--panel); border: 2px solid var(--border);
  font-weight: 600; font-size: 13px; color: var(--muted);
}
.phase.done .ph-dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.phase.current .ph-dot { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.phase:hover .ph-dot { border-color: var(--accent); }
.ph-label { display: block; font-size: 11.5px; line-height: 1.25; margin-top: 5px; color: var(--muted); }
.phase.current .ph-label { color: var(--text); font-weight: 600; }
.phase-desc { margin-top: 12px; font-size: 13.5px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 10px; }
.phase-desc strong { color: var(--text); }

/* ---------- Farbauswahl ---------- */
.color-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border);
  cursor: pointer; font-size: 13px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.swatch.active { border-color: var(--text); }
.swatch.none { background: #fff; color: var(--muted); font-size: 11px; }

#me-name { cursor: pointer; }
#me-name:hover { text-decoration: underline; }

/* ---------- Sonstiges ---------- */
.pill-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.pill-filter button { border: 1px solid var(--border); background: var(--panel); border-radius: 20px; padding: 5px 13px; font-size: 13px; cursor: pointer; color: var(--text); }
.pill-filter button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--panel); border-radius: 20px;
  padding: 5px 13px; font-size: 13px; cursor: pointer; color: var(--text); font-weight: 500;
}
.chip:hover { background: var(--btn-hover); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

code.inline { background: var(--badge-bg); padding: 2px 6px; border-radius: 5px; font-size: 12.5px; word-break: break-all; }
pre.payload { background: var(--hover); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 12px; overflow-x: auto; max-height: 160px; }

.empty { color: var(--muted); padding: 14px 0; font-size: 14px; }

/* Burger-Button: nur mobil sichtbar, schwebt oben links über der Ansicht */
.nav-burger {
  display: none; position: fixed; top: 10px; left: 12px; z-index: 45;
  width: 42px; height: 42px; align-items: center; justify-content: center;
  border: none; border-radius: 8px; background: var(--sidebar); color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.nav-backdrop { display: none; }

@media (max-width: 800px) {
  .nav-burger { display: inline-flex; }
  /* Sidebar wird zum einschiebbaren Drawer */
  aside {
    position: fixed; top: 0; left: 0; width: 250px; height: 100vh; z-index: 70;
    transform: translateX(-100%); transition: transform 0.25s ease;
    box-shadow: 2px 0 18px rgba(0,0,0,0.35);
  }
  #shell.nav-open aside { transform: translateX(0); }
  #shell.nav-open .nav-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 60;
  }
  main { padding: 18px 16px 50px; }
  /* Platz links für den Burger, damit er die Überschrift nicht überlappt */
  .page-head { margin: -18px -16px 12px; padding: 18px 16px 10px 62px; }
  /* Filter/Aktionen rutschen unter den Titel (wie bei den Kunden) statt
     rechts daneben gequetscht zu werden */
  .page-head .actions { flex-basis: 100%; justify-content: flex-start; }
  /* Pipeline: Phasen untereinander statt horizontal scrollen */
  .kanban { display: flex; flex-direction: column; align-items: stretch; gap: 14px; overflow-x: visible; }
  .kanban-col { min-height: 0; }
  .kanban-col h3 { font-size: 12px; letter-spacing: 0.06em; color: var(--muted); }
}

/* ✨-Button (Claude-Textoptimierung) unter Textfeldern */
.ai-btn { align-self: flex-start; margin-top: 2px; font-weight: 400; }

/* Rechnungszeile an Zeiteinträgen: Text + Kopier-Symbol */
.copy-line { border: none; background: none; cursor: pointer; color: var(--muted); padding: 0 2px; margin-left: 4px; font-size: 14px; vertical-align: middle; }
.copy-line:hover { color: var(--accent); }

/* ---------- Übersichts-Filter im Bottom-Sheet (alle Bildschirmgrößen) ----------
   Filter/Suche/Sortierung jeder Übersicht liegen in einem Bottom-Sheet (max.
   640px breit, zentriert), das über den Filter-Knopf mit Zähler im Seitenkopf
   öffnet. Der Primär-Button („Neues …“) sitzt daneben im Kopf. Unter 800px
   weichen die Tabellen (.desktop-only) den gruppierten Karten (.m-cards) und
   der Primär-Button wird zum schwebenden FAB. */
.m-cards, .fab { display: none; }

/* — Kopf-Steuerung: Primär-Button + Filter-Knopf rechts — */
.head-ctl { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.m-filter-btn {
  display: grid; place-items: center; position: relative;
  width: 40px; height: 40px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); color: var(--text); cursor: pointer; box-shadow: var(--shadow);
}
.m-filter-btn:hover { background: var(--btn-hover); }
.m-filter-btn .m-badge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px;
  border-radius: 9px; padding: 0 4px; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

/* — Bottom-Sheet mit den Filtern — */
body.sheet-open { overflow: hidden; }
.scrim {
  position: fixed; inset: 0; z-index: 75;
  background: rgba(15, 22, 30, 0.45);
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
body.sheet-open .scrim { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 50%; bottom: 0; z-index: 80;
  width: 100%; max-width: 640px;
  background: var(--panel); border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 34px rgba(0, 0, 0, 0.25);
  padding: 8px 18px calc(22px + env(safe-area-inset-bottom));
  max-height: 82vh; overflow-y: auto;
  /* visibility: kein Schatten-Durchschein und kein Tab-Fokus im zugeklappten Zustand */
  visibility: hidden;
  transform: translate(-50%, 105%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0.3, 1), visibility 0.28s;
}
body.sheet-open .sheet { visibility: visible; transform: translate(-50%, 0); }
.sheet .grabber {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 6px auto 16px;
}
.sheet .actions { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
.sheet .actions > * { width: 100%; max-width: none !important; }
.sheet .actions input.search-input { order: -1; height: 44px; font-size: 16px; }
.sheet .actions select { height: 44px; }
.sheet .actions .pill-filter { justify-content: flex-start; }
.sheet .actions .pill-filter button { padding: 8px 16px; font-size: 14px; }
.sheet .m-apply { display: block; width: 100%; margin-top: 6px; padding: 12px; font-size: 15px; }

@media (max-width: 800px) {
  .desktop-only { display: none !important; }
  /* Platz unten für den schwebenden Aktionsknopf */
  main { padding-bottom: 96px; }

  /* — Gruppierte Karten — */
  .m-cards { display: block; }
  .m-section {
    position: sticky; top: var(--page-head-h, 58px); z-index: 10;
    display: flex; align-items: center; gap: 8px;
    margin: 0 -16px; padding: 12px 16px 8px; background: var(--bg);
    font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--muted);
  }
  .m-section.hl { color: var(--accent); }
  .m-section .num {
    background: var(--panel); border: 1px solid var(--border); border-radius: 9px;
    padding: 0 8px; font-size: 11.5px; font-weight: 600; color: var(--muted);
  }
  .m-list { display: flex; flex-direction: column; gap: 10px; padding: 2px 0 14px; }
  .m-card {
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 12px 14px;
    display: flex; flex-direction: column; gap: 5px; cursor: pointer;
  }
  .m-card .m-title { font-weight: 600; font-size: 15.5px; line-height: 1.3; overflow-wrap: break-word; }
  .m-card .m-sub { font-size: 13.5px; color: var(--muted); overflow-wrap: break-word; }
  .m-card .m-meta {
    display: flex; flex-wrap: wrap; gap: 5px 8px; align-items: center;
    font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere;
  }
  .m-card .m-right { margin-left: auto; }
  .m-card.done .m-title { text-decoration: line-through; color: var(--muted); }
  .m-task-top { display: flex; gap: 10px; align-items: flex-start; }
  .m-task-top input[type="checkbox"] { width: 18px; height: 18px; margin-top: 2px; }
  .m-task-top .light { margin-top: 5px; }
  /* Delegierte Teilaufgaben innerhalb der Karte kompakt */
  .m-card .task-row.point { margin-left: 28px !important; padding: 2px 0 !important; border: none; }

  /* Reiter-Navigation (Firmen/Kontakte/…) rutscht als scrollbare Zeile unter den Titel */
  .page-head > .pill-filter {
    order: 5; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .page-head > .pill-filter::-webkit-scrollbar { display: none; }
  .page-head > .pill-filter button { white-space: nowrap; flex-shrink: 0; }

  /* — Schwebender Aktionsknopf ersetzt den Primär-Button im Kopf — */
  .head-ctl .btn.primary { display: none; }
  .fab {
    display: flex; align-items: center; gap: 6px;
    position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 40;
    height: 50px; padding: 0 20px; border: none; border-radius: 25px;
    background: var(--accent); color: #fff;
    font-family: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 40, 80, 0.35);
  }
  .fab:active { transform: scale(0.97); }
  /* Bei geöffnetem Sheet tritt der FAB zurück (läge sonst über „Anwenden“) */
  body.sheet-open .fab { display: none; }
}
