:root {
  --bg: #f6f7f9; --card: #fff; --text: #1d2330; --muted: #6b7385; --line: #e3e6ec;
  --primary: #3b5bdb; --primary-soft: #e8edff; --ok: #2b8a3e; --ok-soft: #e6f6ea;
  --warn: #c47f00; --warn-soft: #fff4dc; --bad: #c92a2a; --bad-soft: #ffe8e8;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
pre { white-space: pre-wrap; font: inherit; margin: 0; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px; background: #1d2330; color: #fff; position: sticky; top: 0; z-index: 10; }
.brand { color: #fff; font-weight: 700; font-size: 16px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: #c8cfdd; padding: 6px 12px; border-radius: 6px; }
.topbar nav a.active, .topbar nav a:hover { background: #2d3546; color: #fff; text-decoration: none; }
.topbar-right { margin-left: auto; position: relative; }
.icon-btn { background: none; border: 0; color: #fff; font-size: 18px; cursor: pointer; position: relative; }
.badge { position: absolute; top: -4px; right: -8px; background: var(--bad); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 5px; }
.notif-panel { position: absolute; right: 0; top: 40px; width: 360px; max-height: 480px; overflow: auto; background: #fff; color: var(--text); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.18); padding: 8px; }
.notif-item { padding: 8px; border-bottom: 1px solid var(--line); cursor: pointer; }
.notif-item.unread { background: var(--primary-soft); }
.notif-item:last-child { border: 0; }

main { max-width: 1280px; margin: 0 auto; padding: 24px; }
#banner .banner { background: var(--warn-soft); color: #7a4f00; padding: 10px 24px; text-align: center; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-lead { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-lead { grid-template-columns: 1fr; } .topbar nav a { padding: 6px 6px; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font-size: 24px; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: 12px; }

button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: #c4cad6; text-decoration: none; }
button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
button.sm, .btn.sm { padding: 4px 10px; font-size: 12px; }

label { display: block; font-weight: 600; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
input, textarea, select { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); }
textarea { min-height: 80px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fafbff; }

.score { display: inline-block; min-width: 38px; text-align: center; padding: 2px 8px; border-radius: 20px; font-weight: 700; font-size: 12px; }
.score.hi { background: var(--ok-soft); color: var(--ok); }
.score.mid { background: var(--warn-soft); color: var(--warn); }
.score.lo { background: var(--bad-soft); color: var(--bad); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; background: #eef0f4; color: #444; white-space: nowrap; }
.pill.s-neu { background: #eef0f4; } .pill.s-qualifiziert { background: var(--primary-soft); color: var(--primary); }
.pill.s-kontaktiert { background: #e7f5ff; color: #1971c2; } .pill.s-follow_up { background: var(--warn-soft); color: var(--warn); }
.pill.s-geantwortet { background: #f3e8ff; color: #7b2cbf; } .pill.s-termin, .pill.s-angebot { background: #e6fcf5; color: #087f5b; }
.pill.s-gewonnen { background: var(--ok-soft); color: var(--ok); } .pill.s-verloren, .pill.s-abgelehnt { background: var(--bad-soft); color: var(--bad); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select { width: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { padding: 4px 10px; border-radius: 20px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 12px; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.log { background: #12161f; color: #cfd6e4; font: 12px/1.5 ui-monospace, Menlo, monospace; padding: 12px; border-radius: 8px; max-height: 320px; overflow: auto; white-space: pre-wrap; }
.progress { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--primary); transition: width .4s; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline .t { font-size: 12px; color: var(--muted); }
.timeline .type { font-weight: 600; }
.timeline pre { margin-top: 6px; background: #f8f9fb; padding: 8px; border-radius: 6px; max-height: 260px; overflow: auto; }

.empty { text-align: center; padding: 40px; color: var(--muted); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1d2330; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.err { background: var(--bad); }
.legal { background: var(--warn-soft); border: 1px solid #f1d48a; color: #6a4800; border-radius: 8px; padding: 10px 12px; font-size: 12px; margin-top: 8px; }

.funnel { display: flex; flex-direction: column; gap: 6px; }
.funnel .row { display: grid; grid-template-columns: 110px 1fr 40px; gap: 8px; align-items: center; font-size: 12px; }
.funnel .bar { height: 14px; background: var(--primary); border-radius: 4px; min-width: 2px; }

.login { max-width: 360px; margin: 80px auto; }
.actions select { width: auto; min-width: 170px; }
