/* Kainos Lead Scan – mobil zuerst, Kainos-Farben */
:root {
  --navy: #1b284f;
  --navy-2: #283583;
  --lime: #cfd600;
  --lime-dark: #a9ae00;
  --cyan: #009fda;
  --green: #61a83f;
  --orange: #ec6608;
  --ink: #404040;
  --ink-2: #6b7080;
  --line: #e1e4ea;
  --bg: #f4f5f7;
  --card: #ffffff;
  --danger: #c62828;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(27 40 79 / 6%), 0 4px 14px rgb(27 40 79 / 6%);
  --font: 'Century Gothic', 'Avenir Next', Avenir, 'Segoe UI', system-ui, -apple-system, sans-serif;
  --top: calc(56px + env(safe-area-inset-top));
  --tab: calc(64px + env(safe-area-inset-bottom));
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--navy-2); }
h1, h2, h3 { color: var(--navy); line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
[hidden] { display: none !important; }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .5rem;
  height: var(--top);
  padding: env(safe-area-inset-top) 12px 0 16px;
  background: var(--navy); color: #fff;
}
.brand-mark { position: absolute; left: 0; top: 0; width: 96px; height: 6px; background: var(--lime); }
.brand { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .02em; font-size: 1.05rem; white-space: nowrap; }
.brand b { color: var(--lime); font-weight: 700; }
.topnav { margin-left: auto; display: flex; gap: 2px; }
.topnav a, .icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 42px; height: 42px; border-radius: 10px; color: #fff; background: none; border: 0; cursor: pointer;
}
.topnav a:active, .icon-btn:active { background: rgb(255 255 255 / 12%); }
.topnav .dot {
  position: absolute; top: 5px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--lime); color: var(--navy); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.sync-pill {
  font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap;
  background: rgb(255 255 255 / 14%); color: #fff; border: 0; font-family: inherit;
}
.sync-pill.pending { background: var(--orange); }
.sync-pill.offline { background: #6b7080; }
.sync-pill.error { background: var(--danger); }

/* ---------- Inhalt ---------- */
.view { max-width: 680px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); outline: none; }
body.has-tabs .view { padding-bottom: calc(var(--tab) + 24px); }
.loading, .empty { text-align: center; color: var(--ink-2); padding: 2.5rem 1rem; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.section { margin-top: 24px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 24px 0 8px; }
.section-title h2 { margin: 0; }

.page-head { margin-bottom: 16px; }
.page-head .eyebrow { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); margin-bottom: 2px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); text-decoration: none; font-size: .9rem; margin-bottom: 8px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.notice { border-radius: 12px; padding: 12px 14px; background: #eef7fc; color: #0b5d80; font-size: .92rem; }
.notice.warn { background: #fff4ea; color: #8a3b00; }
.notice.error { background: #fdecec; color: var(--danger); }
.notice.ok { background: #eef7e9; color: #2f6619; }

/* ---------- Listen ---------- */
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  color: inherit; text-decoration: none; border-bottom: 1px solid var(--line); min-height: 60px;
}
.list-item:last-child { border-bottom: 0; }
.list-item:active { background: #f7f8fa; }
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-weight: 700; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .sub { font-size: .87rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .meta { font-size: .78rem; color: var(--ink-2); text-align: right; white-space: nowrap; }
.chev { color: #b5bac6; }

.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: .9rem;
  background: #e9ecf3; color: var(--navy);
}
.avatar.pending { background: #fff1e6; color: var(--orange); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px;
  font-size: .75rem; font-weight: 700; background: #e9ecf3; color: var(--navy); white-space: nowrap;
}
.badge.hot { background: #fde7d9; color: #b34d05; }
.badge.warm { background: #f5f7c9; color: #6d7000; }
.badge.cold { background: #dff2fb; color: #00739f; }
.badge.active { background: #eef7e9; color: #2f6619; }
.badge.planned { background: #e9ecf3; color: var(--navy); }
.badge.closed { background: #eceff1; color: #6b7080; }
.badge.manager, .badge.admin { background: var(--navy); color: #fff; }
.badge.pending { background: #fff1e6; color: #b34d05; }
.badge.error { background: #fdecec; color: var(--danger); }
.rating-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: transparent; }
.rating-dot.hot { background: var(--orange); }
.rating-dot.warm { background: var(--lime-dark); }
.rating-dot.cold { background: var(--cyan); }

/* ---------- Event-Karten ---------- */
.event-card { display: block; color: inherit; text-decoration: none; position: relative; overflow: hidden; }
.event-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--line); }
.event-card.active::before { background: var(--lime); }
.event-card h2 { margin: 0 0 4px; font-size: 1.1rem; }
.event-card .stats { display: flex; gap: 16px; margin-top: 10px; font-size: .85rem; color: var(--ink-2); }
.event-card .stats b { color: var(--navy); font-size: 1.05rem; }

/* ---------- Erfassen ---------- */
.capture-grid { display: grid; gap: 12px; }
.capture-btn {
  position: relative; display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 18px; border-radius: var(--radius); border: 0; cursor: pointer;
  font: inherit; text-align: left; background: var(--card); color: var(--navy); box-shadow: var(--shadow);
}
.capture-btn .ic { flex: none; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: #eef0f5; }
.capture-btn .ic svg { width: 28px; height: 28px; }
.capture-btn strong { display: block; font-size: 1.08rem; }
.capture-btn span.d { font-size: .85rem; color: var(--ink-2); }
.capture-btn.primary { background: var(--navy); color: #fff; padding: 22px 18px; }
.capture-btn.primary .ic { background: var(--lime); color: var(--navy); }
.capture-btn.primary span.d { color: #c9cfe0; }
.capture-btn:active { transform: scale(.99); }
.capture-btn input[type=file] { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }

/* ---------- Formulare ---------- */
label.field { display: block; }
label.field > span { display: block; font-size: .82rem; font-weight: 700; color: var(--ink-2); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  padding: 11px 12px; border-radius: 10px; border: 1px solid #cfd4de; background: #fff;
  -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, #6b7080 50%), linear-gradient(135deg, #6b7080 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--cyan); outline-offset: 0; border-color: var(--cyan); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid { display: grid; gap: 12px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: .95rem; cursor: pointer; }
.check input { width: 22px; height: 22px; flex: none; margin: 1px 0 0; accent-color: var(--navy); -webkit-appearance: auto; appearance: auto; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 8px 14px; border-radius: 99px; border: 1px solid #cfd4de; background: #fff; font: inherit; font-size: .92rem;
  color: var(--ink); cursor: pointer;
}
.chip[aria-pressed=true] { border-color: var(--navy); background: var(--navy); color: #fff; }
.chip.hot[aria-pressed=true] { background: var(--orange); border-color: var(--orange); }
.chip.warm[aria-pressed=true] { background: var(--lime); border-color: var(--lime); color: var(--navy); }
.chip.cold[aria-pressed=true] { background: var(--cyan); border-color: var(--cyan); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px; border-radius: 12px; border: 0; cursor: pointer;
  font: inherit; font-weight: 700; text-decoration: none; background: #e9ecf3; color: var(--navy);
}
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: var(--lime); color: var(--navy); }
.btn.dark { background: var(--navy); color: #fff; }
.btn.ghost { background: transparent; color: var(--navy-2); padding-left: 8px; padding-right: 8px; }
.btn.danger { background: #fdecec; color: var(--danger); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.recording { background: var(--danger); color: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgb(198 40 40 / 18%); } }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

.sticky-actions {
  position: sticky; bottom: 0; margin: 20px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgb(244 245 247 / 0));
}
body.has-tabs .sticky-actions { bottom: var(--tab); padding-bottom: 12px; }

/* ---------- Badge-Vorschau ---------- */
.badge-preview { position: relative; border-radius: 12px; overflow: hidden; background: #111; }
.badge-preview img { display: block; width: 100%; max-height: 220px; object-fit: contain; }
.badge-preview .status {
  position: absolute; left: 8px; bottom: 8px; right: 8px; padding: 6px 10px; border-radius: 8px;
  background: rgb(27 40 79 / 85%); color: #fff; font-size: .85rem;
}
.scanning::after { content: ' …'; }

/* ---------- Tableiste ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; height: var(--tab); padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; max-width: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-2); text-decoration: none; font-size: .72rem; font-weight: 700; position: relative;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--navy); }
.tabbar a.active::before { content: ''; position: absolute; top: 0; width: 36px; height: 3px; border-radius: 0 0 3px 3px; background: var(--lime); }

/* ---------- Dialoge ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgb(15 22 45 / 55%);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out;
}
.modal {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto;
  background: #fff; border-radius: 18px 18px 0 0; padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 18px; }
}
.modal h2 { margin-bottom: 12px; }
.modal .btn-row { margin-top: 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }

/* ---------- QR-Scanner ---------- */
.scanner { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; flex-direction: column; }
.scanner video { flex: 1; width: 100%; object-fit: cover; }
.scanner .frame {
  position: absolute; left: 50%; top: 45%; width: min(70vw, 300px); aspect-ratio: 1; transform: translate(-50%, -50%);
  border: 3px solid var(--lime); border-radius: 18px; box-shadow: 0 0 0 9999px rgb(0 0 0 / 45%);
}
.scanner .bar {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px; align-items: center; color: #fff; text-align: center;
}

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 0; right: 0; top: calc(var(--top) + 8px); z-index: 70; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  max-width: 520px; padding: 11px 16px; border-radius: 12px; font-size: .92rem; font-weight: 700;
  background: var(--navy); color: #fff; box-shadow: 0 6px 24px rgb(0 0 0 / 18%); animation: up .2s ease-out;
}
.toast.ok { background: #2f6619; }
.toast.error { background: var(--danger); }
.toast.warn { background: #8a3b00; }

/* ---------- Detail ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .92rem; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }
.lead-head { display: flex; gap: 14px; align-items: center; }
.lead-head .avatar { width: 56px; height: 56px; font-size: 1.1rem; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.timeline li:last-child { border-bottom: 0; }
details summary { cursor: pointer; color: var(--navy-2); font-weight: 700; font-size: .9rem; }
.pre { white-space: pre-wrap; font-size: .9rem; }

.auth-wrap { max-width: 420px; margin: 6vh auto 0; }
.auth-wrap .logo { font-size: 1.6rem; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.auth-wrap .logo b { background: var(--lime); padding: 0 6px; border-radius: 4px; }

@media (min-width: 720px) {
  .capture-grid { grid-template-columns: 1fr 1fr; }
  .capture-btn.primary { grid-column: 1 / -1; }
}

/* ---------- Fragebogen ---------- */
.questionnaire { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 14px; }
.questionnaire h3 { margin: 0; }
.q-label { font-size: .9rem; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.q .muted.small { margin: -4px 0 6px; }
.req { color: var(--orange); font-weight: 700; }

/* ---------- Dubletten-Hinweis ---------- */
.dup-box { display: grid; gap: 10px; }
.dup-box > strong { color: inherit; }
.dup-item { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid rgb(138 59 0 / 15%); }
.dup-item .small { opacity: .85; }
.notice.ok .btn, .notice.warn .btn:not(.dark) { background: #fff; }

/* ---------- KI-Karte ---------- */
.ai-card { border-left: 5px solid var(--lime); }
.ai-card .badge { background: var(--lime); color: var(--navy); }
.btn.scanning { opacity: .7; }

/* ---------- Auswertung ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; margin-top: 8px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 12px; background: #f4f5f7; color: inherit; text-decoration: none; }
.kpi b { font-size: 1.35rem; color: var(--navy); }
.kpi span { font-size: .78rem; color: var(--ink-2); }
a.kpi { outline: 2px solid var(--lime); outline-offset: -2px; }
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: .85rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; border-radius: 5px; background: #eceef3; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; background: var(--navy); min-width: 2px; }
.bar-value { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.icon-btn.dark-ic { color: var(--navy); font-size: 1.1rem; font-weight: 700; }
.icon-btn:disabled { opacity: .3; }
.q-row { flex-wrap: wrap; row-gap: 4px; }
.q-row .main { flex-basis: 100%; }
.q-row .title, .q-row .sub { white-space: normal; }
.q-row .icon-btn { width: 38px; height: 38px; }
.q-row .icon-btn:first-of-type { margin-left: auto; }
.btn-row .btn.small { flex: 1 1 auto; white-space: nowrap; }
