/* ==========================================================================
   Vlaneo CRM – Gestaltung
   Ruhig, sachlich, gut lesbar. Markenfarbe nur für Hauptaktionen und Auswahl.
   ========================================================================== */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --faint: #98a2b3;

  --brand: #1ba84a;
  --primary: #15803d;
  --primary-hover: #116932;
  --primary-soft: #ecfdf3;
  --primary-line: #abefc6;

  --danger: #b42318;
  --danger-soft: #fef3f2;
  --danger-line: #fecdca;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --warn-line: #fedf89;
  --info: #175cd3;
  --info-soft: #eff8ff;
  --info-line: #b2ddff;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .04);
  --shadow-xl: 0 20px 24px -4px rgba(16, 24, 40, .10), 0 8px 8px -4px rgba(16, 24, 40, .04);
  --sidebar: 244px;
  --appbar: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 14px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; letter-spacing: -0.01em; }
p { margin: 0; }

.ico { flex: none; display: inline-block; vertical-align: -3px; }
.with-ico { display: inline-flex; align-items: center; gap: 6px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.missing { color: var(--warn); }
.danger-text { color: var(--danger); }
.warn-text { color: var(--warn); }
.label { font-weight: 600; color: var(--text-2); font-size: 12.5px; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.spacer { flex: 1; }

/* ---------- Laden & Anmeldung ---------- */
.loading { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 14px; color: var(--muted); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 2.5px solid var(--border); border-top-color: var(--primary); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.auth-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; background: var(--bg); }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 32px; display: flex; flex-direction: column; gap: 16px; }
.auth-title h1 { font-size: 22px; }
.auth-title p { margin-top: 4px; }
.auth-foot { color: var(--faint); font-size: 12px; }
.form-error { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-line); border-radius: var(--radius); padding: 9px 12px; font-size: 13px; }

/* ---------- Marke ---------- */
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { height: 38px; width: auto; max-width: 52px; object-fit: contain; }
.brand.big { flex-direction: column; text-align: center; gap: 12px; }
.brand.big .brand-logo { height: 84px; max-width: 120px; }
.brand-placeholder { width: 38px; height: 38px; border-radius: var(--radius); border: 1.5px dashed var(--brand); color: var(--primary); display: grid; place-items: center; font-weight: 700; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-text strong { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { font-size: 11.5px; color: var(--muted); }

/* ---------- Grundlayout ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 12px; gap: 20px; z-index: 6; }
.sidebar .brand-slot { padding: 2px 6px 6px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav.secondary { margin-top: auto; }
.nav-caption { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 0 10px 6px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 11px; border: 0; background: none; border-radius: var(--radius); padding: 8px 10px; cursor: pointer; font-weight: 500; color: var(--text-2); text-align: left; }
.nav-item .ico { color: var(--muted); }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-hover); font-weight: 600; }
.nav-item.active .ico { color: var(--primary); }
.nav-label { flex: 1; }
.nav-badge { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); border-radius: 999px; font-size: 11.5px; font-weight: 600; padding: 0 7px; line-height: 18px; min-width: 22px; text-align: center; }
.nav-badge.badge-wiedervorlage { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.side-status { font-size: 12px; padding: 0 10px; }
#conn { color: var(--primary); display: inline-flex; align-items: center; gap: 6px; }
#conn::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
#conn.off { color: var(--danger); font-weight: 600; }

.workspace { margin-left: var(--sidebar); min-height: 100vh; display: flex; flex-direction: column; }
.appbar { position: sticky; top: 0; z-index: 8; height: var(--appbar); background: rgba(255, 255, 255, .92); backdrop-filter: saturate(180%) blur(6px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 16px; padding: 0 28px; }
.appbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.appbar-title { font-size: 15px; font-weight: 600; display: none; }
.appbar-right { position: relative; display: flex; align-items: center; gap: 6px; margin-left: auto; }
.only-mobile { display: none !important; }
.bottom-nav { display: none; }
main { width: 100%; max-width: 1240px; margin: 0 auto; padding: 24px 28px 64px; }

/* Schnellsuche */
.gs { position: relative; flex: 0 1 420px; }
.gs-ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.gs-input { width: 100%; height: 38px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 0 12px 0 36px; }
.gs-input:focus { background: #fff; border-color: var(--primary); outline: 3px solid rgba(21, 128, 61, .12); }
.gs-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xl); padding: 4px; z-index: 30; max-height: 60vh; overflow: auto; }
.gs-item { width: 100%; display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name badge" "meta badge"; gap: 0 10px; text-align: left; border: 0; background: none; border-radius: 6px; padding: 8px 10px; cursor: pointer; }
.gs-item:hover { background: var(--surface-2); }
.gs-name { grid-area: name; font-weight: 600; }
.gs-meta { grid-area: meta; font-size: 12px; color: var(--muted); }
.gs-item .badge { grid-area: badge; align-self: center; }
.gs-empty { padding: 10px; color: var(--muted); }

/* Glocke & Benutzer */
.icon-btn { border: 0; background: none; width: 38px; height: 38px; border-radius: var(--radius); cursor: pointer; display: inline-grid; place-items: center; color: var(--text-2); position: relative; }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.bell-count { position: absolute; top: 3px; right: 1px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--text-2); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }
.bell-btn.has-new .bell-count { background: var(--danger); }
.bell-btn.has-new::after { content: ""; position: absolute; top: 8px; left: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px #fff; }
.avatar-btn { display: flex; align-items: center; gap: 8px; border: 0; background: none; border-radius: var(--radius); padding: 4px 8px 4px 4px; cursor: pointer; color: var(--text-2); }
.avatar-btn:hover { background: var(--surface-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-hover); border: 1px solid var(--primary-line); display: grid; place-items: center; font-weight: 600; font-size: 12.5px; flex: none; }
.avatar-name { font-weight: 500; }
.user-menu, .more-menu { position: absolute; top: calc(100% + 8px); right: 0; min-width: 230px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xl); padding: 6px; z-index: 40; display: flex; flex-direction: column; }
.more-menu { left: 12px; right: auto; }
.um-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; flex-direction: column; }
.um-item, .menu-item { display: flex; align-items: center; gap: 10px; border: 0; background: none; border-radius: 6px; padding: 8px 10px; cursor: pointer; text-align: left; color: var(--text-2); }
.um-item:hover, .menu-item:hover, .menu-item.active { background: var(--surface-2); color: var(--text); }

/* ---------- Seitenkopf ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 650; }
.page-head p { margin-top: 2px; color: var(--muted); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 320px; }

/* ---------- Bedienelemente ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--radius); padding: 0 14px; height: 38px; cursor: pointer; font-weight: 600; font-size: 13.5px; text-decoration: none; color: var(--text-2); white-space: nowrap; box-shadow: var(--shadow-xs); transition: background .12s, border-color .12s; }
.btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger-line); }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.small { height: 32px; padding: 0 11px; font-size: 13px; }
.btn.xs { height: 28px; padding: 0 9px; font-size: 12.5px; gap: 5px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 14.5px; }
.btn.block { width: 100%; }
.btn.call { color: var(--primary-hover); }
.show-more { align-self: center; margin-top: 4px; }
.link-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 4px; font-size: 12.5px; }
.link-btn:hover { color: var(--text); text-decoration: underline; }
.link-btn.danger:hover { color: var(--danger); }
.link-strong { border: 0; background: none; padding: 0; cursor: pointer; font-weight: 600; color: var(--text); text-align: left; }
.link-strong:hover { color: var(--primary); text-decoration: underline; }
.phone-link { font-weight: 500; white-space: nowrap; color: var(--text-2); }
.phone-link:hover { color: var(--primary); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.input { width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 8px 12px; background: #fff; min-height: 38px; box-shadow: var(--shadow-xs); }
.input:focus { border-color: var(--primary); outline: 3px solid rgba(21, 128, 61, .12); }
textarea.input { resize: vertical; line-height: 1.45; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.span2 { grid-column: span 2; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; color: var(--text-2); }
.check input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--primary); flex: none; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.toggle input { width: 16px; height: 16px; accent-color: var(--primary); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { border: 1px solid var(--border-strong); background: #fff; border-radius: 999px; padding: 4px 11px; cursor: pointer; font-size: 13px; color: var(--text-2); display: inline-flex; gap: 6px; align-items: center; }
.chip.lg { padding: 6px 13px; font-weight: 500; }
.chip:hover { border-color: var(--text-2); }
.chip.on { background: var(--text); border-color: var(--text); color: #fff; }
.chip.static { cursor: default; font-size: 11.5px; padding: 1px 8px; background: var(--surface-2); border-color: var(--border); }
.chip-warn.on { background: var(--warn); border-color: var(--warn); }
.chip.static.chip-warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.chip-count { background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 0 7px; font-size: 11.5px; font-weight: 600; }
.chip.on .chip-count { background: rgba(255, 255, 255, .18); color: #fff; }

.segmented { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-weight: 500; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.segmented button:hover { color: var(--text); }
.segmented button.on { background: #fff; color: var(--text); box-shadow: var(--shadow-xs); font-weight: 600; }
.segmented.small button { padding: 4px 10px; font-size: 12.5px; }
.segmented.tabs { margin: 0 0 16px; }

/* Status & Eignung: dezente Pillen mit Punkt, Text immer lesbar */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; border: 1px solid var(--border); background: #fff; color: var(--text-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.st-Neu::before { background: var(--info); }
.st-InBearbeitung::before { background: #f79009; }
.st-Kunde { border-color: var(--primary-line); background: var(--primary-soft); color: var(--primary-hover); }
.st-Kunde::before { background: var(--primary); }
.st-KeinInteresse { color: var(--muted); }
.st-KeinInteresse::before { background: var(--faint); }
.st-Gesperrt { border-color: var(--danger-line); background: var(--danger-soft); color: var(--danger); }
.st-Gesperrt::before { background: var(--danger); }
.st-archiv { color: var(--muted); background: var(--surface-2); }
.fit-sehr_passend { color: var(--primary-hover); border-color: var(--primary-line); }
.fit-sehr_passend::before { background: var(--primary); }
.fit-passend::before { background: #47cd89; }
.fit-pruefen { color: var(--warn); border-color: var(--warn-line); }
.fit-pruefen::before { background: #f79009; }
.fit-none { color: var(--muted); }

.hint { background: var(--info-soft); border: 1px solid var(--info-line); color: #194185; border-radius: var(--radius); padding: 10px 14px; font-size: 13.5px; }
.hint.warn { background: var(--warn-soft); border-color: var(--warn-line); color: #93370d; }
.hint.danger { background: var(--danger-soft); border-color: var(--danger-line); color: #912018; }
.hint.note { background: #fffdf5; border-color: #f5e6b5; color: var(--text-2); white-space: pre-wrap; }
.hint .row-actions { margin-top: 10px; }

.empty { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 28px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.empty-icon { width: 44px; height: 44px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); display: grid; place-items: center; margin-bottom: 6px; }
.empty h3 { font-size: 14.5px; }
.empty p { color: var(--muted); max-width: 440px; }
.count-pill { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); border-radius: 999px; font-size: 12px; font-weight: 600; padding: 0 8px; }
.count-pill.danger { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.count-pill.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.count-pill.good { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary-hover); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-xs); }
.panel h3, .card-section h3 { font-size: 14.5px; font-weight: 600; }

/* ---------- Heute ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 28px; }
.kpi-tile { text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-lg); padding: 14px 16px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow-xs); transition: border-color .12s, box-shadow .12s; }
.kpi-tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.kpi-tile-label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.kpi-tile-value { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-tile-sub { font-size: 12px; color: var(--faint); }
.kpi-tile.danger .kpi-tile-value { color: var(--danger); }
.kpi-tile.warn .kpi-tile-value { color: var(--warn); }
.kpi-tile.good .kpi-tile-value { color: var(--primary); }
.today-block { margin-bottom: 32px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.section-head h2 { font-size: 16px; font-weight: 600; }
.section-sub { color: var(--faint); font-size: 12.5px; }

/* ---------- Karten & Listen ---------- */
.card-list, .task-list { display: flex; flex-direction: column; gap: 8px; }
.lead-card { display: flex; gap: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; cursor: pointer; box-shadow: var(--shadow-xs); align-items: center; transition: border-color .12s, box-shadow .12s; }
.lead-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.lc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.lc-title { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lc-title strong { font-size: 14.5px; }
.lc-sub { color: var(--muted); }
.lc-next { font-size: 13px; padding-left: 10px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.lc-next strong { font-weight: 600; color: var(--text); }
.lc-last { color: var(--muted); }
.lc-last .ico { color: var(--faint); }
.lc-why { font-size: 13px; color: var(--text-2); }
.lc-foot { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); align-items: center; margin-top: 2px; }
.lc-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 440px; }
.tone-danger { border-left-color: var(--danger) !important; }
.tone-warn { border-left-color: #f79009 !important; }
.tone-good { border-left-color: var(--primary) !important; }
.tone-info { border-left-color: var(--info) !important; }
.tone-muted { border-left-color: var(--border-strong) !important; color: var(--muted); }
.tone-text-danger { color: var(--danger); font-weight: 600; }
.tone-text-warn { color: var(--warn); font-weight: 600; }
.tone-text-good { color: var(--primary); font-weight: 600; }
.tone-text-info, .tone-text-muted { font-weight: 600; color: var(--text-2); }

.quick-filters { margin-bottom: 10px; }
.more-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px; margin-bottom: 12px; }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow-x: auto; margin: 8px 0 14px; box-shadow: var(--shadow-xs); }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.row { cursor: pointer; }
.table tr.row:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table.compact td, .table.compact th { padding: 8px 12px; }

.task-card { display: grid; grid-template-columns: 84px 1fr auto; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 16px; cursor: pointer; align-items: center; box-shadow: var(--shadow-xs); }
.task-card:hover { border-color: var(--border-strong); }
.task-card.overdue .tc-when strong { color: var(--danger); }
.tc-when { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; }
.tc-when strong { font-size: 18px; font-weight: 600; color: var(--text); }
.tc-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tc-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

/* ---------- Kundenkarte ---------- */
.drawer-overlay { position: fixed; inset: 0; background: rgba(16, 24, 40, .35); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100%); background: var(--bg); z-index: 21; display: flex; flex-direction: column; box-shadow: var(--shadow-xl); }
.drawer-head { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 24px 18px; display: flex; flex-direction: column; gap: 10px; }
.drawer-top { display: flex; justify-content: space-between; align-items: center; }
.drawer-nav { display: flex; align-items: center; gap: 2px; color: var(--muted); }
.card-title { font-size: 20px; font-weight: 650; }
.card-meta, .card-contact { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; color: var(--text-2); }
.card-contact .ico { color: var(--faint); }
.next-action { border: 1px solid var(--border); border-left: 3px solid var(--info); background: var(--surface-2); border-radius: var(--radius); padding: 8px 12px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.next-action.tone-danger { border-left-color: var(--danger); }
.next-action.tone-warn { border-left-color: #f79009; }
.next-action.tone-good { border-left-color: var(--primary); }
.na-label { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.na-reason { font-size: 13px; color: var(--muted); flex-basis: 100%; }
.action-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.action { display: flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--radius); padding: 0 8px; height: 40px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--text-2); box-shadow: var(--shadow-xs); white-space: nowrap; }
.action .ico { color: var(--primary); }
.action:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-hover); }
.action.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.action.primary .ico { color: #fff; }
.action.primary:hover:not(:disabled) { background: var(--primary-hover); color: #fff; }
.action:disabled { opacity: .4; cursor: not-allowed; }
.card-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-fold { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.card-fold > summary { cursor: pointer; padding: 13px 18px; font-weight: 600; font-size: 14px; list-style: none; display: flex; align-items: center; gap: 8px; }
.card-fold > summary::-webkit-details-marker { display: none; }
.card-fold > summary::before { content: ""; width: 7px; height: 7px; border-right: 1.8px solid var(--muted); border-bottom: 1.8px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; margin-right: 4px; }
.card-fold[open] > summary::before { transform: rotate(45deg); }
.card-fold-body { padding: 0 18px 16px; display: flex; flex-direction: column; gap: 10px; }
.link-add { border: 1px dashed var(--border-strong); background: none; color: var(--muted); border-radius: 6px; padding: 2px 9px; font-size: 12.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.link-add:hover { border-color: var(--primary); color: var(--primary-hover); background: var(--primary-soft); }
.link-list { display: inline-flex; flex-wrap: wrap; gap: 4px 16px; }
.input.compact { min-height: 32px; padding: 4px 8px; font-size: 13px; width: auto; }
.input.auto { width: auto; }
.callout.note { background: #fffdf5; border-color: #f5e6b5; }
.align-end { justify-content: flex-end; align-items: flex-start; }
.drawer-body { overflow-y: auto; padding: 18px 24px 64px; display: flex; flex-direction: column; gap: 14px; }
.card-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-xs); }
.callout { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; white-space: pre-wrap; color: var(--text-2); }
.facts { display: grid; grid-template-columns: 130px 1fr; gap: 9px 16px; margin: 0; align-items: baseline; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.facts dd.missing { color: var(--faint); font-style: italic; }
.facts dd .input { max-width: 260px; }
.sources { margin: 0; padding-left: 18px; }
.task-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; border-top: 1px solid var(--border); padding-top: 10px; flex-wrap: wrap; }
.task-row.overdue strong { color: var(--danger); }
.more-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.timeline { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-direction: column; }
.tl { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.tl:first-child { border-top: 0; }
.tl.clickable { cursor: pointer; }
.tl-icon { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.tl-recherche .tl-icon, .tl-aenderung .tl-icon { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.tl-recherche .tl-body, .tl-aenderung .tl-body { color: var(--muted); font-size: 13px; }
.tl-bestellung .tl-icon { background: var(--primary); color: #fff; }
.tl-body { flex: 1; min-width: 0; }
.tl-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.tl-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 3px; color: var(--text-2); }
.tl-actions { margin-top: 2px; }

/* ---------- Dialoge ---------- */
.sheet-overlay { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 50; display: grid; place-items: center; padding: 16px; }
.sheet { width: min(560px, 100%); max-height: calc(100vh - 32px); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); display: flex; flex-direction: column; }
.sheet.wide { width: min(780px, 100%); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.sheet-head h2 { font-size: 17px; font-weight: 600; }
.sheet-body { padding: 18px 20px 22px; overflow-y: auto; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: -22px; background: var(--surface); padding: 12px 0 0; border-top: 1px solid var(--border); margin-top: 4px; }
.sheet-actions.wrap { flex-wrap: wrap; justify-content: flex-start; border-top: 0; }
.sheet-customer { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 12px; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.snippets { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.snippet { text-align: left; border: 1px solid var(--border); background: #fff; border-radius: var(--radius); padding: 8px 10px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.snippet:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-hover); }
.next-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--surface-2); }
.task-editor { display: flex; flex-direction: column; gap: 12px; }
.due-summary { font-weight: 600; color: var(--primary-hover); }
.stage-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stage-option { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 11px 12px; cursor: pointer; font-weight: 500; text-align: left; background: #fff; display: flex; align-items: center; gap: 8px; }
.stage-option.on { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(21, 128, 61, .15); font-weight: 600; }
.pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.pick { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; border: 1px solid var(--border); background: #fff; border-radius: var(--radius); padding: 10px 12px; cursor: pointer; text-align: left; }
.pick:hover { border-color: var(--primary); }

/* ---------- Benachrichtigungen ---------- */
.nt-overlay { position: fixed; inset: 0; background: rgba(16, 24, 40, .25); z-index: 30; }
.nt-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--surface); z-index: 31; display: flex; flex-direction: column; box-shadow: var(--shadow-xl); border-left: 1px solid var(--border); }
.nt-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; }
.nt-head h2 { font-size: 17px; font-weight: 600; }
.nt-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.nt-tabs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 0 20px 12px; border-bottom: 1px solid var(--border); }
.nt-tabs select.input { width: auto; min-height: 32px; padding: 4px 8px; font-size: 12.5px; }
.nt-list { flex: 1; overflow-y: auto; padding: 8px 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.nt-group { font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); padding: 12px 8px 4px; }
.nt-item { display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding: 10px 8px; border-radius: var(--radius); border: 1px solid transparent; }
.nt-item:hover { background: var(--surface-2); border-color: var(--border); }
.nt-item + .nt-item { border-top-color: var(--border); border-top-left-radius: 0; border-top-right-radius: 0; }
.nt-item.fresh .nt-title::after { content: "neu"; margin-left: 8px; font-size: 10.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--primary-hover); background: var(--primary-soft); border-radius: 4px; padding: 1px 5px; vertical-align: 1px; }
.nt-when { display: flex; flex-direction: column; align-items: flex-start; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.nt-when strong { font-size: 15px; color: var(--text); }
.nt-item.late .nt-when strong { color: var(--danger); }
.nt-item.sys .nt-when { color: var(--info); padding-top: 2px; }
.nt-item.sys.tone-danger .nt-when { color: var(--danger); }
.nt-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nt-title { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.nt-meta { font-size: 12px; color: var(--faint); }
.nt-note { font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.nt-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.nt-foot { border-top: 1px solid var(--border); padding: 12px 20px; display: flex; justify-content: flex-end; }

/* ---------- Auswertung ---------- */
.period-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.period-nav { display: flex; align-items: center; gap: 4px; }
.period-nav .input { width: auto; }
.period-bar > select { width: auto; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow-xs); }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.3; }
.kpi-sub { font-size: 12px; color: var(--faint); }
.kpi.good .kpi-value { color: var(--primary); }

/* ---------- Verwaltung ---------- */
.profile-grid { display: grid; grid-template-columns: 260px 1fr; gap: 14px; margin-bottom: 14px; align-items: start; }
.logo-preview { width: 100%; max-height: 180px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.logo-placeholder { border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 30px 10px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.doc-list { margin: 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.status-dot { display: inline-flex; align-items: center; gap: 8px; }
.status-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #f79009; flex: none; }
.status-dot.ok::before { background: var(--primary); }
.status-dot.bad::before { background: var(--danger); }
.note { margin-top: 12px; }

/* ---------- Kurzmeldungen nach dem Speichern (verschwinden von selbst) ---------- */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; max-width: calc(100vw - 32px); pointer-events: none; }
.toast { background: var(--text); color: #fff; border-radius: var(--radius); padding: 9px 14px; box-shadow: var(--shadow-xl); max-width: 480px; font-size: 13.5px; transition: opacity .35s; pointer-events: auto; }
.toast.ok { background: #0c3d20; }
.toast.error { background: var(--danger); }
.toast.hide { opacity: 0; }

/* ---------- Formulare: Gruppen & Einklappbares ---------- */
.form-group { border: 0; padding: 0; margin: 0; min-width: 0; }
.form-group > legend { font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); padding: 0; margin-bottom: 8px; }
.form-group + .form-group, .form-group + .form-fold { border-top: 1px solid var(--border); padding-top: 14px; }
.form-fold { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.form-fold > summary { cursor: pointer; padding: 10px 12px; font-weight: 600; font-size: 13.5px; color: var(--text-2); list-style: none; display: flex; align-items: center; gap: 8px; }
.form-fold > summary::-webkit-details-marker { display: none; }
.form-fold > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.8px solid var(--muted); border-bottom: 1.8px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; margin: 0 4px 0 2px; }
.form-fold[open] > summary::before { transform: rotate(45deg); }
.form-fold > div { padding: 4px 12px 14px; }
.next-step { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.conflict-list { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Mein Tag (Seitenleiste) ---------- */
.my-day { padding: 0 2px; }
.md-card { width: 100%; text-align: left; border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.md-card:hover { border-color: var(--border-strong); background: #fff; }
.md-head { display: flex; justify-content: space-between; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); }
.md-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.md-cell { display: flex; flex-direction: column; line-height: 1.2; }
.md-cell strong { font-size: 18px; font-weight: 650; color: var(--text); }
.md-cell span { font-size: 11.5px; color: var(--muted); }

/* ---------- Diagramme ---------- */
.chart { position: relative; }
.chart-scroll { overflow-x: auto; }
.chart-svg { display: block; max-width: none; }
.chart-value { font-size: 11px; fill: #344054; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-grid { stroke: #e9eaec; stroke-width: 1; }
.chart-base { stroke: #c9ccd1; stroke-width: 1; }
.chart-tick { font-size: 11px; fill: #7a808a; font-variant-numeric: tabular-nums; }
.chart-tick.sub { font-size: 10px; fill: #a0a5ad; }
.chart-hit { fill: transparent; cursor: default; outline: none; }
.chart-hit.on, .chart-hit:focus { fill: rgba(16, 24, 40, .045); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.chart-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.sw-1 { background: #2a78d6; } .sw-2 { background: #eb6834; } .sw-3 { background: #1baf7a; }
.chart-tip { position: absolute; top: 4px; transform: translateX(-50%); background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xl); padding: 8px 10px; font-size: 12.5px; min-width: 190px; pointer-events: none; z-index: 2; }
.chart-tip strong { display: block; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.tip-row b { margin-left: auto; padding-left: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.tip-row.total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
.chart-empty { position: absolute; inset: 30% 0 auto; text-align: center; color: var(--muted); font-size: 13px; pointer-events: none; }

/* ---------- Datenpflege ---------- */
.progress-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 16px; margin-bottom: 14px; box-shadow: var(--shadow-xs); }
.progress-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 2px; }
.progress-sub { margin-bottom: 8px; }
.meter { height: 8px; border-radius: 999px; background: #d1e9d9; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--primary); border-radius: 999px; }
.chip.add-chip { border-style: dashed; color: var(--text-2); padding: 3px 9px; font-size: 12.5px; }
.chip.add-chip:hover { border-color: var(--primary); color: var(--primary-hover); background: var(--primary-soft); }

.hint.slim { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 12px; margin: -12px 0 24px; }
.dup-card { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; background: var(--surface); border: 1px solid var(--warn-line); border-radius: var(--radius-lg); padding: 12px 14px; }
.dup-item { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dup-item + .dup-item { border-left: 1px solid var(--border); padding-left: 12px; }
.kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ---------- Tablet & Smartphone ---------- */
@media (max-width: 1100px) {
  .lead-card { flex-direction: column; align-items: stretch; }
  .lc-actions { justify-content: flex-start; max-width: none; }
  .task-card { grid-template-columns: 72px 1fr; }
  .tc-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .workspace { margin-left: 0; }
  .appbar { padding: 0 10px; gap: 8px; }
  .only-mobile { display: inline-flex !important; }
  .appbar .brand-text, .avatar-name, .avatar-btn .ico { display: none; }
  .appbar .brand-logo { height: 30px; }
  .gs { flex: 1 1 auto; }
  main { padding: 16px 14px 96px; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 15; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-item { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; font-size: 11px; font-weight: 500; color: var(--muted); position: relative; cursor: pointer; min-height: 58px; }
  .bottom-item.active { color: var(--primary-hover); }
  .bottom-item.active::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 2px; background: var(--primary); }
  .bottom-item .nav-badge { position: absolute; top: 4px; right: calc(50% - 24px); font-size: 10.5px; line-height: 16px; min-width: 18px; padding: 0 4px; }
  .page-head h1 { font-size: 19px; }
  .grid2, .grid3, .profile-grid, .dup-card { grid-template-columns: 1fr; }
  .dup-item + .dup-item { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 10px; }
  .span2 { grid-column: auto; }
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dt { margin-top: 10px; }
  .drawer { width: 100%; }
  .drawer-head, .drawer-body { padding-left: 14px; padding-right: 14px; }
  .action-bar { grid-template-columns: repeat(2, 1fr); }
  .sheet-overlay { place-items: end center; padding: 0; }
  .sheet, .sheet.wide { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .table.responsive thead { display: none; }
  .table.responsive tr { display: block; border-bottom: 1px solid var(--border); padding: 8px 2px; }
  .table.responsive td { display: grid; grid-template-columns: 104px minmax(0, 1fr); column-gap: 10px; border: 0; padding: 4px 10px; overflow-wrap: anywhere; }
  .table.responsive td > * { grid-column: 2; }
  .table.responsive td::before { content: attr(data-label); grid-column: 1; grid-row: 1 / span 4; color: var(--muted); font-size: 12.5px; }
  .table.responsive td.row-actions { display: flex; }
  .table.responsive td.row-actions::before { content: none; }
  .quick-filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; }
  .quick-filters .chip { flex: none; }
  .nt-panel { width: 100%; }
  #toasts { bottom: 76px; }
}
@media (max-width: 560px) {
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-tile { padding: 10px 12px; }
  .kpi-tile-value { font-size: 22px; }
  .gs-input::placeholder { color: transparent; }
  .section-sub { display: none; }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } * { transition: none !important; } }

.sidebar { overflow-y: auto; }
