/* =================================================================
   ANFRAGEN-SYSTEM — Stylesheet (Light Mode, Marke shape & raise / SABESUS)
   Eigenständig, keine externen Fonts/CDNs.
   ================================================================= */

:root {
  /* Marke */
  --green-800: #034a3d;
  --green-700: #046656;
  --green-600: #05806a;   /* Primär */
  --green-100: #e1f1ec;
  --green-tint: rgba(5, 128, 106, 0.12);

  /* Neutral */
  --ink-900: #1a1f1e;
  --ink-800: #262f2e;
  --ink-600: #575f5e;
  --ink-500: #7b8482;
  --ink-300: #d4d7d6;
  --ink-200: #e5e7e8;
  --ink-100: #eef1f0;
  --ink-050: #f6f8f7;
  --white:   #ffffff;

  --bg:       #f4f6f5;
  --surface:  #ffffff;
  --border:   #e2e6e4;
  --fg:       var(--ink-800);
  --fg-soft:  var(--ink-600);
  --fg-muted: var(--ink-500);

  /* Status */
  --s-neu-bg: #e7f0fd;   --s-neu-fg: #1d4ed8;
  --s-kon-bg: #fdf0d5;   --s-kon-fg: #a15c07;
  --s-ang-bg: #ede9fe;   --s-ang-fg: #6d28d9;
  --s-gew-bg: #d9f6e4;   --s-gew-fg: #128a4e;
  --s-ver-bg: #eceae8;   --s-ver-fg: #6b6660;

  --danger:   #c0453b;
  --danger-bg: #fbeae8;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(16, 40, 34, 0.05), 0 1px 3px rgba(16, 40, 34, 0.04);
  --shadow-md: 0 6px 18px rgba(16, 40, 34, 0.06);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.5rem; margin: 0; letter-spacing: -0.01em; }
h3 { font-size: 0.95rem; margin: 0 0 12px; letter-spacing: 0.01em; }
a  { color: var(--green-700); text-decoration: none; }
a:hover { color: var(--green-800); text-decoration: underline; }

.muted { color: var(--fg-muted); }
.req   { color: var(--danger); }
.ta-right { text-align: right; }

/* ---------- Wrap ---------- */
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink-900);
}
.brand:hover { text-decoration: none; }
.brand-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--green-600);
  box-shadow: 0 0 0 4px var(--green-tint);
}
.brand-dot-lg { width: 18px; height: 18px; }
.topnav { display: flex; align-items: center; gap: 10px; }
.topnav > a:not(.btn):not(.nav-user) {
  color: var(--fg-soft);
  font-weight: 500;
  padding: 6px 10px;
  text-decoration: none;
}
.topnav > a:not(.btn):not(.nav-user):hover { color: var(--fg); }

/* Benutzer-Chip in der Navigation */
.nav-user {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
  padding: 5px 10px;
  border-radius: 8px;
  text-decoration: none;
  margin-left: 4px;
}
.nav-user:hover { background: var(--ink-050); text-decoration: none; }
.nav-user-name { font-weight: 600; font-size: 0.85rem; color: var(--ink-900); }
.nav-user-role { font-size: 0.7rem; color: var(--fg-muted); }

/* ---------- Benachrichtigungen: Glocke + Klappmenü ---------- */
.notif-wrap { position: relative; display: inline-flex; }
.notif-bell {
  list-style: none;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 9px;
  color: var(--fg-soft);
}
.notif-bell::-webkit-details-marker { display: none; }
.notif-bell::marker { content: ""; }
.notif-bell:hover { background: var(--ink-050); color: var(--fg); }
.notif-wrap[open] .notif-bell { background: var(--ink-100); color: var(--fg); }
.notif-badge {
  position: absolute;
  top: 1px; right: 1px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}
.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(340px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  z-index: 30;
  overflow: hidden;
}
.notif-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.notif-panel-head strong { font-size: 0.9rem; }
.notif-link {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--green-600); font-size: 0.8rem; font-weight: 600;
}
.notif-link:hover { text-decoration: underline; }
.notif-empty { margin: 0; padding: 18px 14px; color: var(--fg-muted); font-size: 0.88rem; }
.notif-list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow-y: auto; }
.notif-item {
  display: block;
  padding: 11px 14px;
  border-bottom: 1px solid var(--ink-100);
  color: var(--fg);
}
.notif-list li:last-child .notif-item { border-bottom: none; }
.notif-item:hover { background: var(--ink-050); text-decoration: none; }
.notif-item-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.notif-item-name {
  font-weight: 600; font-size: 0.86rem; color: var(--ink-900);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.notif-item-time { flex: none; font-size: 0.72rem; color: var(--fg-muted); }
.notif-item-text {
  display: block; margin-top: 2px;
  font-size: 0.8rem; color: var(--fg-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.notif-item-text b { color: var(--fg-soft); font-weight: 600; }

/* Roter Punkt mit Zahl an der Anfrage-Zeile in der Übersicht */
.notif-dot {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  margin-left: 2px;
  border-radius: 9px;
  background: var(--danger); color: #fff;
  font-size: 0.7rem; font-weight: 700; line-height: 1;
  vertical-align: middle;
}

/* Notiz-Karte: Kopfzeile + "neu"-Kennzeichnung */
.notizen-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.notizen-head h3 { margin: 0; }
.notif-flag {
  display: inline-block; margin-left: 4px;
  padding: 1px 7px; border-radius: 999px;
  background: var(--danger); color: #fff;
  font-size: 0.68rem; font-weight: 700; vertical-align: middle;
}
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.notiz.notiz-neu { border-left: 3px solid var(--green-600); background: var(--green-tint); padding-left: 12px; }
.notiz-neu-tag {
  display: inline-block; padding: 0 6px; border-radius: 999px;
  background: var(--green-600); color: #fff;
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--green-600); color: #fff; }
.btn-primary:hover { background: var(--green-700); color: #fff; }
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--fg-soft);
}
.btn-ghost:hover { background: var(--ink-050); color: var(--fg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a5372f; color: #fff; }
.btn-block { width: 100%; }

/* ---------- Flash ---------- */
.flash {
  border-radius: var(--r-sm);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 0.92rem;
  font-weight: 500;
}
.flash-ok  { background: var(--s-gew-bg); color: var(--s-gew-fg); }
.flash-err { background: var(--danger-bg); color: var(--danger); }
.flash-info { background: var(--ink-100); color: var(--fg-soft); }

/* ---------- KPIs ---------- */
.kpis {
  display: grid;
  /* Auto-Fit: passt sich an die Kachel-Anzahl an (z. B. 5) und bricht selbst um. */
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
a.kpi:hover { border-color: var(--green-600); box-shadow: var(--shadow-md); text-decoration: none; }
a.kpi.active { border-color: var(--green-600); box-shadow: 0 0 0 1px var(--green-600); }
.kpi-num { font-size: 1.7rem; font-weight: 700; color: var(--ink-900); line-height: 1.1; }
.kpi-lbl { font-size: 0.82rem; color: var(--fg-muted); font-weight: 500; }
.kpi-static { background: var(--ink-050); }
.kpi-alert .kpi-num { color: var(--danger); }
.kpi-alert.active { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }

/* ---------- Toolbar (Filter + Suche) ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg-soft);
  font-size: 0.86rem;
  font-weight: 500;
}
.pill:hover { border-color: var(--ink-300); text-decoration: none; color: var(--fg); }
.pill.active { background: var(--ink-900); border-color: var(--ink-900); color: #fff; }
.pill-count {
  font-size: 0.76rem;
  background: var(--ink-100);
  color: var(--fg-soft);
  border-radius: 999px;
  padding: 1px 7px;
  font-weight: 600;
}
.pill.active .pill-count { background: rgba(255,255,255,0.22); color: #fff; }
/* farbige Punkte an Status-Pills */
.pill.st-neu::before, .pill.st-kontaktiert::before, .pill.st-angebot::before,
.pill.st-gewonnen::before, .pill.st-verloren::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
}
.pill.st-neu::before        { background: var(--s-neu-fg); }
.pill.st-kontaktiert::before{ background: var(--s-kon-fg); }
.pill.st-angebot::before    { background: var(--s-ang-fg); }
.pill.st-gewonnen::before   { background: var(--s-gew-fg); }
.pill.st-verloren::before   { background: var(--s-ver-fg); }

.search { display: flex; gap: 8px; align-items: center; }
.search input[type="search"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 0.9rem;
  min-width: 230px;
  background: var(--surface);
}
.search input[type="search"]:focus { outline: 2px solid var(--green-tint); border-color: var(--green-600); }

/* ---------- Tabelle ---------- */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow-x: auto;            /* breite Tabelle scrollt IN der Karte – Rest der Seite bleibt stehen */
  box-shadow: var(--shadow-sm);
}
.grid { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.grid td.ta-right, .grid th.ta-right { white-space: nowrap; }   /* Budget nicht umbrechen */

/* Kombinierte Termine-Spalte (Wiedervorlage / Vor-Ort / Installation gestapelt) */
.termine-cell .termin { display: block; white-space: nowrap; font-size: 0.83rem; line-height: 1.5; }
.termine-cell .tl { display: inline-block; min-width: 46px; color: var(--fg-muted); font-size: 0.72rem; }
.grid thead th {
  text-align: left;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  font-weight: 600;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--ink-050);
}
.grid tbody td { padding: 13px 12px; border-bottom: 1px solid var(--ink-100); vertical-align: middle; }
.grid tbody tr:last-child td { border-bottom: 0; }
.row-link { cursor: pointer; transition: background 0.12s; }
.row-link:hover { background: var(--green-tint); }
.rowname { font-weight: 600; color: var(--ink-900); }
.contact { font-size: 0.84rem; }
/* Flex auf den inneren Wrapper, NICHT auf die <td> – sonst füllt die Zelle die
   Zeilenhöhe nicht und ihre Trennlinie rutscht bei nur einer Nummer nach oben. */
.contact-list { display: flex; flex-direction: column; gap: 2px; }
.due { color: var(--danger); font-weight: 700; }

.count-line { margin: 12px 2px 0; font-size: 0.82rem; }

/* ---------- Aktivitätsprotokoll ---------- */
.ta-nowrap { white-space: nowrap; }
.date-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--fg-muted); white-space: nowrap; }
.date-inline input[type="date"] {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 0.9rem; color: var(--fg); background: #fff;
}
.evt {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; white-space: nowrap;
  background: var(--ink-100); color: var(--fg-soft);
}
.evt-login { background: var(--green-tint); color: var(--green-700); }
.evt-del   { background: var(--danger-bg); color: var(--danger); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 2px 0; flex-wrap: wrap; }
.pager-links { display: flex; gap: 8px; }

/* ---------- Badges / Status ---------- */
.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.st-neu          { background: #e7f0fd; color: #1d4ed8; }
.st-kontaktiert  { background: #fdf0d5; color: #a15c07; }
.st-angebot      { background: #ede9fe; color: #6d28d9; }
.st-angenommen   { background: #d0f0ec; color: #0f766e; }
.st-anzahlung    { background: #e2e6fd; color: #4338ca; }
.st-installation { background: #ffe8d4; color: #c2410c; }
.st-ware         { background: #fce4ef; color: #be185d; }
.st-abgeschlossen{ background: #d9f6e4; color: #128a4e; }
.st-abgelehnt    { background: #eceae8; color: #6b6660; }

/* ---------- Empty state ---------- */
.empty {
  background: var(--surface);
  border: 1px dashed var(--ink-300);
  border-radius: var(--r-md);
  padding: 48px 24px;
  text-align: center;
}
.empty p { color: var(--fg-muted); margin: 0 0 16px; }

/* ---------- Page head ---------- */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ---------- Cards & Forms ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.form { padding: 22px 24px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 20px;
}
.form-grid > label,
.form-grid > .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fg-soft);
  grid-column: span 2;            /* Standard: halbe Breite (2 von 4 Spalten) */
}
.form-grid .col-2      { grid-column: 1 / -1; }
.form-grid .col-street { grid-column: span 3; }
.form-grid .col-hnr    { grid-column: span 1; }
.form-grid .col-plz    { grid-column: span 1; }
.form-grid .col-ort    { grid-column: span 3; }
.field-cap { font-size: 0.82rem; font-weight: 600; color: var(--fg-soft); }

/* Segmented Control (Privat / Firma) */
.segmented {
  display: inline-flex;
  width: max-content;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--ink-050);
}
.segmented label { margin: 0; cursor: pointer; font-weight: 600; }
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented span {
  display: block;
  padding: 9px 22px;
  font-size: 0.88rem;
  color: var(--fg-soft);
  transition: background 0.15s, color 0.15s;
}
.segmented label:first-child span { border-right: 1px solid var(--border); }
.segmented input:checked + span { background: var(--green-600); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--green-tint); outline-offset: -2px; }

/* Kleine Tags (Privat / Firma) */
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  vertical-align: middle;
}
.tag-firma  { background: var(--ink-800); color: #fff; }
.tag-privat { background: var(--ink-100); color: var(--fg-soft); }
.tag-loesch { background: var(--danger); color: #fff; }
.tag-sparte { background: var(--green-tint); color: var(--green-700); text-transform: none; letter-spacing: 0; }

/* Löschungs-Vormerkung */
.btn-danger-outline { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger-bg); color: var(--danger); }
.loesch-box {
  background: var(--danger-bg);
  border: 1px solid #f0d5d2;
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 0.86rem;
}
.loesch-box strong { color: var(--danger); }
.loesch-box p { margin: 4px 0 0; }
.loesch-grund { font-style: italic; color: var(--fg-soft); }
.loesch-grund-input { margin-bottom: 8px; }
.notice-loesch {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
  background: var(--danger-bg); border: 1px solid #f0d5d2; color: var(--danger);
  border-radius: var(--r-md); padding: 12px 18px; margin-bottom: 18px;
  font-weight: 500; font-size: 0.9rem;
}
.notice-loesch a { color: var(--danger); font-weight: 700; }
.pill.pill-loesch { border-color: #f0d5d2; color: var(--danger); }
.pill.pill-loesch::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.pill.pill-loesch.active { background: var(--danger); border-color: var(--danger); color: #fff; }
.pill.pill-loesch.active::before { background: #fff; }

/* Bearbeiter-Filter im Suchbereich */
.search select {
  width: auto;
  min-width: 150px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 0.9rem;
  background: var(--surface);
}

/* ---------- Bilder-Galerie (Vor-Ort-Termin) ---------- */
.bilder-card { padding: 22px 24px; margin-top: 20px; }
.bilder-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.bilder-head h3 { margin: 0; }
.bild-upload { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0; }
.bild-upload input[type="file"] { width: auto; font-size: 0.85rem; padding: 6px 8px; }
.bilder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.bild {
  position: relative; margin: 0; aspect-ratio: 1 / 1;
  border-radius: var(--r-sm); overflow: hidden;
  background: var(--ink-100); border: 1px solid var(--border);
}
.bild img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.2s; }
.bild:hover img { transform: scale(1.04); }
.bild-del { position: absolute; top: 6px; right: 6px; margin: 0; }
.bild-del button {
  width: 26px; height: 26px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(26, 31, 30, 0.6); color: #fff; font-size: 0.78rem; line-height: 1;
  display: grid; place-items: center;
}
.bild-del button:hover { background: var(--danger); }

/* Nicht-Bild-Kacheln (PDF / Office / …): Icon + Dateiname statt Vorschaubild */
.bild-file { background: var(--surface); }
.bild-file > a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: 100%; padding: 12px; text-align: center; color: var(--fg-soft);
}
.bild-file > a:hover { background: var(--ink-050); text-decoration: none; }
.datei-ico {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 48px; height: 36px; padding: 0 9px; border-radius: 7px;
  background: var(--ink-800); color: #fff; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.04em;
}
.datei-ico-pdf { background: var(--danger); }
.datei-name {
  font-size: 0.78rem; line-height: 1.3; color: var(--fg-soft); max-width: 100%;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word;
}

/* Datei-Viewer (Overlay mit Bild oder PDF-iframe) */
.dv-overlay {
  position: fixed; inset: 0; z-index: 100; padding: 20px;
  background: rgba(16, 24, 22, 0.72);
  display: flex; align-items: center; justify-content: center;
}
.dv-overlay[hidden] { display: none; }
.dv-box {
  background: var(--surface); border-radius: 12px; overflow: hidden;
  width: min(1000px, 100%); height: min(90vh, 100%);
  display: flex; flex-direction: column; box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
}
.dv-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.dv-name { flex: 1; min-width: 0; font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dv-close {
  flex: none; width: 34px; height: 34px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--ink-100); color: var(--fg); font-size: 0.95rem; line-height: 1;
}
.dv-close:hover { background: var(--danger); color: #fff; }
.dv-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: var(--ink-100); }
.dv-frame { width: 100%; height: 100%; border: 0; }
.dv-img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }

/* ---------- Verlauf (Zeitleiste) ---------- */
.verlauf-card { padding: 22px 24px; margin-top: 16px; }
.verlauf-card h3 { margin-bottom: 14px; }
.verlauf { list-style: none; margin: 0; padding: 0; }
.verlauf-item { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--ink-100); }
.verlauf-item:last-child { border-bottom: 0; }
.verlauf-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: var(--ink-400); }
.verlauf-dot.vl-neu      { background: #1d4ed8; }
.verlauf-dot.vl-status   { background: var(--green-600); }
.verlauf-dot.vl-ergebnis { background: #a15c07; }
.verlauf-dot.vl-edit     { background: var(--ink-400); }
.verlauf-dot.vl-loesch   { background: var(--danger); }
.verlauf-dot.vl-bild     { background: #6d28d9; }
.verlauf-dot.vl-notiz    { background: #0891b2; }
.verlauf-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.verlauf-text { font-size: 0.9rem; color: var(--fg); }
.verlauf-meta { font-size: 0.78rem; color: var(--fg-muted); }

/* ---------- Notizen-Verlauf ---------- */
.notizen-card { padding: 22px 24px; margin-top: 20px; }
.notiz-form { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 18px; }
.notiz-form textarea { flex: 1; }
.notiz-liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.notiz { background: var(--ink-050); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px 14px; }
.notiz-kopf { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.notiz-autor { font-weight: 600; font-size: 0.88rem; color: var(--ink-900); }
.notiz-zeit { font-size: 0.78rem; color: var(--fg-muted); }
.notiz-del { margin: 0 0 0 auto; line-height: 1; }
.notiz-del button {
  width: 22px; height: 22px; border-radius: 50%; border: 0; cursor: pointer;
  background: transparent; color: var(--fg-muted); font-size: 0.72rem; line-height: 1;
  display: grid; place-items: center;
}
.notiz-del button:hover { background: var(--danger-bg); color: var(--danger); }
.notiz-text { font-size: 0.9rem; color: var(--fg); line-height: 1.55; }

/* Zweitzeile in der Namensspalte der Übersicht */
.rowsub { display: block; font-size: 0.78rem; color: var(--fg-muted); margin-top: 2px; }
input, select, textarea {
  font: inherit;
  font-size: 0.92rem;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--white);
  color: var(--fg);
  width: 100%;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--green-tint);
  border-color: var(--green-600);
}
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--ink-100);
}

/* ---------- Detailansicht ---------- */
.detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
.side { display: flex; flex-direction: column; gap: 16px; }
.side-card { padding: 18px; }
.meta { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 0.88rem; }
.meta dt { color: var(--fg-muted); font-weight: 500; }
.meta dd { margin: 0; text-align: right; font-weight: 500; word-break: break-word; }

.status-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.15s, box-shadow 0.15s;
}
.chip:hover { opacity: 1; }
.chip.is-current { opacity: 1; box-shadow: 0 0 0 2px currentColor inset; cursor: default; }

/* ---------- Status-Fortschritt (senkrechter Stepper) ---------- */
.status-flow { padding: 22px 26px; margin-bottom: 20px; }
.vflow { display: flex; flex-direction: column; }

.vstep { position: relative; display: flex; align-items: flex-start; gap: 14px; padding: 6px 0; flex-wrap: wrap; }
/* durchgehende Verbindungslinie zwischen den Punkten */
.vstep:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 18px;                /* Mitte des 38px-Dots */
  top: 25px;                 /* padding-top 6 + Dot-Mitte 19 */
  width: 2px;
  height: 100%;
  background: var(--ink-200);
  z-index: 0;
}
.vstep-main { margin: 0; position: relative; z-index: 1; }
.vstep-btn {
  display: flex; align-items: center; gap: 14px;
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; text-align: left; color: inherit;
}
.vstep-dot {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.9rem;
  background: #fff;
  border: 2px solid var(--ink-300);
  color: var(--fg-muted);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.vstep-label { font-size: 0.92rem; font-weight: 600; color: var(--fg); }

/* Zustände */
.vstep-done .vstep-dot   { background: var(--green-600); border-color: var(--green-600); color: #fff; }
.vstep-done:not(:last-child)::before { background: var(--green-600); } /* Spezifität muss die Basislinie schlagen */
.vstep-done .vstep-label { color: var(--fg-soft); }

.vstep-current .vstep-dot {
  background: #fff; border-color: var(--green-600); color: var(--green-700);
  box-shadow: 0 0 0 4px var(--green-tint);
}
.vstep-current .vstep-label { color: var(--green-700); font-weight: 700; }

.vstep-todo .vstep-label { color: var(--fg-muted); }

.vstep-btn:not([disabled]):hover .vstep-dot   { border-color: var(--green-600); }
.vstep-btn:not([disabled]):hover .vstep-label { color: var(--fg); }
.vstep-btn[disabled] { cursor: default; }

/* Ergebnis-Chips an der Phase "Kontaktiert" */
.vstep-extra { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 0 auto; align-self: center; padding-left: 8px; }
.erg-chip {
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--border); background: #fff;
  color: var(--fg-soft); font: inherit; font-size: 0.76rem; font-weight: 600;
  cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.erg-chip:hover { border-color: var(--ink-500); color: var(--fg); }
.erg-chip.on { background: var(--ink-800); border-color: var(--ink-800); color: #fff; }

.flow-lost {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--ink-100);
}
.flow-lost form { margin: 0; }
.status-flow.is-lost .vflow { opacity: 0.5; }
.status-flow.is-lost .vstep-dot { border-style: dashed; }

/* ---------- Auth ---------- */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--green-100), transparent),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: 32px 30px;
}
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head .brand-dot { margin: 0 auto 14px; }
.auth-head h1 { font-size: 1.4rem; }
.auth-head p { margin: 8px 0 0; font-size: 0.88rem; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }
.auth-card label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 0.82rem; font-weight: 600; color: var(--fg-soft);
}
.setup-manual {
  background: var(--ink-050);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 14px;
  margin-bottom: 18px;
  font-size: 0.85rem;
}
.setup-manual textarea { font-family: ui-monospace, Consolas, monospace; font-size: 0.8rem; margin-top: 8px; }

/* ---------- Footer ---------- */
.foot {
  text-align: center;
  color: var(--fg-muted);
  font-size: 0.8rem;
  padding: 24px;
}

/* Schmalerer Container (Benutzer-/Profilformulare) */
.wrap-narrow { max-width: 720px; }

/* Checkbox-Zeile */
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--fg);
  padding: 7px 0;
}
.check input { width: auto; margin: 0; }

/* Login-Ersteinrichtung: Vorname/Name nebeneinander */
.auth-card .two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* Danger-Bereich (Benutzer löschen) */
.danger-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  margin-top: 20px;
  border-color: #f0d5d2;
}
.danger-card strong { color: var(--danger); }
.danger-card p { margin: 4px 0 0; font-size: 0.85rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .detail { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 680px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid > * { grid-column: 1 / -1 !important; }
  /* Navigation umbrechen statt horizontal scrollen */
  .topbar { height: auto; flex-wrap: wrap; padding: 12px 16px; row-gap: 10px; }
  .topnav { width: 100%; flex-wrap: wrap; gap: 8px 12px; justify-content: flex-start; }
  .nav-user { margin-left: 0; }
  /* Glocken-Panel am Handy an die (variabel hohe) Topbar hängen statt an die
     Glocke – sonst ragt es aus dem Bildschirm, weil die Nav umbricht. */
  .notif-wrap { position: static; }
  .notif-panel { top: calc(100% + 8px); left: 12px; right: 12px; width: auto; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .search { flex-wrap: wrap; }
  .search select { width: 100%; min-width: 0; }
  .search input[type="search"] { flex: 1; min-width: 0; }

  /* Bilder-Galerie: zwei Spalten am Handy */
  .bilder-grid { grid-template-columns: repeat(2, 1fr); }
  .bilder-head { flex-direction: column; align-items: stretch; }

  /* Notiz-Eingabe stapeln */
  .notiz-form { flex-direction: column; align-items: stretch; }

  /* Tabelle → Karten */
  .table-card { border: 0; background: transparent; box-shadow: none; overflow: visible; }
  .grid thead { display: none; }
  .grid, .grid tbody, .grid tr, .grid td { display: block; width: 100%; }
  .grid tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    padding: 6px 14px;
    margin-bottom: 12px;
  }
  .grid tbody td {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: baseline;
    border-bottom: 1px solid var(--ink-100);
    padding: 9px 0;
    text-align: right;
    white-space: normal;   /* in der Karten-Ansicht wieder normal umbrechen */
  }
  .grid tbody tr td:last-child { border-bottom: 0; }
  .grid td::before {
    content: attr(data-label);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--fg-muted);
    font-weight: 600;
    text-align: left;
  }
  .grid td.contact .contact-list { align-items: flex-end; }
  .grid td:empty { display: none; }
  .ta-right { text-align: right; }

  /* Stepper etwas kompakter; Ergebnis-Chips unter die Phase */
  .status-flow { padding: 18px 16px; }
  .vstep-dot { width: 34px; height: 34px; font-size: 0.85rem; }
  .vstep:not(:last-child)::before { left: 16px; top: 23px; }
  .vstep-label { font-size: 0.88rem; }
  .vstep-extra { flex-basis: 100%; margin: 2px 0 0 48px; padding-left: 0; }
}
