:root {
  --bg: #f4f5f7;
  --card: #fff;
  --text: #1d2430;
  --muted: #6b7482;
  --line: #e3e6ea;
  --accent: #1f5fbf;
  --accent-d: #174a96;
  --danger: #c0392b;
  --ok: #1e8449;
  --warn: #b9770e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 0 0 .9rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.due { color: var(--danger); font-weight: 600; }
.warn-text { color: var(--warn); }

/* Kopfzeile */
header.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1.5rem;
  background: #14213d; color: #fff; padding: 0 1.25rem; min-height: 56px;
}
header.top .brand { color: #fff; font-weight: 700; font-size: 1.1rem; letter-spacing: .01em; }
header.top nav { display: flex; align-items: center; gap: .25rem; flex: 1; }
header.top nav a { color: #c9d3e6; padding: .45rem .75rem; border-radius: 7px; }
header.top nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
header.top nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.nav-user { margin-left: auto; display: flex; gap: .25rem; }
.nav-user .muted { color: #8d99b3; }
.burger { display: none; background: none; border: 0; color: #fff; font-size: 1.5rem; margin-left: auto; cursor: pointer; }

main { max-width: 1400px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* Karten & Layout */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; }
.card.narrow { max-width: 420px; width: 100%; }
.narrow-left { max-width: 640px; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.pagehead .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.subline { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-top: .4rem; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.cols > .card { margin-bottom: 0; }
.cols + .card, .cols + .cols { margin-top: 1.25rem; }
.contact-cols { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.span-all { grid-column: 1 / -1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
.span2 { grid-column: span 2; }
.plzrow { display: grid; grid-template-columns: 1.2fr .8fr 2fr; gap: 0 1rem; }
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.center-page h1 { margin-bottom: 1rem; }

/* Formulare */
label { display: block; font-size: .85rem; font-weight: 600; color: #3a4350; margin-bottom: .85rem; }
label.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
input, select, textarea {
  display: block; width: 100%; margin-top: .3rem;
  font: inherit; font-weight: 400; color: var(--text);
  padding: .55rem .7rem; border: 1px solid #cfd4db; border-radius: 8px; background: #fff;
}
input[type=checkbox], input[type=radio] { width: auto; display: inline; margin: 0; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31,95,191,.25); border-color: var(--accent); }
textarea { resize: vertical; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; }
.btn {
  display: inline-flex; align-items: center; gap: .35rem; justify-content: center;
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  padding: .55rem 1rem; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--accent-d); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-light { background: #fff; color: var(--text); border-color: #cfd4db; }
.btn-light:hover { background: #f0f2f5; }
.btn-danger { background: #fff; color: var(--danger); border-color: #e6b0aa; }
.btn-danger:hover { background: #fdf0ee; }
.linkbtn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1.1rem; padding: 0 .25rem; }
.linkbtn:hover { color: var(--danger); }
form.inline { display: inline; margin-left: auto; }
form.busy { opacity: .6; pointer-events: none; }

/* Filter & Toolbar */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .9rem; }
.filters input, .filters select { width: auto; margin: 0; flex: 0 1 auto; }
.filters input[type=search] { flex: 1 1 260px; }
.filters .w-plz { width: 140px; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0 0 .6rem; }
.toolbar select { width: auto; margin: 0; padding: .45rem .6rem; }
.toolbar .btn { padding: .45rem .8rem; }
.quick { display: flex; flex-wrap: wrap; gap: .5rem; margin: -.4rem 0 1.25rem; }

/* Tabellen */
.table-wrap { overflow-x: auto; padding: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .6rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfc; }
.table th a { color: inherit; }
.table tbody tr:hover { background: #f8fafc; }
.table tr:last-child td { border-bottom: 0; }
.table .cb { width: 36px; }
.table .empty { text-align: center; padding: 2.5rem; color: var(--muted); }
.table.small td { padding: .3rem .5rem; }
tr.inactive td { opacity: .55; }
.table.map select.mapped { border-color: var(--ok); background: #f1faf4; }
.pager { display: flex; gap: 1.25rem; justify-content: center; align-items: center; margin-top: 1rem; }

/* Badges */
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #eef0f3; color: #4a5462; white-space: nowrap; }
.st-neu { background: #e8eefb; color: #1f4f9e; }
.st-kontaktiert { background: #eef1f4; color: #47515e; }
.st-interessiert { background: #fff4dc; color: #8a5a00; }
.st-angebot { background: #f3e9fb; color: #6b2f99; }
.st-gewonnen { background: #e3f5e9; color: #1b6b3a; }
.st-verloren { background: #fbe9e7; color: #9b2c1f; }
.type-anruf { background: #e8f3fb; color: #1d5f8a; }
.type-besuch { background: #e3f5e9; color: #1b6b3a; }
.type-termin { background: #fff4dc; color: #8a5a00; }
.type-angebot { background: #f3e9fb; color: #6b2f99; }

/* Meldungen */
.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash-ok { background: #edf8f1; border-color: #b7e1c6; color: #155d31; }
.flash-error { background: #fdf0ee; border-color: #f0c2bb; color: #8e2a1d; }
.flash-warn { background: #fff8e6; border-color: #f1d79c; color: #7a5200; }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; color: var(--text); display: flex; flex-direction: column; }
.card .stat { box-shadow: none; border: 1px solid var(--line); }
a.stat:hover { text-decoration: none; outline: 2px solid rgba(31,95,191,.2); }
.stat-n { font-size: 1.9rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span:last-child { color: var(--muted); font-size: .88rem; }
.pipeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; }
.pipe { display: flex; flex-direction: column; padding: .8rem .9rem; border-radius: 9px; color: inherit; }
.pipe:hover { text-decoration: none; filter: brightness(.97); }
.pipe-n { font-size: 1.5rem; font-weight: 700; }
.pipe-l { font-size: .85rem; font-weight: 600; }
.pipe-bar { height: 4px; background: rgba(0,0,0,.08); border-radius: 2px; margin-top: .5rem; overflow: hidden; }
.pipe-bar span { display: block; height: 100%; background: currentColor; opacity: .55; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border: 0; }
.dl { display: grid; grid-template-columns: 120px 1fr; gap: .5rem 1rem; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

/* Verlauf */
.activity-form { border-bottom: 1px solid var(--line); padding-bottom: 1rem; margin-bottom: 1rem; }
.activity-form textarea { margin: .6rem 0 .8rem; }
.seg { display: flex; flex-wrap: wrap; gap: .35rem; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: inline-block; padding: .35rem .75rem; border: 1px solid #cfd4db; border-radius: 999px; font-weight: 500; cursor: pointer; }
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid rgba(31,95,191,.35); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .75rem 0 .75rem 1rem; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 1.05rem; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid #b6bec9; }
.tl-head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.tl-text { margin-top: .3rem; white-space: normal; word-break: break-word; }

/* Import */
.drop { display: block; border: 2px dashed #c3cad4; border-radius: 10px; padding: 2rem 1rem; text-align: center; position: relative; cursor: pointer; margin: 1rem 0; font-weight: 500; color: var(--muted); }
.drop:hover { border-color: var(--accent); color: var(--accent); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
details.help { margin-top: .5rem; font-size: .88rem; }
details.help summary { cursor: pointer; color: var(--accent); }
.dupe .table { margin: .4rem 0 .8rem; }

/* Tablet & Handy */
@media (max-width: 1000px) {
  .cols, .contact-cols { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 960px) {
  header.top { flex-wrap: wrap; padding: .5rem 1rem; }
  .burger { display: block; }
  header.top nav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; padding-bottom: .5rem; }
  body.nav-open header.top nav { display: flex; }
  .nav-user { margin: .5rem 0 0; border-top: 1px solid rgba(255,255,255,.12); padding-top: .5rem; }
  .table.contacts th:nth-child(3), .table.contacts td:nth-child(3),
  .table.contacts th:nth-child(6), .table.contacts td:nth-child(6) { display: none; }
}
@media (max-width: 760px) {
  main { padding: 1rem .75rem 3rem; }
  .grid2, .grid3, .plzrow { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .filters > * { flex: 1 1 45%; }
  .table.contacts th:nth-child(9), .table.contacts td:nth-child(9) { display: none; }
}
.table .num { text-align: right; }
header.top nav a { white-space: nowrap; }
