:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ─────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 800; font-size: 18px; letter-spacing: -.3px; white-space: nowrap; }
.brand span { color: var(--primary); }
.toolbar { display: flex; gap: 10px; align-items: center; flex: 1; }
.toolbar input[type=search], .toolbar select {
  height: 38px; padding: 0 12px; border: 1px solid var(--line-strong);
  border-radius: 9px; background: #fff; font-size: 14px; color: var(--text);
}
.toolbar input[type=search] { width: 280px; max-width: 36vw; }
.topnav { display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.user-chip {
  background: #eef2ff; color: #4338ca; padding: 5px 12px;
  border-radius: 999px; font-weight: 600; font-size: 13px;
}

/* ── Buttons ────────────────────────────────────────── */
.btn {
  border: 1px solid var(--line-strong); background: #fff; color: var(--text);
  padding: 8px 16px; border-radius: 9px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: .12s; line-height: 1;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fff; border-color: #fca5a5; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; padding: 11px; }

/* ── Board ──────────────────────────────────────────── */
.board {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 18px 20px 40px; overflow-x: auto; min-height: calc(100vh - 64px);
}
.column {
  flex: 0 0 290px; width: 290px; background: #eef1f6;
  border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; max-height: calc(100vh - 100px);
}
.col-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0;
}
.col-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dot); flex: 0 0 auto; }
.col-title { font-weight: 700; font-size: 13px; flex: 1; line-height: 1.25; }
.col-count {
  background: #fff; border: 1px solid var(--line-strong); color: var(--muted);
  font-weight: 700; font-size: 12px; min-width: 24px; text-align: center;
  padding: 2px 7px; border-radius: 999px;
}
.col-cards {
  padding: 10px; display: flex; flex-direction: column; gap: 9px;
  overflow-y: auto; flex: 1; min-height: 40px;
}

/* ── Cards ──────────────────────────────────────────── */
.card {
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--dot, #94a3b8);
  border-radius: 10px; padding: 11px 12px; cursor: pointer;
  box-shadow: var(--shadow); transition: .12s;
}
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.card.dragging { opacity: .45; }
.card-name { font-weight: 700; font-size: 13.5px; margin-bottom: 4px; }
.card-meta { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.card-meta .mdot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot); }
.card-contact { color: var(--muted); font-size: 11.5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sortable-ghost { opacity: .35; }
.col-cards.drop-active { background: rgba(37,99,235,.06); border-radius: 8px; }

/* ── Modal ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 100; overflow-y: auto;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 820px; padding: 24px 26px; position: relative;
}
.modal-sm { max-width: 440px; }
.modal h2 { margin: 0 36px 18px 0; font-size: 20px; }
.modal-close {
  position: absolute; top: 14px; right: 16px; border: none; background: none;
  font-size: 28px; line-height: 1; color: var(--muted); cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal-grid { display: grid; grid-template-columns: 1fr 300px; gap: 24px; }
@media (max-width: 720px) { .modal-grid { grid-template-columns: 1fr; } }

label { display: block; font-weight: 600; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
label input, label select, label textarea {
  display: block; width: 100%; margin-top: 5px;
  padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 9px;
  font-size: 14px; font-family: inherit; color: var(--text); background: #fff;
}
label textarea { resize: vertical; }
.field-row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.save-hint { font-size: 13px; color: #16a34a; font-weight: 600; }

/* ── Lead-Detail-Modal (Redesign) ───────────────────── */
.lead-modal { max-width: 980px; padding: 0; overflow: hidden; }
.lead-overlay { padding: 30px 16px; }

.lead-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.lead-head-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; min-width: 0; }
.lead-head h2 { margin: 0; font-size: 21px; letter-spacing: -.3px; }
.lead-head-right { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

/* Status-Pill-Button */
.status-picker { position: relative; }
.status-pill-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: #f1f5f9; border: 1px solid var(--line-strong);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600;
  color: var(--text); cursor: pointer; transition: .12s;
}
.status-pill-btn:hover { background: #e9eef5; }
.status-pill-btn .sp-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot, #94a3b8); flex: 0 0 auto; }
.status-pill-btn .sp-caret { color: var(--muted); flex: 0 0 auto; }
.status-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; width: 300px; max-height: 360px; overflow-y: auto;
}
.status-menu[hidden] { display: none; }
.status-opt {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: none; border: none; text-align: left; cursor: pointer;
  padding: 8px 10px; border-radius: 8px; font-size: 13px; color: var(--text);
}
.status-opt:hover { background: #f1f5f9; }
.status-opt .so-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot); flex: 0 0 auto; }

/* Icon-Buttons + 3-Punkte-Menü */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: none; background: none; border-radius: 9px;
  color: var(--muted); cursor: pointer; transition: .12s;
}
.icon-btn:hover { background: #f1f5f9; color: var(--text); }
.menu-wrap { position: relative; }
.dots-menu {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 30;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: 5px; min-width: 150px;
}
.dots-menu[hidden] { display: none; }
.dots-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 8px 10px; border-radius: 7px; font-size: 13px; color: var(--text); cursor: pointer;
}
.dots-item:hover { background: #f1f5f9; }
.lead-modal .modal-close { position: static; }

/* Body-Grid */
.lead-grid { display: grid; grid-template-columns: 40% 60%; align-items: start; }
.lead-col-left { padding: 18px 22px; border-right: 1px solid var(--line); min-height: 420px; max-height: 74vh; overflow-y: auto; }
.lead-col-right { padding: 18px 22px; display: flex; flex-direction: column; gap: 16px; max-height: 74vh; overflow-y: auto; }
@media (max-width: 780px) {
  .lead-grid { grid-template-columns: 1fr; }
  .lead-col-left { border-right: none; border-bottom: 1px solid var(--line); max-height: none; }
  .lead-col-right { max-height: none; }
}

/* Tabs */
.lead-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.lead-tab {
  background: none; border: none; padding: 8px 12px; font-size: 13.5px; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.lead-tab:hover { color: var(--text); }
.lead-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.empty-pane { color: var(--muted); font-size: 13px; padding: 24px 4px; text-align: center; }

/* Profil */
.profile-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.profile-head h3 { margin: 0; font-size: 15px; }
.profile-list { display: flex; flex-direction: column; gap: 0; }
.funnel-item { font-size: 13px; border-bottom: 1px solid var(--line); padding: 9px 0; }
.funnel-item:last-child { border-bottom: none; }
.funnel-item .k { color: var(--muted); display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .3px; margin-bottom: 2px; }
.funnel-item .v { color: var(--text); word-break: break-word; font-weight: 500; }
.profile-edit { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }

/* Kontaktdaten-Box */
.lead-box { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.box-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.contact-box { display: flex; gap: 10px; flex-wrap: wrap; }
.contact-pill {
  display: inline-flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; font-size: 13px; color: var(--text); text-decoration: none; font-weight: 500;
}
.contact-pill:hover { background: #f1f5f9; text-decoration: none; }
.contact-pill svg { color: var(--primary); flex: 0 0 auto; }
.contact-pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Beschreibung */
.desc-area {
  display: block; width: 100%; min-height: 120px; resize: vertical;
  padding: 11px 13px; border: 1px solid var(--line-strong); border-radius: 10px;
  font-size: 14px; font-family: inherit; line-height: 1.5; color: var(--text);
  background: #fafbfc; transition: .12s;
}
.desc-area:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.lead-box .save-hint { display: block; margin-top: 7px; color: var(--muted); }

/* Neue Notiz */
.note-row { display: flex; gap: 8px; }
.note-input {
  flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--line-strong);
  border-radius: 9px; font-size: 14px; font-family: inherit; color: var(--text);
}
.note-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.note-row .btn { white-space: nowrap; flex: 0 0 auto; }

/* Verlauf */
.history-list { display: flex; flex-direction: column; gap: 2px; }
.history-item {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13px; padding: 9px 0; border-bottom: 1px solid var(--line);
}
.history-item:last-child { border-bottom: none; }
.hist-bullet { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); margin-top: 5px; flex: 0 0 auto; }
.hist-body { flex: 1; min-width: 0; }
.history-item .hmsg { color: var(--text); word-break: break-word; }
.hist-side { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.hist-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.hist-del {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: none; color: var(--muted); cursor: pointer;
  padding: 3px; border-radius: 6px; opacity: 0; transition: .12s;
}
.history-item:hover .hist-del { opacity: 1; }
.hist-del:hover { color: var(--danger); background: #fef2f2; }
.history-empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

/* Speichern-Dialog */
.confirm-overlay { align-items: center; z-index: 200; }
.confirm-box {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 380px; padding: 22px 24px;
}
.confirm-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.confirm-text { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ── Auth ───────────────────────────────────────────── */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg,#eef2ff,#f1f5f9); }
.auth-card {
  background: #fff; padding: 36px 34px; border-radius: 18px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 380px;
}
.auth-logo { font-weight: 800; font-size: 26px; letter-spacing: -.5px; }
.auth-logo span { color: var(--primary); }
.auth-sub { color: var(--muted); margin: 4px 0 22px; }
.auth-card label { margin-bottom: 16px; }
.auth-card label.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.auth-card label.checkbox input { width: auto; margin: 0; }
.auth-foot { text-align: center; margin-top: 18px; color: var(--muted); font-size: 13px; }

.alert { padding: 11px 14px; border-radius: 10px; font-size: 13.5px; margin-bottom: 16px; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

/* ── Admin ──────────────────────────────────────────── */
.admin-wrap { max-width: 1000px; margin: 30px auto; padding: 0 20px; }
.admin-wrap h1 { font-size: 22px; }
.admin-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.admin-table th, .admin-table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.admin-table th { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.admin-table .actions { display: flex; gap: 6px; }
.badge { background: #f1f5f9; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.status-pill { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-pill.ok { background: #f0fdf4; color: #15803d; }
.status-pill.pending { background: #fffbeb; color: #b45309; }

.loading { padding: 30px; text-align: center; color: var(--muted); }

/* ── Pending-Users Banner (Admin) ───────────────────────────────────── */
.pending-banner {
  margin: 14px 18px 0;
  padding: 14px 16px;
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-left: 5px solid #f59e0b;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.pending-head {
  font-weight: 700;
  color: #b45309;
  font-size: 15px;
  margin-bottom: 8px;
}
.pending-list { display: flex; flex-direction: column; gap: 6px; }
.pending-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 14px; color: var(--text);
}
.pending-name { font-weight: 600; }
.pending-mail { color: var(--muted); }
.pending-row .pending-approve {
  margin-left: auto;
  background: #f59e0b; color: #fff; border: none;
}
.pending-row .pending-approve:hover { background: #d97706; }
.pending-row .pending-approve:disabled { opacity: .6; cursor: default; }
.pending-ok { color: #15803d; font-weight: 700; }
