:root {
  --bg:        #f5f5f7;
  --card:      #ffffff;
  --ink:       #1d1d1f;
  --muted:     #6e6e73;
  --line:      #e3e3e6;
  --accent:    #0071e3;
  --accent-d:  #0066cc;
  --green:     #34c759;
  --red:       #ff3b30;
  --amber:     #ff9f0a;
  --radius:    16px;
  --shadow:    0 1px 3px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* --- Topbar --------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.8);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 10px 20px;
  min-height: 64px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { font-weight: 600; font-size: 17px; color: var(--ink); letter-spacing: -.01em; flex-shrink: 0; }
.nav {
  display: flex; gap: 6px; flex: 1; align-items: center;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 11px 18px; border-radius: 980px;
  color: var(--muted); font-size: 14px; font-weight: 500; white-space: nowrap;
  background: transparent; transition: background .15s ease, color .15s ease;
}
.nav a.active { background: var(--ink); color: #fff; }
.nav a:hover:not(.active) { background: rgba(0,0,0,.06); color: var(--ink); }
.topbar .logout {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 11px 16px; border-radius: 980px;
  color: var(--muted); font-size: 13px; white-space: nowrap; flex-shrink: 0;
  transition: background .15s ease, color .15s ease;
}
.topbar .logout:hover { background: rgba(0,0,0,.06); color: var(--ink); }

/* --- Layout ----------------------------------------------------------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 40px 24px 96px; }
.wrap-narrow { max-width: 560px; margin: 0 auto; padding: 64px 24px; }
.head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 28px; gap: 16px; flex-wrap: wrap;
}
h1 { font-size: 30px; font-weight: 600; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 16px; }
.sub { color: var(--muted); font-size: 15px; margin: 4px 0 0; }

/* --- Cards & Grid ------------------------------------------------------ */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

.pipeline-card { display: block; }
.pipeline-card .num { font-size: 34px; font-weight: 600; letter-spacing: -.03em; }
.pipeline-card .lbl { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* --- Lists / Tables ----------------------------------------------------- */
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
.row-link { display: block; color: inherit; }
.row-link:hover { color: inherit; }

/* --- Buttons -------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff; border: none;
  border-radius: 10px; padding: 9px 16px; font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn:hover { background: var(--accent-d); color: #fff; }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: #f5f5f7; color: var(--ink); }
.btn-danger { background: #fff; color: var(--red); border: 1px solid var(--line); }
.btn-danger:hover { background: #fff0ef; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* --- Forms ------------------------------------------------------------ */
label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin: 0 0 6px; }
input[type=text], input[type=email], input[type=tel], input[type=password],
input[type=file], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--ink);
}
textarea { resize: vertical; min-height: 90px; }
.field { margin-bottom: 18px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

/* --- Choice-Buttons (touch-freundlicher Ersatz für <select>) ------------ */
.choice-group { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.choice-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 18px; border-radius: 980px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 14px; font-weight: 500; cursor: pointer; text-align: center;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.choice-input:checked + .choice-btn { background: var(--ink); color: #fff; border-color: var(--ink); }
.choice-input:focus-visible + .choice-btn { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice-btn:hover { background: #f5f5f7; }
.choice-input:checked + .choice-btn:hover { background: var(--ink); }
.choice-btn.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.choice-btn.is-active:hover { background: var(--ink); }
.choice-group form { margin: 0; }

/* --- Telefon-QR ---------------------------------------------------------- */
.qr-thumb {
  display: block; width: 60px; height: 60px; margin-top: 6px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 3px;
}
.kanban-card .qr-thumb { width: 44px; height: 44px; margin-top: 0; flex-shrink: 0; }
.kanban-tel {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: 8px; font-size: 13px;
}

/* --- Flash / Badges ----------------------------------------------------- */
.flash {
  background: #fff8e6; border: 1px solid #ffe1a8; color: #7a5900;
  border-radius: 10px; padding: 12px 16px; margin-bottom: 20px; font-size: 14px;
}
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500; background: #eef2ff; color: var(--accent-d);
}
.badge-green { background: #e6f9ec; color: #1f8a3d; }
.badge-red { background: #fdeeed; color: #c0392b; }
.badge-amber { background: #fff4e5; color: #b26b00; }
.badge-muted { background: #f0f0f2; color: var(--muted); }

/* --- Tabs (Liste/Kanban) ------------------------------------------------ */
.tabs { display: flex; gap: 6px; background: #eee; border-radius: 10px; padding: 3px; width: fit-content; }
.tabs a {
  padding: 7px 16px; border-radius: 8px; font-size: 14px; font-weight: 500;
  color: var(--muted);
}
.tabs a.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* --- Filter-Leiste ------------------------------------------------------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0 24px; }

/* --- Mehrfachauswahl-Leiste (z.B. Prospects zuweisen) -------------------- */
.bulk-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 16px; margin-bottom: 16px;
}

/* --- Schnelltasten (z.B. Prospect Wiedervorlage) ------------------------- */
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: -16px 0 32px; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; max-width: 260px; }
.filters select { width: auto; min-width: 150px; padding: 8px 12px; font-size: 13px; }

/* --- Kanban -------------------------------------------------------------- */
.kanban { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 16px; }
.kanban-col {
  background: #ececef; border-radius: var(--radius); padding: 10px;
  flex: 1 1 0; min-width: 160px; max-width: 320px;
}
.kanban-col h3 {
  font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; margin: 4px 8px 10px; display: flex; justify-content: space-between;
  align-items: flex-start; gap: 8px;
}
.kanban-col h3 span:first-child { flex: 1; min-width: 0; white-space: normal; word-break: break-word; }
.kanban-col h3 span:last-child { flex-shrink: 0; }
.hook-badge { margin-left: 4px; cursor: help; }
.kanban-cards { min-height: 40px; display: flex; flex-direction: column; gap: 8px; }
.kanban-card {
  background: #fff; border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow);
  cursor: grab; font-size: 14px;
}
.kanban-card:active { cursor: grabbing; }
.kanban-card .firma { font-weight: 600; }
.kanban-card .name { color: var(--muted); font-size: 13px; }
.kanban-card .meta { color: var(--muted); font-size: 12px; margin-top: 6px; }
.sortable-ghost { opacity: .4; }

/* --- Lead-Detail --------------------------------------------------------- */
.activity { border-left: 2px solid var(--line); padding-left: 16px; margin-bottom: 18px; }
.activity .typ { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.activity .zeit { font-size: 12px; color: var(--muted); }
.activity .inhalt { margin-top: 4px; font-size: 14px; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
