:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #293548;
  --border: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --success: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #64748b;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

/* Keine horizontale Bewegung außer in explizit scrollbaren Bereichen (Kanban). */
body { position: relative; width: 100%; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

/* ---- Login ---- */
.page-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top, #1e293b, #0f172a 70%);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 360px;
  max-width: 90vw;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}
.login-card h1 { margin: 0 0 4px; font-size: 1.4rem; }
.login-sub { color: var(--text-dim); margin: 0 0 24px; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 14px;
  background: #fff; color: #1f1f1f !important;
  border: 1px solid #dadce0; border-radius: 6px;
  font-size: 0.95rem; font-weight: 500;
  text-decoration: none !important;
  margin-bottom: 16px;
  transition: background 0.15s;
}
.google-btn:hover { background: #f8faff; }
.google-btn:active { background: #eef3fe; }
.login-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 8px 0 16px;
  color: var(--text-dim); font-size: 0.8rem;
}
.login-divider::before,
.login-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.login-card label { font-size: 0.85rem; color: var(--text-dim); display: block; margin-bottom: 6px; }
.login-card input {
  width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); margin-bottom: 16px; font-size: 1rem;
}
.login-card button {
  width: 100%; padding: 10px; background: var(--accent); color: white; border: none;
  border-radius: 6px; cursor: pointer; font-size: 1rem; font-weight: 600;
}
.login-card button:hover { background: var(--accent-2); }
.error { color: var(--danger); margin-top: 8px; }

/* ---- Dashboard ---- */
.page-dashboard { height: 100vh; display: grid; grid-template-rows: 56px 1fr; }

.topbar {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  gap: 12px;
}
.brand { font-weight: 700; letter-spacing: 0.02em; }
.brand span { color: var(--accent); }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs button {
  background: transparent; border: none; color: var(--text-dim);
  padding: 8px 12px; cursor: pointer; border-radius: 6px; font-size: 0.9rem;
  white-space: nowrap;
}
.tabs button:hover { background: var(--surface-2); color: var(--text); }
.tabs button.active { background: var(--surface-2); color: var(--text); }
.badge {
  display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 10px;
  background: var(--border); font-size: 0.75rem; margin-left: 4px; text-align: center;
}
.badge-critical { background: var(--danger); color: white; }
.topbar-actions { display: flex; gap: 8px; }
.topbar-actions button {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 0.85rem;
}
.topbar-actions button:hover { background: var(--border); }

main#view-container { overflow-y: auto; padding: 20px; }
.view { max-width: 100%; }

h2 { margin-top: 0; }

/* ---- Tables ---- */
table.data {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
table.data th, table.data td {
  padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left;
  vertical-align: top;
}
table.data th { background: var(--surface-2); color: var(--text-dim); font-weight: 600; font-size: 0.85rem; }
table.data tr:hover { background: var(--surface-2); cursor: pointer; }
table.data tr:last-child td { border-bottom: none; }

/* ---- Status-Pill ---- */
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.75rem;
  font-weight: 600; color: white;
}
.age-green { color: var(--success); }
.age-orange { color: var(--warn); }
.age-red { color: var(--danger); font-weight: 600; }

/* ---- Toolbar ---- */
.toolbar {
  display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center;
}
.toolbar input, .toolbar select {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 6px 10px; border-radius: 6px; font-size: 0.9rem;
}
.toolbar button {
  background: var(--accent); color: white; border: none; padding: 6px 14px; border-radius: 6px;
  cursor: pointer; font-size: 0.9rem;
}
.toolbar button:hover { background: var(--accent-2); }
.toolbar button.secondary { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.toolbar button.danger { background: var(--danger); }

/* ---- Pipeline Kanban ---- */
.kanban {
  display: grid;
  grid-template-columns: repeat(8, minmax(220px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.kanban-col {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 400px;
}
.kanban-col h3 {
  padding: 10px 12px; margin: 0; border-bottom: 1px solid var(--border);
  font-size: 0.85rem; color: var(--text-dim); display: flex; justify-content: space-between;
}
.kanban-list { padding: 8px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.kanban-card {
  background: var(--surface-2); padding: 8px 10px; border-radius: 6px; cursor: grab;
  border-left: 3px solid var(--accent);
  font-size: 0.85rem;
}
.kanban-card.dragging { opacity: 0.5; }
.kanban-col.drag-over { background: #1f2d47; }
.kanban-card .meta { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }
.kanban-card.unassigned { border-left-color: var(--warn); border-left-style: dashed; }
.unassigned-tag {
  display: inline-block; padding: 1px 5px; border-radius: 3px;
  background: var(--warn); color: #1e1e1e; font-size: 0.7rem; font-weight: 600;
}
.calendar-badge {
  display: inline-block; padding: 1px 5px; border-radius: 3px;
  background: #10b981; color: #fff; font-size: 0.7rem; font-weight: 600;
  margin-left: 4px;
}
.score-badge {
  display: inline-block; padding: 1px 6px; border-radius: 10px;
  font-size: 0.7rem; font-weight: 700; min-width: 22px; text-align: center;
  margin-left: 4px;
}
.score-badge.score-low  { background: #ef4444; color: #fff; }
.score-badge.score-mid  { background: #f59e0b; color: #1e1e1e; }
.score-badge.score-high { background: #10b981; color: #fff; }

/* ---- View-Toggle (Liste/Board in Meine Leads) ---- */
.view-toggle { display: inline-flex; gap: 0; margin-right: 8px; }
.view-toggle button { border-radius: 4px; padding: 6px 10px; font-size: 0.85rem; }
.view-toggle button:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.view-toggle button:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* ---- Lead-Notizen-Log ---- */
.notes-list { max-height: 240px; overflow-y: auto; margin-bottom: 8px; }
.note-entry { padding: 6px 0; border-bottom: 1px solid var(--border); }
.note-entry:last-child { border-bottom: none; }
.note-meta { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 2px; }
.note-text { font-size: 0.9rem; white-space: pre-wrap; word-wrap: break-word; }
.notes-add textarea {
  width: 100%; padding: 6px 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); font-size: 0.9rem; font-family: inherit;
  resize: vertical; margin-bottom: 6px;
}

/* ---- Drawer ---- */
.drawer {
  position: fixed; right: 0; top: 0; height: 100vh; width: 560px; max-width: 95vw;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -10px 0 20px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; z-index: 100;
}
.drawer[hidden] { display: none; }
.drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.drawer-head h2 { margin: 0; font-size: 1.1rem; }
.drawer-head button {
  background: none; border: none; color: var(--text-dim); font-size: 1.5rem; cursor: pointer;
}
.drawer-body { padding: 0; overflow: hidden; flex: 1; display: flex; flex-direction: column; }
.drawer-body section { margin-bottom: 20px; }
.drawer-body h3 { font-size: 0.9rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.drawer-body dl { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 0.9rem; }
.drawer-body dt { color: var(--text-dim); }
.drawer-body dd { margin: 0; word-break: break-word; }

/* Qualifizierungs-Karten — visuell deutlich getrennt (Erstes Telefonat vs Erstgespräch) */
.qual-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
  border-left-width: 4px;
}
.qual-card h3 { margin-top: 0; padding-top: 0; }
.qual-card--telefonat { border-left-color: #3b82f6; }     /* Blau */
.qual-card--erstgespraech { border-left-color: #8b5cf6; } /* Violett */

/* Ja/Nein-Toggle (CR-001) */
.toggle-group { display: inline-flex; gap: 0; border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
.toggle-group button {
  background: var(--surface); color: var(--text-dim); border: none;
  padding: 6px 14px; cursor: pointer; font-size: 0.85rem;
}
.toggle-group button:not(:last-of-type) { border-right: 1px solid var(--border); }
.toggle-group button.active { background: var(--accent); color: white; font-weight: 600; }
.toggle-group button:disabled { cursor: not-allowed; opacity: 0.6; }
.toggle-group button:not(.active):not(:disabled):hover { background: var(--surface-2); color: var(--text); }

/* Info-Button (z.B. neben Position) */
.info-btn {
  display: inline-block; padding: 0 6px; margin-left: 6px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 50%; cursor: pointer; font-size: 0.75rem; line-height: 1.4;
}
.info-btn:hover { background: var(--accent); color: white; }

/* Drawer Tabs (CR-009) */
.drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0 12px;
  flex-shrink: 0;
}
.drawer-tabs button {
  background: transparent; border: none; color: var(--text-dim);
  padding: 10px 14px; font-size: 0.85rem; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.drawer-tabs button.active {
  color: var(--text); border-bottom-color: var(--accent);
}
.drawer-tabs button:hover { color: var(--text); }
.drawer-tab-content { padding: 16px; overflow-y: auto; flex: 1; }
.drawer-tab-content[hidden] { display: none; }
.drawer-bottom-bar {
  display: flex; gap: 8px; padding: 10px 16px;
  border-top: 1px solid var(--border); background: var(--surface);
  flex-shrink: 0;
}
.drawer-bottom-bar button { padding: 8px 16px; }
.drawer-bottom-bar button.primary {
  background: var(--accent); color: white; border: none; border-radius: 6px;
  cursor: pointer; font-size: 0.9rem; font-weight: 600;
}
.drawer-bottom-bar button.primary:hover { background: var(--accent-2); }
.drawer-bottom-bar button.secondary {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; cursor: pointer; font-size: 0.9rem;
}
.drawer-body textarea, .drawer-body input[type=text], .drawer-body input[type=email],
.drawer-body input[type=tel], .drawer-body input[type=datetime-local],
.drawer-body input[type=number], .drawer-body input[type=date], .drawer-body select {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 6px 8px; border-radius: 4px; font-size: 0.9rem; margin-bottom: 8px;
  font-family: inherit;
}
.drawer-body textarea { min-height: 80px; }

/* Subhint unter Section-H3 — leiser als die Headline */
.section-subhint {
  font-size: 0.75rem; color: var(--text-dim); font-weight: 400;
  margin: -8px 0 10px 0; text-transform: none; letter-spacing: 0;
}

/* Side-by-side Felder im Drawer (Vor-/Nachname, Email/Telefon) */
.field-row {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.field-row > * { flex: 1 1 120px; min-width: 0; }

/* Falsche-Daten-Modal: Fragen-Liste */
.junk-questions {
  margin: 8px 0 0 0; padding-left: 20px;
  font-size: 0.9rem; line-height: 1.5;
}
.junk-questions li { margin: 4px 0; color: var(--text); }

/* Status-Bar über den Drawer-Tabs */
.drawer-status-bar {
  padding: 12px 16px 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Status-Pipeline-Bar (CR-009) */
.status-pipeline {
  display: flex; gap: 0; margin: 8px 0;
  border-radius: 6px; overflow-x: auto; overflow-y: visible;
  background: var(--surface-2); padding: 4px; border: 1px solid var(--border);
}
.status-pipeline button.step {
  flex: 1; min-width: 70px;
  background: transparent; color: var(--text-dim);
  border: 1px solid transparent; border-radius: 4px;
  padding: 8px 6px; cursor: pointer;
  font-size: 0.75rem; font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.status-pipeline button.step.done {
  background: rgba(16,185,129,0.18); color: #6ee7b7;
}
.status-pipeline button.step.current {
  background: var(--accent); color: #fff; font-weight: 600;
  box-shadow: 0 1px 4px rgba(59,130,246,0.4);
}
.status-pipeline button.step.upcoming { color: var(--text-dim); opacity: 0.7; }
.status-pipeline button.step:not(.current):hover {
  background: var(--bg); color: var(--text);
}
.status-secondary { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.status-secondary button {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
  padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: 0.8rem;
}
.status-secondary button:hover { border-color: var(--accent); color: var(--text); }
.status-secondary button.active {
  background: var(--danger); color: #fff; border-color: var(--danger);
}

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 200;
  display: grid; place-items: center;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; min-width: 400px; max-width: 90vw; max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin-top: 0; }
.modal label { display: block; font-size: 0.85rem; color: var(--text-dim); margin: 8px 0 4px; }
.modal input, .modal select, .modal textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 8px 10px; border-radius: 4px; margin-bottom: 12px;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.modal-actions button { padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer; }
.modal-actions button.primary { background: var(--accent); color: white; }
.modal-actions button.secondary { background: var(--surface-2); color: var(--text); }

/* ---- Toasts ---- */
#toast-stack {
  position: fixed; bottom: 16px; right: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 6px; min-width: 240px; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

/* ---- Alerts-Grouped ---- */
.alert-group { margin-bottom: 24px; }
.alert-group h3 { margin: 0 0 8px; }
.alert-card {
  background: var(--surface); border: 1px solid var(--border); padding: 10px 12px; border-radius: 6px;
  margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.alert-card.warn { border-left: 3px solid var(--warn); }
.alert-card.critical { border-left: 3px solid var(--danger); }
.alert-card.info { border-left: 3px solid var(--info); }
.alert-card .meta { font-size: 0.75rem; color: var(--text-dim); }
.alert-card button { background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 0.8rem; }

/* ---- KPI cards ---- */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px;
  margin-bottom: 16px;
}
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi-card .label { font-size: 0.8rem; color: var(--text-dim); }
.kpi-card .value { font-size: 1.8rem; font-weight: 700; margin-top: 4px; }
.kpi-card .sub { font-size: 0.8rem; color: var(--text-dim); margin-top: 2px; }

/* ---- Settings ---- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px;
}
.settings-fullwidth { margin-bottom: 16px; }
.settings-card h3 { margin-top: 0; }
.settings-card label { display: block; font-size: 0.85rem; color: var(--text-dim); margin-top: 10px; }
.settings-card input, .settings-card select, .settings-card textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 6px 8px; border-radius: 4px; margin-top: 4px;
}
.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }
.toggle-row span { font-size: 0.9rem; }

/* ---- Automation groups ---- */
.auto-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 14px;
  background: var(--bg);
}
.auto-group-head h4 { margin: 0 0 4px; font-size: 1rem; }
.auto-group-desc { margin: 0 0 12px; color: var(--text-dim); font-size: 0.85rem; line-height: 1.5; }
.auto-blocks { display: flex; flex-direction: column; gap: 10px; }
.auto-block {
  display: grid;
  gap: 14px;
  align-items: start;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.auto-block-toggle { grid-template-columns: 52px 1fr; align-items: center; }
.auto-block-input { grid-template-columns: 1fr 200px; align-items: center; }
.auto-block-text { min-width: 0; }
.auto-block-title { font-weight: 600; font-size: 0.92rem; margin-bottom: 2px; }
.auto-block-desc { color: var(--text-dim); font-size: 0.82rem; line-height: 1.4; }
.auto-block-control { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.auto-block-control input,
.auto-block-control select {
  width: 100%;
  margin-top: 0;
  text-align: right;
}
.auto-block-control select { text-align: left; }
.auto-unit {
  font-size: 0.82rem; color: var(--text-dim);
  white-space: nowrap;
}

/* ---- iOS-style Switch ---- */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; margin: 0; }
.switch .slider {
  position: absolute; inset: 0;
  background-color: var(--border);
  transition: 0.2s;
  border-radius: 24px;
  cursor: pointer;
}
.switch .slider::before {
  position: absolute; content: "";
  height: 18px; width: 18px;
  left: 3px; top: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
}
.switch input:checked + .slider { background-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

@media (max-width: 900px) {
  .auto-block-input { grid-template-columns: 1fr; }
  .auto-block-control { justify-content: flex-start; }
}

/* ================= MOBILE ================= */
@media (max-width: 640px) {
  html, body { font-size: 15px; -webkit-text-size-adjust: 100%; }

  /* ----- Topbar: saubere 2 Zeilen ----- */
  .page-dashboard { grid-template-rows: auto 1fr; }
  .topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-auto-rows: auto;
    padding: 0;
    height: auto;
    gap: 0;
    align-items: center;
  }
  .brand { padding: 10px 14px; font-size: 1rem; }
  .topbar-actions { padding: 8px 10px; gap: 6px; }
  .topbar-actions #who { display: none; }
  .topbar-actions button {
    min-width: 40px; min-height: 40px; padding: 6px 10px;
    font-size: 0.85rem;
  }
  .tabs {
    grid-column: 1 / -1;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-top: 1px solid var(--border);
    padding: 4px 10px;
    gap: 2px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button {
    min-height: 38px;
    padding: 6px 12px;
    font-size: 0.88rem;
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* Main */
  main#view-container { padding: 12px 10px; }
  h2 { font-size: 1.15rem; margin-bottom: 10px; }

  /* ----- Toolbar kompakt ----- */
  .toolbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
    align-items: center;
    margin-bottom: 10px;
  }
  .toolbar input[type="text"],
  .toolbar input[type="search"] {
    grid-column: 1 / -1;
    width: 100%; min-height: 42px; font-size: 16px;
    padding: 10px 12px;
  }
  .toolbar select {
    min-height: 40px; font-size: 15px;
    padding: 6px 28px 6px 10px;
  }
  .toolbar label {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.85rem; color: var(--text-dim);
    padding: 0 4px;
  }
  .toolbar label input[type="checkbox"] {
    width: 20px; height: 20px; margin: 0;
  }
  .toolbar button {
    min-height: 40px; padding: 8px 14px;
    font-size: 0.9rem;
  }
  .toolbar .hint { display: none; }

  /* Drawer-Scroll ist eigenständig; Body darf nicht hinter dem Drawer weiterbewegen. */
  .drawer-body {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* ----- Tabellen → Card-Layout auf Mobile ----- */
  table.data,
  table.data tbody,
  table.data tr,
  table.data td { display: block; width: 100%; }
  table.data thead { display: none; }
  table.data { background: transparent; box-shadow: none; border-radius: 0; }
  table.data tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 8px;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-auto-rows: auto;
    gap: 6px 10px;
    align-items: center;
    cursor: pointer;
  }
  table.data tr:hover { background: var(--surface); }
  table.data td {
    padding: 0; border: none;
    color: var(--text-dim); font-size: 0.8rem;
  }
  /* Erste Zelle (Name) groß oben links */
  table.data td:nth-child(1) {
    font-size: 1rem; font-weight: 600; color: var(--text);
    grid-column: 1; grid-row: 1;
  }
  /* Zweite Zelle (Status-Pill) oben rechts */
  table.data td:nth-child(2) {
    grid-column: 2; grid-row: 1;
    text-align: right;
  }
  /* Dritte Zelle (Telefon als Call-Button) zweite Zeile spannt */
  table.data td:nth-child(3) {
    grid-column: 1 / -1; grid-row: 2;
  }
  /* Weitere Zellen darunter zusammen */
  table.data td:nth-child(n+4):not(:empty) {
    grid-column: 1 / -1;
    font-size: 0.78rem; color: var(--text-dim);
  }
  table.data td:empty { display: none; }
  /* Empty-State-Zeile (colspan) */
  table.data tr td[colspan] {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
  }
  /* Claim-Button in "Offen" volle Breite */
  table.data td button {
    width: 100%; min-height: 44px; font-size: 0.95rem;
  }

  /* Telefon-Link als großer Call-Button (Mobile-primary-action) */
  table.data a[href^="tel:"] {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 12px 16px;
    border-radius: 10px;
    background: var(--accent);
    color: white !important;
    font-weight: 600; font-size: 1rem;
    text-decoration: none !important;
    min-height: 48px;
    width: 100%;
  }
  table.data a[href^="tel:"]::before {
    content: "📞";
    font-size: 1.1rem;
  }
  table.data a[href^="tel:"]:active { background: var(--accent-2); transform: scale(0.98); }

  /* ----- Drawer: Vollbild ----- */
  .drawer { width: 100vw; max-width: 100vw; left: 0; right: 0; }
  .drawer-head { padding: 12px 14px; padding-top: max(12px, env(safe-area-inset-top)); }
  .drawer-head h2 { font-size: 1.1rem; }
  .drawer-body {
    padding: 14px 14px max(80px, env(safe-area-inset-bottom));
  }
  .drawer-body section { margin-bottom: 18px; }
  .drawer-body dl { grid-template-columns: 1fr; gap: 0; }
  .drawer-body dt {
    font-size: 0.75rem; text-transform: uppercase;
    letter-spacing: 0.05em; margin-top: 10px;
  }
  .drawer-body dd { margin: 2px 0 0; }
  .drawer-body input, .drawer-body select, .drawer-body textarea {
    font-size: 16px; padding: 10px 12px; min-height: 44px;
    width: 100%;
  }
  .drawer-body textarea { min-height: 80px; }
  .drawer-body a[href^="tel:"],
  .drawer-body a[href^="mailto:"] {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 16px; margin: 4px 0;
    border-radius: 8px;
    background: var(--accent); color: white !important;
    font-weight: 600; font-size: 1rem;
    text-decoration: none !important; min-height: 44px;
  }
  .drawer-body a[href^="tel:"]::before { content: "📞"; }
  .drawer-body a[href^="mailto:"] {
    background: var(--surface-2); color: var(--text) !important;
    border: 1px solid var(--border);
  }

  /* Kanban: swipeable */
  .kanban {
    grid-template-columns: repeat(8, 85vw);
    gap: 8px;
    scroll-snap-type: x mandatory;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .kanban-col { scroll-snap-align: start; min-height: 260px; }
  .kanban-card { padding: 12px 14px; font-size: 0.95rem; }
  .kanban-card .meta { font-size: 0.8rem; }

  /* Modals */
  .modal {
    min-width: auto; width: 95vw; max-height: 92vh; padding: 16px;
  }
  .modal input, .modal select, .modal textarea {
    min-height: 42px; font-size: 16px;
  }
  .modal-actions { flex-direction: column-reverse; gap: 8px; }
  .modal-actions button { width: 100%; min-height: 44px; }

  button { min-height: 40px; }

  .alert-card { flex-direction: column; align-items: stretch; gap: 8px; }
  .alert-card > div:last-child { display: flex; gap: 6px; }
  .alert-card button { flex: 1; }

  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-card { padding: 10px 12px; }
  .kpi-card .value { font-size: 1.4rem; }

  #toast-stack { bottom: 8px; right: 8px; left: 8px; }
  .toast { min-width: auto; }
}

/* ================= iOS Home-Bildschirm-Banner ================= */
.ios-install-banner {
  position: fixed;
  bottom: 12px; left: 12px; right: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 500;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}
.ios-install-banner .txt {
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text);
}
.ios-install-banner .txt strong { color: var(--accent); }
.ios-install-banner .share-icon {
  display: inline-block;
  width: 16px; height: 20px;
  vertical-align: -4px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 20'><path fill='%233b82f6' d='M8 0L4 4h3v9h2V4h3L8 0zm-5 8v10c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V8h-2v10H5V8H3z'/></svg>");
  background-size: contain;
  background-repeat: no-repeat;
}
.ios-install-banner button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 14px;
  min-height: 40px;
  cursor: pointer;
}

/* iOS safe-area (Notch) */
@supports (padding: max(0px)) {
  .topbar { padding-top: max(8px, env(safe-area-inset-top)); }
  main#view-container { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
}

/* ---- Checkbox ---- */
input[type=checkbox] { accent-color: var(--accent); }

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .kanban { grid-template-columns: repeat(8, 240px); }
  .settings-grid { grid-template-columns: 1fr; }
}

/* ---- Misc ---- */
.hint { color: var(--text-dim); font-size: 0.85rem; }
.small { font-size: 0.8rem; }
.bar {
  background: var(--surface-2); border-radius: 4px; overflow: hidden; height: 18px; min-width: 80px;
  position: relative;
}
.bar-fill { background: var(--accent); height: 100%; }
.bar-label { position: absolute; left: 6px; top: 1px; font-size: 0.75rem; color: var(--text); mix-blend-mode: difference; }

/* ---- Kalender (Berater-Portal) ---- */
.cal-connection {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; margin: 12px 0 20px;
}
.cal-connection.ok { border-left: 4px solid #10b981; }
.cal-connection.off { border-left: 4px solid #f59e0b; }
.cal-connection a.primary-btn {
  background: var(--accent); color: white; padding: 10px 16px; border-radius: 6px;
  text-decoration: none; font-weight: 500; white-space: nowrap;
}
.cal-connection a.primary-btn:hover { background: var(--accent-2); }

.cal-section { margin-top: 20px; }
.cal-section h3 { margin-bottom: 6px; }

.slot-grid {
  display: grid; gap: 12px; margin-top: 14px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.slot-day {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 12px;
}
.slot-day h4 { margin: 0 0 8px; font-size: 0.95rem; }
.slot-rule {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--surface-2); padding: 6px 10px; border-radius: 4px;
  margin-bottom: 6px; font-size: 0.85rem;
}
.slot-empty { font-size: 0.8rem; margin-bottom: 8px; }
.link-btn {
  background: none; border: none; color: var(--accent); cursor: pointer;
  padding: 4px 6px; font-size: 0.85rem;
}
.link-btn:hover { color: var(--accent-2); text-decoration: underline; }
.link-btn[data-del] { color: #ef4444; }
.link-btn[data-del]:hover { color: #dc2626; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

@media (max-width: 720px) {
  .slot-grid { grid-template-columns: 1fr; }
  .cal-connection { flex-direction: column; align-items: stretch; text-align: left; }
  .cal-connection a.primary-btn { text-align: center; }
}
