:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f1f3f6;
  --line: #e3e6eb;
  --text: #14171c;
  --muted: #646b78;
  --faint: #6b7280;       /* mind. 4,5:1 auf Hintergrund und Weiß */
  --accent: #2f6bff;
  --accent-ink: #ffffff;
  --on-green: #ffffff;
  --on-red: #ffffff;
  --green: #12a150;
  --green-soft: #e3f6ea;
  --red: #e5484d;
  --red-soft: #fdecec;
  --amber: #d98a00;
  --amber-soft: #fff4dc;
  --amber-ink: #9a5a00;   /* Orange für Text: 5:1 auf --amber-soft */
  --green-ink: #0b7a3b;   /* Text-Töne: mind. 4,5:1 auf Weiß und auf der jeweiligen *-soft-Fläche */
  --teal-ink: #0a7480;
  --red-ink: #c42b30;
  --on-amber: #ffffff;
  --teal: #0e9aa7;
  --teal-soft: #e0f5f6;
  --gray-soft: #eef0f3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 14px;
  --nav-w: 208px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #171a21;
    --panel-2: #1e222b;
    --line: #2a2f3a;
    --text: #eceef2;
    --muted: #a1a8b5;
    --faint: #868d99;
    --accent: #5b8cff;
    --accent-ink: #0f1115;  /* dunkle Schrift auf hellen Knöpfen – weiß wäre zu kontrastarm */
    --on-green: #0f1115;
    --on-red: #0f1115;
    --green: #3ccf7c;
    --green-soft: #133222;
    --red: #ff6b6f;
    --red-soft: #3a1a1c;
    --amber: #f2b33d;
    --amber-soft: #36290e;
    --amber-ink: #f2b33d;
    --green-ink: #3ccf7c;
    --teal-ink: #3fc6d1;
    --red-ink: #ff6b6f;
    --on-amber: #0f1115;
    --teal: #3fc6d1;
    --teal-soft: #0f2f33;
    --gray-soft: #232833;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.nav {
  width: var(--nav-w); flex: none; position: sticky; top: 0; height: 100vh;
  padding: 18px 12px; border-right: 1px solid var(--line); background: var(--panel);
  display: flex; flex-direction: column; gap: 2px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 4px 10px 18px; letter-spacing: -.01em; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px;
  color: var(--muted); font-weight: 500;
}
.nav a svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--panel-2); color: var(--text); }
.nav-foot { margin-top: auto; padding: 10px; font-size: 12px; }
.view { flex: 1; min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 60px; outline: none; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .spacer { flex: 1; }

@media (max-width: 820px) {
  .nav {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; width: auto; height: auto; z-index: 20;
    flex-direction: row; justify-content: space-around; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line);
  }
  .nav .brand, .nav-foot { display: none; }
  .nav a { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 8px; }
  .nav a.active { background: none; color: var(--accent); }
  .view { padding: calc(16px + env(safe-area-inset-top)) 16px calc(90px + env(safe-area-inset-bottom)); }
}

/* ---------- Bausteine ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: transform .05s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.green { background: var(--green); border-color: var(--green); color: var(--on-green); }
.btn.red { background: var(--red); border-color: var(--red); color: var(--on-red); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 14px 22px; font-size: 16px; border-radius: 12px; }
.btn kbd { font: 11px/1 ui-monospace, monospace; padding: 2px 5px; border-radius: 4px; background: rgba(127,127,127,.18); }

input[type=text], input[type=password], input[type=number], input[type=search], input[type=tel], input[type=email], input[type=url], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel);
  outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
textarea { resize: vertical; min-height: 70px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
label.field input, label.field select, label.field textarea { font-size: 14px; font-weight: 400; color: var(--text); }
::placeholder { color: var(--faint); opacity: 1; font-weight: 400; }
label.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--gray-soft); color: var(--muted); white-space: nowrap;
}
.pill.green { background: var(--green-soft); color: var(--green-ink); }
.pill.red { background: var(--red-soft); color: var(--red-ink); }
.pill.amber { background: var(--amber-soft); color: var(--amber-ink); }
.pill.teal { background: var(--teal-soft); color: var(--teal-ink); }
.pill.blue { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.dot.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty h2 { color: var(--text); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--panel-2); }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
td.wrap { white-space: normal; min-width: 240px; }

/* ---------- Dialer ---------- */
.dialer { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .dialer { grid-template-columns: 1fr; } }

.queue-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.queue-bar select { width: auto; min-width: 200px; }

.contact-card { padding: 24px; }
.contact-company { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.contact-person { font-size: 16px; color: var(--muted); margin-top: 4px; }
.contact-phone { font-size: 20px; font-weight: 600; margin-top: 14px; font-variant-numeric: tabular-nums; }
.contact-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; color: var(--muted); font-size: 14px; }
.contact-notes { margin-top: 14px; padding: 12px; background: var(--panel-2); border-radius: 10px; font-size: 14px; white-space: pre-wrap; }

.call-panel { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.call-status { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; min-width: 180px; }
.call-timer { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }
.call-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.outcomes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 520px) { .outcomes { grid-template-columns: repeat(2, 1fr); } }
.outcome {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px;
  border-radius: 12px; border: 1.5px solid var(--line); background: var(--panel); cursor: pointer;
  font-weight: 600; font-size: 14px; text-align: left; transition: border-color .12s, background .12s;
}
.outcome:hover { border-color: var(--faint); }
.outcome kbd { font: 11px/1 ui-monospace, monospace; color: var(--faint); }
.outcome.selected { border-color: currentColor; }
.outcome[data-o=meeting] { color: var(--green-ink); } .outcome[data-o=meeting].selected { background: var(--green-soft); }
.outcome[data-o=interest] { color: var(--teal-ink); } .outcome[data-o=interest].selected { background: var(--teal-soft); }
.outcome[data-o=callback] { color: var(--amber-ink); } .outcome[data-o=callback].selected { background: var(--amber-soft); }
.outcome[data-o=no_interest] { color: var(--muted); } .outcome[data-o=no_interest].selected { background: var(--gray-soft); }
.outcome[data-o=no_answer] { color: var(--muted); } .outcome[data-o=no_answer].selected { background: var(--gray-soft); }
.outcome[data-o=wrong_number] { color: var(--red-ink); } .outcome[data-o=wrong_number].selected { background: var(--red-soft); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 13px; font-weight: 500; }
.chip.active { border-color: var(--amber); background: var(--amber-soft); color: var(--amber-ink); }

.countdown { position: relative; overflow: hidden; border-radius: 12px; background: var(--panel-2); padding: 14px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.countdown .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); transition: width 1s linear; }
.countdown strong { font-size: 15px; }

.side-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.side-stats b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.side-stats span { font-size: 12px; color: var(--muted); }

.history-item { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.history-item:last-child { border-bottom: 0; }

.rec-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--red-ink); }

/* ---------- Gesprächs-Detail ---------- */
.drawer { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: flex-end; background: rgba(10, 12, 16, .45); }
.drawer-panel { width: min(720px, 100%); height: 100%; overflow-y: auto; background: var(--bg); padding: 24px; box-shadow: -8px 0 30px rgba(0,0,0,.2); animation: slidein .18s ease-out; }
@keyframes slidein { from { transform: translateX(30px); opacity: .6; } }
@media (max-width: 820px) { .drawer-panel { padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); } }

.transcript { display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 85%; padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.5; }
.bubble .who { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; opacity: .7; margin-bottom: 2px; }
.bubble.me { align-self: flex-end; background: color-mix(in srgb, var(--accent) 14%, var(--panel)); border-bottom-right-radius: 4px; }
.bubble.them { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.raw { white-space: pre-wrap; font-size: 13px; background: var(--panel-2); padding: 12px; border-radius: 10px; max-height: 360px; overflow: auto; }

.objection { padding: 10px 12px; border-radius: 10px; background: var(--panel-2); margin-bottom: 8px; }
.objection q { display: block; margin-top: 4px; color: var(--muted); font-size: 14px; }
ul.clean { margin: 0; padding-left: 18px; }
ul.clean li { margin: 4px 0; }

/* ---------- Auswertung ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.chart { width: 100%; height: 220px; }
.chart text { fill: var(--muted); font-size: 11px; }
.hbar { display: grid; grid-template-columns: minmax(100px, 180px) 1fr 40px; gap: 10px; align-items: center; margin: 6px 0; font-size: 14px; }
.hbar .track { height: 10px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--accent); border-radius: 999px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Import ---------- */
.dropzone { display: block; border: 2px dashed var(--line); border-radius: var(--radius); padding: 32px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone.over, .dropzone:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; align-items: end; }

/* ---------- Setup ---------- */
.check-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.check-item:last-child { border-bottom: 0; }
.check-icon { width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; }
.check-icon.ok { background: var(--green); color: var(--on-green); }
.check-icon.no { background: var(--faint); }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel-2); padding: 1px 5px; border-radius: 5px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(380px, calc(100vw - 32px)); }
@media (max-width: 820px) { .toasts { bottom: calc(80px + env(safe-area-inset-bottom)); left: 16px; right: 16px; } }
.toast { background: var(--text); color: var(--bg); padding: 11px 14px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); animation: slidein .15s ease-out; }
.toast.error { background: var(--red); color: var(--on-red); }
kbd { font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 2px 5px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--line); }

/* ---------- Verbindung verloren ---------- */
.offline {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px; background: var(--red); color: var(--on-red);
  font-size: 14px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.offline code { background: rgba(127,127,127,.25); color: inherit; }

.notice { border-color: var(--amber); background: var(--amber-soft); margin-bottom: 16px; font-size: 14px; }
.notice a { font-weight: 600; }
.machine-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; margin-top: 16px; padding: 10px 14px; border-radius: 10px; background: var(--amber-soft); color: var(--amber-ink); font-size: 14px; font-weight: 600; }
.machine-banner .btn { color: var(--text); }
.pill.red { cursor: pointer; }
.check-icon.err { background: var(--red); color: var(--on-red); }
.check-icon.wait { background: var(--accent); color: var(--accent-ink); }
.check-icon.warn { background: var(--amber); color: var(--on-amber); }
.check-icon.skip { background: var(--faint); }
.check-group { margin: 16px 0 0; }
.check-group:first-child { margin-top: 0; }
.check-fix { margin-top: 4px; color: var(--text); }
.mic-meter { height: 8px; border-radius: 4px; background: var(--gray-soft); overflow: hidden; margin-top: 8px; max-width: 260px; }
.mic-meter > div { height: 100%; width: 0; background: var(--green); transition: width .08s linear; }
.notice.info { border-color: var(--line); }

/* ---------- Korrekturen aus der visuellen Prüfung ---------- */
/* Kontakttabelle: Namen dürfen umbrechen, damit die Aktionen rechts immer ganz sichtbar sind */
table.contacts td, table.contacts th { white-space: normal; }
table.contacts td.mono, table.contacts td.nowrap, .nowrap { white-space: nowrap; }
table.contacts td, table.contacts th { padding-left: 10px; padding-right: 10px; }
/* Aktionen bleiben rechts immer sichtbar – auch wenn die Tabelle auf kleinen Bildschirmen seitlich scrollt */
td.actions, table.contacts th:last-child { width: 1%; position: sticky; right: 0; background: var(--panel); box-shadow: -8px 0 8px -8px rgba(0, 0, 0, .15); }
table.contacts th:last-child { background: var(--panel-2); }
tr.click:hover td.actions { background: var(--panel-2); }
td.actions > div { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; white-space: nowrap; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.only-sm { display: none; }
.chart-wrap { position: relative; }
.chart-max { position: absolute; left: 0; top: 0; font-size: 11px; color: var(--muted); }
.chart-axis { display: grid; font-size: 11px; color: var(--muted); text-align: center; margin-top: 4px; overflow: hidden; }
.chart-axis span { white-space: nowrap; overflow: visible; min-width: 0; }
ul.clean li.none { color: var(--muted); }

@media (max-width: 820px) {
  /* Überschrift oben, Filter/Knöpfe gemeinsam darunter – überall gleich */
  .page-head h1 { flex: 1 0 100%; }
  .page-head .spacer { display: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .hide-sm { display: none; }
  .chart-axis { font-size: 10px; }
  .chart-axis span:nth-child(even) { visibility: hidden; } /* auf dem Handy nur jede zweite Beschriftung */
  .only-sm { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
  /* iPhone zoomt sonst beim Antippen von Feldern unter 16px hinein */
  input, select, textarea, label.field input, label.field select, label.field textarea { font-size: 16px; }
}
/* Auf Touch-Geräten (Handy/Tablet) gibt es keine Tastatur – Tastenkürzel ausblenden */
@media (hover: none) and (pointer: coarse) {
  .btn kbd, .outcome kbd, .kbd-help, .kbd-hint { display: none; }
}
