/* Vertriebsportal – mobile first. Farben als Tokens, hell + dunkel. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e5ea;
  --accent: #16a34a;
  --accent-ink: #ffffff;
  --primary: #0f172a;
  --primary-ink: #ffffff;
  --blue: #2563eb;  --blue-bg: #dbeafe;
  --gray: #475569;  --gray-bg: #e2e8f0;
  --amber: #b45309; --amber-bg: #fef3c7;
  --green: #15803d; --green-bg: #dcfce7;
  --gold: #a16207;  --gold-bg: #fde68a;
  --red: #b91c1c;   --red-bg: #fee2e2;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #131b2e;
    --surface-2: #1c2640;
    --text: #e8edf5;
    --muted: #94a3b8;
    --border: #25304a;
    --accent: #22c55e;
    --accent-ink: #052e16;
    --primary: #e8edf5;
    --primary-ink: #0b1120;
    --blue: #93c5fd;  --blue-bg: #1e3a5f;
    --gray: #cbd5e1;  --gray-bg: #334155;
    --amber: #fcd34d; --amber-bg: #4a3310;
    --green: #86efac; --green-bg: #14532d;
    --gold: #fde047;  --gold-bg: #54400b;
    --red: #fca5a5;   --red-bg: #5b1a1a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
h1 { font-size: 1.5rem; margin: .25rem 0 .75rem; letter-spacing: -.01em; }
.h2 { font-size: 1.05rem; margin: 1.5rem 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }

/* Kopfzeile */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); display: inline-block; }
.dot.big { width: 44px; height: 44px; }
.adminnav { display: flex; gap: 4px; }
.adminnav a { text-decoration: none; padding: 6px 10px; border-radius: 999px; color: var(--muted); font-size: .92rem; }
.adminnav a.on { background: var(--surface-2); color: var(--text); font-weight: 600; }
.logout { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: .9rem; }
.linkbtn { background: none; border: 0; color: var(--muted); font: inherit; font-size: .9rem; text-decoration: underline; cursor: pointer; padding: 0; }

.wrap { max-width: 640px; margin: 0 auto; padding: 16px; }
.wrap.wide { max-width: 1100px; }

/* Buttons & Formulare */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 12px; min-height: 44px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-weight: 600; font-size: .92rem; }
label > input, label > select, label > textarea { margin-top: 6px; font-weight: 400; }
.stack { display: grid; gap: 14px; }
.field .lbl { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }

/* Hinweise */
.flash, .err, .banner {
  display: block; padding: 12px 14px; border-radius: 12px; margin-bottom: 12px;
  background: var(--blue-bg); color: var(--blue); font-weight: 600; text-decoration: none;
}
.flash.ok { background: var(--green-bg); color: var(--green); }
.err, .banner.red { background: var(--red-bg); color: var(--red); }
.banner.amber { background: var(--amber-bg); color: var(--amber); }

/* Login */
.loginbg { min-height: 100vh; display: grid; place-items: center; }
.loginwrap { width: 100%; max-width: 360px; padding: 24px 16px; text-align: center; }
.loginwrap form { text-align: left; margin-top: 20px; }
.loginwrap h1 { font-size: 1.9rem; margin: 10px 0 4px; }
.sub { color: var(--muted); margin: 0; }

/* Tabs + Suche */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; scrollbar-width: none; }
.tabs a {
  flex: 0 0 auto; text-decoration: none; padding: 8px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: .92rem;
}
.tabs a.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.tabs .n { opacity: .7; font-weight: 500; margin-left: 2px; }
.search { margin-bottom: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* Lead-Karten */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card {
  display: flex; align-items: stretch; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.card-main { flex: 1; min-width: 0; padding: 12px 14px; text-decoration: none; display: grid; gap: 3px; }
.card-title { font-weight: 700; overflow-wrap: anywhere; }
.card-meta { color: var(--muted); font-size: .88rem; }
.callbtn {
  flex: 0 0 72px; display: grid; place-items: center; text-decoration: none;
  background: var(--accent); color: var(--accent-ink);
}
.callbtn.off { background: var(--surface-2); color: var(--muted); font-size: .75rem; text-align: center; line-height: 1.2; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.chip {
  display: inline-block; font-size: .76rem; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--gray-bg); color: var(--gray);
}
.chip.blue { background: var(--blue-bg); color: var(--blue); }
.chip.amber { background: var(--amber-bg); color: var(--amber); }
.chip.green { background: var(--green-bg); color: var(--green); }
.chip.gold { background: var(--gold-bg); color: var(--gold); }
.chip.red { background: var(--red-bg); color: var(--red); }
.chip.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }

/* Lead-Detail */
.back { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 8px; }
.lead-title { margin-bottom: 2px; overflow-wrap: anywhere; }
.lead > .muted { margin: 0 0 8px; }
.bigcall {
  display: flex; align-items: center; gap: 14px; margin: 14px 0 8px; padding: 16px 18px;
  border-radius: var(--radius); background: var(--accent); color: var(--accent-ink);
  text-decoration: none; font-size: 1.35rem; font-weight: 700; letter-spacing: .01em;
}
.bigcall span { display: grid; }
.bigcall small { font-size: .78rem; font-weight: 600; opacity: .85; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.links .btn { font-size: .9rem; min-height: 40px; padding: 8px 12px; font-weight: 500; overflow-wrap: anywhere; }
.missed { margin: 12px 0; }
.guide { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; }
.guide summary { font-weight: 600; cursor: pointer; }
.guide ol { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 6px; }

.qualify fieldset {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  margin: 12px 0; padding: 12px 14px 14px; display: grid; gap: 14px; min-width: 0;
}
.qualify legend { font-weight: 700; padding: 0 6px; }
.seg { display: flex; gap: 6px; }
.seg.wrapseg { flex-wrap: wrap; }
.opt { position: relative; flex: 1 1 auto; font-weight: 600; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt span {
  display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); text-align: center; cursor: pointer;
}
.opt input:checked + span { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.wrapseg .opt { flex: 1 1 40%; }
/* Rückruf-/Betrag-Feld nur zeigen, wenn passender Status gewählt ist. */
.when-rueckruf, .when-verkauft { display: none; }
.qualify:has(input[value="rueckruf"]:checked) .when-rueckruf,
.qualify:has(input[value="verkauft"]:checked) .when-verkauft { display: block; }
.dnc { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; color: var(--red);
  background: var(--red-bg); border-radius: 12px; padding: 12px; }
.dnc input { width: 22px; height: 22px; min-height: 0; margin: 0; flex: 0 0 auto; accent-color: var(--red); }
.savebar {
  position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr 1.6fr; gap: 8px;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); background: var(--bg);
}
.card-plain { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; margin-top: 12px; }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.timeline li { display: grid; gap: 1px; padding-bottom: 8px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }

/* Schlanke Nach-dem-Call-Ansicht (lead-quick) */
.small-title { font-size: 1.3rem; }
.quick > .muted { margin: 0 0 12px; }
.moods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mood { position: relative; font-weight: 600; }
.mood input { position: absolute; opacity: 0; pointer-events: none; }
.mood span {
  display: grid; justify-items: center; gap: 4px; padding: 14px 6px 10px; cursor: pointer;
  border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.mood b { font-size: 2.6rem; line-height: 1; font-weight: 400; }
.mood small { font-size: .82rem; color: var(--muted); }
.mood.red input:checked + span { border-color: var(--red); background: var(--red-bg); }
.mood.amber input:checked + span { border-color: var(--amber); background: var(--amber-bg); }
.mood.green input:checked + span { border-color: var(--green); background: var(--green-bg); }
.mood input:checked + span small { color: var(--text); }
.mood input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.sitelink {
  display: block; margin: 14px 0; padding: 14px 16px; border-radius: var(--radius);
  background: var(--blue-bg); color: var(--blue); font-weight: 700; text-decoration: none; overflow-wrap: anywhere;
}
.sitelink.muted-link { background: var(--surface-2); color: var(--muted); }
.voice { display: grid; gap: 8px; }
.micbtn {
  min-height: 56px; border-radius: var(--radius); border: 0; font: inherit; font-weight: 700; font-size: 1.05rem;
  background: var(--primary); color: var(--primary-ink); cursor: pointer;
}
.micbtn .mic-rec { display: none; }
.micbtn.rec { background: var(--red); color: #fff; animation: recpulse 1.4s ease-in-out infinite; }
.micbtn.rec .mic-idle { display: none; }
.micbtn.rec .mic-rec { display: inline; }
@keyframes recpulse { 50% { opacity: .75; } }
@media (prefers-reduced-motion: reduce) { .micbtn.rec { animation: none; } }
.voice .small { margin: 0; }
.savebar.single { grid-template-columns: 1fr; }
.prevnotes { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 0; }
.quickfoot { text-align: center; color: var(--muted); font-size: .92rem; margin: 20px 0 8px; }
.quickfoot a { color: var(--muted); }

/* Emoji ändern / zurücknehmen */
.moodnow { display: grid; gap: 6px; padding: 10px 12px; border-radius: 12px; margin-bottom: 12px; font-size: .92rem; background: var(--surface-2); }
.moodnow.red { background: var(--red-bg); } .moodnow.amber { background: var(--amber-bg); } .moodnow.green { background: var(--green-bg); }
.moodnow .linkbtn { color: var(--text); font-weight: 600; justify-self: start; }
.undobar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  padding: 10px 12px; border-radius: 12px; margin-bottom: 12px; font-size: .92rem; background: var(--surface-2); overflow-wrap: anywhere; }
.undobar.red { background: var(--red-bg); } .undobar.amber { background: var(--amber-bg); } .undobar.green { background: var(--green-bg); }
.undobar-actions { display: flex; gap: 8px; }
.undobar-actions a, .undobar-actions button {
  font: inherit; font-weight: 700; font-size: .88rem; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none;
}

/* Tracking: Erledigte nach Emoji, je Gruppe auf-/zuklappbar */
.moodgroup { background: var(--surface); border: 1px solid var(--border); border-left-width: 5px; border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.moodgroup.red { border-left-color: var(--red); }
.moodgroup.amber { border-left-color: var(--amber); }
.moodgroup.green { border-left-color: var(--green); }
.moodgroup summary { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; list-style: none; font-weight: 700; }
.moodgroup summary::-webkit-details-marker { display: none; }
.moodgroup summary::after { content: "▾"; margin-left: 4px; color: var(--muted); transition: transform .15s; }
.moodgroup[open] summary::after { transform: rotate(180deg); }
.moodgroup-emoji { font-size: 1.8rem; line-height: 1; }
.moodgroup-label { flex: 1; }
.moodgroup-n { background: var(--surface-2); border-radius: 999px; padding: 2px 10px; font-size: .88rem; }
.moodgroup-empty { padding: 0 14px 12px; margin: 0; }
.moodlist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.moodlist li + li { border-top: 1px solid var(--border); }
.moodlist a { display: grid; gap: 2px; padding: 10px 14px; text-decoration: none; }
.moodlist-note { font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }

/* Admin */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 16px 16px; margin-top: 16px; }
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
tr.inactive, li.inactive { opacity: .55; }
tr.pool td { background: var(--surface-2); }
tr.dnc td { background: var(--red-bg); }
td a { font-weight: 600; }
.grid-form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.grid-form .full { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.check input { width: 18px; height: 18px; min-height: 0; margin: 0; }
.filters { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 12px; }
.bulkbar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 10px; }
.bulkbar select { width: auto; }
.splitusers { display: none; gap: 10px; flex-wrap: wrap; }
.bulkbar:has(option[value="split"]:checked) .splitusers { display: inline-flex; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pager a { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); text-decoration: none; }
.pager a.on { background: var(--primary); color: var(--primary-ink); }
.userlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.userlist li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.useractions { display: flex; flex-wrap: wrap; gap: 8px; }
.inline { display: flex; gap: 6px; }
.inline input { width: 170px; }

@media (max-width: 520px) {
  .adminnav { order: 3; width: 100%; }
  .who { display: none; }
}
